@floegence/floe-webapp-core 0.60.1 → 0.61.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.
@@ -6,5 +6,9 @@ export interface Size {
6
6
  /**
7
7
  * Track the usable content box in local CSS pixels, excluding padding and
8
8
  * scrollbars. CSS transforms on the element or its ancestors do not affect it.
9
+ * With preserveWhenHidden, retain the last measurement while there is no rendered
10
+ * box. Real zero-sized boxes still report zero; replacing the element resets it.
9
11
  */
10
- export declare function useResizeObserver(element: Accessor<HTMLElement | null | undefined>): Accessor<Size | null>;
12
+ export declare function useResizeObserver(element: Accessor<HTMLElement | null | undefined>, options?: {
13
+ preserveWhenHidden?: boolean;
14
+ }): Accessor<Size | null>;
@@ -1,29 +1,28 @@
1
- import { createSignal as u, createEffect as h, onCleanup as s } from "solid-js";
2
- function f(d) {
3
- const [a, r] = u(null, {
1
+ import { createSignal as l, createEffect as u, onCleanup as d } from "solid-js";
2
+ function g(o, a = {}) {
3
+ const [c, r] = l(null, {
4
4
  equals: (e, t) => e?.width === t?.width && e?.height === t?.height
5
5
  });
6
- return h(() => {
7
- const e = d();
8
- if (!e) {
9
- r(null);
6
+ return u(() => {
7
+ const e = o();
8
+ if (r(null), !e)
10
9
  return;
11
- }
12
10
  const t = () => {
13
- const n = e.ownerDocument.defaultView.getComputedStyle(e), i = (c) => Number.parseFloat(c) || 0;
11
+ if (a.preserveWhenHidden && e.getClientRects().length === 0) return;
12
+ const n = e.ownerDocument.defaultView.getComputedStyle(e), i = (h) => Number.parseFloat(h) || 0;
14
13
  r({
15
14
  width: Math.max(0, e.clientWidth - i(n.paddingLeft) - i(n.paddingRight)),
16
15
  height: Math.max(0, e.clientHeight - i(n.paddingTop) - i(n.paddingBottom))
17
16
  });
18
17
  };
19
18
  if (t(), typeof ResizeObserver > "u") {
20
- typeof window < "u" && (window.addEventListener("resize", t), s(() => window.removeEventListener("resize", t)));
19
+ typeof window < "u" && (window.addEventListener("resize", t), d(() => window.removeEventListener("resize", t)));
21
20
  return;
22
21
  }
23
- const o = new ResizeObserver(t);
24
- o.observe(e), s(() => o.disconnect());
25
- }), a;
22
+ const s = new ResizeObserver(t);
23
+ s.observe(e), d(() => s.disconnect());
24
+ }), c;
26
25
  }
27
26
  export {
28
- f as useResizeObserver
27
+ g as useResizeObserver
29
28
  };
@@ -1,11 +1,11 @@
1
1
  import { createSignal as f, createMemo as i, onCleanup as F } from "solid-js";
2
- function x(e) {
3
- const a = e.overscan ?? 8;
4
- let t = null, o = null, r = null;
2
+ function T(t) {
3
+ const a = t.overscan ?? 8;
4
+ let e = null, o = null, r = null;
5
5
  const [m, d] = f(0), [z, S] = f(0), c = () => {
6
- t && (d(t.scrollTop), S(t.clientHeight));
6
+ !e || e.getClientRects().length === 0 || (d(e.scrollTop), S(e.clientHeight));
7
7
  }, p = () => {
8
- if (t && r === null) {
8
+ if (e && r === null) {
9
9
  if (typeof requestAnimationFrame > "u") {
10
10
  c();
11
11
  return;
@@ -15,20 +15,20 @@ function x(e) {
15
15
  });
16
16
  }
17
17
  }, l = i(() => {
18
- const n = e.count(), s = e.itemSize(), u = m(), w = z();
18
+ const n = t.count(), s = t.itemSize(), u = m(), w = z();
19
19
  if (n <= 0 || s <= 0) return { start: 0, end: 0 };
20
20
  const b = Math.max(0, Math.floor(u / s) - a), A = Math.min(n, Math.ceil((u + w) / s) + a);
21
21
  return { start: b, end: A };
22
- }), v = i(() => l().start * e.itemSize()), h = i(() => {
23
- const n = e.count();
24
- return Math.max(0, n - l().end) * e.itemSize();
25
- }), M = i(() => e.count() * e.itemSize()), g = (n) => {
26
- t !== n && (o?.disconnect(), o = null, t = n, !(!t || typeof ResizeObserver > "u") && (o = new ResizeObserver(() => c()), o.observe(t), c()));
22
+ }), v = i(() => l().start * t.itemSize()), g = i(() => {
23
+ const n = t.count();
24
+ return Math.max(0, n - l().end) * t.itemSize();
25
+ }), h = i(() => t.count() * t.itemSize()), M = (n) => {
26
+ e !== n && (o?.disconnect(), o = null, e = n, e && (c(), !(typeof ResizeObserver > "u") && (o = new ResizeObserver(() => c()), o.observe(e))));
27
27
  };
28
28
  return F(() => {
29
29
  o?.disconnect(), r !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(r), r = null);
30
- }), { scrollRef: g, onScroll: p, range: l, paddingTop: v, paddingBottom: h, totalSize: M };
30
+ }), { scrollRef: M, onScroll: p, range: l, paddingTop: v, paddingBottom: g, totalSize: h };
31
31
  }
32
32
  export {
33
- x as useVirtualWindow
33
+ T as useVirtualWindow
34
34
  };