@octaviaflow/core 3.0.18-beta.46 → 3.0.18-beta.47

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,4 +1,14 @@
1
1
  import { type CSSProperties, type RefObject } from "react";
2
+ export interface AnchoredRect {
3
+ top: number;
4
+ bottom: number;
5
+ left: number;
6
+ width: number;
7
+ }
8
+ export interface AnchoredViewport {
9
+ width: number;
10
+ height: number;
11
+ }
2
12
  export interface AnchoredPopoverPosition {
3
13
  top?: number;
4
14
  bottom?: number;
@@ -10,6 +20,22 @@ export interface AnchoredPopoverPosition {
10
20
  /** Which way the popover opened — handy for direction-aware entry motion. */
11
21
  direction: "up" | "down";
12
22
  }
23
+ export interface ComputeAnchoredPositionArgs {
24
+ anchor: AnchoredRect;
25
+ viewport: AnchoredViewport;
26
+ /** Measured popover width, used for horizontal clamping. Falls back to the
27
+ * anchor width when unknown (first paint before the popover is measured). */
28
+ popoverWidth?: number;
29
+ gap: number;
30
+ margin: number;
31
+ preferredMinHeight: number;
32
+ }
33
+ /**
34
+ * Pure geometry — extracted so the placement maths can be unit-tested without
35
+ * a DOM. Given the anchor rect, the viewport, and the popover's width, returns
36
+ * the fixed-position coordinates (with vertical flip + horizontal clamp).
37
+ */
38
+ export declare function computeAnchoredPosition({ anchor, viewport, popoverWidth, gap, margin, preferredMinHeight, }: ComputeAnchoredPositionArgs): AnchoredPopoverPosition;
13
39
  export interface UseAnchoredPopoverOptions {
14
40
  /** Gap in px between the trigger and the popover. Default 4. */
15
41
  gap?: number;
@@ -18,6 +44,10 @@ export interface UseAnchoredPopoverOptions {
18
44
  /** Below this much downward space (px) the popover prefers to flip up.
19
45
  * Default 200. */
20
46
  preferredMinHeight?: number;
47
+ /** Ref to the popover element. When provided its measured width is used for
48
+ * horizontal clamping (popovers wider than the trigger anchored near the
49
+ * right edge would otherwise overflow). */
50
+ popoverRef?: RefObject<HTMLElement | null>;
21
51
  }
22
52
  /**
23
53
  * @param anchorRef ref to the trigger element the popover anchors to
@@ -1 +1 @@
1
- {"version":3,"file":"useAnchoredPopover.d.ts","sourceRoot":"","sources":["../../src/utils/useAnchoredPopover.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAmBf,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;gFAC4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;uBACmB;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACxC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,yBAA8B,GACtC,uBAAuB,CA8CzB;AAED;kEACkE;AAClE,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,uBAAuB,EAC5B,KAAK,CAAC,EAAE,aAAa,GACpB,aAAa,CAUf"}
1
+ {"version":3,"file":"useAnchoredPopover.d.ts","sourceRoot":"","sources":["../../src/utils/useAnchoredPopover.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAwBf,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CAC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,EAAE,uBAAuB,EAC5B,KAAK,CAAC,EAAE,aAAa,GACpB,aAAa,CAUf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octaviaflow/core",
3
- "version": "3.0.18-beta.46",
3
+ "version": "3.0.18-beta.47",
4
4
  "description": "OctaviaFlow Design System React components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",