-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ListView components #1919
Merged
Merged
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ed6ed2a
Generics to narrow types to item only when appropriate (#1909)
bmingles 2219115
Tooltip placement override (#1909)
bmingles 5a98665
Rename / move PickerItemContent (#1909)
bmingles 991042f
Smarter item tooltips (#1909)
bmingles 97d7412
forwardedRefs (#1909)
bmingles b7f4df3
Basic ListView implementation (#1909)
bmingles 9fb7de1
ListView table support (#1909)
bmingles 2a04b31
Fixed import (#1909)
bmingles f566e72
Mocking virtualizer (#1909)
bmingles 9b5a119
generate normalized items styleguide util (#1909)
bmingles 157e46f
comments (#1909)
bmingles 85f87c3
Renamed callback ref (#1909)
bmingles 9acfc30
useCheckOverflowRef hook (#1909)
bmingles 4b2cd06
renames (#1909)
bmingles ebf1598
Changed "ref" naming to "callback" (#1909)
bmingles 55d0fc2
cleanup (#1909)
bmingles 9f4c1fb
Cleanup (#1909)
bmingles c964da7
ItemSelection type (#1909)
bmingles a111d5a
Item heights (#1909)
bmingles d488c92
Only render ListView when non-zero height (#1909)
bmingles dac492f
Removed minHeight (#1909)
bmingles f2be02b
Removed unused arg (#1909)
bmingles c7ecd14
useContentRect tests (#1909)
bmingles 663a965
Updated comments (#1909)
bmingles 195c42c
Comments (#1909)
bmingles 055f953
Comments (#1909)
bmingles 8d382b5
useRenderNormalizedItem tests (#1909)
bmingles 91deda8
Fixed useContentRect to update automatically (#1909)
bmingles 962f64c
e2e tests (#1909)
bmingles 599902d
Item key stringify tests (#1909)
bmingles 5fd74dd
Re-use SelectionT (#1909)
bmingles 5b7d5a2
cleanup (#1909)
bmingles 4851669
cleanup (#1909)
bmingles 36d4134
Fixed tests (#1909)
bmingles ae099ca
useCheckOverflow Tests (#1909)
bmingles 342b24c
Cleanup (#1909)
bmingles a65e539
Added test case (#1909)
bmingles 95a4744
Addressed review comments (#1909)
bmingles 383b98c
Simplified illustration example (#1909)
bmingles fb8e4a1
Export spectrum useProvider (#1909)
bmingles 4feb7d9
Removed spectrum dependency (#1909)
bmingles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { | ||
Grid, | ||
Icon, | ||
Item, | ||
ListView, | ||
ItemKey, | ||
Text, | ||
} from '@deephaven/components'; | ||
import { vsAccount, vsPerson } from '@deephaven/icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { generateNormalizedItems, sampleSectionIdAndClasses } from './utils'; | ||
|
||
// Generate enough items to require scrolling | ||
const itemsSimple = [...generateNormalizedItems(52)]; | ||
|
||
function AccountIcon({ | ||
slot, | ||
}: { | ||
slot?: 'illustration' | 'image'; | ||
}): JSX.Element { | ||
return ( | ||
// Images in ListView items require a slot of 'image' or 'illustration' to | ||
// be set in order to be positioned correctly: | ||
// https://github.com/adobe/react-spectrum/blob/784737effd44b9d5e2b1316e690da44555eafd7e/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267 | ||
<Icon slot={slot}> | ||
<FontAwesomeIcon icon={vsAccount} /> | ||
</Icon> | ||
); | ||
} | ||
|
||
export function ListViews(): JSX.Element { | ||
const [selectedKeys, setSelectedKeys] = useState<'all' | Iterable<ItemKey>>( | ||
[] | ||
); | ||
|
||
const onChange = useCallback((keys: 'all' | Iterable<ItemKey>): void => { | ||
setSelectedKeys(keys); | ||
}, []); | ||
|
||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<div {...sampleSectionIdAndClasses('list-views')}> | ||
<h2 className="ui-title">List View</h2> | ||
|
||
<Grid columnGap={14} height="size-6000"> | ||
<Text>Single Child</Text> | ||
<ListView | ||
density="compact" | ||
gridRow="2" | ||
aria-label="Single Child" | ||
selectionMode="multiple" | ||
> | ||
<Item>Aaa</Item> | ||
</ListView> | ||
|
||
<label>Icons</label> | ||
<ListView | ||
gridRow="2" | ||
aria-label="Icon" | ||
density="compact" | ||
selectionMode="multiple" | ||
> | ||
<Item textValue="Item with icon A"> | ||
<AccountIcon slot="image" /> | ||
<Text>Item with icon A</Text> | ||
</Item> | ||
<Item textValue="Item with icon B"> | ||
<AccountIcon slot="image" /> | ||
<Text>Item with icon B</Text> | ||
</Item> | ||
<Item textValue="Item with icon C"> | ||
<AccountIcon slot="image" /> | ||
<Text>Item with icon C</Text> | ||
</Item> | ||
<Item textValue="Item with icon D"> | ||
<AccountIcon slot="image" /> | ||
<Text>Item with icon D with overflowing content</Text> | ||
</Item> | ||
</ListView> | ||
|
||
<label>Mixed Children Types</label> | ||
<ListView | ||
gridRow="2" | ||
aria-label="Mixed Children Types" | ||
density="compact" | ||
maxWidth="size-2400" | ||
selectionMode="multiple" | ||
defaultSelectedKeys={[999, 444]} | ||
> | ||
{/* eslint-disable react/jsx-curly-brace-presence */} | ||
{'String 1'} | ||
{'String 2'} | ||
{'String 3'} | ||
{''} | ||
{'Some really long text that should get truncated'} | ||
{/* eslint-enable react/jsx-curly-brace-presence */} | ||
{444} | ||
{999} | ||
{true} | ||
{false} | ||
<Item>Item Aaa</Item> | ||
<Item>Item Bbb</Item> | ||
<Item textValue="Complex Ccc"> | ||
<Icon slot="image"> | ||
<FontAwesomeIcon icon={vsPerson} /> | ||
</Icon> | ||
<Text>Complex Ccc with text that should be truncated</Text> | ||
</Item> | ||
</ListView> | ||
|
||
<label>Controlled</label> | ||
<ListView | ||
gridRow="2" | ||
aria-label="Controlled" | ||
selectionMode="multiple" | ||
selectedKeys={selectedKeys} | ||
onChange={onChange} | ||
> | ||
{itemsSimple} | ||
</ListView> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
|
||
export default ListViews; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason they don't have a slot provider for
icon
? We could even add a PR for it... seems odd they supportimage
andillustration
but noticon
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing @dsmmcken suggestion may be accurate here. Maybe they are trying to not overload the fact that icons can be included in actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a key difference between listview and listbox, https://react-spectrum.adobe.com/react-spectrum/ListBox.html#complex-items