Skip to content

Commit

Permalink
📝 more info on filterOptions prop
Browse files Browse the repository at this point in the history
  • Loading branch information
harshzalavadiya committed May 3, 2020
1 parent 255a52f commit 551a2b4
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 24 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,27 @@ export default Example;
| `isLoading` | show spinner on select | `boolean` | `false` |
| `shouldToggleOnHover` | toggle dropdown on hover option | `boolean` | `false` |
| `overrideStrings` | Override default strings for i18n | `object` | |
| `onChange` | onChange callback | `function` | |
| `onChange` | onChange callback | `function` | |
| `disabled` | disable dropdown | `boolean` | `false` |
| `selectAllLabel` | _select all_ label | `string` | |
| `disableSearch` | hide search textbox | `boolean` | `false` |
| `filterOptions` | custom filter options | `function` | |
| `filterOptions` | custom filter options | `function` | Fuzzy Search |
| `className` | class name for parent component | `string` | `multi-select` |

### 🔍 Custom filter logic

By default this component uses fuzzy search algorithm to filter options but also allows you to opt-out and use your own logic if you want to below is the example doing just case insensitive search

```js
export function filterOptions(options, filter) {
if (!filter) {
return options;
}
const re = new RegExp(filter, "i");
return options.filter(({ value }) => value && value.match(re));
}
```

## 🌐 Internationalization

