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,64 +1,57 @@
1
- import { Base } from "../base/index.js";
1
+ import { Content, Lifecycle, Trigger, } from "../base/index.js";
2
2
  /**
3
- * Uses the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to add a `data-intersect` attribute to `content` when the `trigger` is intersecting.
3
+ * Uses the
4
+ * [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
5
+ * to add a `data-intersect` attribute to `content` when the `trigger` is intersecting.
4
6
  *
5
- * Use `onIntersect` and `onExit` to customize further with JavaScript.
7
+ * ### Events
8
+ *
9
+ * `intersect`
10
+ *
11
+ * Fired when the `trigger` enters the viewport.
12
+ *
13
+ * `exit`
14
+ *
15
+ * Fired when the `trigger` exits the viewport.
6
16
  *
7
17
  * ### Attributes
8
18
  *
9
19
  * `threshold`
10
20
  *
11
- * Specify a `threshold` between `0` and `1` to determine how much of the `trigger` should be visible for the intersection to occur.
21
+ * Specify a `threshold` between `0` and `1` to determine how much of the
22
+ * `trigger` should be visible for the intersection to occur.
12
23
  */
13
- export class Intersect extends Base {
14
- /** Functions to run when the `trigger` intersects. */
15
- #intersectCallbacks = [];
16
- /** Functions to run when the `trigger` exits. */
17
- #exitCallbacks = [];
24
+ export class Intersect extends Lifecycle(Trigger(Content())) {
18
25
  constructor() {
19
26
  super();
20
27
  }
21
28
  /**
22
- * How much of the `trigger` should be visible for the intersection to occur. For example, given a threshold of `.5`, the intersection would occur when the `trigger` is 50% visible.
29
+ * How much of the `trigger` should be visible for the intersection to occur.
30
+ * For example, given a threshold of `.5`, the intersection would occur when
31
+ * the `trigger` is 50% visible.
23
32
  *
24
33
  * @default 0
25
34
  */
26
35
  get #threshold() {
27
36
  return Number(this.getAttribute("threshold") ?? 0);
28
37
  }
29
- /**
30
- * @param callback Runs when `trigger` intersects.
31
- */
32
- onIntersect(callback) {
33
- this.#intersectCallbacks.push(callback);
34
- }
35
- /**
36
- * @param callback Runs when `trigger` exits.
37
- */
38
- onExit(callback) {
39
- this.#exitCallbacks.push(callback);
40
- }
41
38
  mount() {
42
39
  const observer = new IntersectionObserver((entries) => {
43
- /** Attribute to add or remove from `content`. */
40
+ // attribute to add or remove from `content`
44
41
  const attr = "data-intersect";
45
42
  for (const entry of entries) {
46
43
  if (entry.isIntersecting) {
47
- this.getContent().setAttribute(attr, "");
48
- for (const callback of this.#intersectCallbacks) {
49
- callback();
50
- }
44
+ this.content().setAttribute(attr, "");
51
45
  }
52
46
  else {
53
- this.getContent().removeAttribute(attr);
54
- for (const callback of this.#exitCallbacks) {
55
- callback();
56
- }
47
+ this.content().removeAttribute(attr);
57
48
  }
49
+ this.dispatchEvent(new CustomEvent(entry.isIntersecting ? "intersect" : "exit", {
50
+ detail: { entry },
51
+ }));
58
52
  }
59
53
  }, { threshold: this.#threshold });
60
- for (const trigger of this.getTrigger()) {
54
+ for (const trigger of this.triggers())
61
55
  observer.observe(trigger);
62
- }
63
56
  }
64
57
  }