@schukai/monster 4.143.7 → 4.143.8

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 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"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.143.7"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"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.143.8"}
@@ -1393,16 +1393,29 @@ function getVisualBorderElement(element, side) {
1393
1393
  "textarea",
1394
1394
  "monster-input-group",
1395
1395
  "monster-select",
1396
+ "monster-button",
1397
+ "monster-state-button",
1398
+ "monster-message-state-button",
1399
+ "monster-action-button",
1400
+ "monster-api-button",
1401
+ "monster-confirm-button",
1402
+ "monster-popper-button",
1396
1403
  "[data-monster-role=control]",
1397
1404
  ].join(",");
1398
1405
  if (element.shadowRoot instanceof ShadowRoot) {
1399
- return (
1400
- element.shadowRoot.querySelector("button,input,select,textarea") ||
1401
- element.shadowRoot.querySelector(
1402
- "monster-input-group,monster-select,[data-monster-role=control]",
1403
- ) ||
1404
- element
1406
+ const primaryControl = element.shadowRoot.querySelector(
1407
+ "[data-monster-role=button],button,input,select,textarea",
1405
1408
  );
1409
+ if (primaryControl instanceof HTMLElement && primaryControl !== element) {
1410
+ return getVisualBorderElement.call(this, primaryControl, side);
1411
+ }
1412
+
1413
+ const control = element.shadowRoot.querySelector(selector);
1414
+ if (control instanceof HTMLElement && control !== element) {
1415
+ return getVisualBorderElement.call(this, control, side);
1416
+ }
1417
+
1418
+ return element;
1406
1419
  }
1407
1420
 
1408
1421
  const candidates = Array.from(element.querySelectorAll(selector)).filter(
@@ -1413,10 +1426,14 @@ function getVisualBorderElement(element, side) {
1413
1426
  }
1414
1427
 
1415
1428
  if (side === "right" || side === "bottom") {
1416
- return candidates[candidates.length - 1];
1429
+ return getVisualBorderElement.call(
1430
+ this,
1431
+ candidates[candidates.length - 1],
1432
+ side,
1433
+ );
1417
1434
  }
1418
1435
 
1419
- return candidates[0];
1436
+ return getVisualBorderElement.call(this, candidates[0], side);
1420
1437
  }
1421
1438
 
1422
1439
  /**
@@ -32,6 +32,8 @@ describe("ControlBar", function () {
32
32
  import("../../../../source/components/form/control-bar-spacer.mjs"),
33
33
  import("../../../../source/components/form/button.mjs"),
34
34
  import("../../../../source/components/form/popper-button.mjs"),
35
+ import("../../../../source/components/form/message-state-button.mjs"),
36
+ import("../../../../source/components/form/confirm-button.mjs"),
35
37
  ])
36
38
  .then((m) => {
37
39
  ControlBar = m[0].ControlBar;
@@ -506,6 +508,105 @@ describe("ControlBar", function () {
506
508
  }
507
509
  });
508
510
 
511
+ it("should join borders between message state and confirm buttons", async function () {
512
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
513
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
514
+
515
+ const scheduledCallbacks = [];
516
+ const flushFrames = async () => {
517
+ while (scheduledCallbacks.length > 0) {
518
+ scheduledCallbacks.shift()();
519
+ await new Promise((resolve) => setTimeout(resolve, 0));
520
+ }
521
+ };
522
+
523
+ try {
524
+ window.requestAnimationFrame = (callback) => {
525
+ scheduledCallbacks.push(callback);
526
+ return scheduledCallbacks.length;
527
+ };
528
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
529
+
530
+ const mocks = document.getElementById("mocks");
531
+ mocks.innerHTML = `
532
+ <div id="workflow-border-bar-wrapper">
533
+ <monster-control-bar
534
+ id="workflow-border-bar"
535
+ data-nucleus-role="workflow-lifecycle-integrity-actions"
536
+ >
537
+ <monster-message-state-button
538
+ id="workflow-border-copy"
539
+ data-nucleus-role="workflow-lifecycle-integrity-copy"
540
+ >Diagnose kopieren</monster-message-state-button>
541
+ <monster-confirm-button
542
+ id="workflow-border-repair"
543
+ data-nucleus-role="workflow-lifecycle-integrity-repair"
544
+ >
545
+ <div>
546
+ <p>Workflow-Lifecycle für diese Variante jetzt reparieren?</p>
547
+ </div>
548
+ <div slot="confirm">Ja</div>
549
+ <div slot="cancel">Nein</div>
550
+ <div slot="button">Lifecycle reparieren</div>
551
+ </monster-confirm-button>
552
+ </monster-control-bar>
553
+ </div>
554
+ `;
555
+
556
+ const wrapper = document.getElementById("workflow-border-bar-wrapper");
557
+ const copy = document.getElementById("workflow-border-copy");
558
+ const repair = document.getElementById("workflow-border-repair");
559
+
560
+ wrapper.style.boxSizing = "border-box";
561
+ wrapper.style.width = "400px";
562
+ Object.defineProperty(wrapper, "clientWidth", {
563
+ configurable: true,
564
+ value: 400,
565
+ });
566
+
567
+ for (const control of [copy, repair]) {
568
+ Object.defineProperty(control, "offsetWidth", {
569
+ configurable: true,
570
+ value: 120,
571
+ });
572
+ Object.defineProperty(control, "offsetHeight", {
573
+ configurable: true,
574
+ value: 30,
575
+ });
576
+ control.getBoundingClientRect = () => ({
577
+ width: 120,
578
+ height: 30,
579
+ top: 0,
580
+ right: 120,
581
+ bottom: 30,
582
+ left: 0,
583
+ x: 0,
584
+ y: 0,
585
+ toJSON: () => {},
586
+ });
587
+ }
588
+
589
+ const copyInnerButton = copy.shadowRoot
590
+ ?.querySelector('[data-monster-role="button"]')
591
+ ?.shadowRoot?.querySelector("button");
592
+ const repairInnerButton = repair.shadowRoot?.querySelector(
593
+ '[data-monster-role="button"]',
594
+ );
595
+
596
+ copyInnerButton.style.borderRightWidth = "3px";
597
+ repairInnerButton.style.borderLeftWidth = "3px";
598
+
599
+ await flushFrames();
600
+ await new Promise((resolve) => setTimeout(resolve, 0));
601
+ await new Promise((resolve) => setTimeout(resolve, 0));
602
+
603
+ expect(repair.style.marginLeft).to.equal("-3px");
604
+ } finally {
605
+ window.requestAnimationFrame = originalRequestAnimationFrame;
606
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
607
+ }
608
+ });
609
+
509
610
  it("should size inline spacer lines from adjacent border widths", async function () {
510
611
  const originalRequestAnimationFrame = window.requestAnimationFrame;
511
612
  const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;