@schukai/monster 4.136.12 → 4.136.14

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.136.12"}
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.136.14"}
@@ -828,6 +828,16 @@ function initEventHandler() {
828
828
  let suppressClickUntil = 0;
829
829
 
830
830
  const isInteractiveDragTarget = (event) => {
831
+ if (
832
+ findTargetElementFromEvent(
833
+ event,
834
+ "data-monster-role",
835
+ "datatable-headers",
836
+ )
837
+ ) {
838
+ return true;
839
+ }
840
+
831
841
  if (
832
842
  findTargetElementFromEvent(event, "data-monster-role", "resize-handle")
833
843
  ) {
@@ -284,16 +284,24 @@ function calcAndSetNavigationTopScrollableParentContext() {
284
284
  return;
285
285
  }
286
286
 
287
- const scrollTop = this[scrollableParentSymbol].scrollTop;
288
- const thisTop = scrollTop;
287
+ const parentRect = this[scrollableParentSymbol].getBoundingClientRect();
288
+ const rect = this.getBoundingClientRect();
289
+ const thisTop = rect.top - parentRect.top;
290
+ const thisBottom = rect.bottom - parentRect.top;
289
291
  let top = 0;
290
- top += scrollTop;
292
+ if (thisTop < 0) {
293
+ top = -1 * thisTop;
294
+ }
291
295
 
292
296
  const offset = this.getOption("offset");
293
297
  if (offset > 0) {
294
298
  top += offset;
295
299
  }
296
300
 
301
+ if (thisBottom < 0) {
302
+ return;
303
+ }
304
+
297
305
  fireCustomEvent(this, "new-top", { top: top });
298
306
 
299
307
  this[navigationElementSymbol].style.top = top + "px";
@@ -388,10 +396,15 @@ function createListFromHeadings(nodeList, currentLevel = 1) {
388
396
  li.addEventListener("click", (e) => {
389
397
  e.stopPropagation();
390
398
  getWindow().requestAnimationFrame(() => {
391
- window.scrollTo(0, 0);
392
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
393
- // mostly supported
394
- node?.scrollIntoView({ behavior: "smooth" });
399
+ if (!node) {
400
+ return;
401
+ }
402
+
403
+ node.scrollIntoView({
404
+ behavior: "smooth",
405
+ block: "start",
406
+ inline: "nearest",
407
+ });
395
408
  });
396
409
  });
397
410
 
@@ -579,7 +592,7 @@ function getTemplate() {
579
592
  return `
580
593
  <div data-monster-role="control" part="control">
581
594
  <div class="navigation" data-monster-role="navigation">
582
- <monster-popper data-monster-option-mode="enter">
595
+ <monster-popper data-monster-option-mode="enter" data-monster-option-popper-content-overflow="visible">
583
596
  <div slot="button" data-monster-role="navigation-control">
584
597
  </div>
585
598
  <div data-monster-role="navigation-list">
@@ -188,6 +188,55 @@ describe("Datatable drag scroll", function () {
188
188
  expect(clickCount).to.equal(1);
189
189
  });
190
190
 
191
+ it("does not start drag scroll from header interactions", async function () {
192
+ const mocks = document.getElementById("mocks");
193
+ const datatable = document.createElement("monster-datatable");
194
+ datatable.id = "drag-scroll-header-table";
195
+ datatable.innerHTML = `
196
+ <template id="drag-scroll-header-table-row">
197
+ <div data-monster-head="Name">Alpha</div>
198
+ <div data-monster-head="Value">Beta</div>
199
+ </template>
200
+ `;
201
+ datatable.setOption("data", [{}]);
202
+ mocks.appendChild(datatable);
203
+
204
+ await new Promise((resolve) => setTimeout(resolve, 30));
205
+
206
+ const scroll = datatable.shadowRoot.querySelector(
207
+ "[data-monster-role=table-scroll]",
208
+ );
209
+ const headerCell = datatable.shadowRoot.querySelector(
210
+ "[data-monster-role=datatable-headers] > div",
211
+ );
212
+
213
+ expect(scroll).to.exist;
214
+ expect(headerCell).to.exist;
215
+
216
+ mockScrollableElement(scroll, {
217
+ clientWidth: 200,
218
+ scrollWidth: 600,
219
+ });
220
+
221
+ scroll.scrollLeft = 120;
222
+
223
+ dispatchPointerEvent(headerCell, "pointerdown", {
224
+ clientX: 100,
225
+ clientY: 20,
226
+ });
227
+ dispatchPointerEvent(window, "pointermove", {
228
+ clientX: 40,
229
+ clientY: 24,
230
+ });
231
+ dispatchPointerEvent(window, "pointerup", {
232
+ clientX: 40,
233
+ clientY: 24,
234
+ });
235
+
236
+ expect(scroll.scrollLeft).to.equal(120);
237
+ expect(scroll.classList.contains("is-dragging")).to.equal(false);
238
+ });
239
+
191
240
  it("keeps double click copy for a single cell", async function () {
192
241
  const mocks = document.getElementById("mocks");
193
242
  const datatable = document.createElement("monster-datatable");