@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,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { t as translate } from './locale.utils.js';
2
+ import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
3
3
 
4
- const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.text__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.text__label--required::after{content:\"*\";margin-left:5px;color:#666666}.text__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.text__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.text__input::placeholder{color:#666666}.text__input--invalid{border-bottom:3px solid #cc0000}.text__input:placeholder-shown+.text__label{opacity:0;visibility:hidden;transform:translateY(0)}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
4
+ const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text{font-family:\"Roboto\";font-style:normal}.text__wrapper{position:relative;width:100%}.text__wrapper--autofilled{pointer-events:none}.text__wrapper--autofilled .text__label{color:#979797}.text__wrapper--autofilled .text__input::part(input-field){color:#979797}.text__wrapper--flex{display:flex;gap:5px}.text__wrapper--relative{position:relative}.text__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#2A3841}.text__label--required::after{content:\"*\";font-family:inherit;color:#2A3841;margin-left:2px}.text__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;padding:10px 20px;width:inherit;position:relative;border:2px solid #DEE1EE}.text__input:focus{outline-color:#3E3E3E}.text__input--invalid{border:2px solid #cc0000b3}.text__input::placeholder{color:#979797}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.text__tooltip-icon{width:16px;height:auto}.text__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.text__tooltip.visible{opacity:1}";
5
5
 
6
6
  const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -14,58 +14,124 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14
14
  * Default value for the input.
15
15
  */
16
16
  this.defaultValue = '';
17
+ /**
18
+ * Client custom styling via inline style
19
+ */
20
+ this.clientStyling = '';
17
21
  this.errorMessage = '';
22
+ this.limitStylingAppends = false;
23
+ this.showTooltip = false;
18
24
  this.value = '';
19
- this.customRules = [];
20
25
  this.validationPattern = '';
26
+ this.duplicateInputValue = null;
27
+ this.touched = false;
28
+ this.handleInput = (event) => {
29
+ this.value = event.target.value;
30
+ this.touched = true;
31
+ if (this.debounceTime) {
32
+ clearTimeout(this.debounceTime);
33
+ }
34
+ this.debounceTime = setTimeout(() => {
35
+ this.isValid = this.setValidity();
36
+ this.errorMessage = this.setErrorMessage();
37
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
38
+ this.emitValueHandler(true);
39
+ }, 500);
40
+ };
41
+ this.handleBlur = (event) => {
42
+ this.value = event.target.value;
43
+ this.touched = true;
44
+ this.isValid = this.setValidity();
45
+ this.errorMessage = this.setErrorMessage();
46
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
47
+ };
48
+ this.setClientStyling = () => {
49
+ let sheet = document.createElement('style');
50
+ sheet.innerHTML = this.clientStyling;
51
+ this.stylingContainer.prepend(sheet);
52
+ };
21
53
  }
22
54
  validityChanged() {
55
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
23
56
  if (this.emitValue == true) {
24
57
  this.valueHandler({ name: this.name, value: this.value });
25
58
  }
26
59
  }
27
- validityStateHandler(inputStateEvent) {
28
- this.sendValidityState.emit(inputStateEvent);
29
- }
30
60
  emitValueHandler(newValue) {
31
61
  if (newValue == true && this.isValid) {
32
62
  this.valueHandler({ name: this.name, value: this.value });
33
63
  }
34
64
  }
65
+ validityStateHandler(inputStateEvent) {
66
+ this.sendValidityState.emit(inputStateEvent);
67
+ }
35
68
  valueHandler(inputValueEvent) {
36
69
  this.sendInputValue.emit(inputValueEvent);
37
70
  }
71
+ handleClickOutside(event) {
72
+ if (event.composedPath()[0] === this.tooltipIconReference)
73
+ return;
74
+ if (event.composedPath()[0] !== this.tooltipReference)
75
+ this.showTooltip = false;
76
+ }
77
+ valueChangedHandler(event) {
78
+ if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
79
+ this.duplicateInputValue = event.detail.value;
80
+ if (this.touched) {
81
+ this.isValid = this.setValidity();
82
+ this.errorMessage = this.setErrorMessage();
83
+ }
84
+ }
85
+ if (this.name === event.detail.name + 'Duplicate'
86
+ && this.name.replace('Duplicate', '') === event.detail.name
87
+ && this.touched === true) {
88
+ this.isValid = this.setValidity();
89
+ this.errorMessage = this.setErrorMessage();
90
+ }
91
+ }
38
92
  connectedCallback() {
39
- // @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
- this.customRules = this.setCustomRules();
41
93
  this.validationPattern = this.setPattern();
42
94
  }
