drab 6.5.1 → 7.0.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.
Files changed (39) hide show
  1. package/dist/announcer/index.d.ts +2 -0
  2. package/dist/base/index.d.ts +101 -1536
  3. package/dist/base/index.js +87 -76
  4. package/dist/contextmenu/index.d.ts +1045 -3
  5. package/dist/contextmenu/index.js +15 -15
  6. package/dist/define.d.ts +11 -1
  7. package/dist/define.js +11 -5
  8. package/dist/dialog/index.d.ts +1047 -6
  9. package/dist/dialog/index.js +28 -25
  10. package/dist/editor/index.d.ts +1047 -12
  11. package/dist/editor/index.js +36 -36
  12. package/dist/fullscreen/index.d.ts +1045 -7
  13. package/dist/fullscreen/index.js +8 -8
  14. package/dist/index.d.ts +0 -3
  15. package/dist/index.js +0 -3
  16. package/dist/intersect/index.d.ts +1059 -16
  17. package/dist/intersect/index.js +26 -33
  18. package/dist/prefetch/index.d.ts +706 -25
  19. package/dist/prefetch/index.js +25 -44
  20. package/dist/share/index.d.ts +1413 -11
  21. package/dist/share/index.js +50 -18
  22. package/dist/tablesort/index.d.ts +1390 -5
  23. package/dist/tablesort/index.js +5 -5
  24. package/dist/tabs/index.d.ts +702 -4
  25. package/dist/tabs/index.js +3 -3
  26. package/dist/types/index.d.ts +29 -0
  27. package/dist/wakelock/index.d.ts +1390 -6
  28. package/dist/wakelock/index.js +16 -16
  29. package/package.json +5 -24
  30. package/dist/base/define.js +0 -3
  31. package/dist/copy/define.d.ts +0 -1
  32. package/dist/copy/define.js +0 -3
  33. package/dist/copy/index.d.ts +0 -30
  34. package/dist/copy/index.js +0 -39
  35. package/dist/youtube/define.d.ts +0 -1
  36. package/dist/youtube/define.js +0 -3
  37. package/dist/youtube/index.d.ts +0 -31
  38. package/dist/youtube/index.js +0 -56
  39. /package/dist/{base/define.d.ts → types/index.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Base } from "../base/index.js";
1
+ import { Content, Lifecycle, Trigger, } from "../base/index.js";
2
2
  /**
3
3
  * Provides triggers for the `HTMLDialogElement`.
4
4
  *
@@ -18,62 +18,65 @@ import { Base } from "../base/index.js";
18
18
  * Add the `remove-body-scroll` attribute to remove the scroll from `document.body` when the dialog
19
19
  * is open.
20
20
  */
21
- export class Dialog extends Base {
22
- #initialBodyMarginRight = parseInt(getComputedStyle(document.body).marginRight);
21
+ export class Dialog extends Lifecycle(Trigger(Content())) {
23
22
  constructor() {
24
23
  super();
25
24
  }
26
25
  /** The `HTMLDialogElement` within the element. */
27
- get dialog() {
28
- return this.getContent(HTMLDialogElement);
26
+ get #dialog() {
27
+ return this.content(HTMLDialogElement);
28
+ }
29
+ get #removeBodyScroll() {
30
+ return this.hasAttribute("remove-body-scroll");
31
+ }
32
+ get #clickOutsideClose() {
33
+ return this.hasAttribute("click-outside-close");
34
+ }
35
+ get #scrollbarWidth() {
36
+ return window.innerWidth - document.documentElement.clientWidth;
29
37
  }
30
38
  /** Remove scroll from the body when open with the `remove-body-scroll` attribute. */
31
39
  #toggleBodyScroll(show) {
32
- if (this.hasAttribute("remove-body-scroll")) {
33
- document.body.style.marginRight = `${show
34
- ? this.#initialBodyMarginRight +
35
- // scrollbar width
36
- window.innerWidth -
37
- document.documentElement.clientWidth
38
- : this.#initialBodyMarginRight}px`;
40
+ if (this.#removeBodyScroll) {
41
+ document.documentElement.style.scrollbarGutter = "stable";
39
42
  document.body.style.overflow = show ? "hidden" : "";
40
43
  }
41
44
  }
42
45
  /** Wraps `HTMLDialogElement.showModal()`. */
43
46
  show() {
44
- this.dialog.showModal();
47
+ this.#dialog.showModal();
45
48
  this.#toggleBodyScroll(true);
46
49
  }
47
50
  /** Wraps `HTMLDialogElement.close()`. */
48
51
  close() {
49
52
  this.#toggleBodyScroll(false);
50
- this.dialog.close();
53
+ this.#dialog.close();
51
54
  }
52
55
  /** `show` or `close` depending on the dialog's `open` attribute. */
53
56
  toggle() {
54
- if (this.dialog.open)
57
+ if (this.#dialog.open)
55
58
  this.close();
56
59
  else
57
60
  this.show();
58
61
  }
59
62
  mount() {
60
- this.triggerListener(() => this.toggle());
63
+ this.listener(() => this.toggle());
61
64
  this.safeListener("keydown", (e) => {
62
- if (e.key === "Escape" && this.dialog.open) {
65
+ if (e.key === "Escape" && this.#dialog.open) {
63
66
  e.preventDefault();
64
67
  this.close();
65
68
  }
66
69
  });
67
- if (this.hasAttribute("click-outside-close")) {
70
+ if (this.#clickOutsideClose) {
68
71
  // https://blog.webdevsimplified.com/2023-04/html-dialog/#close-on-outside-click
69
- this.dialog.addEventListener("click", (e) => {
70
- let rect = this.dialog.getBoundingClientRect();
71
- // If dialog covers full viewport (with a small tolerance), use first child element for hit testing
72
+ this.#dialog.addEventListener("click", (e) => {
73
+ let rect = this.#dialog.getBoundingClientRect();
74
+ // If dialog covers full viewport, use first child element for hit testing
72
75
  // Example: https://picocss.com/docs/modal
73
- if (rect.width - window.innerWidth <= 5 && // 5px tolerance for rounding issues
74
- rect.height - window.innerHeight <= 5 &&
75
- this.dialog.firstElementChild) {
76
- rect = this.dialog.firstElementChild.getBoundingClientRect();
76
+ if (Math.abs(rect.width - window.innerWidth) <= this.#scrollbarWidth && // 5px tolerance for rounding issues
77
+ Math.abs(rect.height - window.innerHeight) <= 0 &&
78
+ this.#dialog.firstElementChild) {
79
+ rect = this.#dialog.firstElementChild.getBoundingClientRect();
77
80
  }
78
81
  if (e.clientX < rect.left ||
79
82
  e.clientX > rect.right ||