@everymatrix/general-input 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/cjs/checkbox-input_9.cjs.entry.js +686 -0
  2. package/dist/cjs/general-input.cjs.entry.js +45 -0
  3. package/dist/cjs/general-input.cjs.js +19 -0
  4. package/dist/cjs/index-64a5cb7f.js +1214 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +21 -0
  7. package/dist/collection/collection-manifest.json +21 -0
  8. package/dist/collection/components/checkbox-input/checkbox-input.css +20 -0
  9. package/dist/collection/components/checkbox-input/checkbox-input.js +196 -0
  10. package/dist/collection/components/date-input/date-input.css +60 -0
  11. package/dist/collection/components/date-input/date-input.js +242 -0
  12. package/dist/collection/components/email-input/email-input.css +60 -0
  13. package/dist/collection/components/email-input/email-input.js +259 -0
  14. package/dist/collection/components/general-input/general-input.css +3 -0
  15. package/dist/collection/components/general-input/general-input.js +204 -0
  16. package/dist/collection/components/number-input/number-input.css +67 -0
  17. package/dist/collection/components/number-input/number-input.js +245 -0
  18. package/dist/collection/components/password-input/password-input.css +60 -0
  19. package/dist/collection/components/password-input/password-input.js +210 -0
  20. package/dist/collection/components/radio-input/radio-input.css +22 -0
  21. package/dist/collection/components/radio-input/radio-input.js +245 -0
  22. package/dist/collection/components/select-input/select-input.css +49 -0
  23. package/dist/collection/components/select-input/select-input.js +308 -0
  24. package/dist/collection/components/tel-input/tel-input.css +67 -0
  25. package/dist/collection/components/tel-input/tel-input.js +294 -0
  26. package/dist/collection/components/text-input/text-input.css +60 -0
  27. package/dist/collection/components/text-input/text-input.js +278 -0
  28. package/dist/collection/index.js +1 -0
  29. package/dist/collection/utils/locale.utils.js +27 -0
  30. package/dist/collection/utils/types.js +1 -0
  31. package/dist/collection/utils/utils.js +5 -0
  32. package/dist/components/checkbox-input.d.ts +11 -0
  33. package/dist/components/checkbox-input.js +6 -0
  34. package/dist/components/checkbox-input2.js +78 -0
  35. package/dist/components/date-input.d.ts +11 -0
  36. package/dist/components/date-input.js +6 -0
  37. package/dist/components/date-input2.js +90 -0
  38. package/dist/components/email-input.d.ts +11 -0
  39. package/dist/components/email-input.js +6 -0
  40. package/dist/components/email-input2.js +108 -0
  41. package/dist/components/general-input.d.ts +11 -0
  42. package/dist/components/general-input.js +123 -0
  43. package/dist/components/index.d.ts +26 -0
  44. package/dist/components/index.js +1 -0
  45. package/dist/components/locale.utils.js +29 -0
  46. package/dist/components/number-input.d.ts +11 -0
  47. package/dist/components/number-input.js +6 -0
  48. package/dist/components/number-input2.js +96 -0
  49. package/dist/components/password-input.d.ts +11 -0
  50. package/dist/components/password-input.js +6 -0
  51. package/dist/components/password-input2.js +93 -0
  52. package/dist/components/radio-input.d.ts +11 -0
  53. package/dist/components/radio-input.js +6 -0
  54. package/dist/components/radio-input2.js +89 -0
  55. package/dist/components/select-input.d.ts +11 -0
  56. package/dist/components/select-input.js +6 -0
  57. package/dist/components/select-input2.js +127 -0
  58. package/dist/components/tel-input.d.ts +11 -0
  59. package/dist/components/tel-input.js +6 -0
  60. package/dist/components/tel-input2.js +111 -0
  61. package/dist/components/text-input.d.ts +11 -0
  62. package/dist/components/text-input.js +6 -0
  63. package/dist/components/text-input2.js +112 -0
  64. package/dist/esm/checkbox-input_9.entry.js +674 -0
  65. package/dist/esm/general-input.entry.js +41 -0
  66. package/dist/esm/general-input.js +17 -0
  67. package/dist/esm/index-df80f936.js +1188 -0
  68. package/dist/esm/index.js +1 -0
  69. package/dist/esm/loader.js +17 -0
  70. package/dist/esm/polyfills/core-js.js +11 -0
  71. package/dist/esm/polyfills/css-shim.js +1 -0
  72. package/dist/esm/polyfills/dom.js +79 -0
  73. package/dist/esm/polyfills/es5-html-element.js +1 -0
  74. package/dist/esm/polyfills/index.js +34 -0
  75. package/dist/esm/polyfills/system.js +6 -0
  76. package/dist/general-input/general-input.esm.js +1 -0
  77. package/dist/general-input/index.esm.js +0 -0
  78. package/dist/general-input/p-c9e79656.entry.js +1 -0
  79. package/dist/general-input/p-d9f7fa2e.js +1 -0
  80. package/dist/general-input/p-dea0a4ac.entry.js +1 -0
  81. package/dist/index.cjs.js +1 -0
  82. package/dist/index.js +1 -0
  83. package/dist/stencil.config.js +22 -0
  84. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
  85. package/dist/types/components/checkbox-input/checkbox-input.d.ts +39 -0
  86. package/dist/types/components/date-input/date-input.d.ts +47 -0
  87. package/dist/types/components/email-input/email-input.d.ts +51 -0
  88. package/dist/types/components/general-input/general-input.d.ts +40 -0
  89. package/dist/types/components/number-input/number-input.d.ts +48 -0
  90. package/dist/types/components/password-input/password-input.d.ts +42 -0
  91. package/dist/types/components/radio-input/radio-input.d.ts +48 -0
  92. package/dist/types/components/select-input/select-input.d.ts +55 -0
  93. package/dist/types/components/tel-input/tel-input.d.ts +59 -0
  94. package/dist/types/components.d.ts +749 -0
  95. package/dist/types/index.d.ts +1 -0
  96. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  97. package/dist/types/utils/locale.utils.d.ts +5 -0
  98. package/dist/types/utils/types.d.ts +55 -0
  99. package/dist/types/utils/utils.d.ts +1 -0
  100. package/loader/cdn.js +3 -0
  101. package/loader/index.cjs.js +3 -0
  102. package/loader/index.d.ts +12 -0
  103. package/loader/index.es2017.js +3 -0
  104. package/loader/index.js +4 -0
  105. package/loader/package.json +10 -0
  106. package/package.json +19 -0