43
- handleInput(event) {
44
- this.value = event.target.value;
95
+ componentDidRender() {
96
+ // start custom styling area
97
+ if (!this.limitStylingAppends && this.stylingContainer) {
98
+ if (this.clientStyling)
99
+ this.setClientStyling();
100
+ this.limitStylingAppends = true;
101
+ }
102
+ // end custom styling area
103
+ }
104
+ componentDidLoad() {
105
+ if (this.defaultValue) {
106
+ this.value = this.defaultValue;
107
+ this.valueHandler({ name: this.name, value: this.value });
108
+ if (this.isDuplicateInput) {
109
+ this.touched = true;
110
+ }
111
+ }
45
112
  this.isValid = this.setValidity();
46
- this.errorMessage = this.setErrorMessage();
47
- this.validityStateHandler({ valid: this.isValid, name: this.name });
48
- this.emitValueHandler(true);
49
113
  }
50
114
  setValidity() {
51
- return this.inputReference.validity.valid;
52
- }
53
- // @TODO type here
54
- setCustomRules() {
55
115
  var _a;
56
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
57
- return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
116
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
117
+ return false;
118
+ }
119
+ else {
120
+ return (_a = this.inputReference) === null || _a === void 0 ? void 0 : _a.validity.valid;
58
121
  }
59
122
  }
60
123
  setPattern() {
61
- var _a;
124
+ var _a, _b;
62
125
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
63
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
126
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
64
127
  }
65
128
  }
