@everymatrix/general-input 1.10.2 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/cjs/checkbox-group-input_10.cjs.entry.js +35539 -0
  2. package/dist/cjs/general-input.cjs.entry.js +34 -13
  3. package/dist/cjs/general-input.cjs.js +2 -2
  4. package/dist/cjs/{index-64a5cb7f.js → index-132a0774.js} +119 -6
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/locale.utils-7665b010.js +71 -0
  7. package/dist/cjs/toggle-checkbox-input.cjs.entry.js +85 -0
  8. package/dist/cjs/tooltipIcon-092a795f.js +5 -0
  9. package/dist/collection/collection-manifest.json +3 -1
  10. package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
  11. package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +366 -0
  12. package/dist/collection/components/checkbox-input/checkbox-input.css +47 -1
  13. package/dist/collection/components/checkbox-input/checkbox-input.js +143 -16
  14. package/dist/collection/components/date-input/date-input.css +64 -30
  15. package/dist/collection/components/date-input/date-input.js +194 -13
  16. package/dist/collection/components/email-input/email-input.css +63 -28
  17. package/dist/collection/components/email-input/email-input.js +197 -21
  18. package/dist/collection/components/general-input/general-input.js +163 -21
  19. package/dist/collection/components/number-input/number-input.css +65 -30
  20. package/dist/collection/components/number-input/number-input.js +174 -19
  21. package/dist/collection/components/password-input/password-input.css +120 -29
  22. package/dist/collection/components/password-input/password-input.js +341 -25
  23. package/dist/collection/components/radio-input/radio-input.css +22 -1
  24. package/dist/collection/components/radio-input/radio-input.js +89 -10
  25. package/dist/collection/components/select-input/select-input.css +75 -22
  26. package/dist/collection/components/select-input/select-input.js +180 -37
  27. package/dist/collection/components/tel-input/tel-input.css +91 -33
  28. package/dist/collection/components/tel-input/tel-input.js +202 -24
  29. package/dist/collection/components/text-input/text-input.css +63 -28
  30. package/dist/collection/components/text-input/text-input.js +208 -39
  31. package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.css +76 -0
  32. package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +324 -0
  33. package/dist/collection/utils/locale.utils.js +52 -13
  34. package/dist/collection/utils/tooltipIcon.svg +5 -0
  35. package/dist/components/active-mixin.js +975 -0
  36. package/dist/components/checkbox-group-input.d.ts +11 -0
  37. package/dist/components/checkbox-group-input.js +6 -0
  38. package/dist/components/checkbox-group-input2.js +1125 -0
  39. package/dist/components/checkbox-input2.js +62 -12
  40. package/dist/components/date-input2.js +10247 -15
  41. package/dist/components/email-input2.js +98 -21
  42. package/dist/components/field-mixin.js +12712 -0
  43. package/dist/components/general-input.js +1 -118
  44. package/dist/components/general-input2.js +331 -0
  45. package/dist/components/input-field-shared-styles.js +1114 -0
  46. package/dist/components/number-input2.js +92 -16
  47. package/dist/components/password-input2.js +924 -24
  48. package/dist/components/pattern-mixin.js +85 -0
  49. package/dist/components/radio-input2.js +45 -11
  50. package/dist/components/select-input2.js +87 -27
  51. package/dist/components/tel-input2.js +122 -22
  52. package/dist/components/text-input2.js +120 -34
  53. package/dist/components/toggle-checkbox-input.d.ts +11 -0
  54. package/dist/components/toggle-checkbox-input.js +6 -0
  55. package/dist/components/tooltipIcon.js +70 -0
  56. package/dist/components/vaadin-button.js +461 -0
  57. package/dist/components/vaadin-combo-box.js +4329 -0
  58. package/dist/components/virtual-keyboard-controller.js +2658 -0
  59. package/dist/esm/checkbox-group-input_10.entry.js +35526 -0
  60. package/dist/esm/general-input.entry.js +34 -13
  61. package/dist/esm/general-input.js +2 -2
  62. package/dist/esm/{index-df80f936.js → index-db76d5b5.js} +118 -7
  63. package/dist/esm/loader.js +2 -2
  64. package/dist/esm/locale.utils-95ea2605.js +68 -0
  65. package/dist/esm/toggle-checkbox-input.entry.js +81 -0
  66. package/dist/esm/tooltipIcon-99c1c7b7.js +3 -0
  67. package/dist/general-input/general-input.esm.js +1 -1
  68. package/dist/general-input/p-0966f523.entry.js +3581 -0
  69. package/dist/general-input/p-916a1319.entry.js +1 -0
  70. package/dist/general-input/p-b408093e.js +1 -0
  71. package/dist/general-input/p-c2d4d6ac.entry.js +1 -0
  72. package/dist/general-input/p-f4f4ccda.js +1 -0
  73. package/dist/general-input/p-f6132f1d.js +1 -0
  74. package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +74 -0
  75. package/dist/types/components/checkbox-input/checkbox-input.d.ts +28 -2
  76. package/dist/types/components/date-input/date-input.d.ts +43 -1
  77. package/dist/types/components/email-input/email-input.d.ts +37 -3
  78. package/dist/types/components/general-input/general-input.d.ts +30 -0
  79. package/dist/types/components/number-input/number-input.d.ts +34 -3
  80. package/dist/types/components/password-input/password-input.d.ts +56 -7
  81. package/dist/types/components/radio-input/radio-input.d.ts +17 -1
  82. package/dist/types/components/select-input/select-input.d.ts +36 -3
  83. package/dist/types/components/tel-input/tel-input.d.ts +40 -5
  84. package/dist/types/components/text-input/text-input.d.ts +84 -0
  85. package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +67 -0
  86. package/dist/types/components.d.ts +568 -9
  87. package/dist/types/utils/locale.utils.d.ts +9 -0
  88. package/dist/types/utils/types.d.ts +41 -9
  89. package/package.json +8 -1
  90. package/dist/cjs/checkbox-input_9.cjs.entry.js +0 -623
  91. package/dist/components/locale.utils.js +0 -29
  92. package/dist/esm/checkbox-input_9.entry.js +0 -611
  93. package/dist/general-input/p-1703fce3.entry.js +0 -1
  94. package/dist/general-input/p-d9f7fa2e.js +0 -1
  95. package/dist/general-input/p-dea0a4ac.entry.js +0 -1
  96. /package/dist/types/Users/{user/workspace/everymatrix → adrian.pripon/Documents/Work}/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -0
