import { SpreadsheetProvider, CanvasGrid, SheetSearch } from "@rowsncolumns/spreadsheet";
import { useSearch } from "@rowsncolumns/spreadsheet-state"
const MySpreadsheet = () => {
const { getCellData, getNonEmptyColumnCount, getNonEmptyRowCount } = useSpreadsheetState()
const {
onSearch,
onResetSearch,
onFocusNextResult,
onFocusPreviousResult,
hasNextResult,
hasPreviousResult,
borderStyles,
isSearchActive,
onRequestSearch,
} = useSearch({
getCellData,
sheetId: activeSheetId,
getNonEmptyColumnCount,
getNonEmptyRowCount,
});
return (
<>
<CanvasGrid
...
onRequestSearch={onRequestSearch}
borderStyles={borderStyles}
/>
// Make sure you have a parent div with position: relative
<SheetSearch
isActive={isSearchActive}
onSubmit={onSearch}
onReset={onResetSearch}
onNext={onFocusNextResult}
onPrevious={onFocusPreviousResult}
disableNext={!hasNextResult}
disablePrevious={!hasPreviousResult}
/>
</>
);
};
const App = () => (
<SpreadsheetProvider>
<MySpreadsheet />
</SpreadsheetProvider>
);