66
129
  setErrorMessage() {
130
+ var _a, _b, _c, _d;
67
131
  if (this.inputReference.validity.patternMismatch) {
68
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
132
+ const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
133
+ const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
134
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
69
135
  }
70
136
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
71
137
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -73,11 +139,25 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
73
139
  if (this.inputReference.validity.valueMissing) {
74
140
  return translate('requiredError', this.language);
75
141
  }
142
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
143
+ const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
144
+ const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
145
+ return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
146
+ }
147
+ }
148
+ renderTooltip() {
149
+ if (this.showTooltip) {
150
+ return (h("div", { class: `text__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
151
+ }
152
+ return null;
76
153
  }
77
154
  render() {
78
- const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
79
- console.log('this', this.name, this.defaultValue, this.displayName);
80
- return h("div", { class: 'text__wrapper' }, h("input", { id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, 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, onBlur: (e) => { this.handleInput(e); } }), h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'text__error-message' }, this.errorMessage));
155
+ let invalidClass = '';
156
+ if (this.touched) {
157
+ invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
158
+ }
159
+ return h("div", { class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, h("div", { class: 'text__wrapper--flex' }, h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { class: 'text__wrapper--relative' }, this.tooltip &&
160
+ h("img", { class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { name: this.name, id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.placeholder}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur }), h("small", { class: 'text__error-message' }, this.errorMessage));
81
161
  }
82
162
  static get watchers() { return {
83
163
  "isValid": ["validityChanged"],
@@ -85,17 +165,23 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
85
165
  }; }
86
166
  static get style() { return textInputCss; }
87
167
  }, [1, "text-input", {
88
- "name": [1025],
89
- "displayName": [1, "display-name"],
168
+ "name": [513],
169
+ "displayName": [513, "display-name"],
170
+ "placeholder": [513],
90
171
  "validation": [16],
91
- "defaultValue": [1025, "default-value"],
92
- "rules": [1],
93
- "language": [1],
94
- "checkValidity": [4, "check-validity"],
95
- "emitValue": [4, "emit-value"],
172
+ "defaultValue": [513, "default-value"],
173
+ "autofilled": [516],
174
+ "tooltip": [513],
175
+ "language": [513],
176
+ "checkValidity": [516, "check-validity"],
177
+ "emitValue": [516, "emit-value"],
178
+ "isDuplicateInput": [516, "is-duplicate-input"],
179
+ "clientStyling": [513, "client-styling"],
96
180
  "isValid": [32],
97
- "errorMessage": [32]
98
- }]);
181
+ "errorMessage": [32],
182
+ "limitStylingAppends": [32],
183
+ "showTooltip": [32]
184
+ }, [[4, "click", "handleClickOutside"], [16, "sendInputValue", "valueChangedHandler"]]]);
99
185
  function defineCustomElement() {
100
186
  if (typeof customElements === "undefined") {
101
187
  return;
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ToggleCheckboxInput extends Components.ToggleCheckboxInput, HTMLElement {}
4
+ export const ToggleCheckboxInput: {
5
+ prototype: ToggleCheckboxInput;
6
+ new (): ToggleCheckboxInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { T as ToggleCheckboxInput$1, a as defineCustomElement$1 } from './general-input2.js';
2
+
3
+ const ToggleCheckboxInput = ToggleCheckboxInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { ToggleCheckboxInput, defineCustomElement };
@@ -0,0 +1,70 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const TRANSLATIONS = {
3
+ "en": {
4
+ "dateError": 'The selected date should be between {min} and {max}',
5
+ "dateError2": 'The selected date is not within the accepted range',
6
+ "numberLengthError": 'The number should be between {min} and {max}',
7
+ "lengthError": `The length should be between {minLength} and {maxLength}`,
8
+ "requiredError": 'This input is required.',
9
+ "invalidOriginalPasswordError": "Initial password field does not validate all criteria.",
10
+ "passwordStrength": "Password strength",
11
+ "passwordStrengthWeak": "is not adequate",
12
+ "passwordStrengthStrong": "is adequate",
13
+ "SpecialCharactersNotAllowed": 'Should not contain special characters',
14
+ "InvalidEmailFormat": "Invalid email format.",
15
+ "EmailNotMatching": "Emails not matching!",
16
+ "PasswordNotMatching": "Passwords not matching",
17
+ "MustIncludeNumber": "include a number",
18
+ "MustContainCapital": "contain capital letters",
19
+ "MustIncludePunctation": "punctuation",
20
+ "OnlyNumbers": "Should contains only numbers."
21
+ },
22
+ "hu": {
23
+ "dateError": 'A választott dátumnak {min} és {max} között kell lennie',
24
+ "numberLengthError": 'A számnak {min} és {max} között kell lennie',
25
+ "lengthError": `A hossznak {minLength} és {maxLength} között kell lennie`,
26
+ "requiredError": 'Ez a beviteli mező kötelező.',
27
+ "invalidOriginalPasswordError": "Initial password field does not validate all criteria.",
28
+ "passwordStrength": "Jelszó erőssége",
29
+ "passwordStrengthWeak": "nem megfelelő",
30
+ "passwordStrengthStrong": "megfelelő",
31
+ "SpecialCharactersNotAllowed": 'Nem tartalmazhat speciális karaktereket',
32
+ "InvalidEmailFormat": "Érvénytelen e-mail formátum.",
33
+ "EmailNotMatching": "Az e-mailek nem egyeznek!",
34
+ "PasswordNotMatching": "A jelszavak nem egyeznek",
35
+ "MustIncludeNumber": "tartalmaznia kell egy számot",
36
+ "MustContainCapital": "nagybetűket kell tartalmaznia",
37
+ "MustIncludePunctation": "írásjelet",
38
+ "OnlyNumbers": "Csak számokat kell tartalmaznia."
39
+ }
40
+ };
41
+ const translate = (key, customLang, values) => {
42
+ const lang = customLang;
43
+ let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
44
+ if (values !== undefined) {
45
+ for (const [key, value] of Object.entries(values.values)) {
46
+ const regex = new RegExp(`{${key}}`, 'g');
47
+ translation = translation.replace(regex, value);
48
+ }
49
+ }
50
+ return translation;
51
+ };
52
+ const getTranslations = (url) => {
53
+ // fetch url, get the data, replace the TRANSLATIONS content
54
+ return new Promise((resolve) => {
55
+ fetch(url)
56
+ .then((res) => res.json())
57
+ .then((data) => {
58
+ Object.keys(data).forEach((item) => {
59
+ for (let key in data[item]) {
60
+ TRANSLATIONS[item][key] = data[item][key];
61
+ }
62
+ });
63
+ resolve(true);
64
+ });
65
+ });
66
+ };
67
+
68
+ const tooltipIconSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iNiIgY3k9IjYiIHI9IjUuNSIgc3Ryb2tlPSIjOTc5Nzk3Ii8+CjxyZWN0IHg9IjUiIHk9IjUiIHdpZHRoPSIyIiBoZWlnaHQ9IjUiIGZpbGw9IiM5Nzk3OTciLz4KPGNpcmNsZSBjeD0iNiIgY3k9IjMiIHI9IjEiIGZpbGw9IiM5Nzk3OTciLz4KPC9zdmc+Cg==';
69
+
70
+ export { tooltipIconSvg as a, getTranslations as g, translate as t };