1- import { ControlsWithNote , DocsHeader , Footer } from ' @sb/components' ;
2- import { Canvas , Meta } from ' @storybook/addon-docs/blocks' ;
1+ import { ArgTypesWithNote , ControlsWithNote , DocsHeader , Footer } from ' @sb/components' ;
2+ import { Canvas , Description , Meta } from ' @storybook/addon-docs/blocks' ;
33import * as ComponentStories from ' ./Search.stories' ;
4+ import { SearchItem } from ' ../SearchItem/index.js' ;
5+ import { SearchItemGroup } from ' ../SearchItemGroup/index.js' ;
6+ import { SearchItemShowMore } from ' ../SearchItemShowMore/index.js' ;
7+ import { SearchMessageArea } from ' ../SearchMessageArea/index.js' ;
8+ import { SearchScope } from ' ../SearchScope/index.js' ;
49
510<Meta of = { ComponentStories } />
611
@@ -35,7 +40,7 @@ const scopeData = [
3540 { name: ' Log work' , scope: ' apps' },
3641 { name: ' Manage Products' , scope: ' apps' },
3742 { name: ' Mobile Phones' , scope: ' products' },
38- { name: ' Tablet' , scope: ' products' }
43+ { name: ' Tablet' , scope: ' products' },
3944];
4045
4146function SearchComponent(props ) {
@@ -50,7 +55,7 @@ function SearchComponent(props) {
5055 setFilterData (
5156 scopeData .filter ((item ) => {
5257 return item .scope === scope .text .toLowerCase ();
53- })
58+ }),
5459 );
5560 }
5661 };
@@ -67,4 +72,79 @@ function SearchComponent(props) {
6772
6873</details >
6974
75+ ### Search with ` SearchShowMore ` Item
76+
77+ Search with Grouped Suggestions and Show More (N) Item
78+
79+ <Canvas of = { ComponentStories .ShowMoreItem } />
80+
81+ <details >
82+ <summary >Show static code</summary >
83+
84+ ``` tsx
85+ const allItems = [
86+ { text: ' Search Item 1' , icon: historyIcon },
87+ { text: ' Search Item 2' , icon: searchIcon },
88+ { text: ' Search Item 3' , icon: historyIcon },
89+ { text: ' Search Item 4' , icon: historyIcon },
90+ { text: ' Search Item 5' , icon: searchIcon },
91+ { text: ' Search Item 6' , icon: globeIcon },
92+ ];
93+ const visibleItems = allItems .slice (0 , 3 );
94+ const hiddenItems = allItems .slice (3 );
95+
96+ export function ShowMoreItem() {
97+ const [showHiddenItems, setShowHiddenItems] = useState (false );
98+
99+ return (
100+ <Search showClearIcon = { true } placeholder = " Placeholder" >
101+ <SearchItemGroup headerText = " Group Header 1" >
102+ { visibleItems .map ((item ) => (
103+ <SearchItem key = { item .text } text = { item .text } icon = { item .icon } />
104+ ))}
105+ { ! showHiddenItems && (
106+ <SearchItemShowMore itemsToShowCount = { hiddenItems .length } onClick = { () => setShowHiddenItems (true )} />
107+ )}
108+ { showHiddenItems && hiddenItems .map ((item ) => <SearchItem key = { item .text } text = { item .text } icon = { item .icon } />)}
109+ </SearchItemGroup >
110+
111+ <SearchItemGroup headerText = " Group Header 2" >
112+ <SearchItem text = " Search Item 1" icon = { historyIcon } />
113+ <SearchItem text = " Search Item 2" icon = { historyIcon } />
114+ <SearchItem text = " Search Item 3" icon = { globeIcon } />
115+ </SearchItemGroup >
116+ </Search >
117+ );
118+ }
119+ ```
120+
121+ </details >
122+
123+ ## Subcomponents
124+
125+ ### SearchItem
126+
127+ <Description of = { SearchItem } />
128+ <ArgTypesWithNote metaOf = { ComponentStories } of = { SearchItem } />
129+
130+ ### SearchItemGroup
131+
132+ <Description of = { SearchItemGroup } />
133+ <ArgTypesWithNote metaOf = { ComponentStories } of = { SearchItemGroup } />
134+
135+ ### SearchItemShowMore
136+
137+ <Description of = { SearchItemShowMore } />
138+ <ArgTypesWithNote metaOf = { ComponentStories } of = { SearchItemShowMore } />
139+
140+ ### SearchMessageArea
141+
142+ <Description of = { SearchMessageArea } />
143+ <ArgTypesWithNote metaOf = { ComponentStories } of = { SearchMessageArea } />
144+
145+ ### SearchScope
146+
147+ <Description of = { SearchScope } />
148+ <ArgTypesWithNote metaOf = { ComponentStories } of = { SearchScope } />
149+
70150<Footer />
0 commit comments