-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing some prop function signatures to reduce duplicate or unused …
…code Adding ability to pass function to buttonProps so mobile mode state is available Updating comments to reflect changes Updating README
- Loading branch information
1 parent
6b5ca14
commit 4c3c16d
Showing
10 changed files
with
163 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
# React Search Dialog🔎   | ||
|
||
A batteries included search component that aims to make implementing a modern search experience in your application as easy as possible. With a focus on performance and refraining from reinventing the wheel, **React Search Dialog** is built on top of [Fuse.js](https://fusejs.io/) and [react-window](https://github.com/bvaughn/react-window) so that no matter the data size, you'll get the results you're looking for near instantly! | ||
A batteries included search component that aims to make implementing a modern search experience in your application as easy as possible. With a focus on performance and not reinventing the wheel, **React Search Dialog** is built on top of battle tested libraries [Fuse.js](https://fusejs.io/) and [react-window](https://github.com/bvaughn/react-window) so that no matter the item list, you'll get the results you're looking for near instantly! | ||
|
||
## Features | ||
|
||
- ✅ Handles massive data sets with ease | ||
- ✅ Live results as you type | ||
- ✅ Out of the box styling, with ability to customize as needed | ||
- ✅ Mobile friendly | ||
- ✅ Optional render functions for search results and recent items | ||
- ✅ Build in recent search history (can be disabled) | ||
- ✅ Optional quick select section for common search items (fully customizable) | ||
|
||
## Examples | ||
|
||
## Features | ||
🚧 _Coming soon!_ | ||
|
||
## Props | ||
|
||
Below is a table of all props exposed by the `Search` component. The majority of this table is a pared down, more digestable version of the exported type `SearchProps` so | ||
Below is a table of all props exposed by the `Search` component. The majority of this table is a pared down, more digestible version of the exported type `SearchProps` so | ||
if more detail is needed, please feel free to refer to the type definitions directly! | ||
|
||
| Key | | | ||
| :-----------: | ------------- | | ||
| ✅ | Required | | ||
| ⚠ | Conditionally Optional | | ||
| ❌ | Optional | | ||
|
||
| Required | Prop Name | Prop Type | Description | | ||
| :-----------: | ------------- | ------------- | ------------- | | ||
| ✅ | `items` | Array of `T` (generic) | The items to search through. **IMPORTANT: `T` must have a `label` property OR be a string.** | | ||
| ✅ | `onItemSelect` | `(item: T) => void` | Callback to fire when an item is selected | | ||
| ❌ | `buttonProps` | `ButtonProps` | Props to pass to the button that opens the search dialog. [Click here to read more about the props available to the Button component](https://mui.com/api/button/) | | ||
| ⚠ | `onItemSelect` | `(item: T) => void` | Callback to fire when an item is selected. **IMPORTANT: When NOT passing in your own render function with `renderResult`, this prop is required so that an action can be taken on search result / recent click.** | | ||
| ❌ | `buttonProps` | `ButtonProps OR (isSmallScreen: boolean) => ButtonProps` | Props to pass to the button that opens the search dialog. [Click here to read more about the props available to the Button component](https://mui.com/api/button/) | | ||
| ❌ | `placeholder` | `string` | The placeholder text to display in the search input | | ||
| ❌ | `itemHeight` | `number` or [`ItemHeightPreset`](./react-search-dialog/Search.tsx) | Height of each item in the search results | | ||
| ❌ | `quickFillItems` | Array of `T` (generic) | Items to display in the quick fill section | | ||
| ❌ | `maxHeight` | `string` or `number` | Maximum height of the search dialog | | ||
| ❌ | `maxWidth` | `string` or `number` | Maximum width of the search dialog | | ||
| ❌ | `noHistory` | `boolean` | Whether or not to record or display recent search history | | ||
| ❌ | `renderResult` | `(result: T, onItemSelectCallback: () => void) => JSX.Element` | Callback to render a single search result **IMPORTANT: Because you're supplying the render function for each search result, it's up to you to fire the provided `onItemSelectCallback()` function at the moment a user has selected a specific search item. This is what allows for search history tracking (if enabled) in custom components and handles the firing of your `onItemSelect` function, if defined!** | | ||
| ❌ | `renderRecent` | `(recent: T, onItemSelectCallback: () => void) => JSX.Element` | Callback to render a single recent search item **IMPORTANT: Because you're supplying the render function for each recent search item, it's up to you to fire the provided `onItemSelectCallback()` function at the moment a user has selected a specific recent item. This is what allows for search history tracking (if enabled) in custom components and also handles the firing of your `onItemSelect` function, if defined!** | | ||
| ❌ | `renderResult` | `({ item, closeDialog, addToRecents }) => JSX.Element` | Callback to render a single search result **IMPORTANT: Because you're supplying the render function for each search result, it's up to you to use the `addToRecents` function when a selection is made by the user, and the `closeDialog` function when you see it appropriate for the search dialog to close.** | | ||
| ❌ | `renderRecent` | `({ item, closeDialog, addToRecents }) => JSX.Element` | Callback to render a single recent search item **IMPORTANT: Because you're supplying the render function for each recent search item, it's up to you to use the `addToRecents` function when a selection is made by the user, and the `closeDialog` function when you see it appropriate for the search dialog to close.** | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ | |
"url": "https://github.com/foxtrotperry", | ||
"email": "[email protected]" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/foxtrotperry/react-search-dialog.git" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
|
@@ -49,6 +53,7 @@ | |
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-react": "^7.31.11", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"path": "^0.12.7", | ||
"prettier": "^2.7.1", | ||
"react": "^18.2.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.