@floegence/floe-webapp-core 0.60.0 → 0.60.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,6 +1,9 @@
1
1
  import { type Accessor, type JSX } from 'solid-js';
2
2
  export interface ViewActivationContextValue {
3
3
  id: string;
4
+ /** Immediate presentation visibility. Custom providers default to their active accessor. */
5
+ visible?: Accessor<boolean>;
6
+ /** Activation effects may wait until after the visible content paints. */
4
7
  active: Accessor<boolean>;
5
8
  activationSeq: Accessor<number>;
6
9
  }
@@ -9,4 +12,4 @@ export interface ViewActivationProviderProps {
9
12
  children: JSX.Element;
10
13
  }
11
14
  export declare function ViewActivationProvider(props: ViewActivationProviderProps): JSX.Element;
12
- export declare function useViewActivation(): ViewActivationContextValue;
15
+ export declare function useViewActivation(): Required<ViewActivationContextValue>;
@@ -1,22 +1,25 @@
1
- import { createComponent as i } from "solid-js/web";
2
- import { untrack as n, useContext as r, createContext as c } from "solid-js";
3
- const e = c();
4
- function v(t) {
5
- const o = n(() => t.value);
6
- return i(e.Provider, {
7
- value: o,
1
+ import { createComponent as a } from "solid-js/web";
2
+ import { useContext as o, untrack as v, createContext as u } from "solid-js";
3
+ const i = u();
4
+ function w(t) {
5
+ const n = o(i), e = v(() => t.value), r = e.visible ?? e.active, c = {
6
+ ...e,
7
+ visible: () => (n?.visible() ?? !0) && r()
8
+ };
9
+ return a(i.Provider, {
10
+ value: c,
8
11
  get children() {
9
12
  return t.children;
10
13
  }
11
14
  });
12
15
  }
13
- function w() {
14
- const t = r(e);
16
+ function d() {
17
+ const t = o(i);
15
18
  if (!t)
16
19
  throw new Error("ViewActivationContext not found. Wrap your view with <ViewActivationProvider />.");
17
20
  return t;
18
21
  }
19
22
  export {
20
- v as ViewActivationProvider,
21
- w as useViewActivation
23
+ w as ViewActivationProvider,
24
+ d as useViewActivation
22
25
  };
@@ -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
  };