adt-js-components 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adt-js-components",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "JavaScript components for Nette framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@ const init = (selector, path) => {
22
22
  loadedComponents.push(path);
23
23
 
24
24
  if (path.startsWith('~')) {
25
- import('~/' + path.slice(1) + '/index.js').then(component => {
25
+ import('~/src/' + path.slice(1) + '/index.js').then(component => {
26
26
  component.default.run(componentsConfig[selector] || {});
27
27
  });
28
28
 
@@ -73,10 +73,16 @@ function run(options) {
73
73
  el.innerHTML = '';
74
74
  });
75
75
 
76
+ const alertErrors = [];
76
77
  for (const error of errors) {
77
78
  // because radio lists and checkbox lists contains one error message multiple times
78
- if (!document.getElementById('snippet-' + getErrorElementId(error.element) + '-errors').innerHTML.includes(error.message)) {
79
- document.getElementById('snippet-' + getErrorElementId(error.element) + '-errors').innerHTML += '<div>' + error.message + '</div>';
79
+ const errorElementId = 'snippet-' + getErrorElementId(error.element) + '-errors';
80
+ const errorElement = document.getElementById(errorElementId);
81
+ if (!errorElement) {
82
+ alertErrors.push(error.message);
83
+ console.warn(`Element with ID "${errorElementId}" no exist.`);
84
+ } else if (!errorElement.innerHTML.includes(error.message)) {
85
+ errorElement.innerHTML += `<div>${error.message}</div>`;
80
86
  }
81
87
 
82
88
  error.element.classList.add('is-invalid');
@@ -93,6 +99,10 @@ function run(options) {
93
99
  if (errors.length) {
94
100
  scrollToFirstError(form);
95
101
  }
102
+
103
+ if (alertErrors.length) {
104
+ alert(alertErrors.join('\n'));
105
+ }
96
106
  };
97
107
  } else {
98
108
  console.error('Package nette-forms is missing!');