diff --git a/packages/core/helper-plugin/lib/src/components/Search/Search.stories.mdx b/packages/core/helper-plugin/lib/src/components/Search/Search.stories.mdx new file mode 100644 index 0000000000..ce76e1d266 --- /dev/null +++ b/packages/core/helper-plugin/lib/src/components/Search/Search.stories.mdx @@ -0,0 +1,38 @@ + + +import { ArgsTable, Meta } from '@storybook/addon-docs'; +import Search from './index'; + + + +# Search + +This component provides and input to search an array + +## Usage + +```jsx +import { Search, useQueryParams } from '@strapi/helper-plugin'; +import matchSorter from 'match-sorter'; + +const HomePage = () => { + const [{ query }] = useQueryParams() + const _q = query?._q || '' + const items = [{name: 'Paul', instrument: 'bass'}, {name: 'George', instrument: 'guitar'}] + + const sortedList = matchSorter(items, _q, {keys: ['name', 'instrument']}) + const itemsList = sortedList?.length ? sortedList : items + + return ( + + {itemsList.map(item => ( +
+

{item.name}

+

{item.instrument}

+
+ ))} + ) +}; +``` + +