@lodev09/react-native-true-sheet 3.10.1 → 3.11.0-beta.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/lib/module/TrueSheet.js +3 -0
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +604 -376
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/TrueSheetProvider.js.map +1 -1
- package/lib/module/TrueSheetProvider.web.js +141 -100
- package/lib/module/TrueSheetProvider.web.js.map +1 -1
- package/lib/module/mocks/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.web.js.map +1 -1
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js +2 -3
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js.map +1 -1
- package/lib/module/web/constants.js +16 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/vaul/README.md +9 -0
- package/lib/module/web/vaul/browser.js +30 -0
- package/lib/module/web/vaul/browser.js.map +1 -0
- package/lib/module/web/vaul/constants.js +14 -0
- package/lib/module/web/vaul/constants.js.map +1 -0
- package/lib/module/web/vaul/context.js +57 -0
- package/lib/module/web/vaul/context.js.map +1 -0
- package/lib/module/web/vaul/helpers.js +93 -0
- package/lib/module/web/vaul/helpers.js.map +1 -0
- package/lib/module/web/vaul/index.js +1206 -0
- package/lib/module/web/vaul/index.js.map +1 -0
- package/lib/module/web/vaul/style.css +264 -0
- package/lib/module/web/vaul/types.js +2 -0
- package/lib/module/web/vaul/types.js.map +1 -0
- package/lib/module/web/vaul/use-composed-refs.js +34 -0
- package/lib/module/web/vaul/use-composed-refs.js.map +1 -0
- package/lib/module/web/vaul/use-controllable-state.js +54 -0
- package/lib/module/web/vaul/use-controllable-state.js.map +1 -0
- package/lib/module/web/vaul/use-position-fixed.js +123 -0
- package/lib/module/web/vaul/use-position-fixed.js.map +1 -0
- package/lib/module/web/vaul/use-prevent-scroll.js +258 -0
- package/lib/module/web/vaul/use-prevent-scroll.js.map +1 -0
- package/lib/module/web/vaul/use-scale-background.js +57 -0
- package/lib/module/web/vaul/use-scale-background.js.map +1 -0
- package/lib/module/web/vaul/use-snap-points.js +294 -0
- package/lib/module/web/vaul/use-snap-points.js.map +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +2 -2
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +79 -36
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts +3 -11
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheetProvider.d.ts +2 -2
- package/lib/typescript/src/TrueSheetProvider.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheetProvider.web.d.ts +17 -14
- package/lib/typescript/src/TrueSheetProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/mocks/index.d.ts +1 -2
- package/lib/typescript/src/mocks/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +1 -1
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts +0 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts +2 -3
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts.map +1 -1
- package/lib/typescript/src/web/constants.d.ts +14 -0
- package/lib/typescript/src/web/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/browser.d.ts +8 -0
- package/lib/typescript/src/web/vaul/browser.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/constants.d.ts +12 -0
- package/lib/typescript/src/web/vaul/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/context.d.ts +45 -0
- package/lib/typescript/src/web/vaul/context.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts +17 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/index.d.ts +210 -0
- package/lib/typescript/src/web/vaul/index.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/types.d.ts +7 -0
- package/lib/typescript/src/web/vaul/types.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts +14 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts +9 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts +19 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts +18 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts +2 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts +37 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/TrueSheet.tsx +9 -1
- package/src/TrueSheet.types.ts +88 -38
- package/src/TrueSheet.web.tsx +675 -450
- package/src/TrueSheetProvider.tsx +2 -4
- package/src/TrueSheetProvider.web.tsx +193 -125
- package/src/mocks/index.ts +1 -2
- package/src/navigation/types.ts +0 -1
- package/src/reanimated/ReanimatedTrueSheet.web.tsx +0 -1
- package/src/reanimated/useReanimatedPositionChangeHandler.web.ts +2 -3
- package/src/web/constants.ts +13 -0
- package/src/web/vaul/README.md +9 -0
- package/src/web/vaul/browser.ts +38 -0
- package/src/web/vaul/constants.ts +18 -0
- package/src/web/vaul/context.ts +87 -0
- package/src/web/vaul/helpers.ts +124 -0
- package/src/web/vaul/index.tsx +1590 -0
- package/src/web/vaul/style.css +264 -0
- package/src/web/vaul/types.ts +7 -0
- package/src/web/vaul/use-composed-refs.ts +35 -0
- package/src/web/vaul/use-controllable-state.ts +66 -0
- package/src/web/vaul/use-position-fixed.ts +147 -0
- package/src/web/vaul/use-prevent-scroll.ts +309 -0
- package/src/web/vaul/use-scale-background.ts +64 -0
- package/src/web/vaul/use-snap-points.ts +433 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './style.css';
|
|
4
|
+
export interface WithFadeFromProps {
|
|
5
|
+
/**
|
|
6
|
+
* Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up.
|
|
7
|
+
* Should go from least visible. Example `[0.2, 0.5, 0.8]`.
|
|
8
|
+
* You can also use px values, which doesn't take screen height into account.
|
|
9
|
+
*/
|
|
10
|
+
snapPoints: (number | string)[];
|
|
11
|
+
/**
|
|
12
|
+
* Index of a `snapPoint` from which the overlay fade should be applied. Defaults to the last snap point.
|
|
13
|
+
*/
|
|
14
|
+
fadeFromIndex: number;
|
|
15
|
+
}
|
|
16
|
+
export interface WithoutFadeFromProps {
|
|
17
|
+
/**
|
|
18
|
+
* Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up.
|
|
19
|
+
* Should go from least visible. Example `[0.2, 0.5, 0.8]`.
|
|
20
|
+
* You can also use px values, which doesn't take screen height into account.
|
|
21
|
+
*/
|
|
22
|
+
snapPoints?: (number | string)[];
|
|
23
|
+
fadeFromIndex?: never;
|
|
24
|
+
}
|
|
25
|
+
export type DialogProps = {
|
|
26
|
+
activeSnapPoint?: number | string | null;
|
|
27
|
+
setActiveSnapPoint?: (snapPoint: number | string | null) => void;
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
open?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Number between 0 and 1 that determines when the drawer should be closed.
|
|
32
|
+
* Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
|
|
33
|
+
* @default 0.25
|
|
34
|
+
*/
|
|
35
|
+
closeThreshold?: number;
|
|
36
|
+
/**
|
|
37
|
+
* When `true` the `body` doesn't get any styles assigned from Vaul
|
|
38
|
+
*/
|
|
39
|
+
noBodyStyles?: boolean;
|
|
40
|
+
onOpenChange?: (open: boolean) => void;
|
|
41
|
+
shouldScaleBackground?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* When `false` we don't change body's background color when the drawer is open.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
setBackgroundColorOnScale?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Duration for which the drawer is not draggable after scrolling content inside of the drawer.
|
|
49
|
+
* @default 500ms
|
|
50
|
+
*/
|
|
51
|
+
scrollLockTimeout?: number;
|
|
52
|
+
/**
|
|
53
|
+
* When `true`, don't move the drawer upwards if there's space, but rather only change it's height so it's fully scrollable when the keyboard is open
|
|
54
|
+
*/
|
|
55
|
+
fixed?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `true` only allows the drawer to be dragged by the `<Drawer.Handle />` component.
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
handleOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* When `false` dragging, clicking outside, pressing esc, etc. will not close the drawer.
|
|
63
|
+
* Use this in comination with the `open` prop, otherwise you won't be able to open/close the drawer.
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
dismissible?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* When `false` the drawer can't be dragged by the user. Programmatic snap-point
|
|
69
|
+
* changes still animate. Defaults to `true`.
|
|
70
|
+
*/
|
|
71
|
+
draggable?: boolean;
|
|
72
|
+
onDrag?: (event: React.PointerEvent<HTMLDivElement>, percentageDragged: number) => void;
|
|
73
|
+
onRelease?: (event: React.PointerEvent<HTMLDivElement>, open: boolean) => void;
|
|
74
|
+
/**
|
|
75
|
+
* When `false` it allows to interact with elements outside of the drawer without closing it.
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
modal?: boolean;
|
|
79
|
+
nested?: boolean;
|
|
80
|
+
onClose?: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* Direction of the drawer. Can be `top` or `bottom`, `left`, `right`.
|
|
83
|
+
* @default 'bottom'
|
|
84
|
+
*/
|
|
85
|
+
direction?: 'top' | 'bottom' | 'left' | 'right';
|
|
86
|
+
/**
|
|
87
|
+
* Opened by default, skips initial enter animation. Still reacts to `open` state changes
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
defaultOpen?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* When set to `true` prevents scrolling on the document body on mount, and restores it on unmount.
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
disablePreventScroll?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* When `true` Vaul will reposition inputs rather than scroll then into view if the keyboard is in the way.
|
|
98
|
+
* Setting it to `false` will fall back to the default browser behavior.
|
|
99
|
+
* @default true when {@link snapPoints} is defined
|
|
100
|
+
*/
|
|
101
|
+
repositionInputs?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Disabled velocity based swiping for snap points.
|
|
104
|
+
* This means that a snap point won't be skipped even if the velocity is high enough.
|
|
105
|
+
* Useful if each snap point in a drawer is equally important.
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
snapToSequentialPoint?: boolean;
|
|
109
|
+
container?: HTMLElement | null;
|
|
110
|
+
/**
|
|
111
|
+
* Gets triggered after the open or close animation ends, it receives an `open` argument with the `open` state of the drawer by the time the function was triggered.
|
|
112
|
+
* Useful to revert any state changes for example.
|
|
113
|
+
*/
|
|
114
|
+
onAnimationEnd?: (open: boolean) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Fires on every animation frame while the drawer is open with the drawer's
|
|
117
|
+
* current top edge in the viewport (px). Emits during drag, snap, and the
|
|
118
|
+
* open/close transitions.
|
|
119
|
+
*/
|
|
120
|
+
onPositionChange?: (position: number) => void;
|
|
121
|
+
preventScrollRestoration?: boolean;
|
|
122
|
+
autoFocus?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Renders the drawer as a floating card offset from the bottom edge so it
|
|
125
|
+
* doesn't visually attach to the viewport. Snap points are computed against
|
|
126
|
+
* the reduced floating area, so {@link detachedOffset} is preserved during
|
|
127
|
+
* drag and snap.
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
detached?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Gap (in px) between the drawer's bottom edge and the viewport bottom when
|
|
133
|
+
* {@link detached} is `true`.
|
|
134
|
+
* @default 0
|
|
135
|
+
*/
|
|
136
|
+
detachedOffset?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Corner radius (in px) applied to the clip wrapper's bottom when
|
|
139
|
+
* {@link detached} is `true`, so the floating card's bottom edge stays
|
|
140
|
+
* rounded while it's clipped at the floating anchor.
|
|
141
|
+
* @default 0
|
|
142
|
+
*/
|
|
143
|
+
detachedRadius?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Extra styles merged into the detached clip wrapper. Use this to match the
|
|
146
|
+
* wrapper's horizontal bounds to the drawer's on desktop (e.g. `maxWidth` +
|
|
147
|
+
* auto margins) so its rounded-bottom clip aligns with the drawer.
|
|
148
|
+
*/
|
|
149
|
+
detachedWrapperStyle?: React.CSSProperties;
|
|
150
|
+
/**
|
|
151
|
+
* Caps the visible sheet height (in px) so full and 'auto' snap points
|
|
152
|
+
* respect a user-specified ceiling.
|
|
153
|
+
*/
|
|
154
|
+
maxContentHeight?: number;
|
|
155
|
+
/**
|
|
156
|
+
* When `false` the first snap on mount is applied without a transition so
|
|
157
|
+
* the sheet appears at its target detent instantly. Defaults to `true`.
|
|
158
|
+
*/
|
|
159
|
+
initialAnimated?: boolean;
|
|
160
|
+
} & (WithFadeFromProps | WithoutFadeFromProps);
|
|
161
|
+
export declare function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground, setBackgroundColorOnScale, closeThreshold, scrollLockTimeout, dismissible, draggable, handleOnly, fadeFromIndex, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal, onClose, nested, noBodyStyles, direction, defaultOpen, disablePreventScroll, snapToSequentialPoint, preventScrollRestoration, repositionInputs, onAnimationEnd, onPositionChange, container, autoFocus, detached, detachedOffset, detachedRadius, detachedWrapperStyle, maxContentHeight, initialAnimated, }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
162
|
+
export declare const Overlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
163
|
+
export type ContentProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
|
164
|
+
/**
|
|
165
|
+
* Extra nodes rendered inside the detached clip wrapper as siblings of the
|
|
166
|
+
* drawer. Use for floating elements (e.g. a footer) that should slide with
|
|
167
|
+
* the wrapper on dismiss and drag-overshoot instead of staying pinned.
|
|
168
|
+
*/
|
|
169
|
+
detachedSiblings?: React.ReactNode;
|
|
170
|
+
};
|
|
171
|
+
export declare const Content: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
172
|
+
/**
|
|
173
|
+
* Extra nodes rendered inside the detached clip wrapper as siblings of the
|
|
174
|
+
* drawer. Use for floating elements (e.g. a footer) that should slide with
|
|
175
|
+
* the wrapper on dismiss and drag-overshoot instead of staying pinned.
|
|
176
|
+
*/
|
|
177
|
+
detachedSiblings?: React.ReactNode;
|
|
178
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
179
|
+
export type HandleProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
180
|
+
preventCycle?: boolean;
|
|
181
|
+
};
|
|
182
|
+
export declare const Handle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
183
|
+
preventCycle?: boolean;
|
|
184
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
185
|
+
export declare function NestedRoot({ onDrag, onOpenChange, open: nestedIsOpen, ...rest }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
186
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Portal>;
|
|
187
|
+
export declare function Portal(props: PortalProps): import("react/jsx-runtime").JSX.Element;
|
|
188
|
+
export declare const Drawer: {
|
|
189
|
+
Root: typeof Root;
|
|
190
|
+
NestedRoot: typeof NestedRoot;
|
|
191
|
+
Content: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
192
|
+
/**
|
|
193
|
+
* Extra nodes rendered inside the detached clip wrapper as siblings of the
|
|
194
|
+
* drawer. Use for floating elements (e.g. a footer) that should slide with
|
|
195
|
+
* the wrapper on dismiss and drag-overshoot instead of staying pinned.
|
|
196
|
+
*/
|
|
197
|
+
detachedSiblings?: React.ReactNode;
|
|
198
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
199
|
+
Overlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
200
|
+
Trigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
201
|
+
Portal: typeof Portal;
|
|
202
|
+
Handle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
203
|
+
preventCycle?: boolean;
|
|
204
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
205
|
+
Close: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
206
|
+
Title: React.ForwardRefExoticComponent<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
207
|
+
Description: React.ForwardRefExoticComponent<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
208
|
+
};
|
|
209
|
+
export {};
|
|
210
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/index.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAClE,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* A utility to compose multiple refs together
|
|
5
|
+
* Accepts callback refs and RefObject(s)
|
|
6
|
+
*/
|
|
7
|
+
declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
|
|
8
|
+
/**
|
|
9
|
+
* A custom hook that composes multiple refs
|
|
10
|
+
* Accepts callback refs and RefObject(s)
|
|
11
|
+
*/
|
|
12
|
+
declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
|
|
13
|
+
export { composeRefs, useComposedRefs };
|
|
14
|
+
//# sourceMappingURL=use-composed-refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-composed-refs.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-composed-refs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAc/C;;;GAGG;AACH,iBAAS,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IACvC,MAAM,CAAC,UAChB;AAED;;;GAGG;AACH,iBAAS,eAAe,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,qBAEpD;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type UseControllableStateParams<T> = {
|
|
3
|
+
prop?: T | undefined;
|
|
4
|
+
defaultProp?: T | undefined;
|
|
5
|
+
onChange?: (state: T) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function useControllableState<T>({ prop, defaultProp, onChange, }: UseControllableStateParams<T>): readonly [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>];
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=use-controllable-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-controllable-state.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-controllable-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,0BAA0B,CAAC,CAAC,IAAI;IACnC,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B,CAAC;AAiCF,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,EACtC,IAAI,EACJ,WAAW,EACX,QAAmB,GACpB,EAAE,0BAA0B,CAAC,CAAC,CAAC,iFAoB/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hook is necessary to prevent buggy behavior on iOS devices (need to test on Android).
|
|
3
|
+
* I won't get into too much detail about what bugs it solves, but so far I've found that setting the body to `position: fixed` is the most reliable way to prevent those bugs.
|
|
4
|
+
* Issues that this hook solves:
|
|
5
|
+
* https://github.com/emilkowalski/vaul/issues/435
|
|
6
|
+
* https://github.com/emilkowalski/vaul/issues/433
|
|
7
|
+
* And more that I discovered, but were just not reported.
|
|
8
|
+
*/
|
|
9
|
+
export declare function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollRestoration, noBodyStyles, }: {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
modal: boolean;
|
|
12
|
+
nested: boolean;
|
|
13
|
+
hasBeenOpened: boolean;
|
|
14
|
+
preventScrollRestoration: boolean;
|
|
15
|
+
noBodyStyles: boolean;
|
|
16
|
+
}): {
|
|
17
|
+
restorePositionSetting: () => void;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=use-position-fixed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-position-fixed.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-position-fixed.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AAEH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,KAAK,EACL,MAAM,EACN,aAAa,EACb,wBAAwB,EACxB,YAAY,GACb,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;CACvB;;EAsHA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
3
|
+
interface PreventScrollOptions {
|
|
4
|
+
/** Whether the scroll lock is disabled. */
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
focusCallback?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function isScrollable(node: Element): boolean;
|
|
9
|
+
export declare function getScrollParent(node: Element): Element;
|
|
10
|
+
/**
|
|
11
|
+
* Prevents scrolling on the document body on mount, and
|
|
12
|
+
* restores it on unmount. Also ensures that content does not
|
|
13
|
+
* shift due to the scrollbars disappearing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePreventScroll(options?: PreventScrollOptions): void;
|
|
16
|
+
export declare function isInput(target: Element): boolean;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=use-prevent-scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-prevent-scroll.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-prevent-scroll.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAKnD,eAAO,MAAM,yBAAyB,wBACuB,CAAC;AAE9D,UAAU,oBAAoB;IAC5B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAeD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGnD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAUtD;AAmBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,oBAAyB,QAsBlE;AAoND,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,WAMtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-scale-background.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-scale-background.ts"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,SAuDjC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DrawerDirection } from './types';
|
|
3
|
+
export declare function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction, container, snapToSequentialPoint, isOpen, contentHeight, detachedOffset, maxContentHeight, initialAnimated, }: {
|
|
4
|
+
activeSnapPointProp?: number | string | null;
|
|
5
|
+
setActiveSnapPointProp?(snapPoint: number | null | string): void;
|
|
6
|
+
snapPoints?: (number | string)[];
|
|
7
|
+
fadeFromIndex?: number;
|
|
8
|
+
drawerRef: React.RefObject<HTMLDivElement | null>;
|
|
9
|
+
overlayRef: React.RefObject<HTMLDivElement | null>;
|
|
10
|
+
onSnapPointChange(activeSnapPointIndex: number): void;
|
|
11
|
+
direction?: DrawerDirection;
|
|
12
|
+
container?: HTMLElement | null | undefined;
|
|
13
|
+
snapToSequentialPoint?: boolean;
|
|
14
|
+
isOpen?: boolean;
|
|
15
|
+
contentHeight?: number;
|
|
16
|
+
detachedOffset?: number;
|
|
17
|
+
maxContentHeight?: number;
|
|
18
|
+
initialAnimated?: boolean;
|
|
19
|
+
}): {
|
|
20
|
+
isLastSnapPoint: true | null;
|
|
21
|
+
activeSnapPoint: string | number | null | undefined;
|
|
22
|
+
shouldFade: boolean;
|
|
23
|
+
getPercentageDragged: (absDraggedDistance: number, isDraggingDown: boolean) => number | null;
|
|
24
|
+
setActiveSnapPoint: React.Dispatch<React.SetStateAction<string | number | null | undefined>>;
|
|
25
|
+
activeSnapPointIndex: number | null;
|
|
26
|
+
onRelease: ({ draggedDistance, closeDrawer, velocity, dismissible, }: {
|
|
27
|
+
draggedDistance: number;
|
|
28
|
+
closeDrawer: () => void;
|
|
29
|
+
velocity: number;
|
|
30
|
+
dismissible: boolean;
|
|
31
|
+
}) => void;
|
|
32
|
+
onDrag: ({ draggedDistance }: {
|
|
33
|
+
draggedDistance: number;
|
|
34
|
+
}) => void;
|
|
35
|
+
snapPointsOffset: number[];
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=use-snap-points.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-snap-points.d.ts","sourceRoot":"","sources":["../../../../../src/web/vaul/use-snap-points.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,aAAa,CAAC,EAC5B,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,SAAoB,EACpB,SAAS,EACT,qBAAqB,EACrB,MAAM,EACN,aAAa,EACb,cAAkB,EAClB,gBAAgB,EAChB,eAAsB,GACvB,EAAE;IACD,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,sBAAsB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACjE,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,iBAAiB,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;+CAsUmD,MAAM,kBAAkB,OAAO;;;0EA3H9E;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,IAAI,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,OAAO,CAAC;KACtB;kCA4EoC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE;;EA6GjE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0-beta.0",
|
|
4
4
|
"description": "The true native bottom sheet experience for your React Native Apps.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@eslint/eslintrc": "^3.3.1",
|
|
89
89
|
"@eslint/js": "^9.35.0",
|
|
90
90
|
"@evilmartians/lefthook": "^2.0.4",
|
|
91
|
-
"@
|
|
91
|
+
"@radix-ui/react-dialog": "^1.1.1",
|
|
92
92
|
"@react-native/babel-preset": "^0.83.4",
|
|
93
93
|
"@react-native/eslint-config": "^0.83.4",
|
|
94
94
|
"@react-navigation/native": "^7.1.6",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"react-native-worklets": "0.7.2"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
|
-
"@
|
|
124
|
+
"@radix-ui/react-dialog": ">=1",
|
|
125
125
|
"@react-navigation/native": ">=7",
|
|
126
126
|
"react": "*",
|
|
127
127
|
"react-native": "*",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"react-native-worklets": "*"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|
|
132
|
-
"@
|
|
132
|
+
"@radix-ui/react-dialog": {
|
|
133
133
|
"optional": true
|
|
134
134
|
},
|
|
135
135
|
"@react-navigation/native": {
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import type {
|
|
12
12
|
TrueSheetProps,
|
|
13
|
+
TrueSheetMethods,
|
|
14
|
+
TrueSheetStaticMethods,
|
|
13
15
|
DragBeginEvent,
|
|
14
16
|
DragChangeEvent,
|
|
15
17
|
DragEndEvent,
|
|
@@ -59,7 +61,10 @@ interface TrueSheetState {
|
|
|
59
61
|
shouldRenderNativeView: boolean;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export class TrueSheet
|
|
64
|
+
export class TrueSheet
|
|
65
|
+
extends PureComponent<TrueSheetProps, TrueSheetState>
|
|
66
|
+
implements TrueSheetMethods
|
|
67
|
+
{
|
|
63
68
|
displayName = 'TrueSheet';
|
|
64
69
|
|
|
65
70
|
private readonly nativeRef: RefObject<NativeRef | null>;
|
|
@@ -548,6 +553,9 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
548
553
|
}
|
|
549
554
|
}
|
|
550
555
|
|
|
556
|
+
// Compile-time check: `TrueSheet`'s static surface must satisfy `TrueSheetStaticMethods`.
|
|
557
|
+
TrueSheet satisfies TrueSheetStaticMethods;
|
|
558
|
+
|
|
551
559
|
const styles = StyleSheet.create({
|
|
552
560
|
sheetView: {
|
|
553
561
|
...StyleSheet.absoluteFill,
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -154,30 +154,6 @@ export interface BlurOptions {
|
|
|
154
154
|
interaction?: boolean;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* Defines the stack behavior when a modal is presented on web.
|
|
159
|
-
*
|
|
160
|
-
* @platform web
|
|
161
|
-
*/
|
|
162
|
-
export type StackBehavior =
|
|
163
|
-
/**
|
|
164
|
-
* Mount the modal on top of the current one.
|
|
165
|
-
*/
|
|
166
|
-
| 'push'
|
|
167
|
-
/**
|
|
168
|
-
* Minimize the current modal then mount the new one.
|
|
169
|
-
*/
|
|
170
|
-
| 'switch'
|
|
171
|
-
/**
|
|
172
|
-
* Dismiss the current modal then mount the new one.
|
|
173
|
-
*/
|
|
174
|
-
| 'replace'
|
|
175
|
-
/**
|
|
176
|
-
* Use a regular BottomSheet instead of BottomSheetModal.
|
|
177
|
-
* This bypasses the modal stack entirely.
|
|
178
|
-
*/
|
|
179
|
-
| 'none';
|
|
180
|
-
|
|
181
157
|
/**
|
|
182
158
|
* Inset adjustment behavior for the sheet content.
|
|
183
159
|
*/
|
|
@@ -354,11 +330,11 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
354
330
|
grabberOptions?: GrabberOptions;
|
|
355
331
|
|
|
356
332
|
/**
|
|
357
|
-
* Controls the sheet presentation style on iPad.
|
|
333
|
+
* Controls the sheet presentation style on iPad and web (landscape/tablet).
|
|
358
334
|
* When enabled (true), uses a large page sheet for better readability.
|
|
359
335
|
* When disabled (false), uses a centered form sheet.
|
|
360
336
|
*
|
|
361
|
-
* @platform ios 17
|
|
337
|
+
* @platform ios 17+, web
|
|
362
338
|
* @default true
|
|
363
339
|
*/
|
|
364
340
|
pageSizing?: boolean;
|
|
@@ -489,18 +465,6 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
489
465
|
*/
|
|
490
466
|
detachedOffset?: number;
|
|
491
467
|
|
|
492
|
-
/**
|
|
493
|
-
* Defines the stack behavior when a modal is presented.
|
|
494
|
-
* - `push`: Mount the modal on top of the current one.
|
|
495
|
-
* - `switch`: Minimize the current modal then mount the new one.
|
|
496
|
-
* - `replace`: Dismiss the current modal then mount the new one.
|
|
497
|
-
* - `none`: Use a regular BottomSheet instead of BottomSheetModal.
|
|
498
|
-
*
|
|
499
|
-
* @platform web
|
|
500
|
-
* @default 'switch'
|
|
501
|
-
*/
|
|
502
|
-
stackBehavior?: StackBehavior;
|
|
503
|
-
|
|
504
468
|
/**
|
|
505
469
|
* Called when the sheet's content is mounted and ready.
|
|
506
470
|
* The sheet automatically waits for this event before presenting.
|
|
@@ -587,3 +551,89 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
587
551
|
*/
|
|
588
552
|
onBackPress?: () => boolean | void;
|
|
589
553
|
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Imperative methods available on a TrueSheet ref.
|
|
557
|
+
*
|
|
558
|
+
* Example:
|
|
559
|
+
* ```tsx
|
|
560
|
+
* const sheetRef = useRef<TrueSheetMethods>(null);
|
|
561
|
+
* sheetRef.current?.present();
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
export interface TrueSheetMethods {
|
|
565
|
+
/**
|
|
566
|
+
* Present the sheet at a given detent index.
|
|
567
|
+
*
|
|
568
|
+
* @param index - The detent index to present at (default: `0`).
|
|
569
|
+
* @param animated - Whether to animate the presentation (default: `true`). Ignored on web.
|
|
570
|
+
*/
|
|
571
|
+
present(index?: number, animated?: boolean): Promise<void>;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Resize the sheet to a given detent index.
|
|
575
|
+
*
|
|
576
|
+
* @param index - The detent index to resize to.
|
|
577
|
+
*/
|
|
578
|
+
resize(index: number): Promise<void>;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Dismiss this sheet and all sheets presented on top of it in a single animation.
|
|
582
|
+
*
|
|
583
|
+
* @param animated - Whether to animate the dismissal (default: `true`). Ignored on web.
|
|
584
|
+
*/
|
|
585
|
+
dismiss(animated?: boolean): Promise<void>;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Dismiss only the sheets presented on top of this sheet, keeping this sheet presented.
|
|
589
|
+
* No-op if no sheets are presented on top.
|
|
590
|
+
*
|
|
591
|
+
* @param animated - Whether to animate the dismissal (default: `true`). Ignored on web.
|
|
592
|
+
*/
|
|
593
|
+
dismissStack(animated?: boolean): Promise<void>;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Static methods exposed on the `TrueSheet` component for controlling sheets by `name`.
|
|
598
|
+
*
|
|
599
|
+
* Example:
|
|
600
|
+
* ```ts
|
|
601
|
+
* TrueSheet.present('my-sheet')
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* @note Not supported on web — use the `useTrueSheet()` hook instead.
|
|
605
|
+
*/
|
|
606
|
+
export interface TrueSheetStaticMethods {
|
|
607
|
+
/**
|
|
608
|
+
* Present the sheet with the given `name`.
|
|
609
|
+
*
|
|
610
|
+
* @throws if no sheet with the given `name` is registered.
|
|
611
|
+
*/
|
|
612
|
+
present(name: string, index?: number, animated?: boolean): Promise<void>;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Resize the sheet with the given `name`.
|
|
616
|
+
*
|
|
617
|
+
* @throws if no sheet with the given `name` is registered.
|
|
618
|
+
*/
|
|
619
|
+
resize(name: string, index: number): Promise<void>;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Dismiss the sheet with the given `name` and all sheets presented on top of it.
|
|
623
|
+
*
|
|
624
|
+
* @throws if no sheet with the given `name` is registered.
|
|
625
|
+
*/
|
|
626
|
+
dismiss(name: string, animated?: boolean): Promise<void>;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Dismiss only the sheets presented on top of the sheet with the given `name`.
|
|
630
|
+
*
|
|
631
|
+
* @throws if no sheet with the given `name` is registered.
|
|
632
|
+
*/
|
|
633
|
+
dismissStack(name: string, animated?: boolean): Promise<void>;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Dismiss every presented sheet, from the top of the stack downward.
|
|
637
|
+
*/
|
|
638
|
+
dismissAll(animated?: boolean): Promise<void>;
|
|
639
|
+
}
|