@papernote/ui
Version:
A modern React component library with a paper notebook aesthetic - minimal, professional, and expressive
87 lines • 2.37 kB
TypeScript
import React from 'react';
/**
* PullToRefresh component props
*/
export interface PullToRefreshProps {
/** Content to wrap */
children: React.ReactNode;
/** Async refresh handler - should return a Promise */
onRefresh: () => Promise<void>;
/** Disable pull-to-refresh */
disabled?: boolean;
/** Pull distance required to trigger refresh (default: 80) */
pullThreshold?: number;
/** Maximum pull distance (default: 120) */
maxPull?: number;
/** Custom loading indicator */
loadingIndicator?: React.ReactNode;
/** Custom pull indicator */
pullIndicator?: React.ReactNode;
/** Additional class names for container */
className?: string;
}
/**
* PullToRefresh - Mobile pull-to-refresh gesture handler
*
* Wraps content and provides native-feeling pull-to-refresh functionality.
* Only activates when scrolled to top of content.
*
* @example Basic usage
* ```tsx
* <PullToRefresh onRefresh={async () => {
* await fetchLatestData();
* }}>
* <div className="min-h-screen">
* {content}
* </div>
* </PullToRefresh>
* ```
*
* @example With custom threshold
* ```tsx
* <PullToRefresh
* onRefresh={handleRefresh}
* pullThreshold={100}
* maxPull={150}
* >
* {content}
* </PullToRefresh>
* ```
*/
export default function PullToRefresh({ children, onRefresh, disabled, pullThreshold, maxPull, loadingIndicator, pullIndicator, className, }: PullToRefreshProps): import("react/jsx-runtime").JSX.Element;
/**
* usePullToRefresh - Hook for custom pull-to-refresh implementations
*
* @example
* ```tsx
* const { pullDistance, isRefreshing, bind } = usePullToRefresh({
* onRefresh: async () => {
* await fetchData();
* }
* });
*
* return (
* <div {...bind}>
* {isRefreshing && <Spinner />}
* {content}
* </div>
* );
* ```
*/
export declare function usePullToRefresh({ onRefresh, pullThreshold, maxPull, disabled, }: {
onRefresh: () => Promise<void>;
pullThreshold?: number;
maxPull?: number;
disabled?: boolean;
}): {
pullDistance: number;
isRefreshing: boolean;
isReady: boolean;
progress: number;
bind: {
onTouchStart: (e: React.TouchEvent) => void;
onTouchMove: (e: React.TouchEvent) => void;
onTouchEnd: () => Promise<void>;
};
};
//# sourceMappingURL=PullToRefresh.d.ts.map