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.
- package/dist/announcer/index.d.ts +2 -0
- package/dist/base/index.d.ts +101 -1536
- package/dist/base/index.js +87 -76
- package/dist/contextmenu/index.d.ts +1045 -3
- package/dist/contextmenu/index.js +15 -15
- package/dist/define.d.ts +11 -1
- package/dist/define.js +11 -5
- package/dist/dialog/index.d.ts +1047 -6
- package/dist/dialog/index.js +22 -22
- package/dist/editor/index.d.ts +1047 -12
- package/dist/editor/index.js +36 -36
- package/dist/fullscreen/index.d.ts +1045 -7
- package/dist/fullscreen/index.js +8 -8
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/intersect/index.d.ts +1059 -16
- package/dist/intersect/index.js +26 -33
- package/dist/prefetch/index.d.ts +706 -25
- package/dist/prefetch/index.js +25 -44
- package/dist/share/index.d.ts +1413 -11
- package/dist/share/index.js +50 -18
- package/dist/tablesort/index.d.ts +1390 -5
- package/dist/tablesort/index.js +5 -5
- package/dist/tabs/index.d.ts +702 -4
- package/dist/tabs/index.js +3 -3
- package/dist/types/index.d.ts +29 -0
- package/dist/wakelock/index.d.ts +1390 -6
- package/dist/wakelock/index.js +16 -16
- package/package.json +5 -24
- package/dist/base/define.js +0 -3
- package/dist/copy/define.d.ts +0 -1
- package/dist/copy/define.js +0 -3
- package/dist/copy/index.d.ts +0 -30
- package/dist/copy/index.js +0 -39
- package/dist/youtube/define.d.ts +0 -1
- package/dist/youtube/define.js +0 -3
- package/dist/youtube/index.d.ts +0 -31
- package/dist/youtube/index.js +0 -56
- /package/dist/{base/define.d.ts → types/index.js} +0 -0
package/dist/dialog/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
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
|
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.
|
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
|
33
|
-
document.
|
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
|
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
|
50
|
+
this.#dialog.close();
|
51
51
|
}
|
52
52
|
/** `show` or `close` depending on the dialog's `open` attribute. */
|
53
53
|
toggle() {
|
54
|
-
if (this
|
54
|
+
if (this.#dialog.open)
|
55
55
|
this.close();
|
56
56
|
else
|
57
57
|
this.show();
|
58
58
|
}
|
59
59
|
mount() {
|
60
|
-
this.
|
60
|
+
this.listener(() => this.toggle());
|
61
61
|
this.safeListener("keydown", (e) => {
|
62
|
-
if (e.key === "Escape" && this
|
62
|
+
if (e.key === "Escape" && this.#dialog.open) {
|
63
63
|
e.preventDefault();
|
64
64
|
this.close();
|
65
65
|
}
|
66
66
|
});
|
67
|
-
if (this
|
67
|
+
if (this.#clickOutsideClose) {
|
68
68
|
// https://blog.webdevsimplified.com/2023-04/html-dialog/#close-on-outside-click
|
69
|
-
this
|
70
|
-
let rect = this
|
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
|
76
|
-
rect = this
|
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 ||
|