react-modal-sheet 5.5.0 → 5.7.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/src/types.tsx CHANGED
@@ -103,7 +103,7 @@ export type SheetSnapPoint = {
103
103
  snapValueY: number; // Y value is inverted as `y = 0` means sheet is at the top
104
104
  };
105
105
 
106
- export interface SheetContextType {
106
+ export interface InternalContextType {
107
107
  currentSnap?: number;
108
108
  detent: SheetDetent;
109
109
  disableDrag: boolean;
@@ -114,9 +114,20 @@ export interface SheetContextType {
114
114
  sheetBoundsRef: (node: HTMLDivElement | null) => void;
115
115
  sheetRef: RefObject<any>;
116
116
  unstyled: boolean;
117
+ yProgress: MotionValue<number>;
117
118
  y: MotionValue<any>;
118
119
  }
119
120
 
121
+ export interface ExposedContextType {
122
+ currentSnap?: number;
123
+ height: number;
124
+ snapPoints: SheetSnapPoint[];
125
+ snapTo: (index: number) => void;
126
+ y: MotionValue<number>;
127
+ yInverted: MotionValue<number>;
128
+ yProgress: MotionValue<number>;
129
+ }
130
+
120
131
  export interface SheetScrollerContextType {
121
132
  disableDrag: boolean;
122
133
  setDragDisabled: () => void;
@@ -149,6 +160,7 @@ interface SheetCompoundComponent {
149
160
  DragIndicator: FunctionComponent<SheetDragIndicatorProps>;
150
161
  Content: ContentComponent;
151
162
  Backdrop: BackdropComponent;
163
+ useContext: () => ExposedContextType;
152
164
  }
153
165
 
154
166
  export type SheetCompound = SheetComponent & SheetCompoundComponent;
package/src/utils.ts CHANGED
@@ -114,3 +114,7 @@ export function willOpenKeyboard(target: Element) {
114
114
  export function isHTTPS() {
115
115
  return typeof window !== 'undefined' && window.isSecureContext;
116
116
  }
117
+
118
+ export function clamp(value: number, min: number, max: number) {
119
+ return Math.min(Math.max(value, min), max);
120
+ }