-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ListView components - Smart item tooltip handling (only show when text is overflowing) - Split out some shared util code from Picker - Wrapped Text, View, and Heading in forwardRef **Testing** This can be tested using this PR: deephaven/deephaven-plugins#408 . To make TypeScript happy, you can install DHC as an alpha via: ```sh npm run update-dh-packages -- --scope=@deephaven/js-plugin-ui -- 0.72.1-alpha-list-view.38 ``` BREAKING CHANGE: `LIST_VIEW_ROW_HEIGHT` number constant replaced with dictionary `LIST_VIEW_ROW_HEIGHTS`
- Loading branch information
Showing
42 changed files
with
1,934 additions
and
190 deletions.
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
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,123 @@ | ||
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 AccountIllustration(): 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="illustration"> | ||
<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"> | ||
<AccountIllustration /> | ||
<Text>Item with icon A</Text> | ||
</Item> | ||
<Item textValue="Item with icon B"> | ||
<AccountIllustration /> | ||
<Text>Item with icon B</Text> | ||
</Item> | ||
<Item textValue="Item with icon C"> | ||
<AccountIllustration /> | ||
<Text>Item with icon C</Text> | ||
</Item> | ||
<Item textValue="Item with icon D"> | ||
<AccountIllustration /> | ||
<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.