@yahoo/uds-mobile 2.17.0 → 2.18.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.
- package/dist/bin/generateTheme.mjs +7 -2
- package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +4 -0
- package/dist/components/Popover/Popover.cjs +92 -0
- package/dist/components/Popover/Popover.d.cts +26 -0
- package/dist/components/Popover/Popover.d.cts.map +1 -0
- package/dist/components/Popover/Popover.d.ts +26 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +92 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/PopoverContent.cjs +124 -0
- package/dist/components/Popover/PopoverContent.d.cts +15 -0
- package/dist/components/Popover/PopoverContent.d.cts.map +1 -0
- package/dist/components/Popover/PopoverContent.d.ts +15 -0
- package/dist/components/Popover/PopoverContent.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContent.js +124 -0
- package/dist/components/Popover/PopoverContent.js.map +1 -0
- package/dist/components/Popover/PopoverContext.cjs +14 -0
- package/dist/components/Popover/PopoverContext.d.cts +10 -0
- package/dist/components/Popover/PopoverContext.d.cts.map +1 -0
- package/dist/components/Popover/PopoverContext.d.ts +10 -0
- package/dist/components/Popover/PopoverContext.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContext.js +13 -0
- package/dist/components/Popover/PopoverContext.js.map +1 -0
- package/dist/components/Popover/PopoverDescription.cjs +23 -0
- package/dist/components/Popover/PopoverDescription.d.cts +15 -0
- package/dist/components/Popover/PopoverDescription.d.cts.map +1 -0
- package/dist/components/Popover/PopoverDescription.d.ts +15 -0
- package/dist/components/Popover/PopoverDescription.d.ts.map +1 -0
- package/dist/components/Popover/PopoverDescription.js +23 -0
- package/dist/components/Popover/PopoverDescription.js.map +1 -0
- package/dist/components/Popover/PopoverDismiss.cjs +22 -0
- package/dist/components/Popover/PopoverDismiss.d.cts +15 -0
- package/dist/components/Popover/PopoverDismiss.d.cts.map +1 -0
- package/dist/components/Popover/PopoverDismiss.d.ts +15 -0
- package/dist/components/Popover/PopoverDismiss.d.ts.map +1 -0
- package/dist/components/Popover/PopoverDismiss.js +22 -0
- package/dist/components/Popover/PopoverDismiss.js.map +1 -0
- package/dist/components/Popover/PopoverFrame.cjs +56 -0
- package/dist/components/Popover/PopoverFrame.d.cts +23 -0
- package/dist/components/Popover/PopoverFrame.d.cts.map +1 -0
- package/dist/components/Popover/PopoverFrame.d.ts +23 -0
- package/dist/components/Popover/PopoverFrame.d.ts.map +1 -0
- package/dist/components/Popover/PopoverFrame.js +55 -0
- package/dist/components/Popover/PopoverFrame.js.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.cjs +45 -0
- package/dist/components/Popover/PopoverPortalLayer.d.cts +15 -0
- package/dist/components/Popover/PopoverPortalLayer.d.cts.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.d.ts +15 -0
- package/dist/components/Popover/PopoverPortalLayer.d.ts.map +1 -0
- package/dist/components/Popover/PopoverPortalLayer.js +45 -0
- package/dist/components/Popover/PopoverPortalLayer.js.map +1 -0
- package/dist/components/Popover/PopoverSurface.cjs +228 -0
- package/dist/components/Popover/PopoverSurface.d.cts +26 -0
- package/dist/components/Popover/PopoverSurface.d.cts.map +1 -0
- package/dist/components/Popover/PopoverSurface.d.ts +26 -0
- package/dist/components/Popover/PopoverSurface.d.ts.map +1 -0
- package/dist/components/Popover/PopoverSurface.js +227 -0
- package/dist/components/Popover/PopoverSurface.js.map +1 -0
- package/dist/components/Popover/PopoverTitle.cjs +23 -0
- package/dist/components/Popover/PopoverTitle.d.cts +15 -0
- package/dist/components/Popover/PopoverTitle.d.cts.map +1 -0
- package/dist/components/Popover/PopoverTitle.d.ts +15 -0
- package/dist/components/Popover/PopoverTitle.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTitle.js +23 -0
- package/dist/components/Popover/PopoverTitle.js.map +1 -0
- package/dist/components/Popover/PopoverTrigger.cjs +88 -0
- package/dist/components/Popover/PopoverTrigger.d.cts +15 -0
- package/dist/components/Popover/PopoverTrigger.d.cts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.d.ts +15 -0
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.js +88 -0
- package/dist/components/Popover/PopoverTrigger.js.map +1 -0
- package/dist/components/Popover/index.cjs +14 -0
- package/dist/components/Popover/index.d.cts +9 -0
- package/dist/components/Popover/index.d.ts +9 -0
- package/dist/components/Popover/index.js +8 -0
- package/dist/components/Popover/popoverFrameGeometry.cjs +177 -0
- package/dist/components/Popover/popoverFrameGeometry.d.cts +48 -0
- package/dist/components/Popover/popoverFrameGeometry.d.cts.map +1 -0
- package/dist/components/Popover/popoverFrameGeometry.d.ts +48 -0
- package/dist/components/Popover/popoverFrameGeometry.d.ts.map +1 -0
- package/dist/components/Popover/popoverFrameGeometry.js +177 -0
- package/dist/components/Popover/popoverFrameGeometry.js.map +1 -0
- package/dist/components/Popover/popoverLayer.cjs +16 -0
- package/dist/components/Popover/popoverLayer.d.cts +8 -0
- package/dist/components/Popover/popoverLayer.d.cts.map +1 -0
- package/dist/components/Popover/popoverLayer.d.ts +8 -0
- package/dist/components/Popover/popoverLayer.d.ts.map +1 -0
- package/dist/components/Popover/popoverLayer.js +16 -0
- package/dist/components/Popover/popoverLayer.js.map +1 -0
- package/dist/components/Popover/types.cjs +1 -0
- package/dist/components/Popover/types.d.cts +170 -0
- package/dist/components/Popover/types.d.cts.map +1 -0
- package/dist/components/Popover/types.d.ts +170 -0
- package/dist/components/Popover/types.d.ts.map +1 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Toast/ToastProvider.cjs +1 -1
- package/dist/components/Toast/ToastProvider.js +1 -1
- package/dist/components/internal/Overlay/index.cjs +4 -0
- package/dist/components/internal/Overlay/index.d.cts +4 -2
- package/dist/components/internal/Overlay/index.d.ts +4 -2
- package/dist/components/internal/Overlay/index.js +3 -1
- package/dist/components/internal/Overlay/types.d.cts +47 -1
- package/dist/components/internal/Overlay/types.d.cts.map +1 -1
- package/dist/components/internal/Overlay/types.d.ts +47 -1
- package/dist/components/internal/Overlay/types.d.ts.map +1 -1
- package/dist/components/internal/Overlay/useAnchoredPosition.cjs +225 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.cts +22 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.cts.map +1 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.ts +22 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.d.ts.map +1 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.js +225 -0
- package/dist/components/internal/Overlay/useAnchoredPosition.js.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.cjs +22 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.cts +12 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.cts.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.ts +12 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.d.ts.map +1 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.js +22 -0
- package/dist/components/internal/Overlay/useOverlayDismiss.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +14 -0
- package/dist/jest/mocks/react-native.d.cts +29 -1
- package/dist/jest/mocks/react-native.d.cts.map +1 -1
- package/dist/jest/mocks/react-native.d.ts +29 -1
- package/dist/jest/mocks/react-native.d.ts.map +1 -1
- package/dist/jest/mocks/react-native.js +13 -1
- package/dist/jest/mocks/react-native.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +60 -0
- package/dist/jest/mocks/styles.d.cts +5 -2
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts +5 -2
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +58 -1
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/setup.cjs +46 -3
- package/dist/jest/setup.d.cts.map +1 -1
- package/dist/jest/setup.d.ts.map +1 -1
- package/dist/jest/setup.js +46 -3
- package/dist/jest/setup.js.map +1 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/generated/styles.cjs +6 -0
- package/generated/styles.d.ts +13 -1
- package/generated/styles.mjs +6 -0
- package/generated/unistyles.d.ts +13 -0
- package/package.json +11 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_components_internal_Overlay_OverlayPortal = require("./OverlayPortal.cjs");
|
|
4
|
+
const require_components_internal_Overlay_useAnchoredPosition = require("./useAnchoredPosition.cjs");
|
|
4
5
|
const require_components_internal_Overlay_useControllableState = require("./useControllableState.cjs");
|
|
6
|
+
const require_components_internal_Overlay_useOverlayDismiss = require("./useOverlayDismiss.cjs");
|
|
5
7
|
exports.OverlayPortal = require_components_internal_Overlay_OverlayPortal.OverlayPortal;
|
|
8
|
+
exports.useAnchoredPosition = require_components_internal_Overlay_useAnchoredPosition.useAnchoredPosition;
|
|
6
9
|
exports.useControllableState = require_components_internal_Overlay_useControllableState.useControllableState;
|
|
10
|
+
exports.useOverlayDismiss = require_components_internal_Overlay_useOverlayDismiss.useOverlayDismiss;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import { OverlayPortalProps, UseControllableStateProps, UseControllableStateResult } from "./types.cjs";
|
|
2
|
+
import { AnchoredAlign, AnchoredPlacement, AnchoredRect, AnchoredWidth, OverlayInsets, OverlayPortalProps, UseAnchoredPositionProps, UseAnchoredPositionResult, UseControllableStateProps, UseControllableStateResult, UseOverlayDismissProps } from "./types.cjs";
|
|
3
3
|
import { OverlayPortal } from "./OverlayPortal.cjs";
|
|
4
|
+
import { useAnchoredPosition } from "./useAnchoredPosition.cjs";
|
|
4
5
|
import { useControllableState } from "./useControllableState.cjs";
|
|
5
|
-
|
|
6
|
+
import { useOverlayDismiss } from "./useOverlayDismiss.cjs";
|
|
7
|
+
export { type AnchoredAlign, type AnchoredPlacement, type AnchoredRect, type AnchoredWidth, type OverlayInsets, OverlayPortal, type OverlayPortalProps, type UseAnchoredPositionProps, type UseAnchoredPositionResult, type UseControllableStateProps, type UseControllableStateResult, type UseOverlayDismissProps, useAnchoredPosition, useControllableState, useOverlayDismiss };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import { OverlayPortalProps, UseControllableStateProps, UseControllableStateResult } from "./types.js";
|
|
2
|
+
import { AnchoredAlign, AnchoredPlacement, AnchoredRect, AnchoredWidth, OverlayInsets, OverlayPortalProps, UseAnchoredPositionProps, UseAnchoredPositionResult, UseControllableStateProps, UseControllableStateResult, UseOverlayDismissProps } from "./types.js";
|
|
3
3
|
import { OverlayPortal } from "./OverlayPortal.js";
|
|
4
|
+
import { useAnchoredPosition } from "./useAnchoredPosition.js";
|
|
4
5
|
import { useControllableState } from "./useControllableState.js";
|
|
5
|
-
|
|
6
|
+
import { useOverlayDismiss } from "./useOverlayDismiss.js";
|
|
7
|
+
export { type AnchoredAlign, type AnchoredPlacement, type AnchoredRect, type AnchoredWidth, type OverlayInsets, OverlayPortal, type OverlayPortalProps, type UseAnchoredPositionProps, type UseAnchoredPositionResult, type UseControllableStateProps, type UseControllableStateResult, type UseOverlayDismissProps, useAnchoredPosition, useControllableState, useOverlayDismiss };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { OverlayPortal } from "./OverlayPortal.js";
|
|
3
|
+
import { useAnchoredPosition } from "./useAnchoredPosition.js";
|
|
3
4
|
import { useControllableState } from "./useControllableState.js";
|
|
4
|
-
|
|
5
|
+
import { useOverlayDismiss } from "./useOverlayDismiss.js";
|
|
6
|
+
export { OverlayPortal, useAnchoredPosition, useControllableState, useOverlayDismiss };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
3
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
4
|
|
|
4
5
|
//#region src/components/internal/Overlay/types.d.ts
|
|
5
6
|
interface OverlayPortalProps {
|
|
@@ -16,6 +17,51 @@ interface UseControllableStateProps<T> {
|
|
|
16
17
|
onChange?: (value: T) => void;
|
|
17
18
|
}
|
|
18
19
|
type UseControllableStateResult<T> = [T, Dispatch<SetStateAction<T>>];
|
|
20
|
+
type AnchoredPlacement = 'top' | 'bottom' | 'start' | 'end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'start-top' | 'start-bottom' | 'end-top' | 'end-bottom';
|
|
21
|
+
type AnchoredAlign = 'start' | 'center' | 'end';
|
|
22
|
+
type AnchoredWidth = 'content' | 'trigger' | 'full' | number;
|
|
23
|
+
interface AnchoredRect {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
interface OverlayInsets {
|
|
30
|
+
top?: number;
|
|
31
|
+
right?: number;
|
|
32
|
+
bottom?: number;
|
|
33
|
+
left?: number;
|
|
34
|
+
}
|
|
35
|
+
interface UseAnchoredPositionProps {
|
|
36
|
+
triggerRect: AnchoredRect | null;
|
|
37
|
+
contentSize: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
placement?: AnchoredPlacement;
|
|
42
|
+
align?: AnchoredAlign;
|
|
43
|
+
offset?: number;
|
|
44
|
+
alignOffset?: number;
|
|
45
|
+
avoidCollisions?: boolean;
|
|
46
|
+
collisionPadding?: number;
|
|
47
|
+
width?: AnchoredWidth;
|
|
48
|
+
sameWidth?: boolean;
|
|
49
|
+
insets?: OverlayInsets;
|
|
50
|
+
arrowWidth?: number;
|
|
51
|
+
arrowHeight?: number;
|
|
52
|
+
}
|
|
53
|
+
interface UseAnchoredPositionResult {
|
|
54
|
+
resolvedPlacement: AnchoredPlacement;
|
|
55
|
+
contentStyle: StyleProp<ViewStyle>;
|
|
56
|
+
arrowStyle: StyleProp<ViewStyle>;
|
|
57
|
+
anchorReady: boolean;
|
|
58
|
+
maxWidth: number;
|
|
59
|
+
}
|
|
60
|
+
interface UseOverlayDismissProps {
|
|
61
|
+
open: boolean;
|
|
62
|
+
dismissible?: boolean;
|
|
63
|
+
onDismiss: () => void;
|
|
64
|
+
}
|
|
19
65
|
//#endregion
|
|
20
|
-
export { type OverlayPortalProps, type UseControllableStateProps, type UseControllableStateResult };
|
|
66
|
+
export { type AnchoredAlign, type AnchoredPlacement, type AnchoredRect, type AnchoredWidth, type OverlayInsets, type OverlayPortalProps, type UseAnchoredPositionProps, type UseAnchoredPositionResult, type UseControllableStateProps, type UseControllableStateResult, type UseOverlayDismissProps };
|
|
21
67
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../../src/components/internal/Overlay/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../../src/components/internal/Overlay/types.ts"],"mappings":";;;;;UAGU,kBAAA;EACR,QAAA,EAAU,SAAA;EADF;;;;EAMR,oBAAA;AAAA;AAAA,UAGQ,yBAAA;EACR,KAAA,GAAQ,CAAA;EACR,YAAA,EAAc,CAAA,UAAW,CAAA;EACzB,QAAA,IAAY,KAAA,EAAO,CAAA;AAAA;AAAA,KAGhB,0BAAA,OAAiC,CAAA,EAAG,QAAA,CAAS,cAAA,CAAe,CAAA;AAAA,KAE5D,iBAAA;AAAA,KAcA,aAAA;AAAA,KAEA,aAAA;AAAA,UAEK,YAAA;EACR,CAAA;EACA,CAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,UAGQ,aAAA;EACR,GAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,UAGQ,wBAAA;EACR,WAAA,EAAa,YAAA;EACb,WAAA;IAAe,KAAA;IAAe,MAAA;EAAA;EAC9B,SAAA,GAAY,iBAAA;EACZ,KAAA,GAAQ,aAAA;EACR,MAAA;EACA,WAAA;EACA,eAAA;EACA,gBAAA;EACA,KAAA,GAAQ,aAAA;EACR,SAAA;EACA,MAAA,GAAS,aAAA;EACT,UAAA;EACA,WAAA;AAAA;AAAA,UAGQ,yBAAA;EACR,iBAAA,EAAmB,iBAAA;EACnB,YAAA,EAAc,SAAA,CAAU,SAAA;EACxB,UAAA,EAAY,SAAA,CAAU,SAAA;EACtB,WAAA;EACA,QAAA;AAAA;AAAA,UAGQ,sBAAA;EACR,IAAA;EACA,WAAA;EACA,SAAA;AAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
3
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
4
|
|
|
4
5
|
//#region src/components/internal/Overlay/types.d.ts
|
|
5
6
|
interface OverlayPortalProps {
|
|
@@ -16,6 +17,51 @@ interface UseControllableStateProps<T> {
|
|
|
16
17
|
onChange?: (value: T) => void;
|
|
17
18
|
}
|
|
18
19
|
type UseControllableStateResult<T> = [T, Dispatch<SetStateAction<T>>];
|
|
20
|
+
type AnchoredPlacement = 'top' | 'bottom' | 'start' | 'end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'start-top' | 'start-bottom' | 'end-top' | 'end-bottom';
|
|
21
|
+
type AnchoredAlign = 'start' | 'center' | 'end';
|
|
22
|
+
type AnchoredWidth = 'content' | 'trigger' | 'full' | number;
|
|
23
|
+
interface AnchoredRect {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
interface OverlayInsets {
|
|
30
|
+
top?: number;
|
|
31
|
+
right?: number;
|
|
32
|
+
bottom?: number;
|
|
33
|
+
left?: number;
|
|
34
|
+
}
|
|
35
|
+
interface UseAnchoredPositionProps {
|
|
36
|
+
triggerRect: AnchoredRect | null;
|
|
37
|
+
contentSize: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
placement?: AnchoredPlacement;
|
|
42
|
+
align?: AnchoredAlign;
|
|
43
|
+
offset?: number;
|
|
44
|
+
alignOffset?: number;
|
|
45
|
+
avoidCollisions?: boolean;
|
|
46
|
+
collisionPadding?: number;
|
|
47
|
+
width?: AnchoredWidth;
|
|
48
|
+
sameWidth?: boolean;
|
|
49
|
+
insets?: OverlayInsets;
|
|
50
|
+
arrowWidth?: number;
|
|
51
|
+
arrowHeight?: number;
|
|
52
|
+
}
|
|
53
|
+
interface UseAnchoredPositionResult {
|
|
54
|
+
resolvedPlacement: AnchoredPlacement;
|
|
55
|
+
contentStyle: StyleProp<ViewStyle>;
|
|
56
|
+
arrowStyle: StyleProp<ViewStyle>;
|
|
57
|
+
anchorReady: boolean;
|
|
58
|
+
maxWidth: number;
|
|
59
|
+
}
|
|
60
|
+
interface UseOverlayDismissProps {
|
|
61
|
+
open: boolean;
|
|
62
|
+
dismissible?: boolean;
|
|
63
|
+
onDismiss: () => void;
|
|
64
|
+
}
|
|
19
65
|
//#endregion
|
|
20
|
-
export { type OverlayPortalProps, type UseControllableStateProps, type UseControllableStateResult };
|
|
66
|
+
export { type AnchoredAlign, type AnchoredPlacement, type AnchoredRect, type AnchoredWidth, type OverlayInsets, type OverlayPortalProps, type UseAnchoredPositionProps, type UseAnchoredPositionResult, type UseControllableStateProps, type UseControllableStateResult, type UseOverlayDismissProps };
|
|
21
67
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/components/internal/Overlay/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/components/internal/Overlay/types.ts"],"mappings":";;;;;UAGU,kBAAA;EACR,QAAA,EAAU,SAAA;EADF;;;;EAMR,oBAAA;AAAA;AAAA,UAGQ,yBAAA;EACR,KAAA,GAAQ,CAAA;EACR,YAAA,EAAc,CAAA,UAAW,CAAA;EACzB,QAAA,IAAY,KAAA,EAAO,CAAA;AAAA;AAAA,KAGhB,0BAAA,OAAiC,CAAA,EAAG,QAAA,CAAS,cAAA,CAAe,CAAA;AAAA,KAE5D,iBAAA;AAAA,KAcA,aAAA;AAAA,KAEA,aAAA;AAAA,UAEK,YAAA;EACR,CAAA;EACA,CAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,UAGQ,aAAA;EACR,GAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,UAGQ,wBAAA;EACR,WAAA,EAAa,YAAA;EACb,WAAA;IAAe,KAAA;IAAe,MAAA;EAAA;EAC9B,SAAA,GAAY,iBAAA;EACZ,KAAA,GAAQ,aAAA;EACR,MAAA;EACA,WAAA;EACA,eAAA;EACA,gBAAA;EACA,KAAA,GAAQ,aAAA;EACR,SAAA;EACA,MAAA,GAAS,aAAA;EACT,UAAA;EACA,WAAA;AAAA;AAAA,UAGQ,yBAAA;EACR,iBAAA,EAAmB,iBAAA;EACnB,YAAA,EAAc,SAAA,CAAU,SAAA;EACxB,UAAA,EAAY,SAAA,CAAU,SAAA;EACtB,WAAA;EACA,QAAA;AAAA;AAAA,UAGQ,sBAAA;EACR,IAAA;EACA,WAAA;EACA,SAAA;AAAA"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_native = require("react-native");
|
|
6
|
+
let react_native_safe_area_context = require("react-native-safe-area-context");
|
|
7
|
+
//#region src/components/internal/Overlay/useAnchoredPosition.ts
|
|
8
|
+
const DEFAULT_COLLISION_PADDING = 12;
|
|
9
|
+
const DEFAULT_OFFSET = 9;
|
|
10
|
+
const DEFAULT_ARROW_WIDTH = 22;
|
|
11
|
+
const DEFAULT_ARROW_HEIGHT = 12;
|
|
12
|
+
const DEFAULT_ARROW_BASELINE_INSET = 1;
|
|
13
|
+
function clamp(value, min, max) {
|
|
14
|
+
if (max < min) return min;
|
|
15
|
+
return Math.min(Math.max(value, min), max);
|
|
16
|
+
}
|
|
17
|
+
function resolveLogicalSide(side) {
|
|
18
|
+
return {
|
|
19
|
+
top: "top",
|
|
20
|
+
bottom: "bottom",
|
|
21
|
+
start: react_native.I18nManager.isRTL ? "right" : "left",
|
|
22
|
+
end: react_native.I18nManager.isRTL ? "left" : "right"
|
|
23
|
+
}[side];
|
|
24
|
+
}
|
|
25
|
+
function getOppositeSide(side) {
|
|
26
|
+
switch (side) {
|
|
27
|
+
case "top": return "bottom";
|
|
28
|
+
case "bottom": return "top";
|
|
29
|
+
case "left": return "right";
|
|
30
|
+
case "right": return "left";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function formatPlacement(side, align) {
|
|
34
|
+
const logicalSide = {
|
|
35
|
+
top: "top",
|
|
36
|
+
bottom: "bottom",
|
|
37
|
+
left: react_native.I18nManager.isRTL ? "end" : "start",
|
|
38
|
+
right: react_native.I18nManager.isRTL ? "start" : "end"
|
|
39
|
+
}[side];
|
|
40
|
+
if (align === "center") return logicalSide;
|
|
41
|
+
if (side === "top" || side === "bottom") return `${logicalSide}-${align}`;
|
|
42
|
+
return `${logicalSide}-${align === "start" ? "top" : "bottom"}`;
|
|
43
|
+
}
|
|
44
|
+
function parsePlacement(placement, alignOverride) {
|
|
45
|
+
const [rawSide, rawAlign] = placement.split("-");
|
|
46
|
+
const side = resolveLogicalSide(rawSide);
|
|
47
|
+
if (alignOverride) return {
|
|
48
|
+
side,
|
|
49
|
+
align: alignOverride
|
|
50
|
+
};
|
|
51
|
+
if (!rawAlign) return {
|
|
52
|
+
side,
|
|
53
|
+
align: "center"
|
|
54
|
+
};
|
|
55
|
+
if (rawAlign === "top") return {
|
|
56
|
+
side,
|
|
57
|
+
align: "start"
|
|
58
|
+
};
|
|
59
|
+
if (rawAlign === "bottom") return {
|
|
60
|
+
side,
|
|
61
|
+
align: "end"
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
side,
|
|
65
|
+
align: rawAlign
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function getContentSize(triggerRect, contentSize, maxWidth, sameWidth, width) {
|
|
69
|
+
const resolvedWidth = sameWidth || width === "trigger" ? triggerRect.width : width === "full" ? maxWidth : typeof width === "number" ? width : contentSize.width || triggerRect.width;
|
|
70
|
+
return {
|
|
71
|
+
width: Math.min(resolvedWidth, maxWidth),
|
|
72
|
+
height: contentSize.height
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getCoordinate({ align, alignOffset, contentLength, triggerLength, triggerStart }) {
|
|
76
|
+
if (align === "start") return triggerStart + alignOffset;
|
|
77
|
+
if (align === "end") return triggerStart + triggerLength - contentLength + alignOffset;
|
|
78
|
+
return triggerStart + triggerLength / 2 - contentLength / 2 + alignOffset;
|
|
79
|
+
}
|
|
80
|
+
function getRawPosition({ align, alignOffset, contentHeight, contentWidth, offset, side, triggerRect }) {
|
|
81
|
+
if (side === "top" || side === "bottom") return {
|
|
82
|
+
left: getCoordinate({
|
|
83
|
+
align,
|
|
84
|
+
alignOffset,
|
|
85
|
+
contentLength: contentWidth,
|
|
86
|
+
triggerLength: triggerRect.width,
|
|
87
|
+
triggerStart: triggerRect.x
|
|
88
|
+
}),
|
|
89
|
+
top: side === "top" ? triggerRect.y - contentHeight - offset : triggerRect.y + triggerRect.height + offset
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
left: side === "left" ? triggerRect.x - contentWidth - offset : triggerRect.x + triggerRect.width + offset,
|
|
93
|
+
top: getCoordinate({
|
|
94
|
+
align,
|
|
95
|
+
alignOffset,
|
|
96
|
+
contentLength: contentHeight,
|
|
97
|
+
triggerLength: triggerRect.height,
|
|
98
|
+
triggerStart: triggerRect.y
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function shouldFlip({ contentHeight, contentWidth, maxBottom, maxRight, minLeft, minTop, side, triggerRect, windowHeight, windowWidth }) {
|
|
103
|
+
if (side === "top") return triggerRect.y - contentHeight < minTop && windowHeight - (triggerRect.y + triggerRect.height) > triggerRect.y;
|
|
104
|
+
if (side === "bottom") return triggerRect.y + triggerRect.height + contentHeight > maxBottom && triggerRect.y > windowHeight - (triggerRect.y + triggerRect.height);
|
|
105
|
+
if (side === "left") return triggerRect.x - contentWidth < minLeft && windowWidth - (triggerRect.x + triggerRect.width) > triggerRect.x;
|
|
106
|
+
return triggerRect.x + triggerRect.width + contentWidth > maxRight && triggerRect.x > windowWidth - (triggerRect.x + triggerRect.width);
|
|
107
|
+
}
|
|
108
|
+
function getArrowPosition({ arrowHeight, arrowWidth, contentHeight, contentLeft, contentTop, contentWidth, side, triggerRect }) {
|
|
109
|
+
const arrowBase = {
|
|
110
|
+
position: "absolute",
|
|
111
|
+
zIndex: 2
|
|
112
|
+
};
|
|
113
|
+
if (side === "top" || side === "bottom") {
|
|
114
|
+
const left = clamp(triggerRect.x + triggerRect.width / 2 - contentLeft - arrowWidth / 2, arrowHeight, contentWidth - arrowWidth - arrowHeight);
|
|
115
|
+
return {
|
|
116
|
+
...arrowBase,
|
|
117
|
+
width: arrowWidth,
|
|
118
|
+
height: arrowHeight,
|
|
119
|
+
left,
|
|
120
|
+
...side === "top" ? { bottom: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET } : { top: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET }
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const top = clamp(triggerRect.y + triggerRect.height / 2 - contentTop - arrowWidth / 2, arrowHeight, contentHeight - arrowWidth - arrowHeight);
|
|
124
|
+
return {
|
|
125
|
+
...arrowBase,
|
|
126
|
+
width: arrowHeight,
|
|
127
|
+
height: arrowWidth,
|
|
128
|
+
top,
|
|
129
|
+
...side === "left" ? { right: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET } : { left: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET }
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function useAnchoredPosition({ triggerRect, contentSize, placement = "bottom", align, offset = DEFAULT_OFFSET, alignOffset = 0, avoidCollisions = true, collisionPadding = DEFAULT_COLLISION_PADDING, width = "content", sameWidth = false, insets, arrowWidth, arrowHeight }) {
|
|
133
|
+
const windowDimensions = (0, react_native.useWindowDimensions)();
|
|
134
|
+
const safeAreaInsets = (0, react_native_safe_area_context.useSafeAreaInsets)();
|
|
135
|
+
const resolvedArrowWidth = arrowWidth ?? DEFAULT_ARROW_WIDTH;
|
|
136
|
+
const resolvedArrowHeight = arrowHeight ?? DEFAULT_ARROW_HEIGHT;
|
|
137
|
+
return (0, react.useMemo)(() => {
|
|
138
|
+
const fallbackPlacement = placement;
|
|
139
|
+
const maxWidth = windowDimensions.width - (insets?.left ?? safeAreaInsets.left) - (insets?.right ?? safeAreaInsets.right) - collisionPadding * 2;
|
|
140
|
+
if (!triggerRect) return {
|
|
141
|
+
resolvedPlacement: fallbackPlacement,
|
|
142
|
+
contentStyle: {
|
|
143
|
+
position: "absolute",
|
|
144
|
+
left: collisionPadding,
|
|
145
|
+
top: (insets?.top ?? safeAreaInsets.top) + collisionPadding,
|
|
146
|
+
maxWidth,
|
|
147
|
+
opacity: 0
|
|
148
|
+
},
|
|
149
|
+
arrowStyle: { opacity: 0 },
|
|
150
|
+
anchorReady: false,
|
|
151
|
+
maxWidth
|
|
152
|
+
};
|
|
153
|
+
const minLeft = (insets?.left ?? safeAreaInsets.left) + collisionPadding;
|
|
154
|
+
const minTop = (insets?.top ?? safeAreaInsets.top) + collisionPadding;
|
|
155
|
+
const maxRight = windowDimensions.width - (insets?.right ?? safeAreaInsets.right) - collisionPadding;
|
|
156
|
+
const maxBottom = windowDimensions.height - (insets?.bottom ?? safeAreaInsets.bottom) - collisionPadding;
|
|
157
|
+
const { width: contentWidth, height: contentHeight } = getContentSize(triggerRect, contentSize, maxWidth, sameWidth, width);
|
|
158
|
+
const placementParts = parsePlacement(placement, align);
|
|
159
|
+
let { side } = placementParts;
|
|
160
|
+
const resolvedAlign = placementParts.align;
|
|
161
|
+
if (avoidCollisions && shouldFlip({
|
|
162
|
+
contentHeight,
|
|
163
|
+
contentWidth,
|
|
164
|
+
maxBottom,
|
|
165
|
+
maxRight,
|
|
166
|
+
minLeft,
|
|
167
|
+
minTop,
|
|
168
|
+
side,
|
|
169
|
+
triggerRect,
|
|
170
|
+
windowHeight: windowDimensions.height,
|
|
171
|
+
windowWidth: windowDimensions.width
|
|
172
|
+
})) side = getOppositeSide(side);
|
|
173
|
+
const rawPosition = getRawPosition({
|
|
174
|
+
align: resolvedAlign,
|
|
175
|
+
alignOffset,
|
|
176
|
+
contentHeight,
|
|
177
|
+
contentWidth,
|
|
178
|
+
offset,
|
|
179
|
+
side,
|
|
180
|
+
triggerRect
|
|
181
|
+
});
|
|
182
|
+
const left = clamp(rawPosition.left, minLeft, maxRight - contentWidth);
|
|
183
|
+
const top = clamp(rawPosition.top, minTop, maxBottom - contentHeight);
|
|
184
|
+
return {
|
|
185
|
+
resolvedPlacement: formatPlacement(side, resolvedAlign),
|
|
186
|
+
contentStyle: {
|
|
187
|
+
position: "absolute",
|
|
188
|
+
left,
|
|
189
|
+
top,
|
|
190
|
+
width: sameWidth || width !== "content" ? contentWidth : void 0,
|
|
191
|
+
maxWidth
|
|
192
|
+
},
|
|
193
|
+
arrowStyle: getArrowPosition({
|
|
194
|
+
arrowHeight: resolvedArrowHeight,
|
|
195
|
+
arrowWidth: resolvedArrowWidth,
|
|
196
|
+
contentHeight,
|
|
197
|
+
contentLeft: left,
|
|
198
|
+
contentTop: top,
|
|
199
|
+
contentWidth,
|
|
200
|
+
side,
|
|
201
|
+
triggerRect
|
|
202
|
+
}),
|
|
203
|
+
anchorReady: true,
|
|
204
|
+
maxWidth
|
|
205
|
+
};
|
|
206
|
+
}, [
|
|
207
|
+
align,
|
|
208
|
+
alignOffset,
|
|
209
|
+
avoidCollisions,
|
|
210
|
+
collisionPadding,
|
|
211
|
+
contentSize,
|
|
212
|
+
insets,
|
|
213
|
+
offset,
|
|
214
|
+
placement,
|
|
215
|
+
resolvedArrowHeight,
|
|
216
|
+
resolvedArrowWidth,
|
|
217
|
+
safeAreaInsets,
|
|
218
|
+
sameWidth,
|
|
219
|
+
triggerRect,
|
|
220
|
+
width,
|
|
221
|
+
windowDimensions
|
|
222
|
+
]);
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
exports.useAnchoredPosition = useAnchoredPosition;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { UseAnchoredPositionProps, UseAnchoredPositionResult } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/components/internal/Overlay/useAnchoredPosition.d.ts
|
|
5
|
+
declare function useAnchoredPosition({
|
|
6
|
+
triggerRect,
|
|
7
|
+
contentSize,
|
|
8
|
+
placement,
|
|
9
|
+
align,
|
|
10
|
+
offset,
|
|
11
|
+
alignOffset,
|
|
12
|
+
avoidCollisions,
|
|
13
|
+
collisionPadding,
|
|
14
|
+
width,
|
|
15
|
+
sameWidth,
|
|
16
|
+
insets,
|
|
17
|
+
arrowWidth,
|
|
18
|
+
arrowHeight
|
|
19
|
+
}: UseAnchoredPositionProps): UseAnchoredPositionResult;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useAnchoredPosition };
|
|
22
|
+
//# sourceMappingURL=useAnchoredPosition.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnchoredPosition.d.cts","names":[],"sources":["../../../../src/components/internal/Overlay/useAnchoredPosition.ts"],"mappings":";;;;iBAsTS,mBAAA,CAAA;EACP,WAAA;EACA,WAAA;EACA,SAAA;EACA,KAAA;EACA,MAAA;EACA,WAAA;EACA,eAAA;EACA,gBAAA;EACA,KAAA;EACA,SAAA;EACA,MAAA;EACA,UAAA;EACA;AAAA,GACC,wBAAA,GAA2B,yBAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { UseAnchoredPositionProps, UseAnchoredPositionResult } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/internal/Overlay/useAnchoredPosition.d.ts
|
|
5
|
+
declare function useAnchoredPosition({
|
|
6
|
+
triggerRect,
|
|
7
|
+
contentSize,
|
|
8
|
+
placement,
|
|
9
|
+
align,
|
|
10
|
+
offset,
|
|
11
|
+
alignOffset,
|
|
12
|
+
avoidCollisions,
|
|
13
|
+
collisionPadding,
|
|
14
|
+
width,
|
|
15
|
+
sameWidth,
|
|
16
|
+
insets,
|
|
17
|
+
arrowWidth,
|
|
18
|
+
arrowHeight
|
|
19
|
+
}: UseAnchoredPositionProps): UseAnchoredPositionResult;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useAnchoredPosition };
|
|
22
|
+
//# sourceMappingURL=useAnchoredPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnchoredPosition.d.ts","names":[],"sources":["../../../../src/components/internal/Overlay/useAnchoredPosition.ts"],"mappings":";;;;iBAsTS,mBAAA,CAAA;EACP,WAAA;EACA,WAAA;EACA,SAAA;EACA,KAAA;EACA,MAAA;EACA,WAAA;EACA,eAAA;EACA,gBAAA;EACA,KAAA;EACA,SAAA;EACA,MAAA;EACA,UAAA;EACA;AAAA,GACC,wBAAA,GAA2B,yBAAA"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { I18nManager, useWindowDimensions } from "react-native";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
//#region src/components/internal/Overlay/useAnchoredPosition.ts
|
|
6
|
+
const DEFAULT_COLLISION_PADDING = 12;
|
|
7
|
+
const DEFAULT_OFFSET = 9;
|
|
8
|
+
const DEFAULT_ARROW_WIDTH = 22;
|
|
9
|
+
const DEFAULT_ARROW_HEIGHT = 12;
|
|
10
|
+
const DEFAULT_ARROW_BASELINE_INSET = 1;
|
|
11
|
+
function clamp(value, min, max) {
|
|
12
|
+
if (max < min) return min;
|
|
13
|
+
return Math.min(Math.max(value, min), max);
|
|
14
|
+
}
|
|
15
|
+
function resolveLogicalSide(side) {
|
|
16
|
+
return {
|
|
17
|
+
top: "top",
|
|
18
|
+
bottom: "bottom",
|
|
19
|
+
start: I18nManager.isRTL ? "right" : "left",
|
|
20
|
+
end: I18nManager.isRTL ? "left" : "right"
|
|
21
|
+
}[side];
|
|
22
|
+
}
|
|
23
|
+
function getOppositeSide(side) {
|
|
24
|
+
switch (side) {
|
|
25
|
+
case "top": return "bottom";
|
|
26
|
+
case "bottom": return "top";
|
|
27
|
+
case "left": return "right";
|
|
28
|
+
case "right": return "left";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function formatPlacement(side, align) {
|
|
32
|
+
const logicalSide = {
|
|
33
|
+
top: "top",
|
|
34
|
+
bottom: "bottom",
|
|
35
|
+
left: I18nManager.isRTL ? "end" : "start",
|
|
36
|
+
right: I18nManager.isRTL ? "start" : "end"
|
|
37
|
+
}[side];
|
|
38
|
+
if (align === "center") return logicalSide;
|
|
39
|
+
if (side === "top" || side === "bottom") return `${logicalSide}-${align}`;
|
|
40
|
+
return `${logicalSide}-${align === "start" ? "top" : "bottom"}`;
|
|
41
|
+
}
|
|
42
|
+
function parsePlacement(placement, alignOverride) {
|
|
43
|
+
const [rawSide, rawAlign] = placement.split("-");
|
|
44
|
+
const side = resolveLogicalSide(rawSide);
|
|
45
|
+
if (alignOverride) return {
|
|
46
|
+
side,
|
|
47
|
+
align: alignOverride
|
|
48
|
+
};
|
|
49
|
+
if (!rawAlign) return {
|
|
50
|
+
side,
|
|
51
|
+
align: "center"
|
|
52
|
+
};
|
|
53
|
+
if (rawAlign === "top") return {
|
|
54
|
+
side,
|
|
55
|
+
align: "start"
|
|
56
|
+
};
|
|
57
|
+
if (rawAlign === "bottom") return {
|
|
58
|
+
side,
|
|
59
|
+
align: "end"
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
side,
|
|
63
|
+
align: rawAlign
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getContentSize(triggerRect, contentSize, maxWidth, sameWidth, width) {
|
|
67
|
+
const resolvedWidth = sameWidth || width === "trigger" ? triggerRect.width : width === "full" ? maxWidth : typeof width === "number" ? width : contentSize.width || triggerRect.width;
|
|
68
|
+
return {
|
|
69
|
+
width: Math.min(resolvedWidth, maxWidth),
|
|
70
|
+
height: contentSize.height
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function getCoordinate({ align, alignOffset, contentLength, triggerLength, triggerStart }) {
|
|
74
|
+
if (align === "start") return triggerStart + alignOffset;
|
|
75
|
+
if (align === "end") return triggerStart + triggerLength - contentLength + alignOffset;
|
|
76
|
+
return triggerStart + triggerLength / 2 - contentLength / 2 + alignOffset;
|
|
77
|
+
}
|
|
78
|
+
function getRawPosition({ align, alignOffset, contentHeight, contentWidth, offset, side, triggerRect }) {
|
|
79
|
+
if (side === "top" || side === "bottom") return {
|
|
80
|
+
left: getCoordinate({
|
|
81
|
+
align,
|
|
82
|
+
alignOffset,
|
|
83
|
+
contentLength: contentWidth,
|
|
84
|
+
triggerLength: triggerRect.width,
|
|
85
|
+
triggerStart: triggerRect.x
|
|
86
|
+
}),
|
|
87
|
+
top: side === "top" ? triggerRect.y - contentHeight - offset : triggerRect.y + triggerRect.height + offset
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
left: side === "left" ? triggerRect.x - contentWidth - offset : triggerRect.x + triggerRect.width + offset,
|
|
91
|
+
top: getCoordinate({
|
|
92
|
+
align,
|
|
93
|
+
alignOffset,
|
|
94
|
+
contentLength: contentHeight,
|
|
95
|
+
triggerLength: triggerRect.height,
|
|
96
|
+
triggerStart: triggerRect.y
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function shouldFlip({ contentHeight, contentWidth, maxBottom, maxRight, minLeft, minTop, side, triggerRect, windowHeight, windowWidth }) {
|
|
101
|
+
if (side === "top") return triggerRect.y - contentHeight < minTop && windowHeight - (triggerRect.y + triggerRect.height) > triggerRect.y;
|
|
102
|
+
if (side === "bottom") return triggerRect.y + triggerRect.height + contentHeight > maxBottom && triggerRect.y > windowHeight - (triggerRect.y + triggerRect.height);
|
|
103
|
+
if (side === "left") return triggerRect.x - contentWidth < minLeft && windowWidth - (triggerRect.x + triggerRect.width) > triggerRect.x;
|
|
104
|
+
return triggerRect.x + triggerRect.width + contentWidth > maxRight && triggerRect.x > windowWidth - (triggerRect.x + triggerRect.width);
|
|
105
|
+
}
|
|
106
|
+
function getArrowPosition({ arrowHeight, arrowWidth, contentHeight, contentLeft, contentTop, contentWidth, side, triggerRect }) {
|
|
107
|
+
const arrowBase = {
|
|
108
|
+
position: "absolute",
|
|
109
|
+
zIndex: 2
|
|
110
|
+
};
|
|
111
|
+
if (side === "top" || side === "bottom") {
|
|
112
|
+
const left = clamp(triggerRect.x + triggerRect.width / 2 - contentLeft - arrowWidth / 2, arrowHeight, contentWidth - arrowWidth - arrowHeight);
|
|
113
|
+
return {
|
|
114
|
+
...arrowBase,
|
|
115
|
+
width: arrowWidth,
|
|
116
|
+
height: arrowHeight,
|
|
117
|
+
left,
|
|
118
|
+
...side === "top" ? { bottom: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET } : { top: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET }
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const top = clamp(triggerRect.y + triggerRect.height / 2 - contentTop - arrowWidth / 2, arrowHeight, contentHeight - arrowWidth - arrowHeight);
|
|
122
|
+
return {
|
|
123
|
+
...arrowBase,
|
|
124
|
+
width: arrowHeight,
|
|
125
|
+
height: arrowWidth,
|
|
126
|
+
top,
|
|
127
|
+
...side === "left" ? { right: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET } : { left: -arrowHeight + DEFAULT_ARROW_BASELINE_INSET }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function useAnchoredPosition({ triggerRect, contentSize, placement = "bottom", align, offset = DEFAULT_OFFSET, alignOffset = 0, avoidCollisions = true, collisionPadding = DEFAULT_COLLISION_PADDING, width = "content", sameWidth = false, insets, arrowWidth, arrowHeight }) {
|
|
131
|
+
const windowDimensions = useWindowDimensions();
|
|
132
|
+
const safeAreaInsets = useSafeAreaInsets();
|
|
133
|
+
const resolvedArrowWidth = arrowWidth ?? DEFAULT_ARROW_WIDTH;
|
|
134
|
+
const resolvedArrowHeight = arrowHeight ?? DEFAULT_ARROW_HEIGHT;
|
|
135
|
+
return useMemo(() => {
|
|
136
|
+
const fallbackPlacement = placement;
|
|
137
|
+
const maxWidth = windowDimensions.width - (insets?.left ?? safeAreaInsets.left) - (insets?.right ?? safeAreaInsets.right) - collisionPadding * 2;
|
|
138
|
+
if (!triggerRect) return {
|
|
139
|
+
resolvedPlacement: fallbackPlacement,
|
|
140
|
+
contentStyle: {
|
|
141
|
+
position: "absolute",
|
|
142
|
+
left: collisionPadding,
|
|
143
|
+
top: (insets?.top ?? safeAreaInsets.top) + collisionPadding,
|
|
144
|
+
maxWidth,
|
|
145
|
+
opacity: 0
|
|
146
|
+
},
|
|
147
|
+
arrowStyle: { opacity: 0 },
|
|
148
|
+
anchorReady: false,
|
|
149
|
+
maxWidth
|
|
150
|
+
};
|
|
151
|
+
const minLeft = (insets?.left ?? safeAreaInsets.left) + collisionPadding;
|
|
152
|
+
const minTop = (insets?.top ?? safeAreaInsets.top) + collisionPadding;
|
|
153
|
+
const maxRight = windowDimensions.width - (insets?.right ?? safeAreaInsets.right) - collisionPadding;
|
|
154
|
+
const maxBottom = windowDimensions.height - (insets?.bottom ?? safeAreaInsets.bottom) - collisionPadding;
|
|
155
|
+
const { width: contentWidth, height: contentHeight } = getContentSize(triggerRect, contentSize, maxWidth, sameWidth, width);
|
|
156
|
+
const placementParts = parsePlacement(placement, align);
|
|
157
|
+
let { side } = placementParts;
|
|
158
|
+
const resolvedAlign = placementParts.align;
|
|
159
|
+
if (avoidCollisions && shouldFlip({
|
|
160
|
+
contentHeight,
|
|
161
|
+
contentWidth,
|
|
162
|
+
maxBottom,
|
|
163
|
+
maxRight,
|
|
164
|
+
minLeft,
|
|
165
|
+
minTop,
|
|
166
|
+
side,
|
|
167
|
+
triggerRect,
|
|
168
|
+
windowHeight: windowDimensions.height,
|
|
169
|
+
windowWidth: windowDimensions.width
|
|
170
|
+
})) side = getOppositeSide(side);
|
|
171
|
+
const rawPosition = getRawPosition({
|
|
172
|
+
align: resolvedAlign,
|
|
173
|
+
alignOffset,
|
|
174
|
+
contentHeight,
|
|
175
|
+
contentWidth,
|
|
176
|
+
offset,
|
|
177
|
+
side,
|
|
178
|
+
triggerRect
|
|
179
|
+
});
|
|
180
|
+
const left = clamp(rawPosition.left, minLeft, maxRight - contentWidth);
|
|
181
|
+
const top = clamp(rawPosition.top, minTop, maxBottom - contentHeight);
|
|
182
|
+
return {
|
|
183
|
+
resolvedPlacement: formatPlacement(side, resolvedAlign),
|
|
184
|
+
contentStyle: {
|
|
185
|
+
position: "absolute",
|
|
186
|
+
left,
|
|
187
|
+
top,
|
|
188
|
+
width: sameWidth || width !== "content" ? contentWidth : void 0,
|
|
189
|
+
maxWidth
|
|
190
|
+
},
|
|
191
|
+
arrowStyle: getArrowPosition({
|
|
192
|
+
arrowHeight: resolvedArrowHeight,
|
|
193
|
+
arrowWidth: resolvedArrowWidth,
|
|
194
|
+
contentHeight,
|
|
195
|
+
contentLeft: left,
|
|
196
|
+
contentTop: top,
|
|
197
|
+
contentWidth,
|
|
198
|
+
side,
|
|
199
|
+
triggerRect
|
|
200
|
+
}),
|
|
201
|
+
anchorReady: true,
|
|
202
|
+
maxWidth
|
|
203
|
+
};
|
|
204
|
+
}, [
|
|
205
|
+
align,
|
|
206
|
+
alignOffset,
|
|
207
|
+
avoidCollisions,
|
|
208
|
+
collisionPadding,
|
|
209
|
+
contentSize,
|
|
210
|
+
insets,
|
|
211
|
+
offset,
|
|
212
|
+
placement,
|
|
213
|
+
resolvedArrowHeight,
|
|
214
|
+
resolvedArrowWidth,
|
|
215
|
+
safeAreaInsets,
|
|
216
|
+
sameWidth,
|
|
217
|
+
triggerRect,
|
|
218
|
+
width,
|
|
219
|
+
windowDimensions
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { useAnchoredPosition };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=useAnchoredPosition.js.map
|