@@ -1,39 +1,60 @@
1
- import { Component, h, Prop } from '@stencil/core';
1
+ import { Component, h, Prop, Host } from '@stencil/core';
2
+ import { getTranslations } from '../../utils/locale.utils';
2
3
  export class GeneralInput {
3
4
  constructor() {
4
5
  /**
5
6
  * Type the general-input should take. Can take the default HTML input values.
6
7
  */
7
8
  this.type = 'text';
9
+ /**
10
+ * Client custom styling via inline style
11
+ */
12
+ this.clientStyling = '';
13
+ /**
14
+ * Translations via URL
15
+ */
16
+ this.translationUrl = '';
8
17
  }
9
- render() {
10
- switch (this.type.toLowerCase()) {
18
+ connectedCallback() {
19
+ if (this.translationUrl) {
20
+ getTranslations(this.translationUrl);
21
+ }
22
+ }
23
+ renderInput() {
24
+ var _a;
25
+ switch ((_a = this.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) {
11
26
  case 'text':
12
- return h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language });
27
+ return h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
13
28
  case 'email':
14
- return h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language });
29
+ return h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
15
30
  case 'number':
16
- return h("number-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language });
31
+ return h("number-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
17
32
  case 'checkbox':
18
- return h("checkbox-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language });
33
+ return h("checkbox-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, defaultValue: this.defaultValue, autofilled: this.autofilled, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip });
34
+ case 'checkboxgroup':
35
+ return h("checkbox-group-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, options: this.options });
36
+ case 'togglecheckbox':
37
+ return h("toggle-checkbox-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, options: this.options });
19
38
  case 'datetime':
20
- return h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language });
39
+ return h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, dateFormat: this.dateFormat });
21
40
  case 'password':
22
- return h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language });
41
+ return h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
23
42
  case 'radio':
24
- return h("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language });
43
+ return h("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling });
25
44
  case 'tel':
26
- return h("tel-input", { name: this.name, action: this.action, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language });
45
+ return h("tel-input", { name: this.name, action: this.action, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, emitValue: this.emitValue, language: this.language, autofilled: this.autofilled, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
27
46
  case 'dropdown':
28
- return h("select-input", { name: this.name, action: this.action, displayName: this.displayName, options: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language });
47
+ return h("select-input", { name: this.name, action: this.action, defaultValue: this.defaultValue, displayName: this.displayName, options: this.options, validation: this.validation, emitValue: this.emitValue, autofilled: this.autofilled, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
29
48
  default:
30
- // Nothing here
31
49
  return h("p", null,
32
50
  "The ",
33
51
  this.type,
34
52
  " input type is not valid");
35
53
  }
36
54
  }
55
+ render() {
56
+ return (h(Host, { class: `general-input--${this.name}` }, this.renderInput()));
57
+ }
37
58
  static get is() { return "general-input"; }
38
59
  static get encapsulation() { return "shadow"; }
39
60
  static get originalStyleUrls() { return {
@@ -58,7 +79,7 @@ export class GeneralInput {
58
79
  "text": "Type the general-input should take. Can take the default HTML input values."
59
80
  },
60
81
  "attribute": "type",
61
- "reflect": false,
82
+ "reflect": true,
62
83
  "defaultValue": "'text'"
63
84
  },
64
85
  "name": {
@@ -76,7 +97,7 @@ export class GeneralInput {
76
97
  "text": "Name of the input."
77
98
  },
78
99
  "attribute": "name",
79
- "reflect": false
100
+ "reflect": true
80
101
  },
81
102
  "displayName": {
82
103
  "type": "string",
@@ -93,7 +114,24 @@ export class GeneralInput {
93
114
  "text": "Name of input to be shown to the user."
94
115
  },
95
116
  "attribute": "display-name",
96
- "reflect": false
117
+ "reflect": true
118
+ },
119
+ "placeholder": {
120
+ "type": "string",
121
+ "mutable": false,
122
+ "complexType": {
123
+ "original": "string",
124
+ "resolved": "string",
125
+ "references": {}
126
+ },
127
+ "required": false,
128
+ "optional": false,
129
+ "docs": {
130
+ "tags": [],
131
+ "text": "Placeholder text to be shown."
132
+ },
133
+ "attribute": "placeholder",
134
+ "reflect": true
97
135
  },
98
136
  "action": {
99
137
  "type": "string",
@@ -110,7 +148,7 @@ export class GeneralInput {
110
148
  "text": "Special behaviour an input should have. Can be fetching for data."
111
149
  },
112
150
  "attribute": "action",
113
- "reflect": false
151
+ "reflect": true
114
152
  },
115
153
  "validation": {
116
154
  "type": "unknown",
@@ -147,7 +185,7 @@ export class GeneralInput {
147
185
  "text": "For input elements that have multiple options or choises."
148
186
  },
149
187
  "attribute": "options",
150
- "reflect": false
188
+ "reflect": true
151
189
  },
152
190
  "language": {
153
191
  "type": "string",
@@ -164,7 +202,41 @@ export class GeneralInput {
164
202
  "text": "Currently selected language."
165
203
  },
166
204
  "attribute": "language",
167
- "reflect": false
205
+ "reflect": true
206
+ },
207
+ "autofilled": {
208
+ "type": "boolean",
209
+ "mutable": false,
210
+ "complexType": {
211
+ "original": "boolean",
212
+ "resolved": "boolean",
213
+ "references": {}
214
+ },
215
+ "required": false,
216
+ "optional": false,
217
+ "docs": {
218
+ "tags": [],
219
+ "text": "Boolean. Determines if input should be readonly."
220
+ },
221
+ "attribute": "autofilled",
222
+ "reflect": true
223
+ },
224
+ "tooltip": {
225
+ "type": "string",
226
+ "mutable": false,
227
+ "complexType": {
228
+ "original": "string",
229
+ "resolved": "string",
230
+ "references": {}
231
+ },
232
+ "required": false,
233
+ "optional": false,
234
+ "docs": {
235
+ "tags": [],
236
+ "text": "Tooltip text."
237
+ },
238
+ "attribute": "tooltip",
239
+ "reflect": true
168
240
  },
169
241
  "defaultValue": {
170
242
  "type": "any",
@@ -181,7 +253,7 @@ export class GeneralInput {
181
253
  "text": "Default value for the input."
182
254
  },
183
255
  "attribute": "default-value",
184
- "reflect": false
256
+ "reflect": true
185
257
  },
186
258
  "emitValue": {
187
259
  "type": "boolean",
@@ -198,7 +270,77 @@ export class GeneralInput {
198
270
  "text": "State passed down from the parent element. Will trigger the child specialised input to send it's value through an event."
199
271
  },
200
272
  "attribute": "emit-value",
201
- "reflect": false
273
+ "reflect": true
274
+ },
275
+ "isDuplicateInput": {
276
+ "type": "boolean",
277
+ "mutable": false,
278
+ "complexType": {
279
+ "original": "boolean",
280
+ "resolved": "boolean",
281
+ "references": {}
282
+ },
283
+ "required": false,
284
+ "optional": false,
285
+ "docs": {
286
+ "tags": [],
287
+ "text": "Boolean that triggers certain validation rules, for duplicated inputs."
288
+ },
289
+ "attribute": "is-duplicate-input",
290
+ "reflect": true
291
+ },
292
+ "clientStyling": {
293
+ "type": "any",
294
+ "mutable": false,
295
+ "complexType": {
296
+ "original": "any",
297
+ "resolved": "any",
298
+ "references": {}
299
+ },
300
+ "required": false,
301
+ "optional": false,
302
+ "docs": {
303
+ "tags": [],
304
+ "text": "Client custom styling via inline style"
305
+ },
306
+ "attribute": "client-styling",
307
+ "reflect": true,
308
+ "defaultValue": "''"
309
+ },
310
+ "dateFormat": {
311
+ "type": "string",
312
+ "mutable": false,
313
+ "complexType": {
314
+ "original": "string",
315
+ "resolved": "string",
316
+ "references": {}
317
+ },
318
+ "required": false,
319
+ "optional": false,
320
+ "docs": {
321
+ "tags": [],
322
+ "text": "Date format for date picker."
323
+ },
324
+ "attribute": "date-format",
325
+ "reflect": true
326
+ },
327
+ "translationUrl": {
328
+ "type": "string",
329
+ "mutable": false,
330
+ "complexType": {
331
+ "original": "string",
332
+ "resolved": "string",
333
+ "references": {}
334
+ },
335
+ "required": false,
336
+ "optional": false,
337
+ "docs": {
338
+ "tags": [],
339
+ "text": "Translations via URL"
340
+ },
341
+ "attribute": "translation-url",
342
+ "reflect": true,
343
+ "defaultValue": "''"
202
344
  }
203
345
  }; }
204
346
  }
@@ -6,62 +6,97 @@
6
6
  box-sizing: border-box;
7
7
  }
8
8
 
9
+ .number {
10
+ font-family: "Roboto";
11
+ font-style: normal;
12
+ }
9
13
  .number__wrapper {
10
14
  position: relative;
15
+ width: 100%;
16
+ }
17
+ .number__wrapper--autofilled {
18
+ pointer-events: none;
19
+ }
20
+ .number__wrapper--autofilled .number__label {
21
+ color: #979797;
22
+ }
23
+ .number__wrapper--autofilled .number__input {
24
+ color: #979797;
25
+ }
26
+ .number__wrapper--flex {
11
27
  display: flex;
12
- flex-direction: column-reverse;
13
- padding-top: 10px;
28
+ gap: 5px;
29
+ }
30
+ .number__wrapper--relative {
31
+ position: relative;
14
32
  }
15
33
  .number__label {
16
- color: #474747;
34
+ font-family: inherit;
35
+ font-style: normal;
36
+ font-weight: 500;
17
37
  font-size: 16px;
18
- position: absolute;
19
- bottom: 15px;
20
- left: 5px;
21
- transform: translateY(-25px);
22
- transition: all 0.3s cubic-bezier(0.5, 0, 0.5, 1);
38
+ line-height: 20px;
39
+ color: #2A3841;
23
40
  }
24
41
  .number__label--required::after {
25
42
  content: "*";
26
- margin-left: 5px;
27
- color: #666666;
43
+ font-family: inherit;
44
+ color: #2A3841;
45
+ margin-left: 2px;
28
46
  }
29
47
  .number__input {
30
- width: inherit;
31
- padding: 15px 6px;
32
- position: relative;
33
- border: none;
34
- border-bottom: 3px solid #666666;
48
+ border-radius: 4px;
35
49
  background-color: transparent;
36
- color: #666666;
37
- font-size: 16px;
38
50
  font-family: inherit;
51
+ font-style: normal;
52
+ font-weight: 300;
53
+ font-size: 16px;
54
+ line-height: 19px;
55
+ color: #2A2E3F;
56
+ padding: 10px 20px;
57
+ width: inherit;
58
+ position: relative;
59
+ border: 2px solid #DEE1EE;
39
60
  /* Firefox */
40
61
  -moz-appearance: textfield;
41
62
  /* Chrome, Safari, Edge, Opera */
42
63
  }
64
+ .number__input:focus {
65
+ outline-color: #3E3E3E;
66
+ }
43
67
  .number__input::-webkit-outer-spin-button, .number__input::-webkit-inner-spin-button {
44
68
  -webkit-appearance: none;
45
69
  margin: 0;
46
70
  }
47
- .number__input:focus {
48
- outline: none;
49
- box-shadow: 0 5px 5px rgba(16, 15, 15, 0.1);
50
- }
51
- .number__input::placeholder {
52
- color: #666666;
53
- }
54
71
  .number__input--invalid {
55
- border-bottom: 3px solid #cc0000;
72
+ border: 2px solid #cc0000b3;
56
73
  }
57
- .number__input:placeholder-shown + .number__label {
58
- opacity: 0;
59
- visibility: hidden;
60
- transform: translateY(0);
74
+ .number__input::placeholder {
75
+ color: #979797;
61
76
  }
62
77
  .number__error-message {
63
78
  position: absolute;
64
79
  top: calc(100% + 5px);
65
80
  left: 0;
66
- color: #cc0000;
81
+ color: #cc0000b3;
82
+ }
83
+ .number__tooltip-icon {
84
+ width: 16px;
85
+ height: auto;
86
+ }
87
+ .number__tooltip {
88
+ position: absolute;
89
+ top: 0;
90
+ left: 20px;
91
+ background-color: #FFFFFF;
92
+ border: 1px solid #B0B0B0;
93
+ color: #2B2D3F;
94
+ padding: 10px;
95
+ border-radius: 5px;
96
+ opacity: 0;
97
+ transition: opacity 0.3s ease-in-out;
98
+ z-index: 10;
99
+ }
100
+ .number__tooltip.visible {
101
+ opacity: 1;
67
102
  }
@@ -1,6 +1,39 @@
1
- import { Component, h, Prop, State, Watch, Event } from '@stencil/core';
1
+ import { Component, h, Prop, State, Watch, Event, Listen } from '@stencil/core';
2
2
  import { translate } from '../../utils/locale.utils';
3
+ import tooltipIcon from '../../utils/tooltipIcon.svg';
3
4
  export class NumberInput {
5
+ constructor() {
6
+ /**
7
+ * Client custom styling via inline style
8
+ */
9
+ this.clientStyling = '';
10
+ this.limitStylingAppends = false;
11
+ this.showTooltip = false;
12
+ this.validationPattern = '';
13
+ this.touched = false;
14
+ this.handleInput = (event) => {
15
+ this.value = event.target.value;
16
+ this.touched = true;
17
+ if (this.debounceTime) {
18
+ clearTimeout(this.debounceTime);
19
+ }
20
+ this.debounceTime = setTimeout(() => {
21
+ this.isValid = this.setValidity();
22
+ this.errorMessage = this.setErrorMessage();
23
+ this.emitValueHandler(true);
24
+ }, 500);
25
+ };
26
+ this.handleBlur = () => {
27
+ this.isValid = this.setValidity();
28
+ this.errorMessage = this.setErrorMessage();
29
+ this.touched = true;
30
+ };
31
+ this.setClientStyling = () => {
32
+ let sheet = document.createElement('style');
33
+ sheet.innerHTML = this.clientStyling;
34
+ this.stylingContainer.prepend(sheet);
35
+ };
36
+ }
4
37
  validityChanged() {
5
38
  this.validityStateHandler({ valid: this.isValid, name: this.name });
6
39
  if (this.emitValue == true) {
@@ -18,17 +51,47 @@ export class NumberInput {
18
51
  valueHandler(inputValueEvent) {
19
52
  this.sendInputValue.emit(inputValueEvent);
20
53
  }
21
- handleInput(event) {
22
- this.value = event.target.value;
23
- this.errorMessage = this.setErrorMessage();
54
+ handleClickOutside(event) {
55
+ if (event.composedPath()[0] === this.tooltipIconReference)
56
+ return;
57
+ if (event.composedPath()[0] !== this.tooltipReference)
58
+ this.showTooltip = false;
59
+ }
60
+ connectedCallback() {
61
+ this.validationPattern = this.setPattern();
62
+ }
63
+ componentDidRender() {
64
+ // start custom styling area
65
+ if (!this.limitStylingAppends && this.stylingContainer) {
66
+ if (this.clientStyling)
67
+ this.setClientStyling();
68
+ this.limitStylingAppends = true;
69
+ }
70
+ // end custom styling area
71
+ }
72
+ componentDidLoad() {
24
73
  this.isValid = this.setValidity();
25
- this.validityStateHandler({ valid: this.isValid, name: this.name });
26
- this.emitValueHandler(true);
74
+ if (this.defaultValue) {
75
+ this.value = this.defaultValue;
76
+ this.valueHandler({ name: this.name, value: this.value });
77
+ }
27
78
  }
28
79
  setValidity() {
29
80
  return this.inputReference.validity.valid;
30
81
  }
82
+ setPattern() {
83
+ var _a, _b;
84
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
85
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
86
+ }
87
+ }
31
88
  setErrorMessage() {
89
+ var _a, _b;
90
+ if (this.inputReference.validity.patternMismatch) {
91
+ const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
92
+ const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
93
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
94
+ }
32
95
  if (this.inputReference.validity.rangeUnderflow || this.inputReference.validity.rangeOverflow) {
33
96
  return translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } });
34
97
  }
@@ -36,11 +99,25 @@ export class NumberInput {
36
99
  return translate('requiredError', this.language);
37
100
  }
38
101
  }
102
+ renderTooltip() {
103
+ if (this.showTooltip) {
104
+ return (h("div", { class: `number__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
105
+ }
106
+ return null;
107
+ }
39
108
  render() {
40
- const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'number__input--invalid';
41
- return h("div", { class: 'number__wrapper' },
42
- h("input", { ref: (el) => this.inputReference = el, type: "number", value: this.defaultValue, id: `${this.name}__input`, class: `number__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }),
43
- h("label", { class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
109
+ let invalidClass = '';
110
+ if (this.touched) {
111
+ invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
112
+ }
113
+ return h("div", { class: `number__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el },
114
+ h("div", { class: 'number__wrapper--flex' },
115
+ h("label", { class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
116
+ h("div", { class: 'number__wrapper--relative' },
117
+ this.tooltip &&
118
+ h("img", { class: 'number__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }),
119
+ this.renderTooltip())),
120
+ h("input", { ref: (el) => this.inputReference = el, type: "number", value: this.defaultValue, readOnly: this.autofilled, id: `${this.name}__input`, class: `number__input ${invalidClass}`, pattern: this.validationPattern, placeholder: `${this.placeholder}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: this.handleInput, onBlur: this.handleBlur }),
44
121
  h("small", { class: 'number__error-message' }, this.errorMessage));
45
122
  }
46
123
  static get is() { return "number-input"; }
@@ -67,7 +144,7 @@ export class NumberInput {
67
144
  "text": "Name of the input."
68
145
  },
69
146
  "attribute": "name",
70
- "reflect": false
147
+ "reflect": true
71
148
  },
72
149
  "displayName": {
73
150
  "type": "string",
@@ -84,7 +161,24 @@ export class NumberInput {
84
161
  "text": "Name of input to be shown to the user."
85
162
  },
86
163
  "attribute": "display-name",
87
- "reflect": false
164
+ "reflect": true
165
+ },
166
+ "placeholder": {
167
+ "type": "string",
168
+ "mutable": false,
169
+ "complexType": {
170
+ "original": "string",
171
+ "resolved": "string",
172
+ "references": {}
173
+ },
174
+ "required": false,
175
+ "optional": false,
176
+ "docs": {
177
+ "tags": [],
178
+ "text": "Placeholder text to be shown."
179
+ },
180
+ "attribute": "placeholder",
181
+ "reflect": true
88
182
  },
89
183
  "validation": {
90
184
  "type": "unknown",
@@ -107,11 +201,11 @@ export class NumberInput {
107
201
  }
108
202
  },
109
203
  "defaultValue": {
110
- "type": "number",
204
+ "type": "string",
111
205
  "mutable": false,
112
206
  "complexType": {
113
- "original": "number",
114
- "resolved": "number",
207
+ "original": "string",
208
+ "resolved": "string",
115
209
  "references": {}
116
210
  },
117
211
  "required": false,
@@ -121,7 +215,41 @@ export class NumberInput {
121
215
  "text": "Default value for the input."
122
216
  },
123
217
  "attribute": "default-value",
124
- "reflect": false
218
+ "reflect": true
219
+ },
220
+ "autofilled": {
221
+ "type": "boolean",
222
+ "mutable": false,
223
+ "complexType": {
224
+ "original": "boolean",
225
+ "resolved": "boolean",
226
+ "references": {}
227
+ },
228
+ "required": false,
229
+ "optional": false,
230
+ "docs": {
231
+ "tags": [],
232
+ "text": "Boolean. Determines if input should be readonly."
233
+ },
234
+ "attribute": "autofilled",
235
+ "reflect": true
236
+ },
237
+ "tooltip": {
238
+ "type": "string",
239
+ "mutable": false,
240
+ "complexType": {
241
+ "original": "string",
242
+ "resolved": "string",
243
+ "references": {}
244
+ },
245
+ "required": false,
246
+ "optional": false,
247
+ "docs": {
248
+ "tags": [],
249
+ "text": "Tooltip text."
250
+ },
251
+ "attribute": "tooltip",
252
+ "reflect": true
125
253
  },
126
254
  "language": {
127
255
  "type": "string",
@@ -138,7 +266,7 @@ export class NumberInput {
138
266
  "text": "Currently selected language."
139
267
  },
140
268
  "attribute": "language",
141
- "reflect": false
269
+ "reflect": true
142
270
  },
143
271
  "emitValue": {
144
272
  "type": "boolean",
@@ -155,12 +283,32 @@ export class NumberInput {
155
283
  "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
156
284
  },
157
285
  "attribute": "emit-value",
158
- "reflect": false
286
+ "reflect": true
287
+ },
288
+ "clientStyling": {
289
+ "type": "string",
290
+ "mutable": false,
291
+ "complexType": {
292
+ "original": "string",
293
+ "resolved": "string",
294
+ "references": {}
295
+ },
296
+ "required": false,
297
+ "optional": false,
298
+ "docs": {
299
+ "tags": [],
300
+ "text": "Client custom styling via inline style"
301
+ },
302
+ "attribute": "client-styling",
303
+ "reflect": true,
304
+ "defaultValue": "''"
159
305
  }
160
306
  }; }
161
307
  static get states() { return {
162
308
  "errorMessage": {},
163
- "isValid": {}
309
+ "isValid": {},
310
+ "limitStylingAppends": {},
311
+ "showTooltip": {}
164
312
  }; }
165
313
  static get events() { return [{
166
314
  "method": "sendValidityState",
@@ -210,4 +358,11 @@ export class NumberInput {
210
358
  "propName": "emitValue",
211
359
  "methodName": "emitValueHandler"
212
360
  }]; }
361
+ static get listeners() { return [{
362
+ "name": "click",
363
+ "method": "handleClickOutside",
364
+ "target": "document",
365
+ "capture": false,
366
+ "passive": false
367
+ }]; }
213
368
  }