@schukai/monster 4.143.2 → 4.143.4

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.2"}
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.4"}
@@ -392,6 +392,9 @@ class ControlBar extends CustomElement {
392
392
  }
393
393
  delete this[layoutFrameSymbol];
394
394
  this[layoutTokenSymbol] = (this[layoutTokenSymbol] || 0) + 1;
395
+ if (this[layoutStateSymbol]) {
396
+ this[layoutStateSymbol].scheduled = false;
397
+ }
395
398
 
396
399
  disconnectResizeObserver.call(this);
397
400
  defuseLayoutChangedEvent.call(this);
@@ -1393,7 +1396,13 @@ function getVisualBorderElement(element, side) {
1393
1396
  "[data-monster-role=control]",
1394
1397
  ].join(",");
1395
1398
  if (element.shadowRoot instanceof ShadowRoot) {
1396
- return element.shadowRoot.querySelector(selector) || element;
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
1405
+ );
1397
1406
  }
1398
1407
 
1399
1408
  const candidates = Array.from(element.querySelectorAll(selector)).filter(
@@ -30,6 +30,8 @@ describe("ControlBar", function () {
30
30
  Promise.all([
31
31
  import("../../../../source/components/form/control-bar.mjs"),
32
32
  import("../../../../source/components/form/control-bar-spacer.mjs"),
33
+ import("../../../../source/components/form/button.mjs"),
34
+ import("../../../../source/components/form/popper-button.mjs"),
33
35
  ])
34
36
  .then((m) => {
35
37
  ControlBar = m[0].ControlBar;
@@ -380,6 +382,92 @@ describe("ControlBar", function () {
380
382
  }
381
383
  });
382
384
 
385
+ it("should join borders between direct monster button controls", async function () {
386
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
387
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
388
+
389
+ const scheduledCallbacks = [];
390
+ const flushFrames = async () => {
391
+ while (scheduledCallbacks.length > 0) {
392
+ scheduledCallbacks.shift()();
393
+ await new Promise((resolve) => setTimeout(resolve, 0));
394
+ }
395
+ };
396
+
397
+ try {
398
+ window.requestAnimationFrame = (callback) => {
399
+ scheduledCallbacks.push(callback);
400
+ return scheduledCallbacks.length;
401
+ };
402
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
403
+
404
+ const mocks = document.getElementById("mocks");
405
+ mocks.innerHTML = `
406
+ <div id="monster-button-border-bar-wrapper">
407
+ <monster-control-bar id="monster-button-border-bar">
408
+ <monster-popper-button id="monster-button-border-create">
409
+ <span slot="button">Create</span>
410
+ </monster-popper-button>
411
+ <monster-button id="monster-button-border-tags">Manage tags</monster-button>
412
+ <monster-button id="monster-button-border-import">Import</monster-button>
413
+ </monster-control-bar>
414
+ </div>
415
+ `;
416
+
417
+ const wrapper = document.getElementById(
418
+ "monster-button-border-bar-wrapper",
419
+ );
420
+ const controls = [
421
+ document.getElementById("monster-button-border-create"),
422
+ document.getElementById("monster-button-border-tags"),
423
+ document.getElementById("monster-button-border-import"),
424
+ ];
425
+
426
+ wrapper.style.boxSizing = "border-box";
427
+ wrapper.style.width = "400px";
428
+ Object.defineProperty(wrapper, "clientWidth", {
429
+ configurable: true,
430
+ value: 400,
431
+ });
432
+
433
+ for (const control of controls) {
434
+ Object.defineProperty(control, "offsetWidth", {
435
+ configurable: true,
436
+ value: 80,
437
+ });
438
+ Object.defineProperty(control, "offsetHeight", {
439
+ configurable: true,
440
+ value: 30,
441
+ });
442
+ control.getBoundingClientRect = () => ({
443
+ width: 80,
444
+ height: 30,
445
+ top: 0,
446
+ right: 80,
447
+ bottom: 30,
448
+ left: 0,
449
+ x: 0,
450
+ y: 0,
451
+ toJSON: () => {},
452
+ });
453
+
454
+ const innerButton = control.shadowRoot?.querySelector("button");
455
+ innerButton.style.borderLeftWidth = "3px";
456
+ innerButton.style.borderRightWidth = "3px";
457
+ }
458
+
459
+ await flushFrames();
460
+ await new Promise((resolve) => setTimeout(resolve, 0));
461
+ await new Promise((resolve) => setTimeout(resolve, 0));
462
+
463
+ expect(controls[1].style.marginLeft).to.equal("-3px");
464
+ expect(controls[2].style.marginLeft).to.equal("-3px");
465
+ } finally {
466
+ window.requestAnimationFrame = originalRequestAnimationFrame;
467
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
468
+ }
469
+ });
470
+
383
471
  it("should size inline spacer lines from adjacent border widths", async function () {
384
472
  const originalRequestAnimationFrame = window.requestAnimationFrame;
385
473
  const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
@@ -762,6 +850,100 @@ describe("ControlBar", function () {
762
850
  }
763
851
  });
764
852
 
853
+ it("should reveal the control bar after reconnecting before initial layout", async function () {
854
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
855
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
856
+
857
+ const scheduledCallbacks = [];
858
+ const flushFrames = async () => {
859
+ while (scheduledCallbacks.length > 0) {
860
+ scheduledCallbacks.shift()();
861
+ await new Promise((resolve) => setTimeout(resolve, 0));
862
+ }
863
+ };
864
+
865
+ try {
866
+ window.requestAnimationFrame = (callback) => {
867
+ scheduledCallbacks.push(callback);
868
+ return scheduledCallbacks.length;
869
+ };
870
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
871
+
872
+ const mocks = document.getElementById("mocks");
873
+ mocks.innerHTML = `
874
+ <div id="reconnect-bar-wrapper">
875
+ <monster-control-bar
876
+ id="reconnect-bar"
877
+ class="nucleus-list-main-actions"
878
+ data-monster-option-layout-alignment="right"
879
+ data-monster-option-layout-stacked-alignment="left"
880
+ data-monster-option-layout-stacked-breakpoint="30rem"
881
+ >
882
+ <button id="reconnect-create">Create</button>
883
+ <button id="reconnect-tags">Manage tags</button>
884
+ <button id="reconnect-import">Import</button>
885
+ </monster-control-bar>
886
+ </div>
887
+ `;
888
+
889
+ const wrapper = document.getElementById("reconnect-bar-wrapper");
890
+ const bar = document.getElementById("reconnect-bar");
891
+ const buttons = [
892
+ document.getElementById("reconnect-create"),
893
+ document.getElementById("reconnect-tags"),
894
+ document.getElementById("reconnect-import"),
895
+ ];
896
+ const controlBar = bar.shadowRoot.querySelector(
897
+ '[data-monster-role="control-bar"]',
898
+ );
899
+
900
+ wrapper.style.boxSizing = "border-box";
901
+ Object.defineProperty(wrapper, "clientWidth", {
902
+ configurable: true,
903
+ value: 480,
904
+ });
905
+
906
+ for (const button of buttons) {
907
+ Object.defineProperty(button, "offsetWidth", {
908
+ configurable: true,
909
+ value: 90,
910
+ });
911
+ Object.defineProperty(button, "offsetHeight", {
912
+ configurable: true,
913
+ value: 30,
914
+ });
915
+ button.getBoundingClientRect = () => ({
916
+ width: 90,
917
+ height: 30,
918
+ top: 0,
919
+ right: 90,
920
+ bottom: 30,
921
+ left: 0,
922
+ x: 0,
923
+ y: 0,
924
+ toJSON: () => {},
925
+ });
926
+ }
927
+
928
+ expect(controlBar.style.opacity).to.equal("0");
929
+
930
+ bar.remove();
931
+ wrapper.append(bar);
932
+
933
+ await flushFrames();
934
+ await new Promise((resolve) => setTimeout(resolve, 0));
935
+ await new Promise((resolve) => setTimeout(resolve, 0));
936
+
937
+ expect(controlBar.style.opacity).to.equal("");
938
+ expect(controlBar.getAttribute("data-monster-layout-alignment")).to.equal(
939
+ "right",
940
+ );
941
+ } finally {
942
+ window.requestAnimationFrame = originalRequestAnimationFrame;
943
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
944
+ }
945
+ });
946
+
765
947
  it("should keep the overflow switch stable across the switch-width threshold", async function () {
766
948
  const OriginalResizeObserver = window.ResizeObserver;
767
949
  const originalGlobalResizeObserver = globalThis.ResizeObserver;