diff --git a/plugins/ui/src/deephaven/ui/components/list_view.py b/plugins/ui/src/deephaven/ui/components/list_view.py index f467ba0de..fdebf095b 100644 --- a/plugins/ui/src/deephaven/ui/components/list_view.py +++ b/plugins/ui/src/deephaven/ui/components/list_view.py @@ -9,7 +9,7 @@ from .list_action_menu import ListActionMenuElement from ..elements import BaseElement, Element from .._internal.utils import create_props -from ..types import ColumnName, Stringable, Selection +from ..types import ColumnName, Stringable, Selection, SelectionMode ListViewItem = Union[Stringable, ItemElement] ListViewElement = Element @@ -24,6 +24,7 @@ def list_view( actions: ListActionGroupElement | ListActionMenuElement | None = None, default_selected_keys: Selection | None = None, selected_keys: Selection | None = None, + selection_mode: SelectionMode | None = "MULTIPLE", render_empty_state: Element | None = None, on_selection_change: Callable[[Selection], None] | None = None, on_change: Callable[[Selection], None] | None = None, diff --git a/plugins/ui/src/deephaven/ui/types/types.py b/plugins/ui/src/deephaven/ui/types/types.py index 90bfd8480..d125a15ca 100644 --- a/plugins/ui/src/deephaven/ui/types/types.py +++ b/plugins/ui/src/deephaven/ui/types/types.py @@ -97,7 +97,8 @@ class RowDataValue(CellData): ColumnData = List[Any] TableData = Dict[ColumnName, ColumnData] SearchMode = Literal["SHOW", "HIDE", "DEFAULT"] -SelectionMode = Literal["CELL", "ROW", "COLUMN"] +SelectionArea = Literal["CELL", "ROW", "COLUMN"] +SelectionMode = Literal["SINGLE", "MULTIPLE"] Sentinel = Any TransformedData = Any StringSortDirection = Literal["ASC", "DESC"] diff --git a/plugins/ui/src/js/src/elements/ListView.tsx b/plugins/ui/src/js/src/elements/ListView.tsx index d3e8ce0b0..bcaa44211 100644 --- a/plugins/ui/src/js/src/elements/ListView.tsx +++ b/plugins/ui/src/js/src/elements/ListView.tsx @@ -1,5 +1,6 @@ import React, { ReactElement } from 'react'; import { useSelector } from 'react-redux'; +import type { SelectionMode } from '@react-types/shared'; import { isElementOfType } from '@deephaven/react-hooks'; import { getSettings, RootState } from '@deephaven/redux'; import { @@ -21,27 +22,51 @@ type WrappedDHListViewJSApiProps = Omit & { children: ReactElement; }; -export type ListViewProps = (DHListViewProps | WrappedDHListViewJSApiProps) & +type WrappedDHListViewProps = Omit & { + // The spec specifies that selectionMode should be uppercase, but the Spectrum + // prop is lowercase. We'll accept either to keep things more flexible.s + selectionMode?: SelectionMode | Uppercase; +}; + +export type ListViewProps = ( + | WrappedDHListViewProps + | WrappedDHListViewJSApiProps +) & SerializedListViewEventProps; -function ListView({ children, ...props }: ListViewProps) { +function ListView({ children, selectionMode, ...props }: ListViewProps) { const settings = useSelector(getSettings); const listViewProps = useListViewProps(props); const isObjectView = isElementOfType(children, ObjectView); const table = useReExportedTable(children); + const selectionModeLc = (selectionMode?.toLowerCase() ?? + 'none') as SelectionMode; + if (isObjectView) { return ( table && ( - // eslint-disable-next-line react/jsx-props-no-spreading - + ) ); } - // eslint-disable-next-line react/jsx-props-no-spreading - return {children}; + return ( + + {children} + + ); } export default ListView;