Skip to content

Commit 0de5bee

Browse files
committed
docs: add apis for subcomponents
1 parent 3fe6ffa commit 0de5bee

File tree

5 files changed

+206
-7
lines changed

5 files changed

+206
-7
lines changed

packages/blade/src/components/ListView/_decisions/decisions.md

Lines changed: 206 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Questions like what is pattern, why are we building these patterns, and scope of
1717

1818
```jsx
1919
<ListView>
20-
<ListViewFilterGroup
20+
<ListViewFilters
2121
quickFilters={[
2222
{
2323
title: 'All',
@@ -28,7 +28,7 @@ Questions like what is pattern, why are we building these patterns, and scope of
2828
onClick: () => {},
2929
},
3030
]}
31-
onSearch={() => {
31+
onSearchChange={() => {
3232
/* filter on search */
3333
}}
3434
>
@@ -45,7 +45,7 @@ Questions like what is pattern, why are we building these patterns, and scope of
4545
</MenuOverlay>
4646
</Menu>
4747
</FilterChipGroup>
48-
</ListViewFilterGroup>
48+
</ListViewFilters>
4949
<Table data={{ nodes: filteredNodes }} />
5050
</ListView>
5151
```
@@ -176,7 +176,7 @@ Questions like what is pattern, why are we building these patterns, and scope of
176176

177177
**Pros**
178178

179-
- Less verbose compared to using dropdown and menu inside ListViewFilterGroup
179+
- Less verbose compared to using dropdown and menu inside ListViewFilters
180180

181181
**Cons**
182182

@@ -243,8 +243,207 @@ Similar to [react-data-grid](https://mui.com/x/react-data-grid/filtering/quick-f
243243

244244
## Enhancements / Components
245245

246-
### Dropdown with Search
246+
### Dropdown with AutoComplete in Overlay
247+
248+
![alt text](image-1.png)
249+
250+
```jsx
251+
<Dropdown>
252+
<SelectInput />
253+
<DropdownOverlay>
254+
<DropdownHeader>
255+
<AutoComplete />
256+
</DropdownHeader>
257+
<ActionList>
258+
<ActionListItem />
259+
<ActionListItem />
260+
<ActionListItem />
261+
</ActionList>
262+
</Dropdown>
263+
```
264+
265+
### FilterChipGroup
266+
267+
![alt text](image-3.png)
268+
269+
#### Usage
270+
271+
```jsx
272+
const [duration, setDuration] = React.useState();
273+
const [utrNumber, setUtrNumber] = React.useState();
274+
const utrNumberInputValueRef = React.useRef(null);
275+
276+
<FilterChipGroup>
277+
<Dropdown>
278+
<FilterChip value={duration} onClearButtonClick={({ value }) => setDuration(undefined)}>
279+
Duration
280+
</FilterChip>
281+
<DropdownOverlay>
282+
<ActionList>
283+
<ActionListItem
284+
title="2 days"
285+
value="2d"
286+
onClick={({ name, value }) => setDuration(name)}
287+
/>
288+
<ActionListItem
289+
title="1 week"
290+
value="1w"
291+
onClick={({ name, value }) => setDuration(name)}
292+
/>
293+
<ActionListItem
294+
title="1 month"
295+
value="1m"
296+
onClick={({ name, value }) => setDuration(name)}
297+
/>
298+
</ActionList>
299+
</DropdownOverlay>
300+
</Dropdown>
301+
302+
<Menu>
303+
<FilterChip value={utrNumber} onClearButtonClick={({ value }) => setUtrNumber(undefined)}>
304+
UTR Number
305+
</FilterChip>
306+
<MenuOverlay>
307+
<TextInput ref={utrNumberInputValueRef} />
308+
<Button onClick={() => setUtrNumber(utrNumberInputValueRef.current.value)}>Submit</Button>
309+
</MenuOverlay>
310+
</Menu>
311+
312+
<Dropdown>
313+
<FilterChip
314+
value={status}
315+
defaultValue="Initiated"
316+
onClearButtonClick={({ value }) => setStatus(undefined)}
317+
>
318+
Status
319+
</FilterChip>
320+
<DropdownOverlay>
321+
<ActionList>
322+
<ActionListItem title="All" onClick={({ name, value }) => setStatus(name)} />
323+
<ActionListItem title="Pending" onClick={({ name, value }) => setStatus(name)} />
324+
<ActionListItem title="Completed" onClick={({ name, value }) => setStatus(name)} />
325+
</ActionList>
326+
</DropdownOverlay>
327+
</Dropdown>
328+
</FilterChipGroup>;
329+
```
330+
331+
#### Props
332+
333+
##### FilterChipGroup
334+
335+
```ts
336+
type FilterChipGroupProps = {
337+
/**
338+
* Children prop. Supports Dropdown, Menu components
339+
*
340+
*/
341+
children: React.ReactNode;
342+
};
343+
```
344+
345+
##### FilterChip
346+
347+
FilterChip can be used as a trigger for Dropdown and Menu
348+
349+
```ts
350+
type FilterChipProps = {
351+
/**
352+
* Controlled value of FilterChip.
353+
*
354+
* FilterChip is always a controlled component since selected state of it comes from other components like Menu, Dropdown.
355+
*/
356+
value: string;
357+
358+
/**
359+
* Change handler when FilterChip's value is cleared
360+
*/
361+
onClearButtonClick: ({ value }: { value: string }) => void;
362+
363+
/**
364+
* Children. Title of the Chip
365+
*/
366+
children: string;
367+
368+
/**
369+
* Disabled state for Chip
370+
*/
371+
isDisabled?: boolean;
372+
};
373+
```
374+
375+
### ListView (Layout Component)
376+
377+
Layout Component for handling the overall layout of ListView and Filters
378+
379+
```jsx
380+
<ListView>
381+
<ListViewFilters
382+
quickFilters={[
383+
{
384+
title: 'All',
385+
onClick: () => {},
386+
},
387+
{
388+
title: 'Pending',
389+
onClick: () => {},
390+
},
391+
]}
392+
onSearch={({ value, searchType }) => {
393+
/* filter on search */
394+
}}
395+
>
396+
<FilterGroup />
397+
</ListViewFilters>
398+
<Table />
399+
</ListView>
400+
```
401+
402+
#### Props
403+
404+
##### ListView
405+
406+
```ts
407+
type ListViewProps = {
408+
children: React.ReactNode;
409+
};
410+
```
411+
412+
##### ListViewFilters
413+
414+
![alt text](image-4.png)
415+
416+
```ts
417+
type QuickFilter = {
418+
title: string;
419+
onClick: (e: React.MouseEvent) => void;
420+
};
421+
422+
type OnSearchArgs = {
423+
/**
424+
* Value of the search input field
425+
*/
426+
value: string;
427+
428+
/**
429+
* Value of the Dropdown next to search input
430+
*/
431+
searchType: string;
432+
};
433+
434+
type ListViewFiltersProps = {
435+
/**
436+
* Config of QuickFilters
437+
*/
438+
quickFilters: QuickFilter[];
439+
440+
/**
441+
* Callback when user clicks search button
442+
*/
443+
onSearch: ({ value, searchType }: OnSearchArgs) => void;
444+
};
445+
```
247446

248-
- #### List View References
447+
## References
249448

250-
- [Material UI Data Grid](https://mui.com/x/react-data-grid/filtering-recipes/)
449+
- [Material UI Data Grid](https://mui.com/x/react-data-grid/filtering-recipes/)
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)