@alea-design/ui 0.7.0 → 0.7.2

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.
@@ -1,5 +1,5 @@
1
1
  import { type RefObject } from 'react';
2
- /** Whether a horizontal scroller (found inside box by selector) has hidden content at its start and end, and a function to page it. */
2
+ /** Whether a horizontal scroller has hidden content at its start and end, and a function to page it. The scroller is found inside box by selector, or is box itself when the selector is empty. */
3
3
  export declare function useScrollEdges(box: RefObject<HTMLElement | null>, selector: string, enabled?: boolean): {
4
4
  edges: {
5
5
  start: boolean;
@@ -1,31 +1,32 @@
1
1
  "use client";
2
- import { useState as f, useEffect as a } from "react";
3
- function p(n, l, c = !0) {
4
- const [d, o] = f({ start: !1, end: !1 });
5
- return a(() => {
6
- var i;
7
- const t = c ? (i = n.current) == null ? void 0 : i.querySelector(l) : null;
8
- if (!t) {
9
- o({ start: !1, end: !1 });
2
+ import { useState as h, useEffect as E } from "react";
3
+ function y(r, l, c = !0) {
4
+ const o = () => {
5
+ var e;
6
+ return (l ? (e = r.current) == null ? void 0 : e.querySelector(l) : r.current) ?? null;
7
+ }, [v, d] = h({ start: !1, end: !1 });
8
+ return E(() => {
9
+ const e = c ? o() : null;
10
+ if (!e) {
11
+ d({ start: !1, end: !1 });
10
12
  return;
11
13
  }
12
- const e = () => {
13
- const u = Math.abs(t.scrollLeft);
14
- o({ start: u > 2, end: u + t.clientWidth < t.scrollWidth - 2 });
14
+ const t = () => {
15
+ const u = Math.abs(e.scrollLeft), f = u > 2, a = u + e.clientWidth < e.scrollWidth - 2;
16
+ d((i) => i.start === f && i.end === a ? i : { start: f, end: a });
15
17
  };
16
- e(), t.addEventListener("scroll", e, { passive: !0 });
17
- const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(e);
18
- s == null || s.observe(t);
19
- const r = typeof MutationObserver > "u" ? null : new MutationObserver(e);
20
- return r == null || r.observe(t, { childList: !0 }), () => {
21
- t.removeEventListener("scroll", e), s == null || s.disconnect(), r == null || r.disconnect();
18
+ t(), e.addEventListener("scroll", t, { passive: !0 });
19
+ const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
20
+ s == null || s.observe(e), e.firstElementChild && (s == null || s.observe(e.firstElementChild));
21
+ const n = typeof MutationObserver > "u" ? null : new MutationObserver(t);
22
+ return n == null || n.observe(e, { childList: !0 }), () => {
23
+ e.removeEventListener("scroll", t), s == null || s.disconnect(), n == null || n.disconnect();
22
24
  };
23
- }, [n, l, c]), { edges: d, scroll: (t) => {
24
- var s;
25
- const e = (s = n.current) == null ? void 0 : s.querySelector(l);
26
- e == null || e.scrollBy({ left: t * (getComputedStyle(e).direction === "rtl" ? -1 : 1) * e.clientWidth * 0.8, behavior: "smooth" });
25
+ }, [r, l, c]), { edges: v, scroll: (e) => {
26
+ const t = o();
27
+ t == null || t.scrollBy({ left: e * (getComputedStyle(t).direction === "rtl" ? -1 : 1) * t.clientWidth * 0.8, behavior: "smooth" });
27
28
  } };
28
29
  }
29
30
  export {
30
- p as useScrollEdges
31
+ y as useScrollEdges
31
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/ui",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Alea: the complete React design system. Accessible components from forms to AI, charts and editors, Alea Motion, and W3C design tokens for dark, light and high contrast.",
5
5
  "keywords": [
6
6
  "react",
@@ -61,8 +61,8 @@
61
61
  "react-dom": ">=18.3"
62
62
  },
63
63
  "dependencies": {
64
- "@alea-design/motion": "0.7.0",
65
- "@alea-design/tokens": "0.7.0",
64
+ "@alea-design/motion": "0.7.2",
65
+ "@alea-design/tokens": "0.7.2",
66
66
  "@internationalized/date": "^3.8.0",
67
67
  "lucide-react": "^0.525.0",
68
68
  "qrcode-generator": "^1.5.2",