@adamosuiteservices/ui 2.19.2 → 2.20.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.
@@ -0,0 +1 @@
1
+ export * from './sticky-section';
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ type StickySectionContextValue = {
3
+ /** Whether the section is currently stuck to the top. */
4
+ isSticky: boolean;
5
+ /** The computed top offset in pixels used by the IntersectionObserver. */
6
+ topOffset: number;
7
+ };
8
+ export type StickySectionProps = Readonly<{
9
+ /**
10
+ * Fixed top offset in pixels. When provided, the component skips the
11
+ * `offsetSelector` measurement and uses this value directly.
12
+ */
13
+ topOffset?: number;
14
+ /**
15
+ * CSS selector of the element whose height is used as the top offset.
16
+ * Defaults to `"[data-slot='sidebar-top-bar']"` (the library's sidebar top bar).
17
+ * Ignored when `topOffset` is provided.
18
+ */
19
+ offsetSelector?: string;
20
+ /** Controlled sticky state. When provided, internal detection is bypassed. */
21
+ isSticky?: boolean;
22
+ /** Called whenever the sticky state changes, with the new state and offset. */
23
+ onIsStickyChange?: (isSticky: boolean, topOffset: number) => void;
24
+ children: ReactNode | ((isSticky: boolean, topOffset: number) => ReactNode);
25
+ }>;
26
+ export declare function StickySection({ topOffset: userTopOffset, offsetSelector, isSticky: controlledIsSticky, onIsStickyChange, children, }: StickySectionProps): import("react/jsx-runtime").JSX.Element;
27
+ export declare function useStickySection(): StickySectionContextValue;
28
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from "react";
3
3
  declare const badgeVariants: (props?: ({
4
- variant?: "white" | "default" | "success" | "success-medium" | "warning" | "warning-medium" | "destructive" | "destructive-medium" | "outline" | "secondary" | "info" | "default-medium" | "waiting" | "waiting-medium" | "info-medium" | "muted" | null | undefined;
4
+ variant?: "white" | "default" | "success" | "success-medium" | "warning" | "warning-medium" | "destructive" | "destructive-medium" | "outline" | "secondary" | "info" | "waiting" | "default-medium" | "waiting-medium" | "info-medium" | "muted" | null | undefined;
5
5
  size?: "lg" | null | undefined;
6
6
  shape?: "pill" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -0,0 +1,11 @@
1
+ export type ElementRect = {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ top: number;
7
+ right: number;
8
+ bottom: number;
9
+ left: number;
10
+ };
11
+ export declare function useElementRect(selector: string): ElementRect | null;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./jsx-runtime-BB_1_6y_.cjs"),o=require("react");function b(n){const[u,r]=o.useState(null);return o.useEffect(()=>{const s=document.querySelector(n);if(!s){r(null);return}const e=()=>{const t=s.getBoundingClientRect();r({x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left})};e();const i=new ResizeObserver(e);return i.observe(s),window.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{i.disconnect(),window.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[n]),u}const x=o.createContext(null);function y({topOffset:n,offsetSelector:u="[data-slot='sidebar-top-bar']",isSticky:r,onIsStickyChange:s,children:e}){const i=o.useRef(null),[t,v]=o.useState(!1),p=b(u),c=n??p?.height??64,l=r!==void 0,f=l?r:t;return o.useEffect(()=>{const d=new IntersectionObserver(([w])=>{const S=!w.isIntersecting;l||v(S),s&&s(S,c)},{threshold:[0],rootMargin:`${c}px 0px 0px 0px`});return i.current&&d.observe(i.current),()=>{d.disconnect()}},[c,l,s]),a.jsxRuntimeExports.jsxs(x.Provider,{value:{isSticky:f,topOffset:c},children:[a.jsxRuntimeExports.jsx("div",{ref:i,className:"absolute top-0 h-px"}),typeof e=="function"?e(f,c):e]})}function m(){const n=o.useContext(x);if(!n)throw new Error("useStickySection must be used within StickySection");return n}exports.StickySection=y;exports.useStickySection=m;
@@ -0,0 +1,65 @@
1
+ import { j as p } from "./jsx-runtime-BzflLqGi.js";
2
+ import { useState as a, useEffect as v, createContext as b, useRef as h, useContext as y } from "react";
3
+ function R(n) {
4
+ const [c, r] = a(null);
5
+ return v(() => {
6
+ const o = document.querySelector(n);
7
+ if (!o) {
8
+ r(null);
9
+ return;
10
+ }
11
+ const t = () => {
12
+ const e = o.getBoundingClientRect();
13
+ r({
14
+ x: e.x,
15
+ y: e.y,
16
+ width: e.width,
17
+ height: e.height,
18
+ top: e.top,
19
+ right: e.right,
20
+ bottom: e.bottom,
21
+ left: e.left
22
+ });
23
+ };
24
+ t();
25
+ const s = new ResizeObserver(t);
26
+ return s.observe(o), window.addEventListener("scroll", t), window.addEventListener("resize", t), () => {
27
+ s.disconnect(), window.removeEventListener("scroll", t), window.removeEventListener("resize", t);
28
+ };
29
+ }, [n]), c;
30
+ }
31
+ const w = b(null);
32
+ function k({
33
+ topOffset: n,
34
+ offsetSelector: c = "[data-slot='sidebar-top-bar']",
35
+ isSticky: r,
36
+ onIsStickyChange: o,
37
+ children: t
38
+ }) {
39
+ const s = h(null), [e, x] = a(!1), m = R(c), i = n ?? m?.height ?? 64, u = r !== void 0, f = u ? r : e;
40
+ return v(() => {
41
+ const l = new IntersectionObserver(
42
+ ([S]) => {
43
+ const d = !S.isIntersecting;
44
+ u || x(d), o && o(d, i);
45
+ },
46
+ { threshold: [0], rootMargin: `${i}px 0px 0px 0px` }
47
+ );
48
+ return s.current && l.observe(s.current), () => {
49
+ l.disconnect();
50
+ };
51
+ }, [i, u, o]), /* @__PURE__ */ p.jsxs(w.Provider, { value: { isSticky: f, topOffset: i }, children: [
52
+ /* @__PURE__ */ p.jsx("div", { ref: s, className: "absolute top-0 h-px" }),
53
+ typeof t == "function" ? t(f, i) : t
54
+ ] });
55
+ }
56
+ function O() {
57
+ const n = y(w);
58
+ if (!n)
59
+ throw new Error("useStickySection must be used within StickySection");
60
+ return n;
61
+ }
62
+ export {
63
+ k as StickySection,
64
+ O as useStickySection
65
+ };