UNPKG

@bottom-sheet/state-machine

Version:

The bottom-sheet brains, built on xstate

85 lines (83 loc) 2.82 kB
import { GetInitialHeight, GetSnapPoints, SnapPoints } from "@bottom-sheet/types"; export const assignSnapPoints: (getSnapPoints: GetSnapPoints) => import("xstate").AssignAction<BottomSheetContext, import("xstate").EventObject>; export const assignInitialHeight: (getInitialHeight: GetInitialHeight) => import("xstate").AssignAction<BottomSheetContext, import("xstate").EventObject>; export function computeSnapPoints(input: number | SnapPoints, maxHeight: number): number[]; declare function _computeSnapPointBounds(unsafeHeight: number, snapPoints: SnapPoints): [nearest: number, lower: number, upper: number]; export const computeSnapPointBounds: import("memoize-one").MemoizedFn<typeof _computeSnapPointBounds>; export function computeMinContent({ maxHeight, headerHeight, footerHeight, }: Pick<BottomSheetContext, 'maxHeight' | 'headerHeight' | 'footerHeight'>, minHeight?: number): number; export function computeMaxContent({ maxHeight, headerHeight, contentHeight, footerHeight, }: Pick<BottomSheetContext, 'maxHeight' | 'headerHeight' | 'contentHeight' | 'footerHeight'>, minHeight?: number): number; export const defaultSnapPoints: GetSnapPoints; export const defaultInitialHeight: GetInitialHeight; export type BottomSheetEvent = { type: 'OPEN'; } | { type: 'AUTOFOCUS'; } | { type: 'TRANSITION_OPEN'; } | { type: 'OPENED'; } | { type: 'RESIZE'; payload: { height: number; }; } | { type: 'RESIZED'; } | { type: 'SNAP'; payload: { height: number; }; } | { type: 'SNAPPED'; } | { type: 'DRAG'; } | { type: 'TRANSITION_DRAG'; payload: { height: number; }; } | { type: 'DRAGGED'; } | { type: 'CLOSE'; } | { type: 'CLOSED'; } | { type: 'SET_MAX_HEIGHT'; payload: { maxHeight: number; }; } | { type: 'SET_HEADER_HEIGHT'; payload: { headerHeight: number; }; } | { type: 'SET_CONTENT_HEIGHT'; payload: { contentHeight: number; }; } | { type: 'SET_FOOTER_HEIGHT'; payload: { footerHeight: number; }; }; export interface BottomSheetContext { height: number; initialHeight: number; snapPoints: number[]; lastHeight: number | null; maxContent: number; minContent: number; headerHeight: number | null; contentHeight: number | null; footerHeight: number | null; maxHeight: number; } export const BottomSheetMachine: import("xstate").StateMachine<BottomSheetContext, any, BottomSheetEvent, { value: any; context: BottomSheetContext; }, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("./index.typegen").Typegen0, BottomSheetEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>; //# sourceMappingURL=index.d.ts.map