drab 6.5.1 → 7.0.0

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 +22 -22
  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,62 @@ 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");
29
34
  }
30
35
  /** Remove scroll from the body when open with the `remove-body-scroll` attribute. */
31
36
  #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`;
37
+ if (this.#removeBodyScroll) {
38
+ document.documentElement.style.scrollbarGutter = "stable";
39
39
  document.body.style.overflow = show ? "hidden" : "";
40
40
  }
41
41
  }
42
42
  /** Wraps `HTMLDialogElement.showModal()`. */
43
43
  show() {
44
- this.dialog.showModal();
44
+ this.#dialog.showModal();
45
45
  this.#toggleBodyScroll(true);
46
46
  }
47
47
  /** Wraps `HTMLDialogElement.close()`. */
48
48
  close() {
49
49
  this.#toggleBodyScroll(false);
50
- this.dialog.close();
50
+ this.#dialog.close();
51
51
  }
52
52
  /** `show` or `close` depending on the dialog's `open` attribute. */
53
53
  toggle() {
54
- if (this.dialog.open)
54
+ if (this.#dialog.open)
55
55
  this.close();
56
56
  else
57
57
  this.show();
58
58
  }
59
59
  mount() {
60
- this.triggerListener(() => this.toggle());
60
+ this.listener(() => this.toggle());
61
61
  this.safeListener("keydown", (e) => {
62
- if (e.key === "Escape" && this.dialog.open) {
62
+ if (e.key === "Escape" && this.#dialog.open) {
63
63
  e.preventDefault();
64
64
  this.close();
65
65
  }
66
66
  });
67
- if (this.hasAttribute("click-outside-close")) {
67
+ if (this.#clickOutsideClose) {
68
68
  // https://blog.webdevsimplified.com/2023-04/html-dialog/#close-on-outside-click
69
- this.dialog.addEventListener("click", (e) => {
70
- let rect = this.dialog.getBoundingClientRect();
69
+ this.#dialog.addEventListener("click", (e) => {
70
+ let rect = this.#dialog.getBoundingClientRect();
71
71
  // If dialog covers full viewport (with a small tolerance), use first child element for hit testing
72
72
  // Example: https://picocss.com/docs/modal
73
73
  if (rect.width - window.innerWidth <= 5 && // 5px tolerance for rounding issues
74
74
  rect.height - window.innerHeight <= 5 &&
75
- this.dialog.firstElementChild) {
76
- rect = this.dialog.firstElementChild.getBoundingClientRect();
75
+ this.#dialog.firstElementChild) {
76
+ rect = this.#dialog.firstElementChild.getBoundingClientRect();
77
77
  }
78
78
  if (e.clientX < rect.left ||
79
79
  e.clientX > rect.right ||