@schukai/monster 4.141.0 → 4.141.1

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.141.0"}
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.141.1"}
@@ -1203,10 +1203,12 @@ function calculateControlBarDimensions() {
1203
1203
  }
1204
1204
 
1205
1205
  let width = this.parentElement.clientWidth;
1206
+ let containerWidth = width;
1206
1207
  if (computedStyle.getPropertyValue("box-sizing") !== "border-box") {
1207
1208
  width = computedStyle.getPropertyValue("width");
1208
1209
 
1209
1210
  const pixel = getComputedCssPixels(width);
1211
+ containerWidth = pixel;
1210
1212
 
1211
1213
  this[dimensionsSymbol].setVia("data.space", pixel);
1212
1214
  } else {
@@ -1226,8 +1228,8 @@ function calculateControlBarDimensions() {
1226
1228
  );
1227
1229
  }
1228
1230
 
1229
- this[dimensionsSymbol].setVia("data.visible", !(width === 0));
1230
- this[dimensionsSymbol].setVia("data.containerWidth", width);
1231
+ this[dimensionsSymbol].setVia("data.visible", !(containerWidth === 0));
1232
+ this[dimensionsSymbol].setVia("data.containerWidth", containerWidth);
1231
1233
 
1232
1234
  const itemReferences = [];
1233
1235
 
@@ -1549,6 +1551,10 @@ function isStackedBreakpointMatched() {
1549
1551
  } catch {}
1550
1552
  }
1551
1553
 
1554
+ if (!(width > 0)) {
1555
+ width = getComputedCssPixels(width);
1556
+ }
1557
+
1552
1558
  if (!(width > 0)) {
1553
1559
  return false;
1554
1560
  }
@@ -1583,6 +1589,7 @@ function setLayoutStackedState(stacked) {
1583
1589
  )) {
1584
1590
  queueLayoutChangedEvent.call(this);
1585
1591
  }
1592
+ applyLayoutAlignment.call(this);
1586
1593
  }
1587
1594
 
1588
1595
  /**
@@ -751,4 +751,93 @@ describe("ControlBar", function () {
751
751
  globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
752
752
  }
753
753
  });
754
+
755
+ it("should match the stacked breakpoint when the content-box container width is a css string", async function () {
756
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
757
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
758
+
759
+ const scheduledCallbacks = [];
760
+ const flushFrames = async () => {
761
+ while (scheduledCallbacks.length > 0) {
762
+ scheduledCallbacks.shift()();
763
+ await new Promise((resolve) => setTimeout(resolve, 0));
764
+ }
765
+ };
766
+
767
+ try {
768
+ window.requestAnimationFrame = (callback) => {
769
+ scheduledCallbacks.push(callback);
770
+ return scheduledCallbacks.length;
771
+ };
772
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
773
+
774
+ const mocks = document.getElementById("mocks");
775
+ mocks.innerHTML = `
776
+ <div id="content-box-breakpoint-wrapper">
777
+ <monster-control-bar
778
+ id="content-box-breakpoint-bar"
779
+ data-monster-option-layout-alignment="right"
780
+ data-monster-option-layout-stacked-alignment="left"
781
+ data-monster-option-layout-stacked-breakpoint="480px"
782
+ >
783
+ <button id="content-box-breakpoint-button">Run</button>
784
+ </monster-control-bar>
785
+ </div>
786
+ `;
787
+
788
+ const wrapper = document.getElementById(
789
+ "content-box-breakpoint-wrapper",
790
+ );
791
+ const button = document.getElementById("content-box-breakpoint-button");
792
+ const bar = document.getElementById("content-box-breakpoint-bar");
793
+ const controlBar = bar.shadowRoot.querySelector(
794
+ '[data-monster-role="control-bar"]',
795
+ );
796
+ const switchButton = bar.shadowRoot.querySelector(
797
+ '[data-monster-role="switch"]',
798
+ );
799
+
800
+ wrapper.style.boxSizing = "content-box";
801
+ wrapper.style.width = "350.156px";
802
+ Object.defineProperty(button, "offsetWidth", {
803
+ configurable: true,
804
+ value: 40,
805
+ });
806
+ Object.defineProperty(button, "offsetHeight", {
807
+ configurable: true,
808
+ value: 30,
809
+ });
810
+ button.getBoundingClientRect = () => ({
811
+ width: 40,
812
+ height: 30,
813
+ top: 0,
814
+ right: 40,
815
+ bottom: 30,
816
+ left: 0,
817
+ x: 0,
818
+ y: 0,
819
+ toJSON: () => {},
820
+ });
821
+ Object.defineProperty(switchButton, "offsetWidth", {
822
+ configurable: true,
823
+ value: 20,
824
+ });
825
+
826
+ await flushFrames();
827
+ await new Promise((resolve) => setTimeout(resolve, 0));
828
+ await new Promise((resolve) => setTimeout(resolve, 0));
829
+
830
+ expect(switchButton.hasAttribute("hidden")).to.be.true;
831
+ expect(button.hasAttribute("slot")).to.be.false;
832
+ expect(controlBar.getAttribute("data-monster-layout-stacked")).to.equal(
833
+ "true",
834
+ );
835
+ expect(controlBar.getAttribute("data-monster-layout-alignment")).to.equal(
836
+ "left",
837
+ );
838
+ } finally {
839
+ window.requestAnimationFrame = originalRequestAnimationFrame;
840
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
841
+ }
842
+ });
754
843
  });