@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,395 +1,535 @@
1
- import { Component, h, Prop, State, Watch, Event, Listen, Element } from '@stencil/core';
2
- import { translate } from '../../utils/locale.utils';
3
- import '@vaadin/password-field';
4
- import tooltipIcon from '../../utils/tooltipIcon.svg';
1
+ import { h } from "@stencil/core";
2
+ import { translate } from "../../utils/locale.utils";
3
+ import "@vaadin/password-field";
4
+ import tooltipIcon from "../../utils/tooltipIcon.svg";
5
5
  export class PasswordInput {
6
- constructor() {
7
- /**
8
- * Default value for the input.
9
- */
10
- this.defaultValue = '';
11
- /**
12
- * Client custom styling via inline style
13
- */
14
- this.clientStyling = '';
15
- this.limitStylingAppends = false;
16
- this.showTooltip = false;
17
- this.value = '';
18
- this.validationPattern = '';
19
- this.setClientStyling = () => {
20
- let sheet = document.createElement('style');
21
- sheet.innerHTML = this.clientStyling;
22
- this.stylingContainer.prepend(sheet);
23
- };
24
- }
25
- validityChanged() {
26
- this.validityStateHandler({ valid: this.isValid, name: this.name });
27
- if (this.emitValue == true) {
28
- this.valueHandler({ name: this.name, value: this.value });
6
+ constructor() {
7
+ this.touched = false;
8
+ this.originalValid = false;
9
+ this.validationPattern = '';
10
+ this.duplicateInputValue = null;
11
+ this.handleInput = (event) => {
12
+ this.value = event.target.value;
13
+ this.calculateComplexity(this.value);
14
+ this.showPopup = true;
15
+ this.touched = true;
16
+ if (this.debounceTime) {
17
+ clearTimeout(this.debounceTime);
18
+ }
19
+ this.debounceTime = setTimeout(() => {
20
+ this.isValid = this.setValidity();
21
+ this.errorMessage = this.setErrorMessage();
22
+ this.emitValueHandler(true);
23
+ }, 500);
24
+ };
25
+ this.handleBlur = (event) => {
26
+ this.value = event.target.value;
27
+ this.showPopup = false;
28
+ this.touched = true;
29
+ this.isValid = this.setValidity();
30
+ this.errorMessage = this.setErrorMessage();
31
+ };
32
+ this.handleFocus = () => {
33
+ this.showPopup = true;
34
+ this.calculateComplexity(this.value);
35
+ };
36
+ this.setClientStyling = () => {
37
+ let sheet = document.createElement('style');
38
+ sheet.innerHTML = this.clientStyling;
39
+ this.stylingContainer.prepend(sheet);
40
+ };
41
+ this.name = undefined;
42
+ this.displayName = undefined;
43
+ this.placeholder = undefined;
44
+ this.defaultValue = '';
45
+ this.autofilled = undefined;
46
+ this.tooltip = undefined;
47
+ this.validation = undefined;
48
+ this.language = undefined;
49
+ this.emitValue = undefined;
50
+ this.isDuplicateInput = undefined;
51
+ this.clientStyling = '';
52
+ this.isValid = undefined;
53
+ this.errorMessage = undefined;
54
+ this.limitStylingAppends = false;
55
+ this.showTooltip = false;
56
+ this.passwordComplexity = undefined;
57
+ this.showPopup = undefined;
58
+ this.value = '';
29
59
  }
30
- }
31
- emitValueHandler(newValue) {
32
- if (newValue == true && this.isValid) {
33
- this.valueHandler({ name: this.name, value: this.value });
60
+ validityChanged() {
61
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
62
+ if (this.emitValue == true) {
63
+ this.valueHandler({ name: this.name, value: this.value });
64
+ }
34
65
  }
35
- }
36
- validityStateHandler(inputStateEvent) {
37
- this.sendValidityState.emit(inputStateEvent);
38
- }
39
- valueHandler(inputValueEvent) {
40
- this.sendInputValue.emit(inputValueEvent);
41
- }
42
- valueChangedHandler(event) {
43
- if (this.isDuplicateInput) {
44
- if (this.name === event.detail.name + 'Duplicate') {
45
- this.duplicateInputValue = event.detail.value;
46
- }
66
+ valueChanged() {
67
+ if (!this.isDuplicateInput) {
68
+ // recalculate complexity immediately in order to send the correct validity to the duplicate
69
+ this.calculateComplexity(this.value);
70
+ this.sendOriginalValidityState.emit({ name: this.name, valid: this.setValidity() });
71
+ }
47
72
  }
48
- }
49
- handleClickOutside(event) {
50
- if (event.composedPath()[0] === this.tooltipIconReference)
51
- return;
52
- if (event.composedPath()[0] !== this.tooltipReference)
53
- this.showTooltip = false;
54
- }
55
- connectedCallback() {
56
- this.validationPattern = this.setPattern();
57
- }
58
- componentDidRender() {
59
- // start custom styling area
60
- if (!this.limitStylingAppends && this.stylingContainer) {
61
- if (this.clientStyling)
62
- this.setClientStyling();
63
- this.limitStylingAppends = true;
73
+ emitValueHandler(newValue) {
74
+ if (newValue == true && this.isValid) {
75
+ this.valueHandler({ name: this.name, value: this.value, type: 'duplicate' });
76
+ }
64
77
  }
65
- // end custom styling area
66
- if (this.defaultValue) {
67
- this.value = this.defaultValue;
68
- this.valueHandler({ name: this.name, value: this.value });
78
+ validityStateHandler(inputStateEvent) {
79
+ this.sendValidityState.emit(inputStateEvent);
69
80
  }
70
- }
71
- componentDidLoad() {
72
- this.inputReference = this.element.shadowRoot.querySelector('input');
73
- }
74
- handleInput(event) {
75
- this.value = event.target.value;
76
- this.errorMessage = this.setErrorMessage();
77
- this.isValid = this.setValidity();
78
- this.validityStateHandler({ valid: this.isValid, name: this.name });
79
- this.emitValueHandler(true);
80
- }
81
- setValidity() {
82
- return this.inputReference.validity.valid;
83
- }
84
- setPattern() {
85
- var _a, _b;
86
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
87
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
81
+ valueHandler(inputValueEvent) {
82
+ this.sendInputValue.emit(inputValueEvent);
88
83
  }
89
- }
90
- setErrorMessage() {
91
- var _a;
92
- if (this.inputReference.validity.patternMismatch) {
93
- return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
84
+ originalValidityChangedHandler(event) {
85
+ if (this.isDuplicateInput) {
86
+ if (event.detail.valid) {
87
+ this.originalValid = true;
88
+ this.isValid = this.setValidity();
89
+ }
90
+ else {
91
+ this.originalValid = false;
92
+ this.isValid = false;
93
+ // only show error if the user has touched the input, in order to not show errors on empty inputs
94
+ this.value !== '' && (this.errorMessage = this.setErrorMessage());
95
+ }
96
+ }
94
97
  }
95
- if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
96
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
98
+ valueChangedHandler(event) {
99
+ if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
100
+ this.duplicateInputValue = event.detail.value;
101
+ if (this.touched) {
102
+ this.isValid = this.setValidity();
103
+ this.errorMessage = this.setErrorMessage();
104
+ }
105
+ }
106
+ if (this.name === event.detail.name + 'Duplicate'
107
+ && this.name.replace('Duplicate', '') === event.detail.name
108
+ && this.touched === true) {
109
+ this.isValid = this.setValidity();
110
+ this.errorMessage = this.setErrorMessage();
111
+ }
97
112
  }
98
- if (this.inputReference.validity.valueMissing) {
99
- return translate('requiredError', this.language);
113
+ handleClickOutside(event) {
114
+ if (event.composedPath()[0] === this.tooltipIconReference)
115
+ return;
116
+ if (event.composedPath()[0] !== this.tooltipReference)
117
+ this.showTooltip = false;
100
118
  }
101
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
102
- return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
119
+ componentDidRender() {
120
+ // start custom styling area
121
+ if (!this.limitStylingAppends && this.stylingContainer) {
122
+ if (this.clientStyling)
123
+ this.setClientStyling();
124
+ this.limitStylingAppends = true;
125
+ }
126
+ // end custom styling area
103
127
  }
104
- }
105
- renderTooltip() {
106
- if (this.showTooltip) {
107
- return (h("div", { class: `password__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
128
+ componentDidLoad() {
129
+ this.inputReference = this.element.shadowRoot.querySelector('input');
130
+ this.passwordButton = this.element.shadowRoot.querySelector('vaadin-password-field-button');
131
+ this.passwordButton.tabIndex = -1;
132
+ if (this.defaultValue) {
133
+ this.value = this.defaultValue;
134
+ this.calculateComplexity(this.value);
135
+ this.valueHandler({ name: this.name, value: this.value });
136
+ if (this.isDuplicateInput) {
137
+ this.duplicateInputValue = this.defaultValue;
138
+ this.touched = true;
139
+ }
140
+ }
141
+ this.isValid = this.setValidity();
108
142
  }
109
- return null;
110
- }
111
- render() {
112
- const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
113
- return h("div", { class: 'password__wrapper', ref: el => this.stylingContainer = el },
114
- h("div", { class: 'password__wrapper--flex' },
115
- h("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName),
116
- h("div", { class: 'password__wrapper--relative' },
117
- this.tooltip &&
118
- h("img", { class: 'password__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }),
119
- this.renderTooltip())),
120
- h("vaadin-password-field", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue,
121
- // ref={(el) => this.inputReference = el as HTMLInputElement}
122
- required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, onBlur: (e) => this.handleInput(e) }),
123
- h("small", { class: 'password__error-message' }, this.errorMessage));
124
- }
125
- static get is() { return "password-input"; }
126
- static get encapsulation() { return "shadow"; }
127
- static get originalStyleUrls() { return {
128
- "$": ["password-input.scss"]
129
- }; }
130
- static get styleUrls() { return {
131
- "$": ["password-input.css"]
132
- }; }
133
- static get properties() { return {
134
- "name": {
135
- "type": "string",
136
- "mutable": false,
137
- "complexType": {
138
- "original": "string",
139
- "resolved": "string",
140
- "references": {}
141
- },
142
- "required": false,
143
- "optional": false,
144
- "docs": {
145
- "tags": [],
146
- "text": "Name of the input."
147
- },
148
- "attribute": "name",
149
- "reflect": true
150
- },
151
- "displayName": {
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 input to be shown to the user."
164
- },
165
- "attribute": "display-name",
166
- "reflect": true
167
- },
168
- "placeholder": {
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": "Placeholder text to be shown."
181
- },
182
- "attribute": "placeholder",
183
- "reflect": true
184
- },
185
- "defaultValue": {
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": "Default value for the input."
198
- },
199
- "attribute": "default-value",
200
- "reflect": true,
201
- "defaultValue": "''"
202
- },
203
- "autofilled": {
204
- "type": "boolean",
205
- "mutable": false,
206
- "complexType": {
207
- "original": "boolean",
208
- "resolved": "boolean",
209
- "references": {}
210
- },
211
- "required": false,
212
- "optional": false,
213
- "docs": {
214
- "tags": [],
215
- "text": "Boolean. Determines if input should be readonly."
216
- },
217
- "attribute": "autofilled",
218
- "reflect": true
219
- },
220
- "tooltip": {
221
- "type": "string",
222
- "mutable": false,
223
- "complexType": {
224
- "original": "string",
225
- "resolved": "string",
226
- "references": {}
227
- },
228
- "required": false,
229
- "optional": false,
230
- "docs": {
231
- "tags": [],
232
- "text": "Tooltip text."
233
- },
234
- "attribute": "tooltip",
235
- "reflect": true
236
- },
237
- "validation": {
238
- "type": "unknown",
239
- "mutable": false,
240
- "complexType": {
241
- "original": "ValidationSchema",
242
- "resolved": "ValidationSchema",
243
- "references": {
244
- "ValidationSchema": {
245
- "location": "import",
246
- "path": "../../utils/types"
247
- }
143
+ calculateComplexity(password) {
144
+ this.passwordComplexity = this.validation.custom
145
+ .filter(rule => rule.rule === 'regex')
146
+ .map(rule => {
147
+ const ruleRegex = new RegExp(rule.pattern);
148
+ const passed = ruleRegex.test(password);
149
+ return { rule: rule.displayName, ruleKey: rule.errorKey, passed };
150
+ });
151
+ }
152
+ setValidity() {
153
+ var _a, _b;
154
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
155
+ return false;
156
+ }
157
+ else if (!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed))) {
158
+ return false;
159
+ }
160
+ else {
161
+ return (_b = this.inputReference) === null || _b === void 0 ? void 0 : _b.validity.valid;
248
162
  }
249
- },
250
- "required": false,
251
- "optional": false,
252
- "docs": {
253
- "tags": [],
254
- "text": "Object of validation rules for the input."
255
- }
256
- },
257
- "language": {
258
- "type": "string",
259
- "mutable": false,
260
- "complexType": {
261
- "original": "string",
262
- "resolved": "string",
263
- "references": {}
264
- },
265
- "required": false,
266
- "optional": false,
267
- "docs": {
268
- "tags": [],
269
- "text": "Currently selected language."
270
- },
271
- "attribute": "language",
272
- "reflect": true
273
- },
274
- "emitValue": {
275
- "type": "boolean",
276
- "mutable": false,
277
- "complexType": {
278
- "original": "boolean",
279
- "resolved": "boolean",
280
- "references": {}
281
- },
282
- "required": false,
283
- "optional": false,
284
- "docs": {
285
- "tags": [],
286
- "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
287
- },
288
- "attribute": "emit-value",
289
- "reflect": true
290
- },
291
- "isDuplicateInput": {
292
- "type": "boolean",
293
- "mutable": false,
294
- "complexType": {
295
- "original": "boolean",
296
- "resolved": "boolean",
297
- "references": {}
298
- },
299
- "required": false,
300
- "optional": false,
301
- "docs": {
302
- "tags": [],
303
- "text": "Flag for duplicate inputs, it sets up the input for certain validation rules."
304
- },
305
- "attribute": "is-duplicate-input",
306
- "reflect": true
307
- },
308
- "clientStyling": {
309
- "type": "string",
310
- "mutable": false,
311
- "complexType": {
312
- "original": "string",
313
- "resolved": "string",
314
- "references": {}
315
- },
316
- "required": false,
317
- "optional": false,
318
- "docs": {
319
- "tags": [],
320
- "text": "Client custom styling via inline style"
321
- },
322
- "attribute": "client-styling",
323
- "reflect": true,
324
- "defaultValue": "''"
325
163
  }
326
- }; }
327
- static get states() { return {
328
- "isValid": {},
329
- "errorMessage": {},
330
- "limitStylingAppends": {},
331
- "showTooltip": {}
332
- }; }
333
- static get events() { return [{
334
- "method": "sendValidityState",
335
- "name": "sendValidityState",
336
- "bubbles": true,
337
- "cancelable": true,
338
- "composed": true,
339
- "docs": {
340
- "tags": [],
341
- "text": ""
342
- },
343
- "complexType": {
344
- "original": "InputStateEvent",
345
- "resolved": "InputStateEvent",
346
- "references": {
347
- "InputStateEvent": {
348
- "location": "import",
349
- "path": "../../utils/types"
350
- }
164
+ setPattern() {
165
+ var _a, _b;
166
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
167
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
168
+ }
169
+ }
170
+ setErrorMessage() {
171
+ var _a, _b, _c, _d;
172
+ if (this.isDuplicateInput && !this.originalValid) {
173
+ return translate('invalidOriginalPasswordError', this.language);
174
+ }
175
+ if (this.inputReference.validity.patternMismatch) {
176
+ const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
177
+ const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
178
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
179
+ }
180
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
181
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
351
182
  }
352
- }
353
- }, {
354
- "method": "sendInputValue",
355
- "name": "sendInputValue",
356
- "bubbles": true,
357
- "cancelable": true,
358
- "composed": true,
359
- "docs": {
360
- "tags": [],
361
- "text": ""
362
- },
363
- "complexType": {
364
- "original": "InputValueEvent",
365
- "resolved": "InputValueEvent",
366
- "references": {
367
- "InputValueEvent": {
368
- "location": "import",
369
- "path": "../../utils/types"
370
- }
183
+ if (this.inputReference.validity.valueMissing) {
184
+ return translate('requiredError', this.language);
371
185
  }
372
- }
373
- }]; }
374
- static get elementRef() { return "element"; }
375
- static get watchers() { return [{
376
- "propName": "isValid",
377
- "methodName": "validityChanged"
378
- }, {
379
- "propName": "emitValue",
380
- "methodName": "emitValueHandler"
381
- }]; }
382
- static get listeners() { return [{
383
- "name": "sendInputValue",
384
- "method": "valueChangedHandler",
385
- "target": "body",
386
- "capture": false,
387
- "passive": false
388
- }, {
389
- "name": "click",
390
- "method": "handleClickOutside",
391
- "target": "document",
392
- "capture": false,
393
- "passive": false
394
- }]; }
186
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
187
+ const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
188
+ const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
189
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
190
+ }
191
+ }
192
+ renderTooltip() {
193
+ if (this.showTooltip) {
194
+ return (h("div", { class: `password__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
195
+ }
196
+ return null;
197
+ }
198
+ renderComplexityPopup() {
199
+ const totalRules = this.passwordComplexity.length;
200
+ const passedRules = this.passwordComplexity.filter(complexity => complexity.passed).length;
201
+ const meterValue = passedRules / totalRules;
202
+ const allRulesPassed = this.passwordComplexity.every(complexity => complexity.passed);
203
+ return (h("div", { class: `password__complexity ${!this.showPopup ? 'password__complexity--hidden' : ''}` }, h("div", { class: 'password__complexity--strength' }, h("p", { class: 'password__complexity--text' }, translate('passwordStrength', this.language), "\u00A0", h("span", { class: 'password__complexity--text-bold' }, translate(`${allRulesPassed ? 'passwordStrengthStrong' : 'passwordStrengthWeak'}`, this.language))), h("meter", { value: meterValue, min: "0", max: "1" })), h("div", null, this.passwordComplexity.map((complexity, index) => {
204
+ return (h("div", { key: index }, h("input", { class: 'password__complexity--checkbox', type: "checkbox", checked: complexity.passed, disabled: true }), h("span", null, translate(`${complexity.ruleKey}`, this.language) ? translate(`${complexity.ruleKey}`, this.language) : complexity.rule)));
205
+ }))));
206
+ }
207
+ render() {
208
+ let invalidClass = '';
209
+ if (this.touched) {
210
+ invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
211
+ }
212
+ return h("div", { key: '7f6a07f3c7e3aa53e1d97d674cc7a5591c33f7ce', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: 'a487d206585a3eb30441509070a6ab0747b911b4', class: 'password__wrapper--flex' }, h("label", { key: 'e8c471fa0836cb842f529c3733491249400b534c', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '4d90f18a711b27a621ebf5043906d5f35387a7e5', class: 'password__wrapper--relative' }, this.tooltip &&
213
+ h("img", { key: 'c44c2d9bf69b37761da9d0c5485326391627b8b4', class: 'password__tooltip-icon', src: tooltipIcon, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("vaadin-password-field", { key: '582dde61d4f34b09e8894168c0d09ed5a7b571d8', type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder}`, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus }), h("small", { key: '6fb3a91b1872805085f4d028c0760be8f6383b10', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.isDuplicateInput && this.renderComplexityPopup());
214
+ }
215
+ static get is() { return "password-input"; }
216
+ static get encapsulation() { return "shadow"; }
217
+ static get originalStyleUrls() {
218
+ return {
219
+ "$": ["password-input.scss"]
220
+ };
221
+ }
222
+ static get styleUrls() {
223
+ return {
224
+ "$": ["password-input.css"]
225
+ };
226
+ }
227
+ static get properties() {
228
+ return {
229
+ "name": {
230
+ "type": "string",
231
+ "mutable": false,
232
+ "complexType": {
233
+ "original": "string",
234
+ "resolved": "string",
235
+ "references": {}
236
+ },
237
+ "required": false,
238
+ "optional": false,
239
+ "docs": {
240
+ "tags": [],
241
+ "text": "Name of the input."
242
+ },
243
+ "attribute": "name",
244
+ "reflect": true
245
+ },
246
+ "displayName": {
247
+ "type": "string",
248
+ "mutable": false,
249
+ "complexType": {
250
+ "original": "string",
251
+ "resolved": "string",
252
+ "references": {}
253
+ },
254
+ "required": false,
255
+ "optional": false,
256
+ "docs": {
257
+ "tags": [],
258
+ "text": "Name of input to be shown to the user."
259
+ },
260
+ "attribute": "display-name",
261
+ "reflect": true
262
+ },
263
+ "placeholder": {
264
+ "type": "string",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "string",
268
+ "resolved": "string",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": "Placeholder text to be shown."
276
+ },
277
+ "attribute": "placeholder",
278
+ "reflect": true
279
+ },
280
+ "defaultValue": {
281
+ "type": "string",
282
+ "mutable": false,
283
+ "complexType": {
284
+ "original": "string",
285
+ "resolved": "string",
286
+ "references": {}
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "Default value for the input."
293
+ },
294
+ "attribute": "default-value",
295
+ "reflect": true,
296
+ "defaultValue": "''"
297
+ },
298
+ "autofilled": {
299
+ "type": "boolean",
300
+ "mutable": false,
301
+ "complexType": {
302
+ "original": "boolean",
303
+ "resolved": "boolean",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": "Boolean. Determines if input should be readonly."
311
+ },
312
+ "attribute": "autofilled",
313
+ "reflect": true
314
+ },
315
+ "tooltip": {
316
+ "type": "string",
317
+ "mutable": false,
318
+ "complexType": {
319
+ "original": "string",
320
+ "resolved": "string",
321
+ "references": {}
322
+ },
323
+ "required": false,
324
+ "optional": false,
325
+ "docs": {
326
+ "tags": [],
327
+ "text": "Tooltip text."
328
+ },
329
+ "attribute": "tooltip",
330
+ "reflect": true
331
+ },
332
+ "validation": {
333
+ "type": "unknown",
334
+ "mutable": false,
335
+ "complexType": {
336
+ "original": "ValidationSchema",
337
+ "resolved": "ValidationSchema",
338
+ "references": {
339
+ "ValidationSchema": {
340
+ "location": "import",
341
+ "path": "../../utils/types",
342
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::ValidationSchema"
343
+ }
344
+ }
345
+ },
346
+ "required": false,
347
+ "optional": false,
348
+ "docs": {
349
+ "tags": [],
350
+ "text": "Object of validation rules for the input."
351
+ }
352
+ },
353
+ "language": {
354
+ "type": "string",
355
+ "mutable": false,
356
+ "complexType": {
357
+ "original": "string",
358
+ "resolved": "string",
359
+ "references": {}
360
+ },
361
+ "required": false,
362
+ "optional": false,
363
+ "docs": {
364
+ "tags": [],
365
+ "text": "Currently selected language."
366
+ },
367
+ "attribute": "language",
368
+ "reflect": true
369
+ },
370
+ "emitValue": {
371
+ "type": "boolean",
372
+ "mutable": false,
373
+ "complexType": {
374
+ "original": "boolean",
375
+ "resolved": "boolean",
376
+ "references": {}
377
+ },
378
+ "required": false,
379
+ "optional": false,
380
+ "docs": {
381
+ "tags": [],
382
+ "text": "State passed down from the parent element. Will trigger the input to send it's value through an event."
383
+ },
384
+ "attribute": "emit-value",
385
+ "reflect": true
386
+ },
387
+ "isDuplicateInput": {
388
+ "type": "boolean",
389
+ "mutable": false,
390
+ "complexType": {
391
+ "original": "boolean",
392
+ "resolved": "boolean",
393
+ "references": {}
394
+ },
395
+ "required": false,
396
+ "optional": false,
397
+ "docs": {
398
+ "tags": [],
399
+ "text": "Flag for duplicate inputs, it sets up the input for certain validation rules."
400
+ },
401
+ "attribute": "is-duplicate-input",
402
+ "reflect": true
403
+ },
404
+ "clientStyling": {
405
+ "type": "string",
406
+ "mutable": false,
407
+ "complexType": {
408
+ "original": "string",
409
+ "resolved": "string",
410
+ "references": {}
411
+ },
412
+ "required": false,
413
+ "optional": false,
414
+ "docs": {
415
+ "tags": [],
416
+ "text": "Client custom styling via inline style"
417
+ },
418
+ "attribute": "client-styling",
419
+ "reflect": true,
420
+ "defaultValue": "''"
421
+ }
422
+ };
423
+ }
424
+ static get states() {
425
+ return {
426
+ "isValid": {},
427
+ "errorMessage": {},
428
+ "limitStylingAppends": {},
429
+ "showTooltip": {},
430
+ "passwordComplexity": {},
431
+ "showPopup": {},
432
+ "value": {}
433
+ };
434
+ }
435
+ static get events() {
436
+ return [{
437
+ "method": "sendOriginalValidityState",
438
+ "name": "sendOriginalValidityState",
439
+ "bubbles": true,
440
+ "cancelable": true,
441
+ "composed": true,
442
+ "docs": {
443
+ "tags": [],
444
+ "text": ""
445
+ },
446
+ "complexType": {
447
+ "original": "InputStateEvent",
448
+ "resolved": "InputStateEvent",
449
+ "references": {
450
+ "InputStateEvent": {
451
+ "location": "import",
452
+ "path": "../../utils/types",
453
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::InputStateEvent"
454
+ }
455
+ }
456
+ }
457
+ }, {
458
+ "method": "sendValidityState",
459
+ "name": "sendValidityState",
460
+ "bubbles": true,
461
+ "cancelable": true,
462
+ "composed": true,
463
+ "docs": {
464
+ "tags": [],
465
+ "text": ""
466
+ },
467
+ "complexType": {
468
+ "original": "InputStateEvent",
469
+ "resolved": "InputStateEvent",
470
+ "references": {
471
+ "InputStateEvent": {
472
+ "location": "import",
473
+ "path": "../../utils/types",
474
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::InputStateEvent"
475
+ }
476
+ }
477
+ }
478
+ }, {
479
+ "method": "sendInputValue",
480
+ "name": "sendInputValue",
481
+ "bubbles": true,
482
+ "cancelable": true,
483
+ "composed": true,
484
+ "docs": {
485
+ "tags": [],
486
+ "text": ""
487
+ },
488
+ "complexType": {
489
+ "original": "InputValueEvent",
490
+ "resolved": "InputValueEvent",
491
+ "references": {
492
+ "InputValueEvent": {
493
+ "location": "import",
494
+ "path": "../../utils/types",
495
+ "id": "../../../../packages/stencil/general-input/src/utils/types.ts::InputValueEvent"
496
+ }
497
+ }
498
+ }
499
+ }];
500
+ }
501
+ static get elementRef() { return "element"; }
502
+ static get watchers() {
503
+ return [{
504
+ "propName": "isValid",
505
+ "methodName": "validityChanged"
506
+ }, {
507
+ "propName": "value",
508
+ "methodName": "valueChanged"
509
+ }, {
510
+ "propName": "emitValue",
511
+ "methodName": "emitValueHandler"
512
+ }];
513
+ }
514
+ static get listeners() {
515
+ return [{
516
+ "name": "sendOriginalValidityState",
517
+ "method": "originalValidityChangedHandler",
518
+ "target": "body",
519
+ "capture": false,
520
+ "passive": false
521
+ }, {
522
+ "name": "sendInputValue",
523
+ "method": "valueChangedHandler",
524
+ "target": "body",
525
+ "capture": false,
526
+ "passive": false
527
+ }, {
528
+ "name": "click",
529
+ "method": "handleClickOutside",
530
+ "target": "document",
531
+ "capture": false,
532
+ "passive": false
533
+ }];
534
+ }
395
535
  }