|
11 | 11 | */
|
12 | 12 |
|
13 | 13 | import {action} from '@storybook/addon-actions';
|
14 |
| -import {Autocomplete, Button, Collection, DialogTrigger, Header, Input, Keyboard, Label, ListBox, ListBoxSection, ListLayout, Menu, MenuItem, MenuSection, MenuTrigger, Popover, SearchField, Select, SelectValue, Separator, SubmenuTrigger, Text, TextField, Virtualizer} from 'react-aria-components'; |
| 14 | +import {Autocomplete, Button, Cell, Collection, Column, DialogTrigger, GridList, Header, Input, Keyboard, Label, Link, ListBox, ListBoxSection, ListLayout, Menu, MenuItem, MenuSection, MenuTrigger, OverlayArrow, Popover, Row, SearchField, Select, SelectValue, Separator, SubmenuTrigger, Table, TableBody, TableHeader, TagGroup, TagList, Text, TextField, Tooltip, TooltipTrigger, Virtualizer} from 'react-aria-components'; |
15 | 15 | import {Meta, StoryObj} from '@storybook/react';
|
| 16 | +import {MyCheckbox} from './Table.stories'; |
16 | 17 | import {MyListBoxItem, MyMenuItem} from './utils';
|
17 | 18 | import {MyListBoxLoaderIndicator, renderEmptyState} from './ListBox.stories';
|
| 19 | +import {MyTag} from './TagGroup.stories'; |
18 | 20 | import React from 'react';
|
19 | 21 | import styles from '../example/index.css';
|
| 22 | +import {TreeExampleStaticRender} from './Tree.stories'; |
20 | 23 | import {useAsyncList, useListData, useTreeData} from 'react-stately';
|
21 | 24 | import {useFilter} from 'react-aria';
|
22 | 25 | import './styles.css';
|
| 26 | +import {MyGridListItem} from './GridList.stories'; |
23 | 27 |
|
24 | 28 | export default {
|
25 | 29 | title: 'React Aria Components/Autocomplete',
|
@@ -939,3 +943,144 @@ AutocompleteWithAsyncListBox.story = {
|
939 | 943 | delay: 50
|
940 | 944 | }
|
941 | 945 | };
|
| 946 | + |
| 947 | +// TODO: I'm skipping Breadcrumbs, Tabs for now, not sure it makes sense to filter that via Autocomplete |
| 948 | +// Filtering the Taggroup might make sense |
| 949 | + |
| 950 | +export const AutocompleteWithGridList = () => { |
| 951 | + return ( |
| 952 | + <AutocompleteWrapper> |
| 953 | + <div> |
| 954 | + <TextField autoFocus data-testid="autocomplete-example"> |
| 955 | + <Label style={{display: 'block'}}>Test</Label> |
| 956 | + <Input /> |
| 957 | + </TextField> |
| 958 | + <GridList |
| 959 | + className={styles.menu} |
| 960 | + style={{height: 200}} |
| 961 | + aria-label="test gridlist"> |
| 962 | + <MyGridListItem>1,1 <Button>Actions</Button></MyGridListItem> |
| 963 | + <MyGridListItem>1,2 <Button>Actions</Button></MyGridListItem> |
| 964 | + <MyGridListItem>1,3 <Button>Actions</Button></MyGridListItem> |
| 965 | + <MyGridListItem>2,1 <Button>Actions</Button></MyGridListItem> |
| 966 | + <MyGridListItem>2,2 <Button>Actions</Button></MyGridListItem> |
| 967 | + <MyGridListItem>2,3 <Button>Actions</Button></MyGridListItem> |
| 968 | + <MyGridListItem>3,1 <Button>Actions</Button></MyGridListItem> |
| 969 | + <MyGridListItem>3,2 <Button>Actions</Button></MyGridListItem> |
| 970 | + <MyGridListItem>3,3 <Button>Actions</Button></MyGridListItem> |
| 971 | + </GridList> |
| 972 | + </div> |
| 973 | + </AutocompleteWrapper> |
| 974 | + ); |
| 975 | +}; |
| 976 | + |
| 977 | +export const AutocompleteWithTable = () => { |
| 978 | + return ( |
| 979 | + <AutocompleteWrapper> |
| 980 | + <div> |
| 981 | + <TextField autoFocus data-testid="autocomplete-example"> |
| 982 | + <Label style={{display: 'block'}}>Test</Label> |
| 983 | + <Input /> |
| 984 | + </TextField> |
| 985 | + <Table aria-label="Files" selectionMode="multiple" style={{height: 300, width: 300}}> |
| 986 | + <TableHeader> |
| 987 | + <Column> |
| 988 | + <MyCheckbox slot="selection" /> |
| 989 | + </Column> |
| 990 | + <Column isRowHeader>Name</Column> |
| 991 | + <Column>Type</Column> |
| 992 | + <Column>Date Modified</Column> |
| 993 | + </TableHeader> |
| 994 | + <TableBody> |
| 995 | + <Row> |
| 996 | + <Cell> |
| 997 | + <MyCheckbox slot="selection" /> |
| 998 | + </Cell> |
| 999 | + <Cell>Games</Cell> |
| 1000 | + <Cell>File folder</Cell> |
| 1001 | + <Cell>6/7/2020</Cell> |
| 1002 | + </Row> |
| 1003 | + <Row> |
| 1004 | + <Cell> |
| 1005 | + <MyCheckbox slot="selection" /> |
| 1006 | + </Cell> |
| 1007 | + <Cell>Program Files</Cell> |
| 1008 | + <Cell>File folder</Cell> |
| 1009 | + <Cell>4/7/2021</Cell> |
| 1010 | + </Row> |
| 1011 | + <Row> |
| 1012 | + <Cell> |
| 1013 | + <MyCheckbox slot="selection" /> |
| 1014 | + </Cell> |
| 1015 | + <Cell>bootmgr</Cell> |
| 1016 | + <Cell>System file</Cell> |
| 1017 | + <Cell>11/20/2010</Cell> |
| 1018 | + </Row> |
| 1019 | + <Row> |
| 1020 | + <Cell> |
| 1021 | + <MyCheckbox slot="selection" /> |
| 1022 | + </Cell> |
| 1023 | + <Cell>log.txt</Cell> |
| 1024 | + <Cell>Text Document</Cell> |
| 1025 | + <Cell>1/18/2016</Cell> |
| 1026 | + </Row> |
| 1027 | + </TableBody> |
| 1028 | + </Table> |
| 1029 | + </div> |
| 1030 | + </AutocompleteWrapper> |
| 1031 | + ); |
| 1032 | +}; |
| 1033 | + |
| 1034 | +export const AutocompleteWithTagGroup = () => { |
| 1035 | + return ( |
| 1036 | + <AutocompleteWrapper> |
| 1037 | + <div> |
| 1038 | + <TextField autoFocus data-testid="autocomplete-example"> |
| 1039 | + <Label style={{display: 'block'}}>Test</Label> |
| 1040 | + <Input /> |
| 1041 | + </TextField> |
| 1042 | + <TagGroup> |
| 1043 | + <Label>Categories</Label> |
| 1044 | + <TagList style={{display: 'flex', gap: 4}}> |
| 1045 | + <MyTag href="https://nytimes.com">News</MyTag> |
| 1046 | + <MyTag>Travel</MyTag> |
| 1047 | + <MyTag>Gaming</MyTag> |
| 1048 | + <TooltipTrigger> |
| 1049 | + <MyTag>Shopping</MyTag> |
| 1050 | + <Tooltip |
| 1051 | + offset={5} |
| 1052 | + style={{ |
| 1053 | + background: 'Canvas', |
| 1054 | + color: 'CanvasText', |
| 1055 | + border: '1px solid gray', |
| 1056 | + padding: 5, |
| 1057 | + borderRadius: 4 |
| 1058 | + }}> |
| 1059 | + <OverlayArrow style={{transform: 'translateX(-50%)'}}> |
| 1060 | + <svg width="8" height="8" style={{display: 'block'}}> |
| 1061 | + <path d="M0 0L4 4L8 0" fill="white" strokeWidth={1} stroke="gray" /> |
| 1062 | + </svg> |
| 1063 | + </OverlayArrow> |
| 1064 | + I am a tooltip |
| 1065 | + </Tooltip> |
| 1066 | + </TooltipTrigger> |
| 1067 | + </TagList> |
| 1068 | + </TagGroup> |
| 1069 | + </div> |
| 1070 | + </AutocompleteWrapper> |
| 1071 | + ); |
| 1072 | +}; |
| 1073 | + |
| 1074 | +export const AutocompleteWithTree = () => { |
| 1075 | + return ( |
| 1076 | + <AutocompleteWrapper> |
| 1077 | + <div> |
| 1078 | + <TextField autoFocus data-testid="autocomplete-example"> |
| 1079 | + <Label style={{display: 'block'}}>Test</Label> |
| 1080 | + <Input /> |
| 1081 | + </TextField> |
| 1082 | + <TreeExampleStaticRender /> |
| 1083 | + </div> |
| 1084 | + </AutocompleteWrapper> |
| 1085 | + ); |
| 1086 | +}; |
0 commit comments