@jungle-commerce/typesense-react
Version:
React hooks and components for building search interfaces with Typesense
53 lines • 1.7 kB
TypeScript
import { FacetValue } from '../types';
/**
* Hook return type for numeric facet range management
*/
export interface UseNumericFacetRangeReturn {
/** Available bounds based on all values (accumulated or current) */
bounds: {
min: number;
max: number;
} | null;
/** Currently selected range */
currentRange: {
min: number;
max: number;
} | null;
/** Individual facet values with counts */
values: FacetValue[];
/** Current mode (individual checkbox selection or range) */
mode: 'individual' | 'range';
/** Set the facet to range mode and apply a range */
setRange: (min: number, max: number) => void;
/** Clear the range selection */
clearRange: () => void;
/** Switch between individual and range modes */
setMode: (mode: 'individual' | 'range') => void;
/** Check if field is numeric */
isNumeric: boolean;
/** Selected individual values (when in individual mode) */
selectedValues: string[];
/** Field configuration from schema */
fieldType: string | null;
}
/**
* Hook for managing numeric facet ranges
* @param field - The field name to manage
* @returns Numeric facet range state and actions
*/
export declare function useNumericFacetRange(field: string): UseNumericFacetRangeReturn;
/**
* Helper to convert selected individual values to a range
*/
export declare function valuesToRange(values: string[]): {
min: number;
max: number;
} | null;
/**
* Helper to check if a value is within a range
*/
export declare function isValueInRange(value: string, range: {
min: number;
max: number;
}): boolean;
//# sourceMappingURL=useNumericFacetRange.d.ts.map