-
Notifications
You must be signed in to change notification settings - Fork 16
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 - ui plugins #408
Merged
+913
−591
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2581bf0
ListView (#366)
bmingles de1201c
useReExportedTable (#366)
bmingles d4d9d30
sorting (#366)
bmingles 471a84c
Improved selectionmode handling (#366)
bmingles 1c82d00
Examples (#366)
bmingles e785f1b
Updated examples (#366)
bmingles 1dae787
Cleanup ListView (#366)
bmingles 85f1c15
Default density to compact (#366)
bmingles 6e47a69
Update DHC packages to ^0.75.0 and jsapi-types to ^1.0.0-dev0.34.0 (#…
bmingles 17c2039
Updated README (#366)
bmingles 092b11a
Added aria-label to example (#366)
bmingles f5f651e
Fixed Picker prop types (#366)
bmingles b3d15a2
Helper script to update ui packages (#366)
bmingles c02c3c7
Update dh packages to ^0.76.0 (#366)
bmingles f46bad3
Downgraded @adobe/spectrum to 3.33.1 (#366)
bmingles 5dd4551
Simplified example (#366)
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
Large diffs are not rendered by default.
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
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
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
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,40 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { isElementOfType } from '@deephaven/react-hooks'; | ||
import { getSettings, RootState } from '@deephaven/redux'; | ||
import { ListView as DHListView } from '@deephaven/components'; | ||
import { ListView as DHListViewJSApi } from '@deephaven/jsapi-components'; | ||
import { SerializedListViewProps, useListViewProps } from './useListViewProps'; | ||
import ObjectView from './ObjectView'; | ||
import useReExportedTable from './useReExportedTable'; | ||
|
||
function ListView(props: SerializedListViewProps): JSX.Element | null { | ||
const settings = useSelector(getSettings<RootState>); | ||
const { children, ...listViewProps } = useListViewProps(props); | ||
|
||
const isObjectView = isElementOfType(children, ObjectView); | ||
const table = useReExportedTable(children); | ||
|
||
if (isObjectView) { | ||
return ( | ||
table && ( | ||
<DHListViewJSApi | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...listViewProps} | ||
table={table} | ||
settings={settings} | ||
/> | ||
) | ||
); | ||
} | ||
|
||
return ( | ||
<DHListView | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...listViewProps} | ||
> | ||
{children} | ||
</DHListView> | ||
); | ||
} | ||
|
||
export default ListView; |
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
42 changes: 42 additions & 0 deletions
42
plugins/ui/src/js/src/elements/spectrum/useSelectionEventCallback.ts
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,42 @@ | ||
import type { ItemKey, ItemSelection } from '@deephaven/components'; | ||
import { useCallback } from 'react'; | ||
|
||
export type SerializedSelection = 'all' | ItemKey[]; | ||
|
||
export type SerializedSelectionEventCallback = ( | ||
event: SerializedSelection | ||
) => void; | ||
|
||
/** | ||
* Selection can be 'all' or a Set of keys. If it is a Set, serialize it as an | ||
* array. | ||
* @param selection Selection to serialize | ||
* @returns Serialized selection | ||
*/ | ||
export function serializeSelectionEvent( | ||
selection: ItemSelection | ||
): SerializedSelection { | ||
if (selection instanceof Set) { | ||
return [...selection]; | ||
} | ||
|
||
return selection; | ||
} | ||
|
||
/** | ||
* Get a callback function that can be passed to selection change event handler | ||
* props of Spectrum components. | ||
* @param callback Callback to be called with the serialized selection | ||
* @returns A callback to be passed into the Spectrum component that transforms | ||
* the selection and calls the provided callback | ||
*/ | ||
export function useSelectionEventCallback( | ||
callback?: SerializedSelectionEventCallback | ||
): (selection: ItemSelection) => void { | ||
return useCallback( | ||
(selection: ItemSelection) => { | ||
callback?.(serializeSelectionEvent(selection)); | ||
}, | ||
[callback] | ||
); | ||
} |
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.
Selection isn't working for me at all right now. The second item should be selected initially, and it should update when things are checked off.
Looks like the props aren't actually passed through in @deephaven/components/ListView: https://github.com/deephaven/web-client-ui/blob/a283e13fafe1ecb156985fab00ba15344f180ff4/packages/components/src/spectrum/listView/ListView.tsx#L55
Unsure why that didn't get flagged as an unused variable ...
Also getting a ton of warnings in the logs whenever I change selection, we should squash these warnings or provide default values so Spectrum doesn't complain:
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.
Selection should be fixed by deephaven/web-client-ui#1986 .
I added the aria-label props to examples. I guess we could set a default of "List View" or something like that. @dsmmcken any opinions on this one?