@schukai/monster 4.129.6 → 4.129.7

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.129.6"}
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.129.7"}
@@ -98,6 +98,7 @@ class ConfirmButton extends PopperButton {
98
98
  },
99
99
  });
100
100
 
101
+ obj["popper"]["strategy"] = "fixed";
101
102
  obj["classes"]["confirmButton"] = "monster-button-primary";
102
103
  obj["classes"]["cancelButton"] = "monster-button-secondary";
103
104
  obj["actions"]["cancel"] = (e) => {
@@ -55,11 +55,11 @@ function openPositionedPopper(controlElement, popperElement, options) {
55
55
 
56
56
  stopAutoUpdate(popperElement);
57
57
  popperElement.style.display = "block";
58
+ popperElement.style.position = config.strategy;
58
59
  popperElement.style.removeProperty("transform");
59
60
 
60
61
  // Keep the call signature stable even though only Floating UI is used now.
61
62
  void controlElement;
62
- void config;
63
63
  }
64
64
 
65
65
  function enableFloatingPositioning(controlElement, popperElement, config) {
@@ -93,6 +93,7 @@ function syncFloatingPopover(controlElement, popperElement, config) {
93
93
  Object.assign(popperElement.style, {
94
94
  top: "0",
95
95
  left: "0",
96
+ position: config.strategy,
96
97
  transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
97
98
  });
98
99
 
@@ -106,6 +107,7 @@ function closePositionedPopper(popperElement) {
106
107
  stopAutoUpdate(popperElement);
107
108
  popperElement.style.display = "none";
108
109
  popperElement.style.removeProperty("visibility");
110
+ popperElement.style.removeProperty("position");
109
111
  popperElement.style.removeProperty("transform");
110
112
  }
111
113
 
@@ -119,6 +121,7 @@ function normalizePopperConfig(options) {
119
121
  {
120
122
  placement: "top",
121
123
  engine: "floating",
124
+ strategy: "absolute",
122
125
  },
123
126
  options,
124
127
  );
@@ -15,10 +15,11 @@ let html1, options, html2, ConfirmButton;
15
15
 
16
16
  describe('ConfirmButton', function () {
17
17
 
18
- before(function (done) {
18
+ before(async function () {
19
+
20
+ await initJSDOM();
21
+ await import("element-internals-polyfill");
19
22
 
20
- import("element-internals-polyfill").catch(e => done(e));
21
-
22
23
  if(!global.ResizeObserver) {
23
24
  global.ResizeObserver = ResizeObserverMock;
24
25
  }
@@ -43,16 +44,8 @@ describe('ConfirmButton', function () {
43
44
  </div>
44
45
  `
45
46
 
46
-
47
- initJSDOM().then(() => {
48
-
49
- import("../../../../source/components/form/confirm-button.mjs").then((m) => {
50
- ConfirmButton = m['ConfirmButton'];
51
- done()
52
- }).catch(e => done(e))
53
-
54
-
55
- });
47
+ const m = await import("../../../../source/components/form/confirm-button.mjs");
48
+ ConfirmButton = m['ConfirmButton'];
56
49
  })
57
50
 
58
51
  describe('new ConfirmButton', function () {
@@ -120,8 +113,31 @@ describe('ConfirmButton', function () {
120
113
  }, 0)
121
114
 
122
115
 
116
+ });
117
+
118
+ it('should use fixed positioning by default', function (done) {
119
+
120
+ let mocks = document.getElementById('mocks');
121
+ const button = document.createElement('monster-confirm-button');
122
+ mocks.appendChild(button);
123
+
124
+ setTimeout(() => {
125
+ try {
126
+ button.showDialog();
127
+
128
+ const popper = button.shadowRoot.querySelector('[data-monster-role="popper"]');
129
+ expect(popper).to.exist;
130
+ expect(popper.style.position).to.equal('fixed');
131
+ } catch (e) {
132
+ return done(e);
133
+ }
134
+
135
+ done();
136
+ }, 0)
137
+
138
+
123
139
  });
124
140
  });
125
141
 
126
142
 
127
- });
143
+ });
@@ -86,4 +86,25 @@ describe("PopperButton", function () {
86
86
  }
87
87
  }, 0);
88
88
  });
89
+
90
+ it("should use absolute positioning by default", function (done) {
91
+ let mocks = document.getElementById("mocks");
92
+ const button = document.createElement("monster-popper-button");
93
+ mocks.appendChild(button);
94
+
95
+ setTimeout(() => {
96
+ try {
97
+ button.showDialog();
98
+
99
+ const popper = button.shadowRoot.querySelector(
100
+ '[data-monster-role="popper"]',
101
+ );
102
+ expect(popper).to.exist;
103
+ expect(popper.style.position).to.equal("absolute");
104
+ done();
105
+ } catch (e) {
106
+ done(e);
107
+ }
108
+ }, 0);
109
+ });
89
110
  });
@@ -289,18 +289,19 @@ describe("DOM", function () {
289
289
  firedDisconnected: 0,
290
290
  },
291
291
  };
292
+ static pendingCallbacks = [];
292
293
 
293
294
  connectedCallback() {
294
295
  const mode = this.getAttribute("data-mode") || "replace";
295
296
  MonsterTestRaceItem.stats[mode].connected++;
296
297
 
297
- setTimeout(() => {
298
+ MonsterTestRaceItem.pendingCallbacks.push(() => {
298
299
  if (this.isConnected) {
299
300
  MonsterTestRaceItem.stats[mode].firedConnected++;
300
301
  } else {
301
302
  MonsterTestRaceItem.stats[mode].firedDisconnected++;
302
303
  }
303
- }, 10);
304
+ });
304
305
  }
305
306
 
306
307
  disconnectedCallback() {
@@ -308,6 +309,14 @@ describe("DOM", function () {
308
309
  MonsterTestRaceItem.stats[mode].disconnected++;
309
310
  }
310
311
 
312
+ static flushPendingCallbacks() {
313
+ const pending = [...MonsterTestRaceItem.pendingCallbacks];
314
+ MonsterTestRaceItem.pendingCallbacks = [];
315
+ for (const callback of pending) {
316
+ callback();
317
+ }
318
+ }
319
+
311
320
  static resetStats() {
312
321
  MonsterTestRaceItem.stats = {
313
322
  replace: {
@@ -323,6 +332,7 @@ describe("DOM", function () {
323
332
  firedDisconnected: 0,
324
333
  },
325
334
  };
335
+ MonsterTestRaceItem.pendingCallbacks = [];
326
336
  }
327
337
  }
328
338
 
@@ -671,8 +681,9 @@ describe("DOM", function () {
671
681
 
672
682
  setTimeout(() => {
673
683
  try {
674
- const raceStats =
675
- customElements.get("monster-test-race-item").stats;
684
+ const raceItem = customElements.get("monster-test-race-item");
685
+ raceItem.flushPendingCallbacks();
686
+ const raceStats = raceItem.stats;
676
687
  expect(raceStats.patch.firedDisconnected).to.equal(0);
677
688
  expect(raceStats.replace.firedDisconnected).to.be.greaterThan(
678
689
  0,