adt-js-components 1.5.9 → 1.5.11
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 +1 -1
- package/src/ComponentLoader.js +27 -15
- package/src/SubmitForm/index.js +2 -2
package/package.json
CHANGED
package/src/ComponentLoader.js
CHANGED
|
@@ -10,26 +10,38 @@ const init = (selector, path) => {
|
|
|
10
10
|
componentsConfig = JSON.parse(bodyDataset);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const observer = new MutationObserver((mutationsList) => {
|
|
14
14
|
// component is already loaded
|
|
15
15
|
if (loadedComponents.includes(path)) return;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
for (const mutation of mutationsList) {
|
|
18
|
+
if (mutation.type === 'childList') {
|
|
19
|
+
const target = mutation.target.querySelector(`[data-adt-${selector}]`);
|
|
20
|
+
|
|
21
|
+
if (target) {
|
|
22
|
+
loadedComponents.push(path);
|
|
23
|
+
|
|
24
|
+
if (path.includes('/')) {
|
|
25
|
+
import('JsComponents/' + path + '/index.js').then(component => {
|
|
26
|
+
component.default.run(componentsConfig[selector] || {});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
} else {
|
|
30
|
+
import('adt-js-components/src/' + path + '/index.js').then(component => {
|
|
31
|
+
component.default.run(componentsConfig[selector] || {});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
});
|
|
39
|
+
|
|
40
|
+
// Sleduj celý dokument pro změny ve stromu DOM
|
|
41
|
+
observer.observe(document.body, {
|
|
42
|
+
childList: true,
|
|
43
|
+
subtree: true,
|
|
44
|
+
});
|
|
33
45
|
};
|
|
34
46
|
|
|
35
47
|
const initCurrencyInput = () => {
|
package/src/SubmitForm/index.js
CHANGED
|
@@ -21,9 +21,9 @@ function scrollToFirstError(form) {
|
|
|
21
21
|
scrollParent.scrollBy({top: el.getBoundingClientRect().top - 100, behavior: 'smooth'});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function run(options
|
|
24
|
+
function run(options) {
|
|
25
25
|
function applyEventHandlers(el) {
|
|
26
|
-
$(
|
|
26
|
+
$(el).find('input, textarea, select').on('input', function(e) {
|
|
27
27
|
this.classList.remove('is-invalid');
|
|
28
28
|
if (isList(this)) {
|
|
29
29
|
$(this).parent().parent().find('.is-invalid').removeClass('is-invalid');
|