@@ -0,0 +1,259 @@
1
+ import { Component, h, Prop, State, Watch, Event } from '@stencil/core';
2
+ import { translate } from '../../utils/locale.utils';
3
+ export class EmailInput {
4
+ constructor() {
5
+ this.validationPattern = '';
6
+ }
7
+ checkValidityHandler(newValue) {
8
+ if (newValue == true) {
9
+ this.isValid = this.setValidity();
10
+ this.errorMessage = this.setErrorMessage();
11
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
12
+ }
13
+ }
14
+ validityChanged() {
15
+ if (this.checkValidity == true) {
16
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
17
+ }
18
+ if (this.emitValue == true) {
19
+ this.valueHandler({ name: this.name, value: this.value });
20
+ }
21
+ }
22
+ validityStateHandler(inputStateEvent) {
23
+ this.sendValidityState.emit(inputStateEvent);
24
+ }
25
+ emitValueHandler(newValue) {
26
+ if (newValue == true && this.isValid) {
27
+ this.valueHandler({ name: this.name, value: this.value });
28
+ }
29
+ }
30
+ valueHandler(inputValueEvent) {
31
+ this.sendInputValue.emit(inputValueEvent);
32
+ }
33
+ connectedCallback() {
34
+ this.validationPattern = this.setPattern();
35
+ }
36
+ handleInput(event) {
37
+ this.value = event.target.value;
38
+ if (this.debounceTime) {
39
+ clearTimeout(this.debounceTime);
40
+ }
41
+ this.debounceTime = setTimeout(() => {
42
+ this.errorMessage = this.setErrorMessage();
43
+ this.isValid = this.setValidity();
44
+ }, 500);
45
+ }
46
+ setValidity() {
47
+ return this.inputReference.validity.valid;
48
+ }
49
+ setPattern() {
50
+ var _a;
51
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
52
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
53
+ }
54
+ }
55
+ setErrorMessage() {
56
+ if (this.inputReference.validity.patternMismatch) {
57
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
58
+ }
59
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
60
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
61
+ }
62
+ if (this.inputReference.validity.valueMissing) {
63
+ return translate('requiredError', this.language);
64
+ }
65
+ }
66
+ render() {
67
+ return h("div", { class: 'email__wrapper' },
68
+ h("input", { id: `${this.name}__input`, type: 'email', class: `email__input`, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: (e) => this.handleInput(e) }),
69
+ h("label", { class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
70
+ h("small", { class: 'email__error-message' }, this.errorMessage));
71
+ }
72
+ static get is() { return "email-input"; }
73
+ static get encapsulation() { return "shadow"; }
74
+ static get originalStyleUrls() { return {
75
+ "$": ["email-input.scss"]
76
+ }; }
77
+ static get styleUrls() { return {
78
+ "$": ["email-input.css"]
79
+ }; }
80
+ static get properties() { return {
81
+ "name": {
82
+ "type": "string",
83
+ "mutable": false,
84
+ "complexType": {
85
+ "original": "string",
86
+ "resolved": "string",
87
+ "references": {}
88
+ },
89
+ "required": false,
90
+ "optional": false,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": "Name of the input."
94
+ },
95
+ "attribute": "name",
96
+ "reflect": false
97
+ },
98
+ "displayName": {
99
+ "type": "string",
100
+ "mutable": false,
101
+ "complexType": {
102
+ "original": "string",
103
+ "resolved": "string",
104
+ "references": {}
105
+ },
106
+ "required": false,
107
+ "optional": false,
108
+ "docs": {
109
+ "tags": [],
110
+ "text": "Name of input to be shown to the user."
111
+ },
112
+ "attribute": "display-name",
113
+ "reflect": false
114
+ },
115
+ "validation": {
116
+ "type": "unknown",
117
+ "mutable": false,
118
+ "complexType": {
119
+ "original": "ValidationSchema",
120
+ "resolved": "ValidationSchema",
121
+ "references": {
122
+ "ValidationSchema": {
123
+ "location": "import",
124
+ "path": "../../utils/types"
125
+ }
126
+ }
127
+ },
128
+ "required": false,
129
+ "optional": false,
130
+ "docs": {
131
+ "tags": [],
132
+ "text": "Object of validation rules for the input."
133
+ }
134
+ },
135
+ "defaultValue": {
136
+ "type": "string",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "string",
140
+ "resolved": "string",
141
+ "references": {}
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": "Default value for the input."
148
+ },
149
+ "attribute": "default-value",
150
+ "reflect": false
151
+ },
152
+ "language": {
153
+ "type": "string",
154
+ "mutable": false,
155
+ "complexType": {
156
+ "original": "string",
157
+ "resolved": "string",
158
+ "references": {}
159
+ },
160
+ "required": false,
161
+ "optional": false,
162
+ "docs": {
163
+ "tags": [],
164
+ "text": "Currently selected language."
165
+ },
166
+ "attribute": "language",
167
+ "reflect": false
168
+ },
169
+ "emitValue": {
170
+ "type": "boolean",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "boolean",
174
+ "resolved": "boolean",
175
+ "references": {}
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
182
+ },
183
+ "attribute": "emit-value",
184
+ "reflect": false
185
+ },
186
+ "checkValidity": {
187
+ "type": "boolean",
188
+ "mutable": false,
189
+ "complexType": {
190
+ "original": "boolean",
191
+ "resolved": "boolean",
192
+ "references": {}
193
+ },
194
+ "required": false,
195
+ "optional": false,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": "State passed down from the parent element. Will trigger the input to check for validity."
199
+ },
200
+ "attribute": "check-validity",
201
+ "reflect": false
202
+ }
203
+ }; }
204
+ static get states() { return {
205
+ "errorMessage": {},
206
+ "isValid": {}
207
+ }; }
208
+ static get events() { return [{
209
+ "method": "sendValidityState",
210
+ "name": "sendValidityState",
211
+ "bubbles": true,
212
+ "cancelable": true,
213
+ "composed": true,
214
+ "docs": {
215
+ "tags": [],
216
+ "text": ""
217
+ },
218
+ "complexType": {
219
+ "original": "InputStateEvent",
220
+ "resolved": "InputStateEvent",
221
+ "references": {
222
+ "InputStateEvent": {
223
+ "location": "import",
224
+ "path": "../../utils/types"
225
+ }
226
+ }
227
+ }
228
+ }, {
229
+ "method": "sendInputValue",
230
+ "name": "sendInputValue",
231
+ "bubbles": true,
232
+ "cancelable": true,
233
+ "composed": true,
234
+ "docs": {
235
+ "tags": [],
236
+ "text": ""
237
+ },
238
+ "complexType": {
239
+ "original": "InputValueEvent",
240
+ "resolved": "InputValueEvent",
241
+ "references": {
242
+ "InputValueEvent": {
243
+ "location": "import",
244
+ "path": "../../utils/types"
245
+ }
246
+ }
247
+ }
248
+ }]; }
249
+ static get watchers() { return [{
250
+ "propName": "checkValidity",
251
+ "methodName": "checkValidityHandler"
252
+ }, {
253
+ "propName": "isValid",
254
+ "methodName": "validityChanged"
255
+ }, {
256
+ "propName": "emitValue",
257
+ "methodName": "emitValueHandler"
258
+ }]; }
259
+ }
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,204 @@
1
+ import { Component, h, Prop } from '@stencil/core';
2
+ export class GeneralInput {
3
+ constructor() {
4
+ /**
5
+ * Type the general-input should take. Can take the default HTML input values.
6
+ */
7
+ this.type = 'text';
8
+ }
9
+ render() {
10
+ switch (this.type.toLowerCase()) {
11
+ 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 });
13
+ 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 });
15
+ 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 });
17
+ case 'checkbox':
18
+ return h("checkbox-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language });
19
+ 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 });
21
+ case 'password':
22
+ return h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language });
23
+ 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 });
25
+ 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 });
27
+ 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 });
29
+ default:
30
+ // Nothing here
31
+ return h("p", null,
32
+ "The ",
33
+ this.type,
34
+ " input type is not valid");
35
+ }
36
+ }
37
+ static get is() { return "general-input"; }
38
+ static get encapsulation() { return "shadow"; }
39
+ static get originalStyleUrls() { return {
40
+ "$": ["general-input.scss"]
41
+ }; }
42
+ static get styleUrls() { return {
43
+ "$": ["general-input.css"]
44
+ }; }
45
+ static get properties() { return {
46
+ "type": {
47
+ "type": "string",
48
+ "mutable": false,
49
+ "complexType": {
50
+ "original": "string",
51
+ "resolved": "string",
52
+ "references": {}
53
+ },
54
+ "required": false,
55
+ "optional": false,
56
+ "docs": {
57
+ "tags": [],
58
+ "text": "Type the general-input should take. Can take the default HTML input values."
59
+ },
60
+ "attribute": "type",
61
+ "reflect": false,
62
+ "defaultValue": "'text'"
63
+ },
64
+ "name": {
65
+ "type": "string",
66
+ "mutable": false,
67
+ "complexType": {
68
+ "original": "string",
69
+ "resolved": "string",
70
+ "references": {}
71
+ },
72
+ "required": false,
73
+ "optional": false,
74
+ "docs": {
75
+ "tags": [],
76
+ "text": "Name of the input."
77
+ },
78
+ "attribute": "name",
79
+ "reflect": false
80
+ },
81
+ "displayName": {
82
+ "type": "string",
83
+ "mutable": false,
84
+ "complexType": {
85
+ "original": "string",
86
+ "resolved": "string",
87
+ "references": {}
88
+ },
89
+ "required": false,
90
+ "optional": false,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": "Name of input to be shown to the user."
94
+ },
95
+ "attribute": "display-name",
96
+ "reflect": false
97
+ },
98
+ "action": {
99
+ "type": "string",
100
+ "mutable": false,
101
+ "complexType": {
102
+ "original": "string",
103
+ "resolved": "string",
104
+ "references": {}
105
+ },
106
+ "required": false,
107
+ "optional": false,
108
+ "docs": {
109
+ "tags": [],
110
+ "text": "Special behaviour an input should have. Can be fetching for data."
111
+ },
112
+ "attribute": "action",
113
+ "reflect": false
114
+ },
115
+ "validation": {
116
+ "type": "unknown",
117
+ "mutable": false,
118
+ "complexType": {
119
+ "original": "ValidationSchema",
120
+ "resolved": "ValidationSchema",
121
+ "references": {
122
+ "ValidationSchema": {
123
+ "location": "import",
124
+ "path": "../../utils/types"
125
+ }
126
+ }
127
+ },
128
+ "required": false,
129
+ "optional": false,
130
+ "docs": {
131
+ "tags": [],
132
+ "text": "Object of validation rules for the input."
133
+ }
134
+ },
135
+ "options": {
136
+ "type": "any",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "any",
140
+ "resolved": "any",
141
+ "references": {}
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": "For input elements that have multiple options or choises."
148
+ },
149
+ "attribute": "options",
150
+ "reflect": false
151
+ },
152
+ "language": {
153
+ "type": "string",
154
+ "mutable": false,
155
+ "complexType": {
156
+ "original": "string",
157
+ "resolved": "string",
158
+ "references": {}
159
+ },
160
+ "required": false,
161
+ "optional": false,
162
+ "docs": {
163
+ "tags": [],
164
+ "text": "Currently selected language."
165
+ },
166
+ "attribute": "language",
167
+ "reflect": false
168
+ },
169
+ "defaultValue": {
170
+ "type": "any",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "any",
174
+ "resolved": "any",
175
+ "references": {}
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": "Default value for the input."
182
+ },
183
+ "attribute": "default-value",
184
+ "reflect": false
185
+ },
186
+ "emitValue": {
187
+ "type": "boolean",
188
+ "mutable": false,
189
+ "complexType": {
190
+ "original": "boolean",
191
+ "resolved": "boolean",
192
+ "references": {}
193
+ },
194
+ "required": false,
195
+ "optional": false,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": "State passed down from the parent element. Will trigger the child specialised input to send it's value through an event."
199
+ },
200
+ "attribute": "emit-value",
201
+ "reflect": false
202
+ }
203
+ }; }
204
+ }
@@ -0,0 +1,67 @@
1
+ *,
2
+ *::before,
3
+ *::after {
4
+ padding: 0;
5
+ margin: 0;
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ .number__wrapper {
10
+ position: relative;
11
+ display: flex;
12
+ flex-direction: column-reverse;
13
+ padding-top: 10px;
14
+ }
15
+ .number__label {
16
+ color: #474747;
17
+ 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);
23
+ }
24
+ .number__label--required::after {
25
+ content: "*";
26
+ margin-left: 5px;
27
+ color: #666666;
28
+ }
29
+ .number__input {
30
+ width: inherit;
31
+ padding: 15px 6px;
32
+ position: relative;
33
+ border: none;
34
+ border-bottom: 3px solid #666666;
35
+ background-color: transparent;
36
+ color: #666666;
37
+ font-size: 16px;
38
+ font-family: inherit;
39
+ /* Firefox */
40
+ -moz-appearance: textfield;
41
+ /* Chrome, Safari, Edge, Opera */
42
+ }
43
+ .number__input::-webkit-outer-spin-button, .number__input::-webkit-inner-spin-button {
44
+ -webkit-appearance: none;
45
+ margin: 0;
46
+ }
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
+ .number__input--invalid {
55
+ border-bottom: 3px solid #cc0000;
56
+ }
57
+ .number__input:placeholder-shown + .number__label {
58
+ opacity: 0;
59
+ visibility: hidden;
60
+ transform: translateY(0);
61
+ }
62
+ .number__error-message {
63
+ position: absolute;
64
+ top: calc(100% + 5px);
65
+ left: 0;
66
+ color: #cc0000;
67
+ }