@everymatrix/general-input 0.0.1 → 1.0.69

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 (141) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/checkbox-group-input_10.cjs.entry.js +20007 -16663
  3. package/dist/cjs/general-input.cjs.entry.js +67 -40
  4. package/dist/cjs/general-input.cjs.js +17 -11
  5. package/dist/cjs/index-8cb018cb.js +1316 -0
  6. package/dist/cjs/index.cjs.js +16 -0
  7. package/dist/cjs/loader.cjs.js +7 -13
  8. package/dist/cjs/locale.utils-7a3dfe2f.js +128 -0
  9. package/dist/cjs/toggle-checkbox-input.cjs.entry.js +91 -0
  10. package/dist/cjs/tooltipIcon-7e9ee226.js +5 -0
  11. package/dist/collection/collection-manifest.json +14 -13
  12. package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +26 -6
  13. package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +372 -335
  14. package/dist/collection/components/checkbox-input/checkbox-input.css +16 -10
  15. package/dist/collection/components/checkbox-input/checkbox-input.js +325 -310
  16. package/dist/collection/components/date-input/date-input.css +35 -19
  17. package/dist/collection/components/date-input/date-input.js +401 -328
  18. package/dist/collection/components/email-input/email-input.css +30 -18
  19. package/dist/collection/components/email-input/email-input.js +405 -365
  20. package/dist/collection/components/general-input/general-input.css +1 -0
  21. package/dist/collection/components/general-input/general-input.js +374 -291
  22. package/dist/collection/components/general-input/index.js +1 -0
  23. package/dist/collection/components/number-input/number-input.css +28 -16
  24. package/dist/collection/components/number-input/number-input.js +371 -334
  25. package/dist/collection/components/password-input/password-input.css +105 -11
  26. package/dist/collection/components/password-input/password-input.js +518 -378
  27. package/dist/collection/components/radio-input/radio-input.css +4 -4
  28. package/dist/collection/components/radio-input/radio-input.js +301 -287
  29. package/dist/collection/components/select-input/select-input.css +47 -19
  30. package/dist/collection/components/select-input/select-input.js +428 -398
  31. package/dist/collection/components/tel-input/tel-input.css +52 -23
  32. package/dist/collection/components/tel-input/tel-input.js +441 -404
  33. package/dist/collection/components/text-input/text-input.css +33 -18
  34. package/dist/collection/components/text-input/text-input.js +446 -389
  35. package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.css +82 -0
  36. package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +336 -0
  37. package/dist/collection/index.js +16 -0
  38. package/dist/collection/utils/locale.utils.js +118 -21
  39. package/dist/collection/utils/tooltipIcon.svg +4 -4
  40. package/dist/collection/utils/utils.js +3 -3
  41. package/dist/esm/app-globals-0f993ce5.js +3 -0
  42. package/dist/esm/checkbox-group-input_10.entry.js +20007 -16663
  43. package/dist/esm/general-input.entry.js +67 -40
  44. package/dist/esm/general-input.js +14 -11
  45. package/dist/esm/index-514fda47.js +1287 -0
  46. package/dist/esm/index.js +16 -1
  47. package/dist/esm/loader.js +7 -13
  48. package/dist/esm/locale.utils-21605050.js +125 -0
  49. package/dist/esm/toggle-checkbox-input.entry.js +87 -0
  50. package/dist/esm/tooltipIcon-0a5a06a2.js +3 -0
  51. package/dist/general-input/general-input.esm.js +1 -1
  52. package/dist/general-input/index.esm.js +1 -0
  53. package/dist/general-input/p-03e81c11.js +2 -0
  54. package/dist/general-input/p-2dccd0bf.js +1 -0
  55. package/dist/general-input/p-34939f14.entry.js +1 -0
  56. package/dist/general-input/p-b32f19c2.entry.js +5430 -0
  57. package/dist/general-input/p-c43bb82e.entry.js +1 -0
  58. package/dist/general-input/p-cfe9eb31.js +1 -0
  59. package/dist/general-input/p-e1255160.js +1 -0
  60. package/dist/stencil.config.dev.js +17 -0
  61. package/dist/stencil.config.js +14 -19
  62. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.d.ts +2 -0
  63. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.dev.d.ts +2 -0
  64. package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +69 -67
  65. package/dist/types/components/checkbox-input/checkbox-input.d.ts +61 -60
  66. package/dist/types/components/date-input/date-input.d.ts +79 -65
  67. package/dist/types/components/email-input/email-input.d.ts +76 -73
  68. package/dist/types/components/general-input/general-input.d.ts +72 -57
  69. package/dist/types/components/general-input/index.d.ts +1 -0
  70. package/dist/types/components/number-input/number-input.d.ts +70 -66
  71. package/dist/types/components/password-input/password-input.d.ts +87 -75
  72. package/dist/types/components/radio-input/radio-input.d.ts +55 -55
  73. package/dist/types/components/select-input/select-input.d.ts +78 -77
  74. package/dist/types/components/tel-input/tel-input.d.ts +84 -80
  75. package/dist/types/components/text-input/text-input.d.ts +81 -78
  76. package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +67 -0
  77. package/dist/types/components.d.ts +331 -25
  78. package/dist/types/stencil-public-runtime.d.ts +142 -33
  79. package/dist/types/utils/locale.utils.d.ts +13 -1
  80. package/dist/types/utils/types.d.ts +58 -47
  81. package/loader/cdn.js +1 -3
  82. package/loader/index.cjs.js +1 -3
  83. package/loader/index.d.ts +13 -1
  84. package/loader/index.es2017.js +1 -3
  85. package/loader/index.js +1 -3
  86. package/loader/package.json +1 -0
  87. package/package.json +9 -9
  88. package/dist/cjs/index-1768513d.js +0 -1286
  89. package/dist/components/active-mixin.js +0 -975
  90. package/dist/components/checkbox-group-input.d.ts +0 -11
  91. package/dist/components/checkbox-group-input.js +0 -6
  92. package/dist/components/checkbox-group-input2.js +0 -5793
  93. package/dist/components/checkbox-input.d.ts +0 -11
  94. package/dist/components/checkbox-input.js +0 -6
  95. package/dist/components/checkbox-input2.js +0 -127
  96. package/dist/components/date-input.d.ts +0 -11
  97. package/dist/components/date-input.js +0 -6
  98. package/dist/components/date-input2.js +0 -5182
  99. package/dist/components/email-input.d.ts +0 -11
  100. package/dist/components/email-input.js +0 -6
  101. package/dist/components/email-input2.js +0 -150
  102. package/dist/components/field-mixin.js +0 -12712
  103. package/dist/components/general-input.d.ts +0 -11
  104. package/dist/components/general-input.js +0 -140
  105. package/dist/components/index.d.ts +0 -26
  106. package/dist/components/index.js +0 -1
  107. package/dist/components/input-field-shared-styles.js +0 -1067
  108. package/dist/components/number-input.d.ts +0 -11
  109. package/dist/components/number-input.js +0 -6
  110. package/dist/components/number-input2.js +0 -139
  111. package/dist/components/password-input.d.ts +0 -11
  112. package/dist/components/password-input.js +0 -6
  113. package/dist/components/password-input2.js +0 -879
  114. package/dist/components/pattern-mixin.js +0 -85
  115. package/dist/components/radio-input.d.ts +0 -11
  116. package/dist/components/radio-input.js +0 -6
  117. package/dist/components/radio-input2.js +0 -115
  118. package/dist/components/select-input.d.ts +0 -11
  119. package/dist/components/select-input.js +0 -6
  120. package/dist/components/select-input2.js +0 -166
  121. package/dist/components/tel-input.d.ts +0 -11
  122. package/dist/components/tel-input.js +0 -6
  123. package/dist/components/tel-input2.js +0 -178
  124. package/dist/components/text-input.d.ts +0 -11
  125. package/dist/components/text-input.js +0 -6
  126. package/dist/components/text-input2.js +0 -157
  127. package/dist/components/tooltipIcon.js +0 -30
  128. package/dist/components/vaadin-button.js +0 -461
  129. package/dist/components/vaadin-combo-box.js +0 -4329
  130. package/dist/components/virtual-keyboard-controller.js +0 -2693
  131. package/dist/esm/index-7e24a6f1.js +0 -1259
  132. package/dist/esm/polyfills/core-js.js +0 -11
  133. package/dist/esm/polyfills/css-shim.js +0 -1
  134. package/dist/esm/polyfills/dom.js +0 -79
  135. package/dist/esm/polyfills/es5-html-element.js +0 -1
  136. package/dist/esm/polyfills/index.js +0 -34
  137. package/dist/esm/polyfills/system.js +0 -6
  138. package/dist/general-input/p-61d76ec3.entry.js +0 -1
  139. package/dist/general-input/p-a79eb0a3.entry.js +0 -4413
  140. package/dist/general-input/p-fb647820.js +0 -1
  141. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -2