You can override the strings to be whatever you want, including translations for your languages.
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-multi-select-component",
"version": "2.0.4",
"version": "2.0.5",
"description": "Simple and lightweight multiple selection dropdown component with checkboxes, search and select-all",
"author": "Harsh Zalavadiya",
"license": "MIT",
Expand All @@ -24,11 +24,11 @@
},
"dependencies": {
"@rooks/use-outside-click": "^3.6.0",
"goober": "^1.7.1"
"goober": "^1.8.0"
},
"devDependencies": {
"@ampproject/filesize": "^4.0.1",
"@babel/core": "^7.9.0",
"@ampproject/filesize": "^4.2.0",
"@babel/core": "^7.9.6",
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-docs": "^5.3.18",
"@storybook/addon-info": "^5.3.18",
Expand All @@ -38,14 +38,14 @@
"@storybook/addons": "^5.3.18",
"@storybook/react": "^5.3.18",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.6",
"@types/react-dom": "^16.9.7",
"babel-loader": "^8.1.0",
"husky": "^4.2.5",
"react": "^16.13.1",
"react-docgen-typescript-loader": "^3.7.2",
"react-dom": "^16.13.1",
"react-is": "^16.13.1",
"ts-loader": "^7.0.1",
"ts-loader": "^7.0.2",
"tsdx": "^0.13.2",
"tslib": "^1.11.1",
"typescript": "^3.8.3"
Expand Down
116 changes: 100 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# yarn lockfile v1


"@ampproject/filesize@^4.0.1":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@ampproject/filesize/-/filesize-4.1.0.tgz#8d0642b39dbdf8bdacfe5151fadaa28068b35456"
integrity sha512-H206vnnu2mb26yI3OdABKsaD/pvcW2jH3TefoG7Q0mZrsO2unq8mKQTGNvooG8qfHJBiwzsiSxN4bLMDkNUtsQ==
"@ampproject/filesize@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@ampproject/filesize/-/filesize-4.2.0.tgz#d3fae7c878a55c8bfe35f34ab7a13bd41130502b"
integrity sha512-Esy8zDHYuXxOjYPkOm7JC6yVs38SAVvWDUq8jMYWVJDi3+cltTdmWyPNB8vDjjKitXfKx6n9bQoeW0hvQ9sH3g==
dependencies:
"@kristoferbaxter/async" "0.0.7"
"@kristoferbaxter/async" "1.0.0"
bytes "3.1.0"
fast-glob "3.2.2"
kleur "3.0.3"
Expand Down Expand Up @@ -57,7 +57,7 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.4.4", "@babel/core@^7.4.5", "@babel/core@^7.7.5", "@babel/core@^7.9.0":
"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.4.4", "@babel/core@^7.4.5", "@babel/core@^7.7.5":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.9.0.tgz#ac977b538b77e132ff706f3b8a4dbad09c03c56e"
integrity sha512-kWc7L0fw1xwvI0zi8OKVBuxRVefwGOrKSQMvrQ3dW+bIIavBY3/NpXmpjMy7bQnLgwgzWQZ8TlM57YHpHNHz4w==
Expand All @@ -79,6 +79,28 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/core@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.9.6.tgz#d9aa1f580abf3b2286ef40b6904d390904c63376"
integrity sha512-nD3deLvbsApbHAHttzIssYqgb883yU/d9roe4RZymBCDaZryMJDbptVpEpeQuRh4BJ+SYI8le9YGxKvFEvl1Wg==
dependencies:
"@babel/code-frame" "^7.8.3"
"@babel/generator" "^7.9.6"
"@babel/helper-module-transforms" "^7.9.0"
"@babel/helpers" "^7.9.6"
"@babel/parser" "^7.9.6"
"@babel/template" "^7.8.6"
"@babel/traverse" "^7.9.6"
"@babel/types" "^7.9.6"
convert-source-map "^1.7.0"
debug "^4.1.0"
gensync "^1.0.0-beta.1"
json5 "^2.1.2"
lodash "^4.17.13"
resolve "^1.3.2"
semver "^5.4.1"
source-map "^0.5.0"

"@babel/generator@^7.4.0", "@babel/generator@^7.8.4", "@babel/generator@^7.9.0":
version "7.9.4"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.9.4.tgz#12441e90c3b3c4159cdecf312075bf1a8ce2dbce"
Expand All @@ -89,6 +111,16 @@
lodash "^4.17.13"
source-map "^0.5.0"

"@babel/generator@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.9.6.tgz#5408c82ac5de98cda0d77d8124e99fa1f2170a43"
integrity sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==
dependencies:
"@babel/types" "^7.9.6"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.5.0"

"@babel/helper-annotate-as-pure@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.8.3.tgz#60bc0bc657f63a0924ff9a4b4a0b24a13cf4deee"
Expand Down Expand Up @@ -179,6 +211,15 @@
"@babel/template" "^7.8.3"
"@babel/types" "^7.8.3"

"@babel/helper-function-name@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz#2b53820d35275120e1874a82e5aabe1376920a5c"
integrity sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==
dependencies:
"@babel/helper-get-function-arity" "^7.8.3"
"@babel/template" "^7.8.3"
"@babel/types" "^7.9.5"

"@babel/helper-get-function-arity@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz#b894b947bd004381ce63ea1db9f08547e920abd5"
Expand Down Expand Up @@ -280,6 +321,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed"
integrity sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw==

"@babel/helper-validator-identifier@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80"
integrity sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==

"@babel/helper-wrap-function@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.8.3.tgz#9dbdb2bb55ef14aaa01fe8c99b629bd5352d8610"
Expand All @@ -299,6 +345,15 @@
"@babel/traverse" "^7.9.0"
"@babel/types" "^7.9.0"

"@babel/helpers@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.9.6.tgz#092c774743471d0bb6c7de3ad465ab3d3486d580"
integrity sha512-tI4bUbldloLcHWoRUMAj4g1bF313M/o6fBKhIsb3QnGVPwRm9JsNf/gqMkQ7zjqReABiffPV6RWj7hEglID5Iw==
dependencies:
"@babel/template" "^7.8.3"
"@babel/traverse" "^7.9.6"
"@babel/types" "^7.9.6"

"@babel/highlight@^7.0.0", "@babel/highlight@^7.8.3":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079"
Expand All @@ -313,6 +368,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8"
integrity sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==

"@babel/parser@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.6.tgz#3b1bbb30dabe600cd72db58720998376ff653bc7"
integrity sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==

"@babel/plugin-proposal-async-generator-functions@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.8.3.tgz#bad329c670b382589721b27540c7d288601c6e6f"
Expand Down Expand Up @@ -974,6 +1034,21 @@
globals "^11.1.0"
lodash "^4.17.13"

"@babel/traverse@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.9.6.tgz#5540d7577697bf619cc57b92aa0f1c231a94f442"
integrity sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==
dependencies:
"@babel/code-frame" "^7.8.3"
"@babel/generator" "^7.9.6"
"@babel/helper-function-name" "^7.9.5"
"@babel/helper-split-export-declaration" "^7.8.3"
"@babel/parser" "^7.9.6"
"@babel/types" "^7.9.6"
debug "^4.1.0"
globals "^11.1.0"
lodash "^4.17.13"

"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.6.0", "@babel/types@^7.7.0", "@babel/types@^7.8.3", "@babel/types@^7.8.6", "@babel/types@^7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.0.tgz#00b064c3df83ad32b2dbf5ff07312b15c7f1efb5"
Expand All @@ -983,6 +1058,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.9.5", "@babel/types@^7.9.6":
version "7.9.6"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.6.tgz#2c5502b427251e9de1bd2dff95add646d95cc9f7"
integrity sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==
dependencies:
"@babel/helper-validator-identifier" "^7.9.5"
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@base2/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.0.tgz#860ce718b0b73f4009e153541faff2cb6b85d047"
Expand Down Expand Up @@ -1256,10 +1340,10 @@
"@types/istanbul-reports" "^1.1.1"
"@types/yargs" "^13.0.0"

"@kristoferbaxter/async@0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@kristoferbaxter/async/-/async-0.0.7.tgz#2fe5877588fc7102445ca7918a5bcc59d3c69061"
integrity sha512-3cKFLZEnqJ5yILVbyyYD4Xld8aZ5vUQbkLxTlPz1blpUtCd5PIhf4uKTM9+SIr/q2JK+OSmmU4rdx1kgAPBPCQ==
"@kristoferbaxter/async@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@kristoferbaxter/async/-/async-1.0.0.tgz#33c8e8c6b055f15f4ee8a711b9594336a6fb1671"
integrity sha512-CAQQQ8mUUBKI2P7stYojHwHb+ShdFN8SrC90/96V4m2XlDSctXAA+5PD5CqCICs0o5c/83cYJCeub+FSetKLrw==

"@mdx-js/loader@^1.5.1":
version "1.5.8"
Expand Down Expand Up @@ -2139,7 +2223,7 @@
dependencies:
"@types/react" "*"

"@types/react-dom@^16.9.6":
"@types/react-dom@^16.9.7":
version "16.9.7"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.7.tgz#60844d48ce252d7b2dccf0c7bb937130e27c0cd2"
integrity sha512-GHTYhM8/OwUCf254WO5xqR/aqD3gC9kSTLpopWGpQLpnw23jk44RvMHsyUSEplvRJZdHxhJGMMLF0kCPYHPhQA==
Expand Down Expand Up @@ -6033,7 +6117,7 @@ globrex@^0.1.1:
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==

goober@^1.7.1:
goober@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/goober/-/goober-1.8.0.tgz#ed97e40e87300c6d1c8304a9d4b0f1398ff7669a"
integrity sha512-9ZFoOkBccexjqIgcwlhq7C/eCSkgTZX0BdNUkOnBFLedrJgo3R8lp9ckd/qqtngtF/JDyXSxJzwMU98kNjZ4Mw==
Expand Down Expand Up @@ -11482,10 +11566,10 @@ ts-jest@^24.0.2:
semver "^5.5"
yargs-parser "10.x"

ts-loader@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.1.tgz#ac9ae9eb8f5ebd0aa7b78b44db20691b6e31251b"
integrity sha512-wdGs9xO8UnwASwbluehzXciBtc9HfGlYA8Aiv856etLmdv8mJfAxCkt3YpS4g7G1IsGxaCVKQ102Qh0zycpeZQ==
ts-loader@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.2.tgz#465bc904aea4c331e9550e7c7d75dd17a0b7c24c"
integrity sha512-DwpZFB67RoILQHx42dMjSgv2STpacsQu5X+GD/H9ocd8IhU0m8p3b/ZrIln2KmcucC6xep2PdEMEblpWT71euA==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
Expand Down

0 comments on commit 551a2b4

Please sign in to comment.