@yahoo/uds-mobile 2.3.4 → 2.4.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/android/build.gradle +39 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/yahoo/uds/screencornerradius/UDSScreenCornerRadiusModule.kt +44 -0
- package/dist/bin/generateTheme.mjs +10 -0
- package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +4 -1
- package/dist/components/AndroidBackHandler.cjs +31 -0
- package/dist/components/AndroidBackHandler.d.cts +21 -0
- package/dist/components/AndroidBackHandler.d.cts.map +1 -0
- package/dist/components/AndroidBackHandler.d.ts +21 -0
- package/dist/components/AndroidBackHandler.d.ts.map +1 -0
- package/dist/components/AndroidBackHandler.js +30 -0
- package/dist/components/AndroidBackHandler.js.map +1 -0
- package/dist/components/Avatar.cjs +1 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/Badge.cjs +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs +336 -0
- package/dist/components/BottomSheet/BottomSheet.d.cts +33 -0
- package/dist/components/BottomSheet/BottomSheet.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +33 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheet.js +334 -0
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetContent.cjs +65 -0
- package/dist/components/BottomSheet/BottomSheetContent.d.cts +22 -0
- package/dist/components/BottomSheet/BottomSheetContent.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetContent.d.ts +22 -0
- package/dist/components/BottomSheet/BottomSheetContent.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetContent.js +63 -0
- package/dist/components/BottomSheet/BottomSheetContent.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.cjs +28 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.d.cts +25 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.d.ts +25 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.js +27 -0
- package/dist/components/BottomSheet/BottomSheetDismiss.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHandle.cjs +56 -0
- package/dist/components/BottomSheet/BottomSheetHandle.d.cts +14 -0
- package/dist/components/BottomSheet/BottomSheetHandle.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHandle.d.ts +14 -0
- package/dist/components/BottomSheet/BottomSheetHandle.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHandle.js +55 -0
- package/dist/components/BottomSheet/BottomSheetHandle.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHeader.cjs +69 -0
- package/dist/components/BottomSheet/BottomSheetHeader.d.cts +16 -0
- package/dist/components/BottomSheet/BottomSheetHeader.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHeader.d.ts +16 -0
- package/dist/components/BottomSheet/BottomSheetHeader.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetHeader.js +68 -0
- package/dist/components/BottomSheet/BottomSheetHeader.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.cjs +26 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.d.cts +23 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.d.ts +23 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.js +24 -0
- package/dist/components/BottomSheet/BottomSheetInternalProvider.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetProvider.cjs +33 -0
- package/dist/components/BottomSheet/BottomSheetProvider.d.cts +24 -0
- package/dist/components/BottomSheet/BottomSheetProvider.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetProvider.d.ts +24 -0
- package/dist/components/BottomSheet/BottomSheetProvider.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetProvider.js +31 -0
- package/dist/components/BottomSheet/BottomSheetProvider.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.cjs +28 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.d.cts +25 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.d.cts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.d.ts +25 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.js +27 -0
- package/dist/components/BottomSheet/BottomSheetTrigger.js.map +1 -0
- package/dist/components/BottomSheet/index.cjs +19 -0
- package/dist/components/BottomSheet/index.d.cts +11 -0
- package/dist/components/BottomSheet/index.d.ts +11 -0
- package/dist/components/BottomSheet/index.js +11 -0
- package/dist/components/BottomSheet/types.cjs +1 -0
- package/dist/components/BottomSheet/types.d.cts +173 -0
- package/dist/components/BottomSheet/types.d.cts.map +1 -0
- package/dist/components/BottomSheet/types.d.ts +173 -0
- package/dist/components/BottomSheet/types.d.ts.map +1 -0
- package/dist/components/BottomSheet/types.js +1 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.cjs +191 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.d.cts +69 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.d.cts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.d.ts +69 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.d.ts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.js +190 -0
- package/dist/components/BottomSheet/useBottomSheetDrag.js.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.cjs +61 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.d.cts +48 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.d.cts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.d.ts +48 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.d.ts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.js +60 -0
- package/dist/components/BottomSheet/useBottomSheetScroll.js.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.cjs +142 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.d.cts +79 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.d.cts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.d.ts +79 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.d.ts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.js +140 -0
- package/dist/components/BottomSheet/useBottomSheetSnapModel.js.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetStore.cjs +79 -0
- package/dist/components/BottomSheet/useBottomSheetStore.d.cts +45 -0
- package/dist/components/BottomSheet/useBottomSheetStore.d.cts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetStore.d.ts +45 -0
- package/dist/components/BottomSheet/useBottomSheetStore.d.ts.map +1 -0
- package/dist/components/BottomSheet/useBottomSheetStore.js +77 -0
- package/dist/components/BottomSheet/useBottomSheetStore.js.map +1 -0
- package/dist/components/BottomSheet/useExpansionMargins.cjs +57 -0
- package/dist/components/BottomSheet/useExpansionMargins.d.cts +59 -0
- package/dist/components/BottomSheet/useExpansionMargins.d.cts.map +1 -0
- package/dist/components/BottomSheet/useExpansionMargins.d.ts +59 -0
- package/dist/components/BottomSheet/useExpansionMargins.d.ts.map +1 -0
- package/dist/components/BottomSheet/useExpansionMargins.js +56 -0
- package/dist/components/BottomSheet/useExpansionMargins.js.map +1 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.cjs +53 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.d.cts +31 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.d.cts.map +1 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.d.ts +31 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.d.ts.map +1 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.js +52 -0
- package/dist/components/BottomSheet/useKeyboardAvoidance.js.map +1 -0
- package/dist/components/BottomSheet/utils.cjs +77 -0
- package/dist/components/BottomSheet/utils.d.cts +50 -0
- package/dist/components/BottomSheet/utils.d.cts.map +1 -0
- package/dist/components/BottomSheet/utils.d.ts +50 -0
- package/dist/components/BottomSheet/utils.d.ts.map +1 -0
- package/dist/components/BottomSheet/utils.js +72 -0
- package/dist/components/BottomSheet/utils.js.map +1 -0
- package/dist/components/Box.cjs +1 -1
- package/dist/components/Box.js +1 -1
- package/dist/components/Button.cjs +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Checkbox.cjs +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/Chip.cjs +1 -1
- package/dist/components/Chip.js +1 -1
- package/dist/components/Icon.cjs +1 -1
- package/dist/components/Icon.js +1 -1
- package/dist/components/IconButton.cjs +1 -1
- package/dist/components/IconButton.js +1 -1
- package/dist/components/Image.cjs +1 -1
- package/dist/components/Image.js +1 -1
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Link.cjs +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/Pressable.cjs +1 -1
- package/dist/components/Pressable.js +1 -1
- package/dist/components/Radio.cjs +1 -1
- package/dist/components/Radio.js +1 -1
- package/dist/components/Screen.cjs +1 -1
- package/dist/components/Screen.js +1 -1
- package/dist/components/Scrim.cjs +73 -0
- package/dist/components/Scrim.d.cts +43 -0
- package/dist/components/Scrim.d.cts.map +1 -0
- package/dist/components/Scrim.d.ts +43 -0
- package/dist/components/Scrim.d.ts.map +1 -0
- package/dist/components/Scrim.js +71 -0
- package/dist/components/Scrim.js.map +1 -0
- package/dist/components/Switch.cjs +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Text.cjs +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/UDSProvider.cjs +38 -0
- package/dist/components/UDSProvider.d.cts +30 -0
- package/dist/components/UDSProvider.d.cts.map +1 -0
- package/dist/components/UDSProvider.d.ts +30 -0
- package/dist/components/UDSProvider.d.ts.map +1 -0
- package/dist/components/UDSProvider.js +37 -0
- package/dist/components/UDSProvider.js.map +1 -0
- package/dist/native/UDSScreenCornerRadiusModule.cjs +30 -0
- package/dist/native/UDSScreenCornerRadiusModule.d.cts +12 -0
- package/dist/native/UDSScreenCornerRadiusModule.d.cts.map +1 -0
- package/dist/native/UDSScreenCornerRadiusModule.d.ts +12 -0
- package/dist/native/UDSScreenCornerRadiusModule.d.ts.map +1 -0
- package/dist/native/UDSScreenCornerRadiusModule.js +17 -0
- package/dist/native/UDSScreenCornerRadiusModule.js.map +1 -0
- package/dist/portal.cjs +81 -0
- package/dist/portal.d.cts +18 -0
- package/dist/portal.d.cts.map +1 -0
- package/dist/portal.d.ts +18 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +79 -0
- package/dist/portal.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/generated/styles.cjs +10 -0
- package/generated/styles.d.ts +15 -2
- package/generated/styles.mjs +10 -0
- package/generated/unistyles.d.ts +21 -0
- package/ios/UDSMobile.podspec +25 -0
- package/ios/UDSScreenCornerRadiusModule.swift +218 -0
- package/package.json +40 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
let react = require("react");
|
|
5
|
+
|
|
6
|
+
//#region src/components/BottomSheet/useBottomSheetStore.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a lightweight external store for bottom-sheet open/close state.
|
|
9
|
+
* Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.
|
|
10
|
+
*
|
|
11
|
+
* @param initialOpen - Initial open state.
|
|
12
|
+
* @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
function createBottomSheetStore(initialOpen) {
|
|
16
|
+
let isOpen = initialOpen;
|
|
17
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
18
|
+
function subscribe(listener) {
|
|
19
|
+
listeners.add(listener);
|
|
20
|
+
return () => {
|
|
21
|
+
listeners.delete(listener);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getSnapshot() {
|
|
25
|
+
return isOpen;
|
|
26
|
+
}
|
|
27
|
+
function setOpen(next) {
|
|
28
|
+
if (next === isOpen) return;
|
|
29
|
+
isOpen = next;
|
|
30
|
+
for (const listener of listeners) listener();
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
subscribe,
|
|
34
|
+
getSnapshot,
|
|
35
|
+
setOpen
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
|
|
40
|
+
/** @internal — retrieve the internal store from a controller. */
|
|
41
|
+
function getBottomSheetInternal(controller) {
|
|
42
|
+
const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
|
|
43
|
+
if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
|
|
44
|
+
return internal;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a {@link BottomSheetController} that manages open/close state.
|
|
48
|
+
*
|
|
49
|
+
* Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.
|
|
50
|
+
* The returned controller can be passed to `<BottomSheetProvider controller={...}>`
|
|
51
|
+
* or `<BottomSheet controller={...}>`.
|
|
52
|
+
*
|
|
53
|
+
* @param props - Optional `defaultOpen` and/or controlled `open` value.
|
|
54
|
+
* @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* const store = useBottomSheetStore();
|
|
59
|
+
* // ...
|
|
60
|
+
* <Button onPress={() => store.open()}>Open</Button>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function useBottomSheetStore({ defaultOpen = false, open: openProp } = {}) {
|
|
64
|
+
const [store] = (0, react.useState)(() => createBottomSheetStore(openProp ?? defaultOpen));
|
|
65
|
+
(0, react.useEffect)(() => {
|
|
66
|
+
if (openProp !== void 0) store.setOpen(openProp);
|
|
67
|
+
}, [openProp, store]);
|
|
68
|
+
const isOpen = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
69
|
+
return {
|
|
70
|
+
open: (0, react.useCallback)(() => store.setOpen(true), [store]),
|
|
71
|
+
close: (0, react.useCallback)(() => store.setOpen(false), [store]),
|
|
72
|
+
isOpen,
|
|
73
|
+
[BOTTOM_SHEET_INTERNAL_STORE_KEY]: store
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
exports.getBottomSheetInternal = getBottomSheetInternal;
|
|
79
|
+
exports.useBottomSheetStore = useBottomSheetStore;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { BottomSheetController, UseBottomSheetStoreProps } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/components/BottomSheet/useBottomSheetStore.d.ts
|
|
5
|
+
type Listener = () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a lightweight external store for bottom-sheet open/close state.
|
|
8
|
+
* Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.
|
|
9
|
+
*
|
|
10
|
+
* @param initialOpen - Initial open state.
|
|
11
|
+
* @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare function createBottomSheetStore(initialOpen: boolean): {
|
|
15
|
+
subscribe: (listener: Listener) => () => void;
|
|
16
|
+
getSnapshot: () => boolean;
|
|
17
|
+
setOpen: (next: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
type InternalStore = ReturnType<typeof createBottomSheetStore>;
|
|
20
|
+
/** @internal — retrieve the internal store from a controller. */
|
|
21
|
+
declare function getBottomSheetInternal(controller: BottomSheetController): InternalStore;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a {@link BottomSheetController} that manages open/close state.
|
|
24
|
+
*
|
|
25
|
+
* Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.
|
|
26
|
+
* The returned controller can be passed to `<BottomSheetProvider controller={...}>`
|
|
27
|
+
* or `<BottomSheet controller={...}>`.
|
|
28
|
+
*
|
|
29
|
+
* @param props - Optional `defaultOpen` and/or controlled `open` value.
|
|
30
|
+
* @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const store = useBottomSheetStore();
|
|
35
|
+
* // ...
|
|
36
|
+
* <Button onPress={() => store.open()}>Open</Button>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function useBottomSheetStore({
|
|
40
|
+
defaultOpen,
|
|
41
|
+
open: openProp
|
|
42
|
+
}?: UseBottomSheetStoreProps): BottomSheetController;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getBottomSheetInternal, useBottomSheetStore };
|
|
45
|
+
//# sourceMappingURL=useBottomSheetStore.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBottomSheetStore.d.cts","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetStore.ts"],"mappings":";;;;KAIK,QAAA;;AAF0E;;;;;AAElE;;iBAUJ,sBAAA,CAAuB,WAAA;wBAID,QAAA;;;;KA2B1B,aAAA,GAAgB,UAAA,QAAkB,sBAAA;;iBAO9B,sBAAA,CAAuB,UAAA,EAAY,qBAAA,GAAwB,aAAA;;;;AAvBpC;;;;;AAgB6B;;;;;;;;;iBAkCpD,mBAAA,CAAA;EACP,WAAA;EACA,IAAA,EAAM;AAAA,IACL,wBAAA,GAAgC,qBAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { BottomSheetController, UseBottomSheetStoreProps } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/BottomSheet/useBottomSheetStore.d.ts
|
|
5
|
+
type Listener = () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a lightweight external store for bottom-sheet open/close state.
|
|
8
|
+
* Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.
|
|
9
|
+
*
|
|
10
|
+
* @param initialOpen - Initial open state.
|
|
11
|
+
* @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare function createBottomSheetStore(initialOpen: boolean): {
|
|
15
|
+
subscribe: (listener: Listener) => () => void;
|
|
16
|
+
getSnapshot: () => boolean;
|
|
17
|
+
setOpen: (next: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
type InternalStore = ReturnType<typeof createBottomSheetStore>;
|
|
20
|
+
/** @internal — retrieve the internal store from a controller. */
|
|
21
|
+
declare function getBottomSheetInternal(controller: BottomSheetController): InternalStore;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a {@link BottomSheetController} that manages open/close state.
|
|
24
|
+
*
|
|
25
|
+
* Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.
|
|
26
|
+
* The returned controller can be passed to `<BottomSheetProvider controller={...}>`
|
|
27
|
+
* or `<BottomSheet controller={...}>`.
|
|
28
|
+
*
|
|
29
|
+
* @param props - Optional `defaultOpen` and/or controlled `open` value.
|
|
30
|
+
* @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const store = useBottomSheetStore();
|
|
35
|
+
* // ...
|
|
36
|
+
* <Button onPress={() => store.open()}>Open</Button>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function useBottomSheetStore({
|
|
40
|
+
defaultOpen,
|
|
41
|
+
open: openProp
|
|
42
|
+
}?: UseBottomSheetStoreProps): BottomSheetController;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getBottomSheetInternal, useBottomSheetStore };
|
|
45
|
+
//# sourceMappingURL=useBottomSheetStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBottomSheetStore.d.ts","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetStore.ts"],"mappings":";;;;KAIK,QAAA;;AAF0E;;;;;AAElE;;iBAUJ,sBAAA,CAAuB,WAAA;wBAID,QAAA;;;;KA2B1B,aAAA,GAAgB,UAAA,QAAkB,sBAAA;;iBAO9B,sBAAA,CAAuB,UAAA,EAAY,qBAAA,GAAwB,aAAA;;;;AAvBpC;;;;;AAgB6B;;;;;;;;;iBAkCpD,mBAAA,CAAA;EACP,WAAA;EACA,IAAA,EAAM;AAAA,IACL,wBAAA,GAAgC,qBAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/BottomSheet/useBottomSheetStore.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a lightweight external store for bottom-sheet open/close state.
|
|
7
|
+
* Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.
|
|
8
|
+
*
|
|
9
|
+
* @param initialOpen - Initial open state.
|
|
10
|
+
* @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function createBottomSheetStore(initialOpen) {
|
|
14
|
+
let isOpen = initialOpen;
|
|
15
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
16
|
+
function subscribe(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return () => {
|
|
19
|
+
listeners.delete(listener);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getSnapshot() {
|
|
23
|
+
return isOpen;
|
|
24
|
+
}
|
|
25
|
+
function setOpen(next) {
|
|
26
|
+
if (next === isOpen) return;
|
|
27
|
+
isOpen = next;
|
|
28
|
+
for (const listener of listeners) listener();
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
subscribe,
|
|
32
|
+
getSnapshot,
|
|
33
|
+
setOpen
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
|
|
38
|
+
/** @internal — retrieve the internal store from a controller. */
|
|
39
|
+
function getBottomSheetInternal(controller) {
|
|
40
|
+
const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
|
|
41
|
+
if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
|
|
42
|
+
return internal;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a {@link BottomSheetController} that manages open/close state.
|
|
46
|
+
*
|
|
47
|
+
* Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.
|
|
48
|
+
* The returned controller can be passed to `<BottomSheetProvider controller={...}>`
|
|
49
|
+
* or `<BottomSheet controller={...}>`.
|
|
50
|
+
*
|
|
51
|
+
* @param props - Optional `defaultOpen` and/or controlled `open` value.
|
|
52
|
+
* @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const store = useBottomSheetStore();
|
|
57
|
+
* // ...
|
|
58
|
+
* <Button onPress={() => store.open()}>Open</Button>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
function useBottomSheetStore({ defaultOpen = false, open: openProp } = {}) {
|
|
62
|
+
const [store] = useState(() => createBottomSheetStore(openProp ?? defaultOpen));
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (openProp !== void 0) store.setOpen(openProp);
|
|
65
|
+
}, [openProp, store]);
|
|
66
|
+
const isOpen = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
67
|
+
return {
|
|
68
|
+
open: useCallback(() => store.setOpen(true), [store]),
|
|
69
|
+
close: useCallback(() => store.setOpen(false), [store]),
|
|
70
|
+
isOpen,
|
|
71
|
+
[BOTTOM_SHEET_INTERNAL_STORE_KEY]: store
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { getBottomSheetInternal, useBottomSheetStore };
|
|
77
|
+
//# sourceMappingURL=useBottomSheetStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBottomSheetStore.js","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetStore.ts"],"sourcesContent":["import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\n\nimport type { BottomSheetController, UseBottomSheetStoreProps } from './types';\n\ntype Listener = () => void;\n\n/**\n * Creates a lightweight external store for bottom-sheet open/close state.\n * Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.\n *\n * @param initialOpen - Initial open state.\n * @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.\n * @internal\n */\nfunction createBottomSheetStore(initialOpen: boolean) {\n let isOpen = initialOpen;\n const listeners = new Set<Listener>();\n\n function subscribe(listener: Listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n\n function getSnapshot() {\n return isOpen;\n }\n\n function setOpen(next: boolean) {\n if (next === isOpen) {\n return;\n }\n isOpen = next;\n for (const listener of listeners) {\n listener();\n }\n }\n\n return { subscribe, getSnapshot, setOpen };\n}\n\n/** @internal */\nconst BOTTOM_SHEET_INTERNAL_STORE_KEY = '__bottomSheetInternal';\n\ntype InternalStore = ReturnType<typeof createBottomSheetStore>;\n\ntype BottomSheetControllerWithInternal = BottomSheetController & {\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: InternalStore;\n};\n\n/** @internal — retrieve the internal store from a controller. */\nfunction getBottomSheetInternal(controller: BottomSheetController): InternalStore {\n const internal = (controller as BottomSheetControllerWithInternal)[\n BOTTOM_SHEET_INTERNAL_STORE_KEY\n ];\n if (!internal) {\n throw new Error('Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.');\n }\n return internal;\n}\n\n/**\n * Creates a {@link BottomSheetController} that manages open/close state.\n *\n * Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.\n * The returned controller can be passed to `<BottomSheetProvider controller={...}>`\n * or `<BottomSheet controller={...}>`.\n *\n * @param props - Optional `defaultOpen` and/or controlled `open` value.\n * @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.\n *\n * @example\n * ```tsx\n * const store = useBottomSheetStore();\n * // ...\n * <Button onPress={() => store.open()}>Open</Button>\n * ```\n */\nfunction useBottomSheetStore({\n defaultOpen = false,\n open: openProp,\n}: UseBottomSheetStoreProps = {}): BottomSheetController {\n // Use useState with lazy initializer to create the store once.\n const [store] = useState(() => createBottomSheetStore(openProp ?? defaultOpen));\n\n // Sync controlled `open` prop into store via effect.\n useEffect(() => {\n if (openProp !== undefined) {\n store.setOpen(openProp);\n }\n }, [openProp, store]);\n\n const isOpen = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const open = useCallback(() => store.setOpen(true), [store]);\n const close = useCallback(() => store.setOpen(false), [store]);\n\n return {\n open,\n close,\n isOpen,\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: store,\n } as BottomSheetController;\n}\n\nexport { getBottomSheetInternal, useBottomSheetStore };\n"],"mappings":";;;;;;;;;;;;AAcA,SAAS,uBAAuB,aAAsB;CACpD,IAAI,SAAS;CACb,MAAM,4BAAY,IAAI,KAAe;CAErC,SAAS,UAAU,UAAoB;AACrC,YAAU,IAAI,SAAS;AACvB,eAAa;AACX,aAAU,OAAO,SAAS;;;CAI9B,SAAS,cAAc;AACrB,SAAO;;CAGT,SAAS,QAAQ,MAAe;AAC9B,MAAI,SAAS,OACX;AAEF,WAAS;AACT,OAAK,MAAM,YAAY,UACrB,WAAU;;AAId,QAAO;EAAE;EAAW;EAAa;EAAS;;;AAI5C,MAAM,kCAAkC;;AASxC,SAAS,uBAAuB,YAAkD;CAChF,MAAM,WAAY,WAChB;AAEF,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6EAA6E;AAE/F,QAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAS,oBAAoB,EAC3B,cAAc,OACd,MAAM,aACsB,EAAE,EAAyB;CAEvD,MAAM,CAAC,SAAS,eAAe,uBAAuB,YAAY,YAAY,CAAC;AAG/E,iBAAgB;AACd,MAAI,aAAa,OACf,OAAM,QAAQ,SAAS;IAExB,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,SAAS,qBAAqB,MAAM,WAAW,MAAM,YAAY;AAKvE,QAAO;EACL,MAJW,kBAAkB,MAAM,QAAQ,KAAK,EAAE,CAAC,MAAM,CAAC;EAK1D,OAJY,kBAAkB,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,CAAC;EAK5D;GACC,kCAAkC;EACpC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
const require_components_BottomSheet_utils = require('./utils.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
7
|
+
|
|
8
|
+
//#region src/components/BottomSheet/useExpansionMargins.ts
|
|
9
|
+
/**
|
|
10
|
+
* Animates sheet margins from their base values to `0` as the sheet expands
|
|
11
|
+
* from the second-highest snap point to the max snap point.
|
|
12
|
+
*
|
|
13
|
+
* Also returns the interpolation thresholds (`maxSnapTranslateY` and
|
|
14
|
+
* `thresholdTranslateY`) so the caller can animate other properties
|
|
15
|
+
* (e.g. the height constraint's effective bottom inset) in sync.
|
|
16
|
+
*
|
|
17
|
+
* @returns An animated margin style and the expansion interpolation thresholds.
|
|
18
|
+
*/
|
|
19
|
+
function useExpansionMargins({ enabled, baseMarginHorizontal, baseMarginBottom, resolvedSnapPoints, containerHeight, bottomInsetPx, expandedBottomInsetPx, translateY }) {
|
|
20
|
+
const { maxSnapTranslateY, thresholdTranslateY } = (0, react.useMemo)(() => {
|
|
21
|
+
if (!enabled || resolvedSnapPoints.length === 0) return {
|
|
22
|
+
maxSnapTranslateY: 0,
|
|
23
|
+
thresholdTranslateY: 0
|
|
24
|
+
};
|
|
25
|
+
const h = containerHeight.value;
|
|
26
|
+
const maxIdx = resolvedSnapPoints.length - 1;
|
|
27
|
+
const maxHeight = require_components_BottomSheet_utils.resolveHeightToPx(resolvedSnapPoints[maxIdx], h);
|
|
28
|
+
const maxTransY = h - Math.min(maxHeight, h - expandedBottomInsetPx) - expandedBottomInsetPx;
|
|
29
|
+
const thresholdHeight = require_components_BottomSheet_utils.resolveHeightToPx(resolvedSnapPoints[require_components_BottomSheet_utils.clampIndex(maxIdx - 1, resolvedSnapPoints.length)], h);
|
|
30
|
+
return {
|
|
31
|
+
maxSnapTranslateY: maxTransY,
|
|
32
|
+
thresholdTranslateY: h - Math.min(thresholdHeight, h - bottomInsetPx) - bottomInsetPx
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
enabled,
|
|
36
|
+
resolvedSnapPoints,
|
|
37
|
+
containerHeight.value,
|
|
38
|
+
bottomInsetPx,
|
|
39
|
+
expandedBottomInsetPx
|
|
40
|
+
]);
|
|
41
|
+
return {
|
|
42
|
+
animatedMarginStyle: (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
43
|
+
if (!enabled) return {};
|
|
44
|
+
const mh = (0, react_native_reanimated.interpolate)(translateY.value, [maxSnapTranslateY, thresholdTranslateY], [0, baseMarginHorizontal], "clamp");
|
|
45
|
+
return {
|
|
46
|
+
marginLeft: mh,
|
|
47
|
+
marginRight: mh,
|
|
48
|
+
marginBottom: (0, react_native_reanimated.interpolate)(translateY.value, [maxSnapTranslateY, thresholdTranslateY], [0, baseMarginBottom], "clamp")
|
|
49
|
+
};
|
|
50
|
+
}),
|
|
51
|
+
maxSnapTranslateY,
|
|
52
|
+
thresholdTranslateY
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.useExpansionMargins = useExpansionMargins;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import { BottomSheetHeight } from "./types.cjs";
|
|
3
|
+
import { SharedValue } from "react-native-reanimated";
|
|
4
|
+
|
|
5
|
+
//#region src/components/BottomSheet/useExpansionMargins.d.ts
|
|
6
|
+
/** @internal */
|
|
7
|
+
interface UseExpansionMarginsParams {
|
|
8
|
+
/** Whether `fullWidthAtMaxSnap` is enabled on the sheet. */
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
/** Base horizontal margin from configurator tokens (px). */
|
|
11
|
+
baseMarginHorizontal: number;
|
|
12
|
+
/** Base bottom margin from configurator tokens (px). */
|
|
13
|
+
baseMarginBottom: number;
|
|
14
|
+
/** Resolved snap points array. */
|
|
15
|
+
resolvedSnapPoints: BottomSheetHeight[];
|
|
16
|
+
/** Container height (UI-thread shared value). */
|
|
17
|
+
containerHeight: SharedValue<number>;
|
|
18
|
+
/** Bottom inset in px (margin + safe area). */
|
|
19
|
+
bottomInsetPx: number;
|
|
20
|
+
/** Bottom inset at max snap when expanded (safe area only, no margin). */
|
|
21
|
+
expandedBottomInsetPx: number;
|
|
22
|
+
/** The sheet's animated translateY shared value. */
|
|
23
|
+
translateY: SharedValue<number>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Animates sheet margins from their base values to `0` as the sheet expands
|
|
27
|
+
* from the second-highest snap point to the max snap point.
|
|
28
|
+
*
|
|
29
|
+
* Also returns the interpolation thresholds (`maxSnapTranslateY` and
|
|
30
|
+
* `thresholdTranslateY`) so the caller can animate other properties
|
|
31
|
+
* (e.g. the height constraint's effective bottom inset) in sync.
|
|
32
|
+
*
|
|
33
|
+
* @returns An animated margin style and the expansion interpolation thresholds.
|
|
34
|
+
*/
|
|
35
|
+
declare function useExpansionMargins({
|
|
36
|
+
enabled,
|
|
37
|
+
baseMarginHorizontal,
|
|
38
|
+
baseMarginBottom,
|
|
39
|
+
resolvedSnapPoints,
|
|
40
|
+
containerHeight,
|
|
41
|
+
bottomInsetPx,
|
|
42
|
+
expandedBottomInsetPx,
|
|
43
|
+
translateY
|
|
44
|
+
}: UseExpansionMarginsParams): {
|
|
45
|
+
animatedMarginStyle: {
|
|
46
|
+
marginLeft?: undefined;
|
|
47
|
+
marginRight?: undefined;
|
|
48
|
+
marginBottom?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
marginLeft: number;
|
|
51
|
+
marginRight: number;
|
|
52
|
+
marginBottom: number;
|
|
53
|
+
};
|
|
54
|
+
maxSnapTranslateY: number;
|
|
55
|
+
thresholdTranslateY: number;
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { useExpansionMargins };
|
|
59
|
+
//# sourceMappingURL=useExpansionMargins.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpansionMargins.d.cts","names":[],"sources":["../../../src/components/BottomSheet/useExpansionMargins.ts"],"mappings":";;;;;;UAQU,yBAAA;EAAA;EAER,OAAA;;EAEA,oBAAA;EAMiB;EAJjB,gBAAA;EAUuB;EARvB,kBAAA,EAAoB,iBAAA;EANpB;EAQA,eAAA,EAAiB,WAAA;EAJjB;EAMA,aAAA;EAJoB;EAMpB,qBAAA;EAJiB;EAMjB,UAAA,EAAY,WAAA;AAAA;;;;;AAAW;;;;;;iBAahB,mBAAA,CAAA;EACP,OAAA;EACA,oBAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;EACA,aAAA;EACA,qBAAA;EACA;AAAA,GACC,yBAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import { BottomSheetHeight } from "./types.js";
|
|
3
|
+
import { SharedValue } from "react-native-reanimated";
|
|
4
|
+
|
|
5
|
+
//#region src/components/BottomSheet/useExpansionMargins.d.ts
|
|
6
|
+
/** @internal */
|
|
7
|
+
interface UseExpansionMarginsParams {
|
|
8
|
+
/** Whether `fullWidthAtMaxSnap` is enabled on the sheet. */
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
/** Base horizontal margin from configurator tokens (px). */
|
|
11
|
+
baseMarginHorizontal: number;
|
|
12
|
+
/** Base bottom margin from configurator tokens (px). */
|
|
13
|
+
baseMarginBottom: number;
|
|
14
|
+
/** Resolved snap points array. */
|
|
15
|
+
resolvedSnapPoints: BottomSheetHeight[];
|
|
16
|
+
/** Container height (UI-thread shared value). */
|
|
17
|
+
containerHeight: SharedValue<number>;
|
|
18
|
+
/** Bottom inset in px (margin + safe area). */
|
|
19
|
+
bottomInsetPx: number;
|
|
20
|
+
/** Bottom inset at max snap when expanded (safe area only, no margin). */
|
|
21
|
+
expandedBottomInsetPx: number;
|
|
22
|
+
/** The sheet's animated translateY shared value. */
|
|
23
|
+
translateY: SharedValue<number>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Animates sheet margins from their base values to `0` as the sheet expands
|
|
27
|
+
* from the second-highest snap point to the max snap point.
|
|
28
|
+
*
|
|
29
|
+
* Also returns the interpolation thresholds (`maxSnapTranslateY` and
|
|
30
|
+
* `thresholdTranslateY`) so the caller can animate other properties
|
|
31
|
+
* (e.g. the height constraint's effective bottom inset) in sync.
|
|
32
|
+
*
|
|
33
|
+
* @returns An animated margin style and the expansion interpolation thresholds.
|
|
34
|
+
*/
|
|
35
|
+
declare function useExpansionMargins({
|
|
36
|
+
enabled,
|
|
37
|
+
baseMarginHorizontal,
|
|
38
|
+
baseMarginBottom,
|
|
39
|
+
resolvedSnapPoints,
|
|
40
|
+
containerHeight,
|
|
41
|
+
bottomInsetPx,
|
|
42
|
+
expandedBottomInsetPx,
|
|
43
|
+
translateY
|
|
44
|
+
}: UseExpansionMarginsParams): {
|
|
45
|
+
animatedMarginStyle: {
|
|
46
|
+
marginLeft?: undefined;
|
|
47
|
+
marginRight?: undefined;
|
|
48
|
+
marginBottom?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
marginLeft: number;
|
|
51
|
+
marginRight: number;
|
|
52
|
+
marginBottom: number;
|
|
53
|
+
};
|
|
54
|
+
maxSnapTranslateY: number;
|
|
55
|
+
thresholdTranslateY: number;
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { useExpansionMargins };
|
|
59
|
+
//# sourceMappingURL=useExpansionMargins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpansionMargins.d.ts","names":[],"sources":["../../../src/components/BottomSheet/useExpansionMargins.ts"],"mappings":";;;;;;UAQU,yBAAA;EAAA;EAER,OAAA;;EAEA,oBAAA;EAMiB;EAJjB,gBAAA;EAUuB;EARvB,kBAAA,EAAoB,iBAAA;EANpB;EAQA,eAAA,EAAiB,WAAA;EAJjB;EAMA,aAAA;EAJoB;EAMpB,qBAAA;EAJiB;EAMjB,UAAA,EAAY,WAAA;AAAA;;;;;AAAW;;;;;;iBAahB,mBAAA,CAAA;EACP,OAAA;EACA,oBAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;EACA,aAAA;EACA,qBAAA;EACA;AAAA,GACC,yBAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { clampIndex, resolveHeightToPx } from "./utils.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { interpolate, useAnimatedStyle } from "react-native-reanimated";
|
|
5
|
+
|
|
6
|
+
//#region src/components/BottomSheet/useExpansionMargins.ts
|
|
7
|
+
/**
|
|
8
|
+
* Animates sheet margins from their base values to `0` as the sheet expands
|
|
9
|
+
* from the second-highest snap point to the max snap point.
|
|
10
|
+
*
|
|
11
|
+
* Also returns the interpolation thresholds (`maxSnapTranslateY` and
|
|
12
|
+
* `thresholdTranslateY`) so the caller can animate other properties
|
|
13
|
+
* (e.g. the height constraint's effective bottom inset) in sync.
|
|
14
|
+
*
|
|
15
|
+
* @returns An animated margin style and the expansion interpolation thresholds.
|
|
16
|
+
*/
|
|
17
|
+
function useExpansionMargins({ enabled, baseMarginHorizontal, baseMarginBottom, resolvedSnapPoints, containerHeight, bottomInsetPx, expandedBottomInsetPx, translateY }) {
|
|
18
|
+
const { maxSnapTranslateY, thresholdTranslateY } = useMemo(() => {
|
|
19
|
+
if (!enabled || resolvedSnapPoints.length === 0) return {
|
|
20
|
+
maxSnapTranslateY: 0,
|
|
21
|
+
thresholdTranslateY: 0
|
|
22
|
+
};
|
|
23
|
+
const h = containerHeight.value;
|
|
24
|
+
const maxIdx = resolvedSnapPoints.length - 1;
|
|
25
|
+
const maxHeight = resolveHeightToPx(resolvedSnapPoints[maxIdx], h);
|
|
26
|
+
const maxTransY = h - Math.min(maxHeight, h - expandedBottomInsetPx) - expandedBottomInsetPx;
|
|
27
|
+
const thresholdHeight = resolveHeightToPx(resolvedSnapPoints[clampIndex(maxIdx - 1, resolvedSnapPoints.length)], h);
|
|
28
|
+
return {
|
|
29
|
+
maxSnapTranslateY: maxTransY,
|
|
30
|
+
thresholdTranslateY: h - Math.min(thresholdHeight, h - bottomInsetPx) - bottomInsetPx
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
enabled,
|
|
34
|
+
resolvedSnapPoints,
|
|
35
|
+
containerHeight.value,
|
|
36
|
+
bottomInsetPx,
|
|
37
|
+
expandedBottomInsetPx
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
animatedMarginStyle: useAnimatedStyle(() => {
|
|
41
|
+
if (!enabled) return {};
|
|
42
|
+
const mh = interpolate(translateY.value, [maxSnapTranslateY, thresholdTranslateY], [0, baseMarginHorizontal], "clamp");
|
|
43
|
+
return {
|
|
44
|
+
marginLeft: mh,
|
|
45
|
+
marginRight: mh,
|
|
46
|
+
marginBottom: interpolate(translateY.value, [maxSnapTranslateY, thresholdTranslateY], [0, baseMarginBottom], "clamp")
|
|
47
|
+
};
|
|
48
|
+
}),
|
|
49
|
+
maxSnapTranslateY,
|
|
50
|
+
thresholdTranslateY
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useExpansionMargins };
|
|
56
|
+
//# sourceMappingURL=useExpansionMargins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpansionMargins.js","names":[],"sources":["../../../src/components/BottomSheet/useExpansionMargins.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { interpolate, useAnimatedStyle } from 'react-native-reanimated';\n\nimport type { BottomSheetHeight } from './types';\nimport { clampIndex, resolveHeightToPx } from './utils';\n\n/** @internal */\ninterface UseExpansionMarginsParams {\n /** Whether `fullWidthAtMaxSnap` is enabled on the sheet. */\n enabled: boolean;\n /** Base horizontal margin from configurator tokens (px). */\n baseMarginHorizontal: number;\n /** Base bottom margin from configurator tokens (px). */\n baseMarginBottom: number;\n /** Resolved snap points array. */\n resolvedSnapPoints: BottomSheetHeight[];\n /** Container height (UI-thread shared value). */\n containerHeight: SharedValue<number>;\n /** Bottom inset in px (margin + safe area). */\n bottomInsetPx: number;\n /** Bottom inset at max snap when expanded (safe area only, no margin). */\n expandedBottomInsetPx: number;\n /** The sheet's animated translateY shared value. */\n translateY: SharedValue<number>;\n}\n\n/**\n * Animates sheet margins from their base values to `0` as the sheet expands\n * from the second-highest snap point to the max snap point.\n *\n * Also returns the interpolation thresholds (`maxSnapTranslateY` and\n * `thresholdTranslateY`) so the caller can animate other properties\n * (e.g. the height constraint's effective bottom inset) in sync.\n *\n * @returns An animated margin style and the expansion interpolation thresholds.\n */\nfunction useExpansionMargins({\n enabled,\n baseMarginHorizontal,\n baseMarginBottom,\n resolvedSnapPoints,\n containerHeight,\n bottomInsetPx,\n expandedBottomInsetPx,\n translateY,\n}: UseExpansionMarginsParams) {\n // Compute threshold and max snap translateY positions.\n // Max snap uses expandedBottomInsetPx (margins collapsed), threshold uses bottomInsetPx.\n const { maxSnapTranslateY, thresholdTranslateY } = useMemo(() => {\n if (!enabled || resolvedSnapPoints.length === 0) {\n return { maxSnapTranslateY: 0, thresholdTranslateY: 0 };\n }\n\n const h = containerHeight.value;\n const maxIdx = resolvedSnapPoints.length - 1;\n const maxHeight = resolveHeightToPx(resolvedSnapPoints[maxIdx]!, h);\n const clampedMax = Math.min(maxHeight, h - expandedBottomInsetPx);\n const maxTransY = h - clampedMax - expandedBottomInsetPx;\n\n // Threshold is the second-highest snap, or the max snap if only one exists.\n const thresholdIdx = clampIndex(maxIdx - 1, resolvedSnapPoints.length);\n const thresholdHeight = resolveHeightToPx(resolvedSnapPoints[thresholdIdx]!, h);\n const clampedThreshold = Math.min(thresholdHeight, h - bottomInsetPx);\n const thresholdTransY = h - clampedThreshold - bottomInsetPx;\n\n return { maxSnapTranslateY: maxTransY, thresholdTranslateY: thresholdTransY };\n }, [enabled, resolvedSnapPoints, containerHeight.value, bottomInsetPx, expandedBottomInsetPx]);\n\n const animatedMarginStyle = useAnimatedStyle(() => {\n if (!enabled) {\n return {};\n }\n\n // When translateY moves from thresholdTranslateY to maxSnapTranslateY\n // (sheet expanding), margins go from base values to 0.\n const mh = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginHorizontal],\n 'clamp',\n );\n const mb = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginBottom],\n 'clamp',\n );\n\n return {\n marginLeft: mh,\n marginRight: mh,\n marginBottom: mb,\n };\n });\n\n return { animatedMarginStyle, maxSnapTranslateY, thresholdTranslateY };\n}\n\nexport { useExpansionMargins };\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAS,oBAAoB,EAC3B,SACA,sBACA,kBACA,oBACA,iBACA,eACA,uBACA,cAC4B;CAG5B,MAAM,EAAE,mBAAmB,wBAAwB,cAAc;AAC/D,MAAI,CAAC,WAAW,mBAAmB,WAAW,EAC5C,QAAO;GAAE,mBAAmB;GAAG,qBAAqB;GAAG;EAGzD,MAAM,IAAI,gBAAgB;EAC1B,MAAM,SAAS,mBAAmB,SAAS;EAC3C,MAAM,YAAY,kBAAkB,mBAAmB,SAAU,EAAE;EAEnE,MAAM,YAAY,IADC,KAAK,IAAI,WAAW,IAAI,sBAAsB,GAC9B;EAInC,MAAM,kBAAkB,kBAAkB,mBADrB,WAAW,SAAS,GAAG,mBAAmB,OAAO,GACO,EAAE;AAI/E,SAAO;GAAE,mBAAmB;GAAW,qBAFf,IADC,KAAK,IAAI,iBAAiB,IAAI,cAAc,GACtB;GAE8B;IAC5E;EAAC;EAAS;EAAoB,gBAAgB;EAAO;EAAe;EAAsB,CAAC;AA6B9F,QAAO;EAAE,qBA3BmB,uBAAuB;AACjD,OAAI,CAAC,QACH,QAAO,EAAE;GAKX,MAAM,KAAK,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,qBAAqB,EACzB,QACD;AAQD,UAAO;IACL,YAAY;IACZ,aAAa;IACb,cAVS,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,iBAAiB,EACrB,QACD;IAMA;IACD;EAE4B;EAAmB;EAAqB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_native = require("react-native");
|
|
6
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
7
|
+
|
|
8
|
+
//#region src/components/BottomSheet/useKeyboardAvoidance.ts
|
|
9
|
+
/** Duration (ms) for the keyboard offset animation. */
|
|
10
|
+
const KEYBOARD_ANIMATION_DURATION = 250;
|
|
11
|
+
/**
|
|
12
|
+
* Offsets the sheet's `translateY` when the software keyboard opens or closes.
|
|
13
|
+
*
|
|
14
|
+
* - **iOS**: Listens to `keyboardWillShow` / `keyboardWillHide` for smoother,
|
|
15
|
+
* synchronous animation with the keyboard.
|
|
16
|
+
* - **Android**: Listens to `keyboardDidShow` / `keyboardDidHide` (will-events
|
|
17
|
+
* are not available on Android).
|
|
18
|
+
*
|
|
19
|
+
* Captures `translateY` before the offset and restores it when the keyboard hides.
|
|
20
|
+
*/
|
|
21
|
+
function useKeyboardAvoidance({ isOpen, translateY, isAnimating }) {
|
|
22
|
+
(0, react.useEffect)(() => {
|
|
23
|
+
if (!isOpen) return;
|
|
24
|
+
let preKeyboardTranslateY = null;
|
|
25
|
+
const showEvent = react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
|
|
26
|
+
const hideEvent = react_native.Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
|
|
27
|
+
const showSub = react_native.Keyboard.addListener(showEvent, (event) => {
|
|
28
|
+
const keyboardHeight = event.endCoordinates.height;
|
|
29
|
+
if (keyboardHeight <= 0) return;
|
|
30
|
+
if (preKeyboardTranslateY === null) preKeyboardTranslateY = translateY.value;
|
|
31
|
+
isAnimating.value = false;
|
|
32
|
+
const target = preKeyboardTranslateY - keyboardHeight;
|
|
33
|
+
translateY.value = (0, react_native_reanimated.withTiming)(Math.max(0, target), { duration: KEYBOARD_ANIMATION_DURATION });
|
|
34
|
+
});
|
|
35
|
+
const hideSub = react_native.Keyboard.addListener(hideEvent, () => {
|
|
36
|
+
if (preKeyboardTranslateY !== null) {
|
|
37
|
+
translateY.value = (0, react_native_reanimated.withTiming)(preKeyboardTranslateY, { duration: KEYBOARD_ANIMATION_DURATION });
|
|
38
|
+
preKeyboardTranslateY = null;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
showSub.remove();
|
|
43
|
+
hideSub.remove();
|
|
44
|
+
};
|
|
45
|
+
}, [
|
|
46
|
+
isOpen,
|
|
47
|
+
translateY,
|
|
48
|
+
isAnimating
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.useKeyboardAvoidance = useKeyboardAvoidance;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import { SharedValue } from "react-native-reanimated";
|
|
3
|
+
|
|
4
|
+
//#region src/components/BottomSheet/useKeyboardAvoidance.d.ts
|
|
5
|
+
/** @internal */
|
|
6
|
+
interface UseKeyboardAvoidanceParams {
|
|
7
|
+
/** Whether the sheet is currently open. */
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
/** The sheet's animated translateY shared value. */
|
|
10
|
+
translateY: SharedValue<number>;
|
|
11
|
+
/** Whether the sheet is currently animating (snap/close spring). */
|
|
12
|
+
isAnimating: SharedValue<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Offsets the sheet's `translateY` when the software keyboard opens or closes.
|
|
16
|
+
*
|
|
17
|
+
* - **iOS**: Listens to `keyboardWillShow` / `keyboardWillHide` for smoother,
|
|
18
|
+
* synchronous animation with the keyboard.
|
|
19
|
+
* - **Android**: Listens to `keyboardDidShow` / `keyboardDidHide` (will-events
|
|
20
|
+
* are not available on Android).
|
|
21
|
+
*
|
|
22
|
+
* Captures `translateY` before the offset and restores it when the keyboard hides.
|
|
23
|
+
*/
|
|
24
|
+
declare function useKeyboardAvoidance({
|
|
25
|
+
isOpen,
|
|
26
|
+
translateY,
|
|
27
|
+
isAnimating
|
|
28
|
+
}: UseKeyboardAvoidanceParams): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useKeyboardAvoidance };
|
|
31
|
+
//# sourceMappingURL=useKeyboardAvoidance.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardAvoidance.d.cts","names":[],"sources":["../../../src/components/BottomSheet/useKeyboardAvoidance.ts"],"mappings":";;;;;UASU,0BAAA;EAAA;EAER,MAAA;;EAEA,UAAA,EAAY,WAAA;EAFZ;EAIA,WAAA,EAAa,WAAA;AAAA;;;;;AAAW;;;;;;iBAajB,oBAAA,CAAA;EAAuB,MAAA;EAAQ,UAAA;EAAY;AAAA,GAAe,0BAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import { SharedValue } from "react-native-reanimated";
|
|
3
|
+
|
|
4
|
+
//#region src/components/BottomSheet/useKeyboardAvoidance.d.ts
|
|
5
|
+
/** @internal */
|
|
6
|
+
interface UseKeyboardAvoidanceParams {
|
|
7
|
+
/** Whether the sheet is currently open. */
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
/** The sheet's animated translateY shared value. */
|
|
10
|
+
translateY: SharedValue<number>;
|
|
11
|
+
/** Whether the sheet is currently animating (snap/close spring). */
|
|
12
|
+
isAnimating: SharedValue<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Offsets the sheet's `translateY` when the software keyboard opens or closes.
|
|
16
|
+
*
|
|
17
|
+
* - **iOS**: Listens to `keyboardWillShow` / `keyboardWillHide` for smoother,
|
|
18
|
+
* synchronous animation with the keyboard.
|
|
19
|
+
* - **Android**: Listens to `keyboardDidShow` / `keyboardDidHide` (will-events
|
|
20
|
+
* are not available on Android).
|
|
21
|
+
*
|
|
22
|
+
* Captures `translateY` before the offset and restores it when the keyboard hides.
|
|
23
|
+
*/
|
|
24
|
+
declare function useKeyboardAvoidance({
|
|
25
|
+
isOpen,
|
|
26
|
+
translateY,
|
|
27
|
+
isAnimating
|
|
28
|
+
}: UseKeyboardAvoidanceParams): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useKeyboardAvoidance };
|
|
31
|
+
//# sourceMappingURL=useKeyboardAvoidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardAvoidance.d.ts","names":[],"sources":["../../../src/components/BottomSheet/useKeyboardAvoidance.ts"],"mappings":";;;;;UASU,0BAAA;EAAA;EAER,MAAA;;EAEA,UAAA,EAAY,WAAA;EAFZ;EAIA,WAAA,EAAa,WAAA;AAAA;;;;;AAAW;;;;;;iBAajB,oBAAA,CAAA;EAAuB,MAAA;EAAQ,UAAA;EAAY;AAAA,GAAe,0BAAA"}
|