@@ -1,421 +1,458 @@
1
- import { Component, h, Prop, State, Event, Watch, Listen } from '@stencil/core';
2
- import { translate } from '../../utils/locale.utils';
3
- import '@vaadin/combo-box';
4
- import tooltipIcon from '../../utils/tooltipIcon.svg';
1
+ import { h } from "@stencil/core";
2
+ import { translate } from "../../utils/locale.utils";
3
+ import "@vaadin/combo-box";
4
+ import tooltipIcon from "../../utils/tooltipIcon.svg";
5
5
  export class TelInput {
6
- constructor() {
7
- /**
8
- * Client custom styling via inline style
9
- */
10
- this.clientStyling = '';
11
- this.limitStylingAppends = false;
12
- this.showTooltip = false;
13
- this.validationPattern = '';
14
- this.setClientStyling = () => {
15
- let sheet = document.createElement('style');
16
- sheet.innerHTML = this.clientStyling;
17
- this.stylingContainer.prepend(sheet);
18
- };
19
- }
20
- validityChanged() {
21
- this.validityStateHandler({ valid: this.isValid, name: this.name });
22
- if (this.emitValue == true) {
23
- this.valueHandler({ name: this.name, value: this.value });
6
+ constructor() {
7
+ this.validationPattern = '';
8
+ this.touched = false;
9
+ this.handleInput = (event) => {
10
+ this.phoneValue = event.target.value;
11
+ this.value = { prefix: this.prefixValue, phone: this.phoneValue };
12
+ this.touched = true;
13
+ if (this.debounceTime) {
14
+ clearTimeout(this.debounceTime);
15
+ }
16
+ this.debounceTime = setTimeout(() => {
17
+ this.isValid = this.setValidity();
18
+ this.errorMessage = this.setErrorMessage();
19
+ this.emitValueHandler(true);
20
+ }, 500);
21
+ };
22
+ this.handleBlur = () => {
23
+ this.isValid = this.setValidity();
24
+ this.touched = true;
25
+ this.errorMessage = this.setErrorMessage();
26
+ };
27
+ this.setClientStyling = () => {
28
+ let sheet = document.createElement('style');
29
+ sheet.innerHTML = this.clientStyling;
30
+ this.stylingContainer.prepend(sheet);
31
+ };
32
+ this.name = undefined;
33
+ this.displayName = undefined;
34
+ this.placeholder = undefined;
35
+ this.showLabels = undefined;
36
+ this.action = undefined;
37
+ this.validation = undefined;
38
+ this.defaultValue = undefined;
39
+ this.autofilled = undefined;
40
+ this.tooltip = undefined;
41
+ this.language = undefined;
42
+ this.emitValue = undefined;
43
+ this.clientStyling = '';
44
+ this.isValid = undefined;
45
+ this.errorMessage = undefined;
46
+ this.limitStylingAppends = false;
47
+ this.showTooltip = false;
24
48
  }
25
- }
26
- validityStateHandler(inputStateEvent) {
27
- this.sendValidityState.emit(inputStateEvent);
28
- }
29
- emitValueHandler(newValue) {
30
- if (newValue == true && this.isValid) {
31
- this.valueHandler({ name: this.name, value: this.value });
49
+ validityChanged() {
50
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
51
+ if (this.emitValue == true) {
52
+ this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
53
+ }
32
54
  }
33
- }
34
- valueHandler(inputValueEvent) {
35
- this.sendInputValue.emit(inputValueEvent);
36
- }
37
- handleClickOutside(event) {
38
- if (event.composedPath()[0] === this.tooltipIconReference)
39
- return;
40
- if (event.composedPath()[0] !== this.tooltipReference)
41
- this.showTooltip = false;
42
- }
43
- connectedCallback() {
44
- this.validationPattern = this.setPattern();
45
- if (this.defaultValue) {
46
- this.prefixValue = this.defaultValue.split('|')[0];
47
- this.phoneValue = this.defaultValue.split('|')[1];
55
+ validityStateHandler(inputStateEvent) {
56
+ this.sendValidityState.emit(inputStateEvent);
48
57
  }
49
- }
50
- componentWillLoad() {
51
- if (this.action) {
52
- if (this.action.split(" ")[0] == 'GET') {
53
- return this.getPhoneCodes().then((options) => {
54
- this.phoneCodesOptions = options.phoneCodes.map(code => {
55
- return { label: code.Prefix, value: code.Prefix };
56
- });
57
- });
58
- }
58
+ emitValueHandler(newValue) {
59
+ if (newValue == true && this.isValid) {
60
+ this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
61
+ }
59
62
  }
60
- }
61
- componentDidRender() {
62
- // start custom styling area
63
- if (!this.limitStylingAppends && this.stylingContainer) {
64
- if (this.clientStyling)
65
- this.setClientStyling();
66
- this.limitStylingAppends = true;
63
+ valueHandler(inputValueEvent) {
64
+ this.sendInputValue.emit(inputValueEvent);
65
+ }
66
+ handleClickOutside(event) {
67
+ if (event.composedPath()[0] === this.tooltipIconReference)
68
+ return;
69
+ if (event.composedPath()[0] !== this.tooltipReference)
70
+ this.showTooltip = false;
71
+ }
72
+ connectedCallback() {
73
+ this.validationPattern = this.setPattern();
74
+ if (this.defaultValue) {
75
+ this.prefixValue = this.defaultValue.prefix ? this.defaultValue.prefix : this.defaultValue;
76
+ this.phoneValue = this.defaultValue.phone || null;
77
+ }
67
78
  }
68
- // end custom styling area
69
- if (this.defaultValue) {
70
- this.value = `${this.prefixValue}|${this.phoneValue}`;
71
- this.valueHandler({ name: this.name, value: this.value });
79
+ componentWillLoad() {
80
+ if (this.action) {
81
+ if (this.action.split(" ")[0] == 'GET') {
82
+ const endpoint = this.action.split(" ")[1];
83
+ return this.getPhoneCodes(endpoint).then((options) => {
84
+ this.phoneCodesOptions = options.phoneCodes.map(code => {
85
+ return { label: code.Prefix, value: code.Prefix };
86
+ });
87
+ });
88
+ }
89
+ }
72
90
  }
73
- }
74
- getPhoneCodes() {
75
- // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
76
- const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
77
- return new Promise((resolve, reject) => {
78
- fetch(url.href)
79
- .then((res) => res.json())
80
- .then((options) => {
81
- resolve(options);
82
- }).catch((err) => {
83
- console.error(err);
84
- reject(err);
85
- });
86
- });
87
- }
88
- handleInput(event) {
89
- this.phoneValue = event.target.value;
90
- this.value = `${this.prefixValue}|${this.phoneValue}`;
91
- this.errorMessage = this.setErrorMessage();
92
- this.isValid = this.setValidity();
93
- this.validityStateHandler({ valid: this.isValid, name: this.name });
94
- this.emitValueHandler(true);
95
- }
96
- handlePrefixInput(event) {
97
- this.prefixValue = event.target.value;
98
- this.value = `${this.prefixValue}|${this.phoneValue}`;
99
- this.emitValueHandler(true);
100
- }
101
- setValidity() {
102
- return this.inputReference.validity.valid;
103
- }
104
- setPattern() {
105
- var _a, _b;
106
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
107
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
91
+ componentDidRender() {
92
+ // start custom styling area
93
+ if (!this.limitStylingAppends && this.stylingContainer) {
94
+ if (this.clientStyling)
95
+ this.setClientStyling();
96
+ this.limitStylingAppends = true;
97
+ }
98
+ // end custom styling area
108
99
  }
109
- }
110
- setErrorMessage() {
111
- var _a;
112
- if (this.inputReference.validity.patternMismatch) {
113
- return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
100
+ componentDidLoad() {
101
+ this.isValid = this.setValidity();
102
+ if (this.defaultValue) {
103
+ this.value = this.defaultValue;
104
+ this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
105
+ }
114
106
  }
115
- if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
116
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
107
+ getPhoneCodes(endpoint) {
108
+ const url = new URL(endpoint);
109
+ return new Promise((resolve, reject) => {
110
+ fetch(url.href)
111
+ .then((res) => res.json())
112
+ .then((options) => {
113
+ resolve(options);
114
+ }).catch((err) => {
115
+ console.error(err);
116
+ reject(err);
117
+ });
118
+ });
117
119
  }
118
- if (this.inputReference.validity.valueMissing) {
119
- return translate('requiredError', this.language);
120
+ handlePrefixInput(event) {
121
+ this.prefixValue = event.target.value;
122
+ this.value = { prefix: this.prefixValue, phone: this.phoneValue };
123
+ this.emitValueHandler(true);
120
124
  }
121
- }
122
- renderTooltip() {
123
- if (this.showTooltip) {
124
- return (h("div", { class: `tel__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
125
+ setValidity() {
126
+ return this.inputReference.validity.valid;
125
127
  }
126
- return null;
127
- }
128
- render() {
129
- const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__wrapper--flex--invalid';
130
- return h("div", { class: 'tel__wrapper', ref: el => this.stylingContainer = el },
131
- h("div", { class: 'tel__wrapper--flex-label' },
132
- h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
133
- h("div", { class: 'tel__wrapper--relative' },
134
- this.tooltip &&
135
- h("img", { class: 'tel__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }),
136
- this.renderTooltip())),
137
- h("div", { class: `tel__wrapper--flex ${invalidClass}` },
138
- h("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }),
139
- h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })),
140
- h("small", { class: 'tel__error-message' }, this.errorMessage));
141
- }
142
- static get is() { return "tel-input"; }
143
- static get encapsulation() { return "shadow"; }
144
- static get originalStyleUrls() { return {
145
- "$": ["tel-input.scss"]
146
- }; }
147
- static get styleUrls() { return {
148
- "$": ["tel-input.css"]
149
- }; }
150
- static get properties() { return {
151
- "name": {
152
- "type": "string",
153
- "mutable": false,
154
- "complexType": {
155
- "original": "string",
156
- "resolved": "string",
157
- "references": {}
158
- },
159
- "required": false,
160
- "optional": false,
161
- "docs": {
162
- "tags": [],
163
- "text": "Name of the input."
164
- },
165
- "attribute": "name",
166
- "reflect": true
167
- },
168
- "displayName": {
169
- "type": "string",
170
- "mutable": false,
171
- "complexType": {
172
- "original": "string",
173
- "resolved": "string",
174
- "references": {}
175
- },
176
- "required": false,
177
- "optional": false,
178
- "docs": {
179
- "tags": [],
180
- "text": "Name of input to be shown to the user."
181
- },
182
- "attribute": "display-name",
183
- "reflect": true
184
- },
185
- "placeholder": {
186
- "type": "string",
187
- "mutable": false,
188
- "complexType": {
189
- "original": "string",
190
- "resolved": "string",
191
- "references": {}
192
- },
193
- "required": false,
194
- "optional": false,
195
- "docs": {
196
- "tags": [],
197
- "text": "Placeholder text to be shown."
198
- },
199
- "attribute": "placeholder",
200
- "reflect": true
201
- },
202
- "showLabels": {
203
- "type": "boolean",
204
- "mutable": false,
205
- "complexType": {
206
- "original": "boolean",
207
- "resolved": "boolean",
208
- "references": {}
209
- },
210
- "required": false,
211
- "optional": false,
212
- "docs": {
213
- "tags": [],
214
- "text": "Boolean that defines if the widget show labels or placeholders."
215
- },
216
- "attribute": "show-labels",
217
- "reflect": true
218
- },
219
- "action": {
220
- "type": "string",
221
- "mutable": false,
222
- "complexType": {
223
- "original": "string",
224
- "resolved": "string",
225
- "references": {}
226
- },
227
- "required": false,
228
- "optional": false,
229
- "docs": {
230
- "tags": [],
231
- "text": "Special behaviour an input should have. Can be fetching for data."
232
- },
233
- "attribute": "action",
234
- "reflect": true
235
- },
236
- "validation": {
237
- "type": "unknown",
238
- "mutable": false,
239
- "complexType": {
240
- "original": "ValidationSchema",
241
- "resolved": "ValidationSchema",
242
- "references": {
243
- "ValidationSchema": {
244
- "location": "import",
245
- "path": "../../utils/types"
246
- }
128
+ setPattern() {
129
+ var _a, _b;
130
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
131
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
247
132
  }
248
- },
249
- "required": false,
250
- "optional": false,
251
- "docs": {
252
- "tags": [],
253
- "text": "Object of validation rules for the input."
254
- }
255
- },
256
- "defaultValue": {
257
- "type": "string",
258
- "mutable": false,
259
- "complexType": {
260
- "original": "string",
261
- "resolved": "string",
262
- "references": {}
263
- },
264
- "required": false,
265
- "optional": false,
266
- "docs": {
267
- "tags": [],
268
- "text": "Default value for the input."
269
- },
270
- "attribute": "default-value",
271
- "reflect": true
272
- },
273
- "autofilled": {
274
- "type": "boolean",
275
- "mutable": false,
276
- "complexType": {
277
- "original": "boolean",
278
- "resolved": "boolean",
279
- "references": {}
280
- },
281
- "required": false,
282
- "optional": false,
283
- "docs": {
284
- "tags": [],
285
- "text": "Boolean. Determines if input should be readonly."
286
- },
287
- "attribute": "autofilled",
288
- "reflect": true
289
- },
290
- "tooltip": {
291
- "type": "string",
292
- "mutable": false,
293
- "complexType": {
294
- "original": "string",
295
- "resolved": "string",
296
- "references": {}
297
- },
298
- "required": false,
299
- "optional": false,
300
- "docs": {
301
- "tags": [],
302
- "text": "Tooltip text."
303
- },
304
- "attribute": "tooltip",
305
- "reflect": true
306
- },
307
- "language": {
308
- "type": "string",
309
- "mutable": false,
310
- "complexType": {
311
- "original": "string",
312
- "resolved": "string",
313
- "references": {}
314
- },
315
- "required": false,
316
- "optional": false,
317
- "docs": {
318
- "tags": [],
319
- "text": "Currently selected language."
320
- },
321
- "attribute": "language",
322
- "reflect": true
323
- },
324
- "emitValue": {
325
- "type": "boolean",
326
- "mutable": false,
327
- "complexType": {
328
- "original": "boolean",
329
- "resolved": "boolean",
330
- "references": {}
331
- },
332
- "required": false,
333
- "optional": false,
334
- "docs": {
335
- "tags": [],
336
- "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
337
- },
338
- "attribute": "emit-value",
339
- "reflect": true
340
- },
341
- "clientStyling": {
342
- "type": "string",
343
- "mutable": false,
344
- "complexType": {
345
- "original": "string",
346
- "resolved": "string",
347
- "references": {}
348
- },
349
- "required": false,
350
- "optional": false,
351
- "docs": {
352
- "tags": [],
353
- "text": "Client custom styling via inline style"
354
- },
355
- "attribute": "client-styling",
356
- "reflect": true,
357
- "defaultValue": "''"
358
133
  }
359
- }; }
360
- static get states() { return {
361
- "isValid": {},
362
- "errorMessage": {},
363
- "limitStylingAppends": {},
364
- "showTooltip": {}
365
- }; }
366
- static get events() { return [{
367
- "method": "sendValidityState",
368
- "name": "sendValidityState",
369
- "bubbles": true,
370
- "cancelable": true,
371
- "composed": true,
372
- "docs": {
373
- "tags": [],
374
- "text": ""
375
- },
376
- "complexType": {
377
- "original": "InputStateEvent",
378
- "resolved": "InputStateEvent",
379
- "references": {
380
- "InputStateEvent": {
381
- "location": "import",
382
- "path": "../../utils/types"
383
- }
134
+ setErrorMessage() {
135
+ var _a, _b;
136
+ if (this.inputReference.validity.patternMismatch) {
137
+ const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
138
+ const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
139
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
140
+ }
141
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
142
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
384
143
  }
385
- }
386
- }, {
387
- "method": "sendInputValue",
388
- "name": "sendInputValue",
389
- "bubbles": true,
390
- "cancelable": true,
391
- "composed": true,
392
- "docs": {
393
- "tags": [],
394
- "text": ""
395
- },
396
- "complexType": {
397
- "original": "InputValueEvent",
398
- "resolved": "InputValueEvent",
399
- "references": {
400
- "InputValueEvent": {
401
- "location": "import",
402
- "path": "../../utils/types"
403
- }
144
+ if (this.inputReference.validity.valueMissing) {
145
+ return translate('requiredError', this.language);
404
146
  }
405
- }
406
- }]; }
407
- static get watchers() { return [{
408
- "propName": "isValid",
409
- "methodName": "validityChanged"
410
- }, {
411
- "propName": "emitValue",
412
- "methodName": "emitValueHandler"
413
- }]; }
414
- static get listeners() { return [{
415
- "name": "click",
416
- "method": "handleClickOutside",
417
- "target": "document",
418
- "capture": false,
419
- "passive": false
420
- }]; }
147
+ }
148
+ renderTooltip() {
149
+ if (this.showTooltip) {
150
+ return (h("div", { class: `tel__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
151
+ }
152
+ return null;
153
+ }
154
+ render() {
155
+ let invalidClass = '';
156
+ if (this.touched) {
157
+ invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
158
+ }
159
+ return h("div", { key: '5febd36c339710683111039d477196daac87853c', class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: 'fb779beee03992b23478ffcaac85095420048ceb', class: 'tel__wrapper--flex-label' }, h("label", { key: '5b69271c1c8bf403a003d765adb40a553e09466e', class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '040c487308231459fc92eba2e643a80639df09d6', class: 'tel__wrapper--relative' }, this.tooltip &&
160
+ h("img", { key: '91efd4656c718c75e5047413daf10c22c37e8f93', class: 'tel__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("div", { key: '6215f80b6bccb3dfb03dbbc485c850725633627c', class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { key: '3b7b1ef3415619c51d74f5fc7c5e034acb8f037f', class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), h("input", { key: '886553206896c367ba96f015d81b44ea86f741ea', type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onInput: this.handleInput, onBlur: this.handleBlur })), h("small", { key: 'd4c88d386c3342c789527d925e9cd061494b785c', class: 'tel__error-message' }, this.errorMessage));
161
+ }
162
+ static get is() { return "tel-input"; }
163
+ static get encapsulation() { return "shadow"; }
164
+ static get originalStyleUrls() {
165
+ return {
166
+ "$": ["tel-input.scss"]
167
+ };
168
+ }
169
+ static get styleUrls() {
170
+ return {
171
+ "$": ["tel-input.css"]
172
+ };
173
+ }
174
+ static get properties() {
175
+ return {
176
+ "name": {
177
+ "type": "string",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "string",
181
+ "resolved": "string",
182
+ "references": {}
183
+ },
184
+ "required": false,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": "Name of the input."
189
+ },
190
+ "attribute": "name",
191
+ "reflect": true
192
+ },
193
+ "displayName": {
194
+ "type": "string",
195
+ "mutable": false,
196
+ "complexType": {
197
+ "original": "string",
198
+ "resolved": "string",
199
+ "references": {}
200
+ },
201
+ "required": false,
202
+ "optional": false,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": "Name of input to be shown to the user."
206
+ },
207
+ "attribute": "display-name",
208
+ "reflect": true
209
+ },
210
+ "placeholder": {
211
+ "type": "string",
212
+ "mutable": false,
213
+ "complexType": {
214
+ "original": "string",
215
+ "resolved": "string",
216
+ "references": {}
217
+ },
218
+ "required": false,
219
+ "optional": false,
220
+ "docs": {
221
+ "tags": [],
222
+ "text": "Placeholder text to be shown."
223
+ },
224
+ "attribute": "placeholder",
225
+ "reflect": true
226
+ },
227
+ "showLabels": {
228
+ "type": "boolean",
229
+ "mutable": false,
230
+ "complexType": {
231
+ "original": "boolean",
232
+ "resolved": "boolean",
233
+ "references": {}
234
+ },
235
+ "required": false,
236
+ "optional": false,
237
+ "docs": {
238
+ "tags": [],
239
+ "text": "Boolean that defines if the widget show labels or placeholders."
240
+ },
241
+ "attribute": "show-labels",
242
+ "reflect": true
243
+ },
244
+ "action": {
245
+ "type": "string",
246
+ "mutable": false,
247
+ "complexType": {
248
+ "original": "string",
249
+ "resolved": "string",
250
+ "references": {}
251
+ },
252
+ "required": false,
253
+ "optional": false,
254
+ "docs": {
255
+ "tags": [],
256
+ "text": "Special behaviour an input should have. Can be fetching for data."
257
+ },
258
+ "attribute": "action",
259
+ "reflect": true
260
+ },
261
+ "validation": {
262
+ "type": "unknown",
263
+ "mutable": false,
264
+ "complexType": {
265
+ "original": "ValidationSchema",
266
+ "resolved": "ValidationSchema",
267
+ "references": {
268
+ "ValidationSchema": {
269
+ "location": "import",
270
+ "path": "../../utils/types",
271
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::ValidationSchema"
272
+ }
273
+ }
274
+ },
275
+ "required": false,
276
+ "optional": false,
277
+ "docs": {
278
+ "tags": [],
279
+ "text": "Object of validation rules for the input."
280
+ }
281
+ },
282
+ "defaultValue": {
283
+ "type": "any",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "string | any",
287
+ "resolved": "any",
288
+ "references": {}
289
+ },
290
+ "required": false,
291
+ "optional": false,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": "Default value for the input."
295
+ },
296
+ "attribute": "default-value",
297
+ "reflect": true
298
+ },
299
+ "autofilled": {
300
+ "type": "boolean",
301
+ "mutable": false,
302
+ "complexType": {
303
+ "original": "boolean",
304
+ "resolved": "boolean",
305
+ "references": {}
306
+ },
307
+ "required": false,
308
+ "optional": false,
309
+ "docs": {
310
+ "tags": [],
311
+ "text": "Boolean. Determines if input should be readonly."
312
+ },
313
+ "attribute": "autofilled",
314
+ "reflect": true
315
+ },
316
+ "tooltip": {
317
+ "type": "string",
318
+ "mutable": false,
319
+ "complexType": {
320
+ "original": "string",
321
+ "resolved": "string",
322
+ "references": {}
323
+ },
324
+ "required": false,
325
+ "optional": false,
326
+ "docs": {
327
+ "tags": [],
328
+ "text": "Tooltip text."
329
+ },
330
+ "attribute": "tooltip",
331
+ "reflect": true
332
+ },
333
+ "language": {
334
+ "type": "string",
335
+ "mutable": false,
336
+ "complexType": {
337
+ "original": "string",
338
+ "resolved": "string",
339
+ "references": {}
340
+ },
341
+ "required": false,
342
+ "optional": false,
343
+ "docs": {
344
+ "tags": [],
345
+ "text": "Currently selected language."
346
+ },
347
+ "attribute": "language",
348
+ "reflect": true
349
+ },
350
+ "emitValue": {
351
+ "type": "boolean",
352
+ "mutable": false,
353
+ "complexType": {
354
+ "original": "boolean",
355
+ "resolved": "boolean",
356
+ "references": {}
357
+ },
358
+ "required": false,
359
+ "optional": false,
360
+ "docs": {
361
+ "tags": [],
362
+ "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
363
+ },
364
+ "attribute": "emit-value",
365
+ "reflect": true
366
+ },
367
+ "clientStyling": {
368
+ "type": "string",
369
+ "mutable": false,
370
+ "complexType": {
371
+ "original": "string",
372
+ "resolved": "string",
373
+ "references": {}
374
+ },
375
+ "required": false,
376
+ "optional": false,
377
+ "docs": {
378
+ "tags": [],
379
+ "text": "Client custom styling via inline style"
380
+ },
381
+ "attribute": "client-styling",
382
+ "reflect": true,
383
+ "defaultValue": "''"
384
+ }
385
+ };
386
+ }
387
+ static get states() {
388
+ return {
389
+ "isValid": {},
390
+ "errorMessage": {},
391
+ "limitStylingAppends": {},
392
+ "showTooltip": {}
393
+ };
394
+ }
395
+ static get events() {
396
+ return [{
397
+ "method": "sendValidityState",
398
+ "name": "sendValidityState",
399
+ "bubbles": true,
400
+ "cancelable": true,
401
+ "composed": true,
402
+ "docs": {
403
+ "tags": [],
404
+ "text": ""
405
+ },
406
+ "complexType": {
407
+ "original": "InputStateEvent",
408
+ "resolved": "InputStateEvent",
409
+ "references": {
410
+ "InputStateEvent": {
411
+ "location": "import",
412
+ "path": "../../utils/types",
413
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::InputStateEvent"
414
+ }
415
+ }
416
+ }
417
+ }, {
418
+ "method": "sendInputValue",
419
+ "name": "sendInputValue",
420
+ "bubbles": true,
421
+ "cancelable": true,
422
+ "composed": true,
423
+ "docs": {
424
+ "tags": [],
425
+ "text": ""
426
+ },
427
+ "complexType": {
428
+ "original": "InputValueEvent",
429
+ "resolved": "InputValueEvent",
430
+ "references": {
431
+ "InputValueEvent": {
432
+ "location": "import",
433
+ "path": "../../utils/types",
434
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::InputValueEvent"
435
+ }
436
+ }
437
+ }
438
+ }];
439
+ }
440
+ static get watchers() {
441
+ return [{
442
+ "propName": "isValid",
443
+ "methodName": "validityChanged"
444
+ }, {
445
+ "propName": "emitValue",
446
+ "methodName": "emitValueHandler"
447
+ }];
448
+ }
449
+ static get listeners() {
450
+ return [{
451
+ "name": "click",
452
+ "method": "handleClickOutside",
453
+ "target": "document",
454
+ "capture": false,
455
+ "passive": false
456
+ }];
457
+ }
421
458
  }