@mrmeg/expo-ui 0.7.1 → 0.7.3
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/components/BottomSheet.d.ts +92 -16
- package/dist/components/BottomSheet.js +205 -411
- package/dist/components/Dialog.js +16 -8
- package/dist/components/SegmentedControl.d.ts +52 -0
- package/dist/components/SegmentedControl.js +25 -0
- package/dist/components/Slider.d.ts +23 -3
- package/dist/components/Slider.js +26 -147
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +10 -2
- package/dist/components/TextInput.d.ts +1 -1
- package/dist/components/TextInput.js +121 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +4 -2
- package/dist/components/BottomSheetKeyboard.d.ts +0 -7
- package/dist/components/BottomSheetKeyboard.js +0 -35
|
@@ -1,24 +1,102 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ViewProps, StyleProp, ViewStyle, ScrollViewProps } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* BottomSheet — a sliding bottom sheet with a compound API, backed by the
|
|
5
|
+
* platform's native sheet via `@expo/ui/community/bottom-sheet`:
|
|
6
|
+
*
|
|
7
|
+
* - iOS: SwiftUI `.sheet()` with presentation detents
|
|
8
|
+
* - Android: Material3 `ModalBottomSheet`
|
|
9
|
+
* - Web: `vaul` drawer (bundled with @expo/ui)
|
|
10
|
+
*
|
|
11
|
+
* The compound surface (Trigger / Content / Handle / Header / Body / Footer /
|
|
12
|
+
* Close), controlled + uncontrolled state, and theming match a hand-rolled
|
|
13
|
+
* sheet, but the platform owns gestures and keyboard avoidance — so there's no
|
|
14
|
+
* PanResponder, snap-physics, or keyboard lift-and-shrink code to maintain.
|
|
15
|
+
*
|
|
16
|
+
* Platform-owned behaviors (props accepted for ergonomics, but the platform
|
|
17
|
+
* decides):
|
|
18
|
+
* - `.Handle` is a no-op: the platform draws the drag indicator.
|
|
19
|
+
* - `swipeEnabled` / `avoidKeyboard` / `dismissKeyboardOnDrag` are accepted
|
|
20
|
+
* for call-site ergonomics but have no effect — the platform handles them.
|
|
21
|
+
* - Sheet *chrome* (corner radius, system background, safe area) is the
|
|
22
|
+
* platform's on native; theming reaches the content + background color.
|
|
23
|
+
* - On Android only two snap states exist (partial / expanded); extra snap
|
|
24
|
+
* points map to the nearest of those two.
|
|
25
|
+
*
|
|
26
|
+
* Scrollable bodies: the native sheet doesn't bound the hosted RN content to
|
|
27
|
+
* the detent height, so a tall `Body` overflows and clips its footer/tail. When
|
|
28
|
+
* `Body` detects overflow, `Content` caps the column to the detent height so the
|
|
29
|
+
* `ScrollView` actually scrolls to the bottom. Swipe-to-dismiss still works (the
|
|
30
|
+
* native sheet coordinates the pan: a pull at the top of the scroll view
|
|
31
|
+
* dismisses, elsewhere it scrolls). A close affordance is also surfaced for
|
|
32
|
+
* scrollable sheets so there's a one-tap close: the `Header` renders a trailing
|
|
33
|
+
* X, or — if there's no `Header` — `Content` floats one in the top-right corner.
|
|
34
|
+
* No extra props required.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <BottomSheet open={open} onOpenChange={setOpen} snapPoints={["50%"]}>
|
|
39
|
+
* <BottomSheet.Trigger asChild>
|
|
40
|
+
* <Button>Open</Button>
|
|
41
|
+
* </BottomSheet.Trigger>
|
|
42
|
+
* <BottomSheet.Content>
|
|
43
|
+
* <BottomSheet.Header>
|
|
44
|
+
* <SansSerifBoldText>Title</SansSerifBoldText>
|
|
45
|
+
* </BottomSheet.Header>
|
|
46
|
+
* <BottomSheet.Body>
|
|
47
|
+
* <SansSerifText>Content</SansSerifText>
|
|
48
|
+
* </BottomSheet.Body>
|
|
49
|
+
* <BottomSheet.Footer>
|
|
50
|
+
* <Button>Action</Button>
|
|
51
|
+
* </BottomSheet.Footer>
|
|
52
|
+
* </BottomSheet.Content>
|
|
53
|
+
* </BottomSheet>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
3
56
|
type SnapPoint = number | `${number}%`;
|
|
4
57
|
interface BottomSheetContextValue {
|
|
5
58
|
open: boolean;
|
|
6
59
|
onOpenChange: (open: boolean) => void;
|
|
7
60
|
toggle: () => void;
|
|
8
|
-
snapPoints:
|
|
9
|
-
currentSnapIndex: number;
|
|
61
|
+
snapPoints: SnapPoint[];
|
|
10
62
|
closeOnBackdropPress: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* True when a `Body`'s content overflows its viewport (is genuinely
|
|
65
|
+
* scrollable). Drives two things: `Content` caps the column to the detent
|
|
66
|
+
* height so the `ScrollView` can reach its bottom, and a close affordance is
|
|
67
|
+
* surfaced (a `Header` X, or floating if there's no `Header`) so a long sheet
|
|
68
|
+
* always has a one-tap close. Set by `Body`.
|
|
69
|
+
*/
|
|
70
|
+
scrollable: boolean;
|
|
71
|
+
setScrollable: (scrollable: boolean) => void;
|
|
72
|
+
/** Whether a `Header` is mounted, so `Content` knows to render a fallback close. */
|
|
73
|
+
hasHeader: boolean;
|
|
74
|
+
setHasHeader: (present: boolean) => void;
|
|
75
|
+
/** Whether a `Footer` is mounted, so `Body` can own the bottom safe-area inset when it isn't. */
|
|
76
|
+
hasFooter: boolean;
|
|
77
|
+
setHasFooter: (present: boolean) => void;
|
|
11
78
|
}
|
|
12
79
|
interface BottomSheetProps {
|
|
13
|
-
/** Controlled open state */
|
|
80
|
+
/** Controlled open state. Omit to use uncontrolled mode with `defaultOpen`. */
|
|
14
81
|
open?: boolean;
|
|
15
|
-
/** Callback when open state changes */
|
|
82
|
+
/** Callback when open state changes. */
|
|
16
83
|
onOpenChange?: (open: boolean) => void;
|
|
17
|
-
/**
|
|
84
|
+
/** Initial open state for uncontrolled mode. Default: false. */
|
|
18
85
|
defaultOpen?: boolean;
|
|
19
|
-
/** Snap point heights (px or percentage strings) */
|
|
86
|
+
/** Snap point heights (px or percentage strings). Default: ["50%"]. */
|
|
20
87
|
snapPoints?: SnapPoint[];
|
|
21
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Whether swiping/pulling down (or tapping the backdrop) dismisses the sheet.
|
|
90
|
+
* Maps to the native sheet's `enablePanDownToClose` (iOS
|
|
91
|
+
* `interactiveDismissDisabled`). Default: true.
|
|
92
|
+
*
|
|
93
|
+
* Works with scrollable bodies — the native sheet coordinates the pan (pull at
|
|
94
|
+
* the top of the scroll view dismisses, elsewhere it scrolls). Set to `false`
|
|
95
|
+
* to disable dismiss entirely; the sheet then surfaces an explicit close
|
|
96
|
+
* affordance automatically (a `Header` X, or a floating X if there's no
|
|
97
|
+
* `Header`). Scrollable sheets also get that close affordance regardless, so
|
|
98
|
+
* there's always a one-tap close.
|
|
99
|
+
*/
|
|
22
100
|
closeOnBackdropPress?: boolean;
|
|
23
101
|
children: React.ReactNode;
|
|
24
102
|
}
|
|
@@ -28,13 +106,11 @@ interface BottomSheetTriggerProps {
|
|
|
28
106
|
style?: StyleProp<ViewStyle>;
|
|
29
107
|
}
|
|
30
108
|
interface BottomSheetContentProps extends ViewProps {
|
|
31
|
-
/**
|
|
109
|
+
/** Accepted for call-site ergonomics; ignored (platform owns gestures). */
|
|
32
110
|
swipeEnabled?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
velocityThreshold?: number;
|
|
35
|
-
/** Whether to move the sheet with the native keyboard animation. Default: true. */
|
|
111
|
+
/** Accepted for call-site ergonomics; ignored (platform owns keyboard avoidance). */
|
|
36
112
|
avoidKeyboard?: boolean;
|
|
37
|
-
/**
|
|
113
|
+
/** Accepted for call-site ergonomics; ignored (platform owns keyboard). */
|
|
38
114
|
dismissKeyboardOnDrag?: boolean;
|
|
39
115
|
style?: StyleProp<ViewStyle>;
|
|
40
116
|
children: React.ReactNode;
|
|
@@ -57,12 +133,12 @@ interface BottomSheetCloseProps {
|
|
|
57
133
|
style?: StyleProp<ViewStyle>;
|
|
58
134
|
}
|
|
59
135
|
declare function useBottomSheetContext(): BottomSheetContextValue;
|
|
60
|
-
declare function BottomSheetRoot({ open: controlledOpen, onOpenChange: controlledOnOpenChange, defaultOpen, snapPoints
|
|
136
|
+
declare function BottomSheetRoot({ open: controlledOpen, onOpenChange: controlledOnOpenChange, defaultOpen, snapPoints, closeOnBackdropPress, children, }: BottomSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
61
137
|
declare function BottomSheetTrigger({ asChild, children, style: styleOverride }: BottomSheetTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
-
declare function BottomSheetContent({ swipeEnabled
|
|
63
|
-
declare function BottomSheetHandle(
|
|
138
|
+
declare function BottomSheetContent({ swipeEnabled: _swipeEnabled, avoidKeyboard: _avoidKeyboard, dismissKeyboardOnDrag: _dismissKeyboardOnDrag, style: styleOverride, children, }: BottomSheetContentProps): import("react/jsx-runtime").JSX.Element;
|
|
139
|
+
declare function BottomSheetHandle(_props: BottomSheetHandleProps): null;
|
|
64
140
|
declare function BottomSheetHeader({ children, style, ...props }: BottomSheetHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
-
declare function BottomSheetBody({ children, style, ...props }: BottomSheetBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
141
|
+
declare function BottomSheetBody({ children, style, contentContainerStyle, onContentSizeChange, onLayout, ...props }: BottomSheetBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
66
142
|
declare function BottomSheetFooter({ children, style, ...props }: BottomSheetFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
67
143
|
declare function BottomSheetClose({ asChild, children, style: styleOverride }: BottomSheetCloseProps): import("react/jsx-runtime").JSX.Element;
|
|
68
144
|
declare const BottomSheet: typeof BottomSheetRoot & {
|