@schukai/monster 4.113.0 → 4.114.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.114.0] - 2026-01-30
6
+
7
+ ### Add Features
8
+
9
+ - Improve validation error handling and context management
10
+
11
+
12
+
5
13
  ## [4.113.0] - 2026-01-30
6
14
 
7
15
  ### Add Features
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.113.0"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.114.0"}
@@ -424,18 +424,56 @@ function getOrCreateValidationErrorElement(target, key) {
424
424
  let errorElement = label.querySelector(
425
425
  `monster-context-error[data-monster-validation-for="${marker}"]`,
426
426
  );
427
+ const contextEndContainer = getOrCreateContextEndContainer(label);
427
428
  if (errorElement) {
429
+ if (errorElement.parentElement !== contextEndContainer) {
430
+ contextEndContainer.appendChild(errorElement);
431
+ }
432
+ errorElement.style.marginInlineStart = "";
428
433
  return errorElement;
429
434
  }
430
435
 
431
436
  errorElement = document.createElement("monster-context-error");
432
437
  errorElement.setAttribute("data-monster-validation-for", marker);
433
- errorElement.style.marginInlineStart = "auto";
434
- label.appendChild(errorElement);
438
+ contextEndContainer.appendChild(errorElement);
435
439
 
436
440
  return errorElement;
437
441
  }
438
442
 
443
+ /**
444
+ * @private
445
+ * @param {HTMLLabelElement} label
446
+ * @return {HTMLSpanElement}
447
+ */
448
+ function getOrCreateContextEndContainer(label) {
449
+ let container = label.querySelector('[data-monster-role="context-end"]');
450
+ if (container) {
451
+ return container;
452
+ }
453
+
454
+ container = document.createElement("span");
455
+ container.setAttribute("data-monster-role", "context-end");
456
+ container.style.display = "inline-flex";
457
+ container.style.alignItems = "center";
458
+ container.style.marginInlineStart = "auto";
459
+
460
+ const contextSelectors =
461
+ ":scope > monster-context-help," +
462
+ ":scope > monster-context-error," +
463
+ ":scope > monster-context-note," +
464
+ ":scope > monster-context-hint," +
465
+ ":scope > monster-context-warning," +
466
+ ":scope > monster-context-info," +
467
+ ":scope > monster-context-success";
468
+ const contextElements = label.querySelectorAll(contextSelectors);
469
+ for (const contextElement of contextElements) {
470
+ container.appendChild(contextElement);
471
+ }
472
+
473
+ label.appendChild(container);
474
+ return container;
475
+ }
476
+
439
477
  /**
440
478
  * @private
441
479
  * @param {HTMLElement} target