@everymatrix/general-input 1.44.0 → 1.45.2

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