@yahoo/uds 3.114.0-beta.3 → 3.115.0-beta.1
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/automated-config/dist/generated/autoVariants.cjs +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.js +3 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1883 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1882 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +84 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +84 -0
- package/dist/automated-config/dist/properties.cjs +57 -11
- package/dist/automated-config/dist/properties.d.cts +8 -0
- package/dist/automated-config/dist/properties.d.ts +8 -0
- package/dist/automated-config/dist/properties.js +57 -11
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/cli/commands/sync.cjs +4 -0
- package/dist/cli/commands/sync.js +4 -0
- package/dist/components/Scrim.cjs +28 -0
- package/dist/components/Scrim.d.cts +14 -0
- package/dist/components/Scrim.d.ts +14 -0
- package/dist/components/Scrim.js +26 -0
- package/dist/components/client/BottomSheet/BottomSheet.cjs +209 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.cts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.ts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.js +207 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.cjs +26 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.cts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.ts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.js +24 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.js +13 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.cjs +30 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.js +28 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.cjs +42 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.cts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.ts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.js +40 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.cjs +21 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.js +19 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.js +13 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.cjs +32 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.cts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.ts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.js +29 -0
- package/dist/components/client/BottomSheet/index.cjs +22 -0
- package/dist/components/client/BottomSheet/index.d.cts +10 -0
- package/dist/components/client/BottomSheet/index.d.ts +10 -0
- package/dist/components/client/BottomSheet/index.js +12 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.cjs +188 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.cts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.ts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.js +185 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.cjs +138 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.cts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.ts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.js +135 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.cjs +34 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.cts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.ts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.js +31 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.cjs +17 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.cts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.js +15 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.cjs +89 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.cts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.ts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.js +87 -0
- package/dist/components/client/BottomSheet/useViewportHeight.cjs +32 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.cts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.ts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.js +30 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.cjs +48 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.cts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.ts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.js +46 -0
- package/dist/components/client/BottomSheet/utils.cjs +128 -0
- package/dist/components/client/BottomSheet/utils.d.cts +61 -0
- package/dist/components/client/BottomSheet/utils.d.ts +61 -0
- package/dist/components/client/BottomSheet/utils.js +118 -0
- package/dist/components/client/Menu/Menu.Content.cjs +1 -1
- package/dist/components/client/Menu/Menu.Content.js +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/components/client/Menu/Menu.index.d.cts +1 -1
- package/dist/components/client/index.cjs +16 -0
- package/dist/components/client/index.d.cts +10 -1
- package/dist/components/client/index.d.ts +10 -1
- package/dist/components/client/index.js +9 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +10 -6
- package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.js +10 -6
- package/dist/components/index.cjs +24 -0
- package/dist/components/index.d.cts +9 -1
- package/dist/components/index.d.ts +9 -1
- package/dist/components/index.js +17 -1
- package/dist/config/dist/index.cjs +110 -2
- package/dist/config/dist/index.js +110 -2
- package/dist/fixtures/dist/index.cjs +103 -0
- package/dist/fixtures/dist/index.d.cts +3 -2
- package/dist/fixtures/dist/index.d.ts +3 -2
- package/dist/fixtures/dist/index.js +103 -1
- package/dist/fixtures/index.cjs +1 -0
- package/dist/fixtures/index.d.cts +2 -2
- package/dist/fixtures/index.d.ts +2 -2
- package/dist/fixtures/index.js +2 -2
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +11 -2
- package/dist/runtime/bottomSheetConfig.cjs +11 -0
- package/dist/runtime/bottomSheetConfig.d.cts +15 -0
- package/dist/runtime/bottomSheetConfig.d.ts +15 -0
- package/dist/runtime/bottomSheetConfig.js +9 -0
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/udsConfig.cjs +2 -0
- package/dist/runtime/udsConfig.d.cts +2 -0
- package/dist/runtime/udsConfig.d.ts +2 -0
- package/dist/runtime/udsConfig.js +2 -0
- package/dist/styles/styler.d.cts +47 -44
- package/dist/styles/styler.d.ts +51 -48
- package/dist/styles/variants.d.cts +9 -0
- package/dist/styles/variants.d.ts +9 -0
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +2 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +3 -1
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.cts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.ts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.cts +4 -4
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.ts +4 -4
- package/dist/tokens/automation/configs/index.cjs +2 -0
- package/dist/tokens/automation/configs/index.d.cts +2 -2
- package/dist/tokens/automation/configs/index.d.ts +2 -2
- package/dist/tokens/automation/configs/index.js +2 -2
- package/dist/tokens/automation/index.cjs +2 -0
- package/dist/tokens/automation/index.d.cts +2 -2
- package/dist/tokens/automation/index.d.ts +2 -2
- package/dist/tokens/automation/index.js +2 -2
- package/dist/tokens/index.cjs +2 -0
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +76 -1
- package/dist/types/dist/index.d.ts +76 -1
- package/dist/uds/generated/componentData.cjs +358 -117
- package/dist/uds/generated/componentData.js +305 -118
- package/dist/uds/generated/tailwindPurge.cjs +57 -29
- package/dist/uds/generated/tailwindPurge.js +57 -29
- package/generated/componentData.json +475 -209
- package/generated/tailwindPurge.ts +39 -8
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
import { BottomSheetHeight } from "../../../types/dist/index.js";
|
|
3
|
+
import "../../../tokens/index.js";
|
|
4
|
+
import { MutableRefObject } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/BottomSheet/useBottomSheetSnapModel.d.ts
|
|
7
|
+
interface UseBottomSheetSnapModelParams {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
snapPointsProp?: BottomSheetHeight[];
|
|
10
|
+
height?: BottomSheetHeight;
|
|
11
|
+
defaultSnapPointIndex: number;
|
|
12
|
+
snapPointIndexProp?: number;
|
|
13
|
+
onSnapPointChange?: (index: number, height: BottomSheetHeight) => void;
|
|
14
|
+
viewportHeightPx: number;
|
|
15
|
+
maxHeightPx: number;
|
|
16
|
+
setTranslateAnimated: (nextTranslatePx: number) => void;
|
|
17
|
+
isDraggingRef: MutableRefObject<boolean>;
|
|
18
|
+
}
|
|
19
|
+
interface UseBottomSheetSnapModelResult {
|
|
20
|
+
resolvedSnapPoints: BottomSheetHeight[];
|
|
21
|
+
snapPointsPx: number[];
|
|
22
|
+
maxSnapPointPx: number;
|
|
23
|
+
snapPointTranslatesPx: number[];
|
|
24
|
+
activeSnapIndex: number;
|
|
25
|
+
restTranslatePx: number;
|
|
26
|
+
setRestTranslatePx: React.Dispatch<React.SetStateAction<number>>;
|
|
27
|
+
isSnapPointControlled: boolean;
|
|
28
|
+
emitSnapPointChange: (nextIndex: number) => void;
|
|
29
|
+
openTimeRef: MutableRefObject<number | null>;
|
|
30
|
+
lastTimeDragPreventedRef: MutableRefObject<number | null>;
|
|
31
|
+
isEnteringRef: MutableRefObject<boolean>;
|
|
32
|
+
}
|
|
33
|
+
declare function useBottomSheetSnapModel({
|
|
34
|
+
isOpen,
|
|
35
|
+
snapPointsProp,
|
|
36
|
+
height,
|
|
37
|
+
defaultSnapPointIndex,
|
|
38
|
+
snapPointIndexProp,
|
|
39
|
+
onSnapPointChange,
|
|
40
|
+
viewportHeightPx,
|
|
41
|
+
maxHeightPx,
|
|
42
|
+
setTranslateAnimated,
|
|
43
|
+
isDraggingRef
|
|
44
|
+
}: UseBottomSheetSnapModelParams): UseBottomSheetSnapModelResult;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useBottomSheetSnapModel };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { clampIndex, resolveHeightToPx } from "./utils.js";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { clamp } from "lodash-es";
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/BottomSheet/useBottomSheetSnapModel.ts
|
|
8
|
+
const DEFAULT_SNAP_POINT = "40%";
|
|
9
|
+
const OPEN_SHEET_ENTER_DELAY_MS = 50;
|
|
10
|
+
function useBottomSheetSnapModel({ isOpen, snapPointsProp, height, defaultSnapPointIndex, snapPointIndexProp, onSnapPointChange, viewportHeightPx, maxHeightPx, setTranslateAnimated, isDraggingRef }) {
|
|
11
|
+
const openTimeRef = useRef(null);
|
|
12
|
+
const lastTimeDragPreventedRef = useRef(null);
|
|
13
|
+
const openEnterTimeoutRef = useRef(null);
|
|
14
|
+
const isEnteringRef = useRef(false);
|
|
15
|
+
const resolvedSnapPoints = useMemo(() => {
|
|
16
|
+
if (snapPointsProp?.length) return snapPointsProp;
|
|
17
|
+
if (height !== void 0) return [height];
|
|
18
|
+
return [DEFAULT_SNAP_POINT];
|
|
19
|
+
}, [height, snapPointsProp]);
|
|
20
|
+
const snapPointsPx = useMemo(() => {
|
|
21
|
+
return resolvedSnapPoints.map((sp) => clamp(resolveHeightToPx(sp, viewportHeightPx), 0, maxHeightPx));
|
|
22
|
+
}, [
|
|
23
|
+
maxHeightPx,
|
|
24
|
+
resolvedSnapPoints,
|
|
25
|
+
viewportHeightPx
|
|
26
|
+
]);
|
|
27
|
+
const maxSnapPointPx = useMemo(() => Math.max(0, ...snapPointsPx), [snapPointsPx]);
|
|
28
|
+
const snapPointTranslatesPx = useMemo(() => {
|
|
29
|
+
return snapPointsPx.map((h) => maxSnapPointPx - h);
|
|
30
|
+
}, [maxSnapPointPx, snapPointsPx]);
|
|
31
|
+
const isSnapPointControlled = snapPointIndexProp !== void 0;
|
|
32
|
+
const [uncontrolledSnapIndex, setUncontrolledSnapIndex] = useState(() => clampIndex(defaultSnapPointIndex, resolvedSnapPoints.length));
|
|
33
|
+
const activeSnapIndex = clampIndex(isSnapPointControlled ? snapPointIndexProp ?? 0 : uncontrolledSnapIndex, resolvedSnapPoints.length);
|
|
34
|
+
const activeTranslatePx = snapPointTranslatesPx[activeSnapIndex] ?? maxSnapPointPx;
|
|
35
|
+
const [restTranslatePx, setRestTranslatePx] = useState(() => maxSnapPointPx);
|
|
36
|
+
const lastEmittedTranslateRef = useRef(null);
|
|
37
|
+
const emitSnapPointChange = useCallback((nextIndex) => {
|
|
38
|
+
const clamped = clampIndex(nextIndex, resolvedSnapPoints.length);
|
|
39
|
+
const nextTranslatePx = snapPointTranslatesPx[clamped] ?? maxSnapPointPx;
|
|
40
|
+
onSnapPointChange?.(clamped, resolvedSnapPoints[clamped]);
|
|
41
|
+
if (!isSnapPointControlled) setUncontrolledSnapIndex(clamped);
|
|
42
|
+
setRestTranslatePx(nextTranslatePx);
|
|
43
|
+
lastEmittedTranslateRef.current = nextTranslatePx;
|
|
44
|
+
setTranslateAnimated(nextTranslatePx);
|
|
45
|
+
}, [
|
|
46
|
+
isSnapPointControlled,
|
|
47
|
+
maxSnapPointPx,
|
|
48
|
+
onSnapPointChange,
|
|
49
|
+
resolvedSnapPoints,
|
|
50
|
+
setTranslateAnimated,
|
|
51
|
+
snapPointTranslatesPx
|
|
52
|
+
]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const wasOpen = openTimeRef.current !== null;
|
|
55
|
+
if (!isOpen) {
|
|
56
|
+
if (openEnterTimeoutRef.current !== null) {
|
|
57
|
+
window.clearTimeout(openEnterTimeoutRef.current);
|
|
58
|
+
openEnterTimeoutRef.current = null;
|
|
59
|
+
}
|
|
60
|
+
isEnteringRef.current = false;
|
|
61
|
+
openTimeRef.current = null;
|
|
62
|
+
setRestTranslatePx(maxSnapPointPx);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (wasOpen) return;
|
|
66
|
+
isEnteringRef.current = true;
|
|
67
|
+
openTimeRef.current = Date.now();
|
|
68
|
+
const initialSnapIndex = isSnapPointControlled ? activeSnapIndex : clampIndex(defaultSnapPointIndex, resolvedSnapPoints.length);
|
|
69
|
+
if (!isSnapPointControlled) setUncontrolledSnapIndex(initialSnapIndex);
|
|
70
|
+
setRestTranslatePx(maxSnapPointPx);
|
|
71
|
+
const initialTranslatePx = snapPointTranslatesPx[initialSnapIndex] ?? maxSnapPointPx;
|
|
72
|
+
openEnterTimeoutRef.current = window.setTimeout(() => {
|
|
73
|
+
isEnteringRef.current = false;
|
|
74
|
+
setRestTranslatePx(initialTranslatePx);
|
|
75
|
+
setTranslateAnimated(initialTranslatePx);
|
|
76
|
+
openEnterTimeoutRef.current = null;
|
|
77
|
+
}, OPEN_SHEET_ENTER_DELAY_MS);
|
|
78
|
+
}, [
|
|
79
|
+
activeSnapIndex,
|
|
80
|
+
defaultSnapPointIndex,
|
|
81
|
+
isOpen,
|
|
82
|
+
isSnapPointControlled,
|
|
83
|
+
maxSnapPointPx,
|
|
84
|
+
resolvedSnapPoints.length,
|
|
85
|
+
setTranslateAnimated,
|
|
86
|
+
snapPointTranslatesPx
|
|
87
|
+
]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
return () => {
|
|
90
|
+
if (openEnterTimeoutRef.current !== null) {
|
|
91
|
+
window.clearTimeout(openEnterTimeoutRef.current);
|
|
92
|
+
openEnterTimeoutRef.current = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}, []);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!isOpen || isEnteringRef.current || isDraggingRef.current) return;
|
|
98
|
+
setRestTranslatePx(activeTranslatePx);
|
|
99
|
+
if (lastEmittedTranslateRef.current === activeTranslatePx) {
|
|
100
|
+
lastEmittedTranslateRef.current = null;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
setTranslateAnimated(activeTranslatePx);
|
|
104
|
+
}, [
|
|
105
|
+
activeTranslatePx,
|
|
106
|
+
isDraggingRef,
|
|
107
|
+
isOpen,
|
|
108
|
+
setTranslateAnimated
|
|
109
|
+
]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!isOpen) return;
|
|
112
|
+
if (activeSnapIndex === resolvedSnapPoints.length - 1) openTimeRef.current = Date.now();
|
|
113
|
+
}, [
|
|
114
|
+
activeSnapIndex,
|
|
115
|
+
isOpen,
|
|
116
|
+
resolvedSnapPoints.length
|
|
117
|
+
]);
|
|
118
|
+
return {
|
|
119
|
+
resolvedSnapPoints,
|
|
120
|
+
snapPointsPx,
|
|
121
|
+
maxSnapPointPx,
|
|
122
|
+
snapPointTranslatesPx,
|
|
123
|
+
activeSnapIndex,
|
|
124
|
+
restTranslatePx,
|
|
125
|
+
setRestTranslatePx,
|
|
126
|
+
isSnapPointControlled,
|
|
127
|
+
emitSnapPointChange,
|
|
128
|
+
openTimeRef,
|
|
129
|
+
lastTimeDragPreventedRef,
|
|
130
|
+
isEnteringRef
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { useBottomSheetSnapModel };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
const require_components_client_BottomSheet_useBottomSheetStoreInternal = require('./useBottomSheetStoreInternal.cjs');
|
|
6
|
+
let _ariakit_react = require("@ariakit/react");
|
|
7
|
+
|
|
8
|
+
//#region src/components/client/BottomSheet/useBottomSheetStore.ts
|
|
9
|
+
/** @internal */
|
|
10
|
+
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
|
|
11
|
+
/** @internal */
|
|
12
|
+
function getBottomSheetInternal(controller) {
|
|
13
|
+
const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
|
|
14
|
+
if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
|
|
15
|
+
return internal;
|
|
16
|
+
}
|
|
17
|
+
const useBottomSheetStore = ({ animated = true, defaultOpen = false, open: openProp } = {}) => {
|
|
18
|
+
const bottomSheetInternal = require_components_client_BottomSheet_useBottomSheetStoreInternal.useBottomSheetStoreInternal({
|
|
19
|
+
animated,
|
|
20
|
+
open: openProp,
|
|
21
|
+
defaultOpen
|
|
22
|
+
});
|
|
23
|
+
const isOpen = (0, _ariakit_react.useStoreState)(bottomSheetInternal, (state) => state.open);
|
|
24
|
+
return {
|
|
25
|
+
open: bottomSheetInternal.show,
|
|
26
|
+
close: bottomSheetInternal.hide,
|
|
27
|
+
isOpen,
|
|
28
|
+
[BOTTOM_SHEET_INTERNAL_STORE_KEY]: bottomSheetInternal
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.getBottomSheetInternal = getBottomSheetInternal;
|
|
34
|
+
exports.useBottomSheetStore = useBottomSheetStore;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useBottomSheetStore.d.ts
|
|
5
|
+
interface UseBottomSheetStoreProps {
|
|
6
|
+
/**
|
|
7
|
+
* The initial state of the bottom sheet.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the bottom sheet is open.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
open?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the bottom sheet is animated.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
animated?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface BottomSheetController {
|
|
23
|
+
/** Open the bottom sheet. */
|
|
24
|
+
open: () => void;
|
|
25
|
+
/** Close the bottom sheet. */
|
|
26
|
+
close: () => void;
|
|
27
|
+
/** Whether the bottom sheet is currently open. */
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** @internal */
|
|
31
|
+
declare function getBottomSheetInternal(controller: BottomSheetController): _ariakit_react0.DialogStore;
|
|
32
|
+
declare const useBottomSheetStore: ({
|
|
33
|
+
animated,
|
|
34
|
+
defaultOpen,
|
|
35
|
+
open: openProp
|
|
36
|
+
}?: UseBottomSheetStoreProps) => BottomSheetController;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { type BottomSheetController, type UseBottomSheetStoreProps, getBottomSheetInternal, useBottomSheetStore };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useBottomSheetStore.d.ts
|
|
5
|
+
interface UseBottomSheetStoreProps {
|
|
6
|
+
/**
|
|
7
|
+
* The initial state of the bottom sheet.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the bottom sheet is open.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
open?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the bottom sheet is animated.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
animated?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface BottomSheetController {
|
|
23
|
+
/** Open the bottom sheet. */
|
|
24
|
+
open: () => void;
|
|
25
|
+
/** Close the bottom sheet. */
|
|
26
|
+
close: () => void;
|
|
27
|
+
/** Whether the bottom sheet is currently open. */
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** @internal */
|
|
31
|
+
declare function getBottomSheetInternal(controller: BottomSheetController): _ariakit_react0.DialogStore;
|
|
32
|
+
declare const useBottomSheetStore: ({
|
|
33
|
+
animated,
|
|
34
|
+
defaultOpen,
|
|
35
|
+
open: openProp
|
|
36
|
+
}?: UseBottomSheetStoreProps) => BottomSheetController;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { type BottomSheetController, type UseBottomSheetStoreProps, getBottomSheetInternal, useBottomSheetStore };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useBottomSheetStoreInternal } from "./useBottomSheetStoreInternal.js";
|
|
4
|
+
import { useStoreState } from "@ariakit/react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/BottomSheet/useBottomSheetStore.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
|
|
9
|
+
/** @internal */
|
|
10
|
+
function getBottomSheetInternal(controller) {
|
|
11
|
+
const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
|
|
12
|
+
if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
|
|
13
|
+
return internal;
|
|
14
|
+
}
|
|
15
|
+
const useBottomSheetStore = ({ animated = true, defaultOpen = false, open: openProp } = {}) => {
|
|
16
|
+
const bottomSheetInternal = useBottomSheetStoreInternal({
|
|
17
|
+
animated,
|
|
18
|
+
open: openProp,
|
|
19
|
+
defaultOpen
|
|
20
|
+
});
|
|
21
|
+
const isOpen = useStoreState(bottomSheetInternal, (state) => state.open);
|
|
22
|
+
return {
|
|
23
|
+
open: bottomSheetInternal.show,
|
|
24
|
+
close: bottomSheetInternal.hide,
|
|
25
|
+
isOpen,
|
|
26
|
+
[BOTTOM_SHEET_INTERNAL_STORE_KEY]: bottomSheetInternal
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { getBottomSheetInternal, useBottomSheetStore };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
let _ariakit_react = require("@ariakit/react");
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.ts
|
|
8
|
+
const useBottomSheetStoreInternal = ({ animated = true, defaultOpen = false, open } = {}) => {
|
|
9
|
+
return (0, _ariakit_react.useDialogStore)({
|
|
10
|
+
animated,
|
|
11
|
+
open,
|
|
12
|
+
defaultOpen
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useBottomSheetStoreInternal = useBottomSheetStoreInternal;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
import { DialogStoreProps } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts
|
|
6
|
+
type UseBottomSheetStoreInternalProps = Pick<DialogStoreProps, 'animated' | 'open' | 'defaultOpen'>;
|
|
7
|
+
declare const useBottomSheetStoreInternal: ({
|
|
8
|
+
animated,
|
|
9
|
+
defaultOpen,
|
|
10
|
+
open
|
|
11
|
+
}?: UseBottomSheetStoreInternalProps) => _ariakit_react0.DialogStore;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
import { DialogStoreProps } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts
|
|
6
|
+
type UseBottomSheetStoreInternalProps = Pick<DialogStoreProps, 'animated' | 'open' | 'defaultOpen'>;
|
|
7
|
+
declare const useBottomSheetStoreInternal: ({
|
|
8
|
+
animated,
|
|
9
|
+
defaultOpen,
|
|
10
|
+
open
|
|
11
|
+
}?: UseBottomSheetStoreInternalProps) => _ariakit_react0.DialogStore;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useDialogStore } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.ts
|
|
6
|
+
const useBottomSheetStoreInternal = ({ animated = true, defaultOpen = false, open } = {}) => {
|
|
7
|
+
return useDialogStore({
|
|
8
|
+
animated,
|
|
9
|
+
open,
|
|
10
|
+
defaultOpen
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.ts
|
|
8
|
+
/**
|
|
9
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
10
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
11
|
+
*
|
|
12
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
13
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
14
|
+
* resolves pixel snap points
|
|
15
|
+
*/
|
|
16
|
+
function useExpansionMargins({ sheetRef, maxSnapPxRef, fullWidthAtMaxSnap, snapPointsLength, isOpen, forceZeroRef }) {
|
|
17
|
+
const thresholdRef = (0, react.useRef)(null);
|
|
18
|
+
const marginsRef = (0, react.useRef)(null);
|
|
19
|
+
const applyExpansionMargins = (0, react.useCallback)((el, currentTranslatePx) => {
|
|
20
|
+
if (forceZeroRef.current) {
|
|
21
|
+
el.style.marginLeft = "0px";
|
|
22
|
+
el.style.marginRight = "0px";
|
|
23
|
+
el.style.marginBottom = "0px";
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const threshold = thresholdRef.current;
|
|
27
|
+
if (threshold == null) return;
|
|
28
|
+
let margins = marginsRef.current;
|
|
29
|
+
if (!margins) {
|
|
30
|
+
el.style.removeProperty("margin-left");
|
|
31
|
+
el.style.removeProperty("margin-right");
|
|
32
|
+
el.style.removeProperty("margin-bottom");
|
|
33
|
+
const computed = getComputedStyle(el);
|
|
34
|
+
const left = parseFloat(computed.marginLeft) || 0;
|
|
35
|
+
const right = parseFloat(computed.marginRight) || 0;
|
|
36
|
+
const bottom = parseFloat(computed.marginBottom) || 0;
|
|
37
|
+
if (left === 0 && right === 0 && bottom === 0) return;
|
|
38
|
+
margins = {
|
|
39
|
+
left,
|
|
40
|
+
right,
|
|
41
|
+
bottom
|
|
42
|
+
};
|
|
43
|
+
marginsRef.current = margins;
|
|
44
|
+
}
|
|
45
|
+
const maxSnap = maxSnapPxRef.current;
|
|
46
|
+
const range = maxSnap - threshold;
|
|
47
|
+
if (range <= 0) return;
|
|
48
|
+
const rawProgress = (maxSnap - currentTranslatePx - threshold) / range;
|
|
49
|
+
const progress = Math.max(0, Math.min(1, rawProgress));
|
|
50
|
+
if (progress <= 0) {
|
|
51
|
+
marginsRef.current = null;
|
|
52
|
+
el.style.removeProperty("margin-left");
|
|
53
|
+
el.style.removeProperty("margin-right");
|
|
54
|
+
el.style.removeProperty("margin-bottom");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
el.style.marginLeft = `${margins.left * (1 - progress)}px`;
|
|
58
|
+
el.style.marginRight = `${margins.right * (1 - progress)}px`;
|
|
59
|
+
el.style.marginBottom = `${margins.bottom * (1 - progress)}px`;
|
|
60
|
+
}, [
|
|
61
|
+
forceZeroRef,
|
|
62
|
+
maxSnapPxRef,
|
|
63
|
+
thresholdRef,
|
|
64
|
+
marginsRef
|
|
65
|
+
]);
|
|
66
|
+
(0, react.useEffect)(() => {
|
|
67
|
+
if (isOpen && fullWidthAtMaxSnap && snapPointsLength >= 2) return;
|
|
68
|
+
marginsRef.current = null;
|
|
69
|
+
const el = sheetRef.current;
|
|
70
|
+
if (el) {
|
|
71
|
+
el.style.removeProperty("margin-left");
|
|
72
|
+
el.style.removeProperty("margin-right");
|
|
73
|
+
el.style.removeProperty("margin-bottom");
|
|
74
|
+
if (!isOpen) el.style.removeProperty("height");
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
isOpen,
|
|
78
|
+
fullWidthAtMaxSnap,
|
|
79
|
+
snapPointsLength,
|
|
80
|
+
sheetRef
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
applyExpansionMargins,
|
|
84
|
+
thresholdRef
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.useExpansionMargins = useExpansionMargins;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.d.ts
|
|
5
|
+
interface UseExpansionMarginsParams {
|
|
6
|
+
sheetRef: React.RefObject<HTMLElement | null>;
|
|
7
|
+
maxSnapPxRef: React.RefObject<number>;
|
|
8
|
+
fullWidthAtMaxSnap: boolean;
|
|
9
|
+
snapPointsLength: number;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/** When true, forces all margins to 0 (e.g. virtual keyboard visible). */
|
|
12
|
+
forceZeroRef: React.RefObject<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
16
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
17
|
+
*
|
|
18
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
19
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
20
|
+
* resolves pixel snap points
|
|
21
|
+
*/
|
|
22
|
+
declare function useExpansionMargins({
|
|
23
|
+
sheetRef,
|
|
24
|
+
maxSnapPxRef,
|
|
25
|
+
fullWidthAtMaxSnap,
|
|
26
|
+
snapPointsLength,
|
|
27
|
+
isOpen,
|
|
28
|
+
forceZeroRef
|
|
29
|
+
}: UseExpansionMarginsParams): {
|
|
30
|
+
applyExpansionMargins: (el: HTMLElement, currentTranslatePx: number) => void;
|
|
31
|
+
thresholdRef: React.RefObject<number | null>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.d.ts
|
|
5
|
+
interface UseExpansionMarginsParams {
|
|
6
|
+
sheetRef: React.RefObject<HTMLElement | null>;
|
|
7
|
+
maxSnapPxRef: React.RefObject<number>;
|
|
8
|
+
fullWidthAtMaxSnap: boolean;
|
|
9
|
+
snapPointsLength: number;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/** When true, forces all margins to 0 (e.g. virtual keyboard visible). */
|
|
12
|
+
forceZeroRef: React.RefObject<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
16
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
17
|
+
*
|
|
18
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
19
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
20
|
+
* resolves pixel snap points
|
|
21
|
+
*/
|
|
22
|
+
declare function useExpansionMargins({
|
|
23
|
+
sheetRef,
|
|
24
|
+
maxSnapPxRef,
|
|
25
|
+
fullWidthAtMaxSnap,
|
|
26
|
+
snapPointsLength,
|
|
27
|
+
isOpen,
|
|
28
|
+
forceZeroRef
|
|
29
|
+
}: UseExpansionMarginsParams): {
|
|
30
|
+
applyExpansionMargins: (el: HTMLElement, currentTranslatePx: number) => void;
|
|
31
|
+
thresholdRef: React.RefObject<number | null>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.ts
|
|
6
|
+
/**
|
|
7
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
8
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
9
|
+
*
|
|
10
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
11
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
12
|
+
* resolves pixel snap points
|
|
13
|
+
*/
|
|
14
|
+
function useExpansionMargins({ sheetRef, maxSnapPxRef, fullWidthAtMaxSnap, snapPointsLength, isOpen, forceZeroRef }) {
|
|
15
|
+
const thresholdRef = useRef(null);
|
|
16
|
+
const marginsRef = useRef(null);
|
|
17
|
+
const applyExpansionMargins = useCallback((el, currentTranslatePx) => {
|
|
18
|
+
if (forceZeroRef.current) {
|
|
19
|
+
el.style.marginLeft = "0px";
|
|
20
|
+
el.style.marginRight = "0px";
|
|
21
|
+
el.style.marginBottom = "0px";
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const threshold = thresholdRef.current;
|
|
25
|
+
if (threshold == null) return;
|
|
26
|
+
let margins = marginsRef.current;
|
|
27
|
+
if (!margins) {
|
|
28
|
+
el.style.removeProperty("margin-left");
|
|
29
|
+
el.style.removeProperty("margin-right");
|
|
30
|
+
el.style.removeProperty("margin-bottom");
|
|
31
|
+
const computed = getComputedStyle(el);
|
|
32
|
+
const left = parseFloat(computed.marginLeft) || 0;
|
|
33
|
+
const right = parseFloat(computed.marginRight) || 0;
|
|
34
|
+
const bottom = parseFloat(computed.marginBottom) || 0;
|
|
35
|
+
if (left === 0 && right === 0 && bottom === 0) return;
|
|
36
|
+
margins = {
|
|
37
|
+
left,
|
|
38
|
+
right,
|
|
39
|
+
bottom
|
|
40
|
+
};
|
|
41
|
+
marginsRef.current = margins;
|
|
42
|
+
}
|
|
43
|
+
const maxSnap = maxSnapPxRef.current;
|
|
44
|
+
const range = maxSnap - threshold;
|
|
45
|
+
if (range <= 0) return;
|
|
46
|
+
const rawProgress = (maxSnap - currentTranslatePx - threshold) / range;
|
|
47
|
+
const progress = Math.max(0, Math.min(1, rawProgress));
|
|
48
|
+
if (progress <= 0) {
|
|
49
|
+
marginsRef.current = null;
|
|
50
|
+
el.style.removeProperty("margin-left");
|
|
51
|
+
el.style.removeProperty("margin-right");
|
|
52
|
+
el.style.removeProperty("margin-bottom");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
el.style.marginLeft = `${margins.left * (1 - progress)}px`;
|
|
56
|
+
el.style.marginRight = `${margins.right * (1 - progress)}px`;
|
|
57
|
+
el.style.marginBottom = `${margins.bottom * (1 - progress)}px`;
|
|
58
|
+
}, [
|
|
59
|
+
forceZeroRef,
|
|
60
|
+
maxSnapPxRef,
|
|
61
|
+
thresholdRef,
|
|
62
|
+
marginsRef
|
|
63
|
+
]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isOpen && fullWidthAtMaxSnap && snapPointsLength >= 2) return;
|
|
66
|
+
marginsRef.current = null;
|
|
67
|
+
const el = sheetRef.current;
|
|
68
|
+
if (el) {
|
|
69
|
+
el.style.removeProperty("margin-left");
|
|
70
|
+
el.style.removeProperty("margin-right");
|
|
71
|
+
el.style.removeProperty("margin-bottom");
|
|
72
|
+
if (!isOpen) el.style.removeProperty("height");
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
isOpen,
|
|
76
|
+
fullWidthAtMaxSnap,
|
|
77
|
+
snapPointsLength,
|
|
78
|
+
sheetRef
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
applyExpansionMargins,
|
|
82
|
+
thresholdRef
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
const require_components_client_BottomSheet_utils = require('./utils.cjs');
|
|
6
|
+
let react = require("react");
|
|
7
|
+
|
|
8
|
+
//#region src/components/client/BottomSheet/useViewportHeight.ts
|
|
9
|
+
/**
|
|
10
|
+
* Hook to get the viewport height in pixels.
|
|
11
|
+
* @returns The viewport height in pixels.
|
|
12
|
+
*/
|
|
13
|
+
function useViewportHeight() {
|
|
14
|
+
const [viewportHeightPx, setViewportHeightPx] = (0, react.useState)(require_components_client_BottomSheet_utils.getViewportHeightPx);
|
|
15
|
+
(0, react.useEffect)(() => {
|
|
16
|
+
if (typeof window === "undefined") return;
|
|
17
|
+
function onResize() {
|
|
18
|
+
setViewportHeightPx(require_components_client_BottomSheet_utils.getViewportHeightPx());
|
|
19
|
+
}
|
|
20
|
+
onResize();
|
|
21
|
+
window.addEventListener("resize", onResize);
|
|
22
|
+
window.visualViewport?.addEventListener("resize", onResize);
|
|
23
|
+
return () => {
|
|
24
|
+
window.removeEventListener("resize", onResize);
|
|
25
|
+
window.visualViewport?.removeEventListener("resize", onResize);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
return viewportHeightPx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.useViewportHeight = useViewportHeight;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/BottomSheet/useViewportHeight.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the viewport height in pixels.
|
|
5
|
+
* @returns The viewport height in pixels.
|
|
6
|
+
*/
|
|
7
|
+
declare function useViewportHeight(): number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useViewportHeight };
|