diff --git a/plugins/ui/DESIGN.md b/plugins/ui/DESIGN.md index 910605d54..10f2185ae 100644 --- a/plugins/ui/DESIGN.md +++ b/plugins/ui/DESIGN.md @@ -1052,6 +1052,7 @@ ui.section( | `**props` | `Any` | Any other Section prop | ###### ui.list_action_group + A group of action buttons that can be used to create a list of actions. This component should be used within the actions prop of a `ListView` component. @@ -1066,16 +1067,17 @@ def list_action_group( ``` ###### Parameters -| Parameter | Type | Description | -|-------------------------|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `*children` | `ActionGroupItem` | The actions to render within the action group. | -| `on_action` | `Callable[[ActionKey, Key], None] \| None` | Handler that is called when an item is pressed. The first argument is the key of the action, the second argument is the key of the list_view item. | -| `on_selection_change` | `Callable[[Selection, Key], None] \| None` | Handler that is called when the selection changes. The first argument is the selection, the second argument is the key of the list_view item. | -| `on_change` | `Callable[[Selection, Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. The first argument is the selection, the second argument is the key of the list_view item. | -| `**props` | `Any` | Any other [ActionGroup](https://react-spectrum.adobe.com/react-spectrum/ActionGroup.html) prop. | +| Parameter | Type | Description | +| --------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `ActionGroupItem` | The actions to render within the action group. | +| `on_action` | `Callable[[ActionKey, Key], None] \| None` | Handler that is called when an item is pressed. The first argument is the key of the action, the second argument is the key of the list_view item. | +| `on_selection_change` | `Callable[[Selection, Key], None] \| None` | Handler that is called when the selection changes. The first argument is the selection, the second argument is the key of the list_view item. | +| `on_change` | `Callable[[Selection, Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. The first argument is the selection, the second argument is the key of the list_view item. | +| `**props` | `Any` | Any other [ActionGroup](https://react-spectrum.adobe.com/react-spectrum/ActionGroup.html) prop. | ###### ui.list_action_menu + A group of action buttons that can be used to create a list of actions. This component should be used within the actions prop of a `ListView` component. @@ -1089,12 +1091,13 @@ def list_action_menu( ``` ###### Parameters -| Parameter | Type | Description | -|-------------------------|------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------| -| `*children` | `ActionMenuItem` | The options to render within the picker. | -| `on_action` | `Callable[[ActionKey, Key], None] \| None` | Handler that is called when an item is pressed. The first argument is the key of the action, the second argument is the key of the list_view item. | -| `on_open_change` | `Callable[[bool, Key], None] \| None` | The first argument is a boolean indicating if the menu is open, the second argument is the key of the list_view item. | -| `**props` | `Any` | Any other [ActionMenu](https://react-spectrum.adobe.com/react-spectrum/ActionMenu.html) prop. | + +| Parameter | Type | Description | +| ---------------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `ActionMenuItem` | The options to render within the picker. | +| `on_action` | `Callable[[ActionKey, Key], None] \| None` | Handler that is called when an item is pressed. The first argument is the key of the action, the second argument is the key of the list_view item. | +| `on_open_change` | `Callable[[bool, Key], None] \| None` | The first argument is a boolean indicating if the menu is open, the second argument is the key of the list_view item. | +| `**props` | `Any` | Any other [ActionMenu](https://react-spectrum.adobe.com/react-spectrum/ActionMenu.html) prop. | ##### ui.item_table_source @@ -1119,27 +1122,28 @@ ui.item_table_source( ###### Parameters -| Parameter | Type | Description | -| ---------------------- | ----------------------------------------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `*children` | `Item \| SectionElement \| Table \| PartitionedTable` | The options to render within the picker. | -| `key_column` | `ColumnName \| None` | The column of values to use as item keys. Defaults to the first column. | -| `label_column` | `ColumnName \| None` | The column of values to display as primary text. Defaults to the `key_column` value. | -| `description_column` | `ColumnName \| None` | The column of values to display as descriptions. | -| `icon_column` | `ColumnName \| None` | The column of values to map to icons. | -| `title_column` | `ColumnName \| None` | Only valid if table is of type `PartitionedTable`. The column of values to display as section names. Should be the same for all values in the constituent `Table`. If not specified, the section titles will be created from the `key_columns` of the `PartitionedTable`. | -| `actions` | `ListActionGroupElement \| ListActionMenuElement \| None` | The action group or menus to render for all elements within the component, if supported. | +| Parameter | Type | Description | +| -------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `Item \| SectionElement \| Table \| PartitionedTable` | The options to render within the picker. | +| `key_column` | `ColumnName \| None` | The column of values to use as item keys. Defaults to the first column. | +| `label_column` | `ColumnName \| None` | The column of values to display as primary text. Defaults to the `key_column` value. | +| `description_column` | `ColumnName \| None` | The column of values to display as descriptions. | +| `icon_column` | `ColumnName \| None` | The column of values to map to icons. | +| `title_column` | `ColumnName \| None` | Only valid if table is of type `PartitionedTable`. The column of values to display as section names. Should be the same for all values in the constituent `Table`. If not specified, the section titles will be created from the `key_columns` of the `PartitionedTable`. | +| `actions` | `ListActionGroupElement \| ListActionMenuElement \| None` | The action group or menus to render for all elements within the component, if supported. | ##### ui.picker -A picker that can be used to select from a list. Children should be one of five types: -1. If children are of type `Item`, they are the dropdown options. -2. If children are of type `SectionElement`, they are the dropdown sections. +A picker that can be used to select from a list. Children should be one of five types: + +1. If children are of type `Item`, they are the dropdown options. +2. If children are of type `SectionElement`, they are the dropdown sections. 3. If children are of type `Table`, the values in the table are the dropdown options. There can only be one child, the `Table`. 4. If children are of type `PartitionedTable`, the values in the table are the dropdown options and the partitions create multiple sections. There can only be one child, the `PartitionedTable`. -5. If children are of type `ItemTableSource`, complex items are created from the source. -There can only be one child, the `ItemTableSource`. -Supported ItemTableSource arguments are `key_column`, `label_column`, `description_column`, -`icon_column`, and `title_column`. +5. If children are of type `ItemTableSource`, complex items are created from the source. + There can only be one child, the `ItemTableSource`. + Supported ItemTableSource arguments are `key_column`, `label_column`, `description_column`, + `icon_column`, and `title_column`. ```py import deephaven.ui as ui @@ -1155,14 +1159,14 @@ ui.picker( ###### Parameters -| Parameter | Type | Description | -| ---------------------- |--------------------------------------------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `*children` | `Item \| SectionElement \| Table \| PartitionedTable \| ItemTableSource` | The options to render within the picker. | -| `default_selected_key` | `Key \| None` | The initial selected key in the collection (uncontrolled). | -| `selected_key` | `Key \| None` | The currently selected key in the collection (controlled). | -| `on_selection_change` | `Callable[[Key], None] \| None` | Handler that is called when the selection changes. | -| `on_change` | `Callable[[Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. | -| `**props` | `Any` | Any other [Picker](https://react-spectrum.adobe.com/react-spectrum/Picker.html) prop, with the exception of `items`, `validate`, `errorMessage` (as a callback) and `onLoadMore` | +| Parameter | Type | Description | +| ---------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `Item \| SectionElement \| Table \| PartitionedTable \| ItemTableSource` | The options to render within the picker. | +| `default_selected_key` | `Key \| None` | The initial selected key in the collection (uncontrolled). | +| `selected_key` | `Key \| None` | The currently selected key in the collection (controlled). | +| `on_selection_change` | `Callable[[Key], None] \| None` | Handler that is called when the selection changes. | +| `on_change` | `Callable[[Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. | +| `**props` | `Any` | Any other [Picker](https://react-spectrum.adobe.com/react-spectrum/Picker.html) prop, with the exception of `items`, `validate`, `errorMessage` (as a callback) and `onLoadMore` | ```py import deephaven.ui as ui @@ -1266,13 +1270,15 @@ picker7 = ui.picker( ``` ###### ui.list_view -A list view that can be used to create a list of items. Children should be one of three types: -1. If children are of type `Item`, they are the list items. -2. If children are of type `Table`, the values in the table are the list items. There can only be one child, the `Table`. -3. If children are of type ItemTableSource, complex items are created from the table. -There can only be one child, the `ItemTableSource`. -Supported `ItemTableSource` arguments are `key_column`, `label_column`, `description_column`, -`icon_column`, and `actions`. + +A list view that can be used to create a list of items. Children should be one of three types: + +1. If children are of type `Item`, they are the list items. +2. If children are of type `Table`, the values in the table are the list items. There can only be one child, the `Table`. +3. If children are of type ItemTableSource, complex items are created from the table. + There can only be one child, the `ItemTableSource`. + Supported `ItemTableSource` arguments are `key_column`, `label_column`, `description_column`, + `icon_column`, and `actions`. ```py import deephaven.ui as ui @@ -1290,16 +1296,17 @@ ui.list_view( ``` ###### Parameters -| Parameter | Type | Description | -|-------------------------|-----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `*children` | `Item \| Table \| ItemTableSource` | The options to render within the list_view. | -| `selection_mode` | `SelectionMode \| None` | By default `"MULTIPLE"`, which allows multiple selection. May also be `"SINGLE"` to allow only single selection, or `"None"`/`None` to allow no selection. | -| `default_selected_keys` | `Selection \| None` | The initial selected keys in the collection (uncontrolled). | -| `selected_keys` | `Selection \| None` | The currently selected keys in the collection (controlled). | -| `render_empty_state` | `Element \| None` | Sets what the `list_view` should render when there is no content to display. | -| `on_selection_change` | `Callable[[Selection], None] \| None` | Handler that is called when the selections changes. | -| `on_change` | `Callable[[Selection], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selections changes. | -| `**props` | `Any` | Any other [ListView](https://react-spectrum.adobe.com/react-spectrum/ListView.html) prop, with the exception of `items`, `dragAndDropHooks`, and `onLoadMore`. | + +| Parameter | Type | Description | +| ----------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `Item \| Table \| ItemTableSource` | The options to render within the list_view. | +| `selection_mode` | `SelectionMode \| None` | By default `"MULTIPLE"`, which allows multiple selection. May also be `"SINGLE"` to allow only single selection, or `"None"`/`None` to allow no selection. | +| `default_selected_keys` | `Selection \| None` | The initial selected keys in the collection (uncontrolled). | +| `selected_keys` | `Selection \| None` | The currently selected keys in the collection (controlled). | +| `render_empty_state` | `Element \| None` | Sets what the `list_view` should render when there is no content to display. | +| `on_selection_change` | `Callable[[Selection], None] \| None` | Handler that is called when the selections changes. | +| `on_change` | `Callable[[Selection], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selections changes. | +| `**props` | `Any` | Any other [ListView](https://react-spectrum.adobe.com/react-spectrum/ListView.html) prop, with the exception of `items`, `dragAndDropHooks`, and `onLoadMore`. | ```py import deephaven.ui as ui @@ -1516,14 +1523,15 @@ date_picker8 = ui.date_picker( ##### ui.combo_box A combo_box that can be used to search or select from a list. Children should be one of five types: -1. If children are of type `Item`, they are the dropdown options. -2. If children are of type `SectionElement`, they are the dropdown sections. + +1. If children are of type `Item`, they are the dropdown options. +2. If children are of type `SectionElement`, they are the dropdown sections. 3. If children are of type `Table`, the values in the table are the dropdown options. There can only be one child, the `Table`. 4. If children are of type `PartitionedTable`, the values in the table are the dropdown options and the partitions create multiple sections. There can only be one child, the `PartitionedTable`. -5. If children are of type `ItemTableSource`, complex items are created from the source. -There can only be one child, the ItemTableSource. -Supported ItemTableSource arguments are `key_column`, `label_column`, `description_column`, -`icon_column`, and `title_column`. +5. If children are of type `ItemTableSource`, complex items are created from the source. + There can only be one child, the ItemTableSource. + Supported ItemTableSource arguments are `key_column`, `label_column`, `description_column`, + `icon_column`, and `title_column`. ```py import deephaven.ui as ui @@ -1543,18 +1551,18 @@ ui.combo_box( ###### Parameters -| Parameter | Type | Description | -| ---------------------- |--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `*children` | `Item \| SectionElement \| Table \| PartitionedTable \| ItemTableSource` | The options to render within the combo_box. | -| `default_selected_key` | `Key \| None` | The initial selected key in the collection (uncontrolled). | -| `selected_key` | `Key \| None` | The currently selected key in the collection (controlled). | -| `input_value` | `str \| None` | The value of the search input (controlled). | -| `default_input_value` | `str \| None` | The default value of the search input (uncontrolled). | -| `on_input_change` | `Callable[[str], None] \| None` | Handler that is called when the search input value changes. | -| `on_selection_change` | `Callable[[Key], None] \| None` | Handler that is called when the selection changes. | -| `on_change` | `Callable[[Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. | -| `on_open_change` | `Callable[[bool, MenuTriggerAction], None] \| None` | Method that is called when the open state of the menu changes. Returns the new open state and the action that caused the opening of the menu. | -| `**props` | `Any` | Any other [Combo_Box](https://react-spectrum.adobe.com/react-spectrum/ComboBox.html) prop, with the exception of `items`, `validate`, `errorMessage` (as a callback) and `onLoadMore` | +| Parameter | Type | Description | +| ---------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `*children` | `Item \| SectionElement \| Table \| PartitionedTable \| ItemTableSource` | The options to render within the combo_box. | +| `default_selected_key` | `Key \| None` | The initial selected key in the collection (uncontrolled). | +| `selected_key` | `Key \| None` | The currently selected key in the collection (controlled). | +| `input_value` | `str \| None` | The value of the search input (controlled). | +| `default_input_value` | `str \| None` | The default value of the search input (uncontrolled). | +| `on_input_change` | `Callable[[str], None] \| None` | Handler that is called when the search input value changes. | +| `on_selection_change` | `Callable[[Key], None] \| None` | Handler that is called when the selection changes. | +| `on_change` | `Callable[[Key], None] \| None` | Alias of `on_selection_change`. Handler that is called when the selection changes. | +| `on_open_change` | `Callable[[bool, MenuTriggerAction], None] \| None` | Method that is called when the open state of the menu changes. Returns the new open state and the action that caused the opening of the menu. | +| `**props` | `Any` | Any other [Combo_Box](https://react-spectrum.adobe.com/react-spectrum/ComboBox.html) prop, with the exception of `items`, `validate`, `errorMessage` (as a callback) and `onLoadMore` | ```py import deephaven.ui as ui @@ -1723,8 +1731,8 @@ ui_table( front_columns: ColumnNameCombination | None, hide_columns: ColumnNameCombination | None, quick_filters: dict[ColumnName, QuickFilterExpression] | None, - show_search: bool | None, - show_quick_filters: bool | None, + show_search: bool, + show_quick_filters: bool, show_column_headers: bool | None, selection_mode: SelectionMode | None, selection_area: SelectionArea | None, @@ -1756,8 +1764,8 @@ ui_table( | `front_columns` | `ColumnNameCombination \| None` | The columns to show at the front of the table. May be a single column name. These will not be moveable in the UI. | | `hide_columns` | `ColumnNameCombination \| None` | The columns to hide by default from the table. May be a single column name. The user can still resize the columns to view them. | | `quick_filters` | `dict[ColumnName, QuickFilterExpression] \| None` | Quick filters for the UI to apply to the table. | -| `show_search` | `bool \| None` | `True` to show the search bar by default, `False` to not. | -| `show_quick_filters` | `bool \| None` | `True` to show the quick filters by default, `False` to not. | +| `show_search` | `bool` | `True` to show the search bar by default, `False` to not. `False` by default. | +| `show_quick_filters` | `bool` | `True` to show the quick filters by default, `False` to not. `False` by default. | | `show_column_headers` | `bool \| None` | `True` to show the column headers by default, `False` to not. | | `selection_mode` | `SelectionMode \| None` | Can be `MULTIPLE` to allow multiple selection or `SINGLE` to not allow it. | | `selection_area` | `SelectionArea \| None` | The unit that is selected on press. Can be `ROW`, `COLUMN`, or `CELL`. | diff --git a/plugins/ui/src/deephaven/ui/components/table.py b/plugins/ui/src/deephaven/ui/components/table.py index 9f4e8226a..27398533d 100644 --- a/plugins/ui/src/deephaven/ui/components/table.py +++ b/plugins/ui/src/deephaven/ui/components/table.py @@ -4,7 +4,9 @@ from ..elements import UITable from ..types import ( CellPressCallback, + ColumnName, ColumnPressCallback, + QuickFilterExpression, RowPressCallback, ) @@ -18,6 +20,9 @@ def table( on_cell_double_press: CellPressCallback | None = None, on_column_press: ColumnPressCallback | None = None, on_column_double_press: ColumnPressCallback | None = None, + quick_filters: dict[ColumnName, QuickFilterExpression] | None = None, + show_quick_filters: bool = False, + show_search: bool = False, ) -> UITable: """ Customization to how a table is displayed, how it behaves, and listen to UI events. @@ -40,6 +45,9 @@ def table( The first parameter is the column name. on_column_double_press: The callback function to run when a column is double clicked. The first parameter is the column name. + quick_filters: The quick filters to apply to the table. Dictionary of column name to filter value. + show_quick_filters: Whether to show the quick filter bar by default. + show_search: Whether to show the search bar by default. """ props = locals() del props["table"] diff --git a/plugins/ui/src/deephaven/ui/elements/UITable.py b/plugins/ui/src/deephaven/ui/elements/UITable.py index 19084f3a8..fb80cb0f3 100644 --- a/plugins/ui/src/deephaven/ui/elements/UITable.py +++ b/plugins/ui/src/deephaven/ui/elements/UITable.py @@ -16,7 +16,6 @@ from ..types import ( ColumnName, AggregationOperation, - SearchMode, QuickFilterExpression, Color, ContextMenuAction, @@ -58,11 +57,6 @@ def remap_sort_direction(direction: TableSortDirection | str) -> Literal["ASC", class UITableProps(TypedDict): - can_search: NotRequired[bool] - """ - Whether the search bar is accessible or not. Use the system default if no value set. - """ - on_row_press: NotRequired[RowPressCallback] """ Callback function to run when a row is clicked. @@ -190,7 +184,9 @@ def _with_dict_prop(self, key: str, value: dict[str, Any]) -> "UITable": A new UITable with the passed in prop added to the existing props """ logger.debug("_with_dict_prop(%s, %s)", key, value) - existing = self._props.get(key, {}) + existing = ( + self._props.get(key) or {} + ) # Turn missing or explicit None into empty dict return UITable(**{**self._props, key: {**existing, **value}}) # type: ignore def render(self, context: RenderContext) -> dict[str, Any]: @@ -250,29 +246,6 @@ def back_columns(self, columns: str | list[str]) -> "UITable": """ raise NotImplementedError() - def can_search(self, mode: SearchMode) -> "UITable": - """ - Set the search bar to explicitly be accessible or inaccessible, or use the system default. - - Args: - mode: Set the search bar to explicitly be accessible or inaccessible, - or use the system default. - - Returns: - A new UITable - """ - if mode == "SHOW": - return self._with_prop("can_search", True) - elif mode == "HIDE": - return self._with_prop("can_search", False) - elif mode == "DEFAULT": - new = self._with_prop("can_search", None) - # pop current can_search value if it exists - new._props.pop("can_search", None) - return new - - raise ValueError(f"Invalid search mode: {mode}") - def column_group( self, name: str, children: list[str], color: str | None ) -> "UITable": @@ -477,20 +450,6 @@ def on_row_double_press(self, callback: RowPressCallback) -> "UITable": ) return self._with_prop("on_row_double_press", callback) - def quick_filter( - self, filter: dict[ColumnName, QuickFilterExpression] - ) -> "UITable": - """ - Add a quick filter for the UI to apply to the table. - - Args: - filter: The quick filter to apply to the table. - - Returns: - A new UITable - """ - return self._with_dict_prop("filters", filter) - def selection_mode(self, mode: SelectionMode) -> "UITable": """ Set the selection mode for the table. diff --git a/plugins/ui/src/deephaven/ui/types/types.py b/plugins/ui/src/deephaven/ui/types/types.py index ee6948a87..ab0300fb2 100644 --- a/plugins/ui/src/deephaven/ui/types/types.py +++ b/plugins/ui/src/deephaven/ui/types/types.py @@ -100,7 +100,6 @@ class RowDataValue(CellData): RowData = Dict[ColumnName, Any] ColumnData = List[Any] TableData = Dict[ColumnName, ColumnData] -SearchMode = Literal["SHOW", "HIDE", "DEFAULT"] SelectionArea = Literal["CELL", "ROW", "COLUMN"] SelectionMode = Literal["SINGLE", "MULTIPLE"] Sentinel = Any diff --git a/plugins/ui/src/js/src/elements/UITable.tsx b/plugins/ui/src/js/src/elements/UITable.tsx index 0c137c27e..7127e67b4 100644 --- a/plugins/ui/src/js/src/elements/UITable.tsx +++ b/plugins/ui/src/js/src/elements/UITable.tsx @@ -25,11 +25,12 @@ function UITable({ onColumnDoublePress, onRowPress, onRowDoublePress, - canSearch, - filters, + quickFilters, sorts, alwaysFetchColumns, table: exportedTable, + showSearch: showSearchBar, + showQuickFilters, }: UITableProps): JSX.Element | null { const dh = useApi(); const [model, setModel] = useState(); @@ -47,12 +48,16 @@ function UITable({ }, [columns, utils, sorts]); const hydratedQuickFilters = useMemo(() => { - if (filters !== undefined && model !== undefined && columns !== undefined) { - log.debug('Hydrating filters', filters); + if ( + quickFilters !== undefined && + model !== undefined && + columns !== undefined + ) { + log.debug('Hydrating filters', quickFilters); const dehydratedQuickFilters: DehydratedQuickFilter[] = []; - Object.entries(filters).forEach(([columnName, filter]) => { + Object.entries(quickFilters).forEach(([columnName, filter]) => { const columnIndex = model.getColumnIndexByName(columnName); if (columnIndex !== undefined) { dehydratedQuickFilters.push([columnIndex, { text: filter }]); @@ -62,7 +67,7 @@ function UITable({ return utils.hydrateQuickFilters(columns, dehydratedQuickFilters); } return undefined; - }, [filters, model, columns, utils]); + }, [quickFilters, model, columns, utils]); // Just load the object on mount useEffect(() => { @@ -110,19 +115,22 @@ function UITable({ ] ); - const irisGridProps: Partial = useMemo( - () => ({ - mouseHandlers, - alwaysFetchColumns, - showSearchBar: canSearch, - sorts: hydratedSorts, - quickFilters: hydratedQuickFilters, - settings, - }), + const irisGridProps = useMemo( + () => + ({ + mouseHandlers, + alwaysFetchColumns, + showSearchBar, + sorts: hydratedSorts, + quickFilters: hydratedQuickFilters, + isFilterBarShown: showQuickFilters, + settings, + }) satisfies Partial, [ mouseHandlers, alwaysFetchColumns, - canSearch, + showSearchBar, + showQuickFilters, hydratedSorts, hydratedQuickFilters, settings, diff --git a/plugins/ui/src/js/src/elements/UITableUtils.tsx b/plugins/ui/src/js/src/elements/UITableUtils.tsx index b86dc7bb4..22cd0f9d5 100644 --- a/plugins/ui/src/js/src/elements/UITableUtils.tsx +++ b/plugins/ui/src/js/src/elements/UITableUtils.tsx @@ -30,9 +30,10 @@ export interface UITableProps { onColumnPress?: (columnName: ColumnName) => void; onColumnDoublePress?: (columnName: ColumnName) => void; alwaysFetchColumns?: string[]; - canSearch?: boolean; - filters?: Record; + quickFilters?: Record; sorts?: DehydratedSort[]; + showSearch: boolean; + showQuickFilters: boolean; [key: string]: unknown; } diff --git a/plugins/ui/test/deephaven/ui/test_ui_table.py b/plugins/ui/test/deephaven/ui/test_ui_table.py index d832bf243..86a9713b7 100644 --- a/plugins/ui/test/deephaven/ui/test_ui_table.py +++ b/plugins/ui/test/deephaven/ui/test_ui_table.py @@ -19,7 +19,9 @@ def expect_render(self, ui_table, expected_props: dict[str, Any]): context = RenderContext(on_change, on_queue) result = ui_table.render(context) - self.assertDictEqual(result, expected_props) + # Can replace 2nd param with result | expected_props after dropping Python 3.8 + # https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative + self.assertDictEqual(result, {**result, **expected_props}) def test_empty_ui_table(self): import deephaven.ui as ui @@ -39,7 +41,6 @@ def callback(row): self.expect_render( t, { - "table": self.source, "onRowDoublePress": callback, }, ) @@ -54,7 +55,6 @@ def test_always_fetch_columns(self): self.expect_render( t, { - "table": self.source, "alwaysFetchColumns": ["X"], }, ) @@ -64,7 +64,6 @@ def test_always_fetch_columns(self): self.expect_render( t, { - "table": self.source, "alwaysFetchColumns": ["X", "Y"], }, ) @@ -74,95 +73,88 @@ def test_always_fetch_columns(self): self.expect_render( t, { - "table": self.source, "alwaysFetchColumns": ["X", "Y"], }, ) - def test_can_search(self): + def test_quick_filters(self): import deephaven.ui as ui - ui_table = ui.table(self.source) - - t = ui_table.can_search("SHOW") + t = ui.table(self.source, quick_filters={"X": "X > 1"}) self.expect_render( t, { - "table": self.source, - "canSearch": True, + "quickFilters": {"X": "X > 1"}, }, ) - t = ui_table.can_search("HIDE") + t = ui.table(self.source, quick_filters={"X": "X > 1", "Y": "Y < 2"}) self.expect_render( t, { - "table": self.source, - "canSearch": False, + "quickFilters": {"X": "X > 1", "Y": "Y < 2"}, }, ) - t = ui_table.can_search("DEFAULT") + def test_show_quick_filters(self): + import deephaven.ui as ui + + t = ui.table(self.source) self.expect_render( t, { - "table": self.source, + "showQuickFilters": False, }, ) - t = ui_table.can_search("SHOW").can_search("DEFAULT") + t = ui.table(self.source, show_quick_filters=True) self.expect_render( t, { - "table": self.source, + "showQuickFilters": True, }, ) - t = ui_table.can_search("HIDE").can_search("DEFAULT") + t = ui.table(self.source, show_quick_filters=False) self.expect_render( t, { - "table": self.source, + "showQuickFilters": False, }, ) - def test_quick_filter(self): + def test_show_search(self): import deephaven.ui as ui - ui_table = ui.table(self.source) - - t = ui_table.quick_filter({"X": "X > 1"}) + t = ui.table(self.source) self.expect_render( t, { - "table": self.source, - "filters": {"X": "X > 1"}, + "showSearch": False, }, ) - t = ui_table.quick_filter({"X": "X > 1"}).quick_filter({"X": "X > 2"}) + t = ui.table(self.source, show_search=True) self.expect_render( t, { - "table": self.source, - "filters": {"X": "X > 2"}, + "showSearch": True, }, ) - t = ui_table.quick_filter({"X": "X > 1", "Y": "Y < 2"}) + t = ui.table(self.source, show_search=False) self.expect_render( t, { - "table": self.source, - "filters": {"X": "X > 1", "Y": "Y < 2"}, + "showSearch": False, }, ) @@ -176,7 +168,6 @@ def test_sort(self): self.expect_render( t, { - "table": self.source, "sorts": [{"column": "X", "direction": "ASC", "is_abs": False}], }, ) @@ -185,7 +176,6 @@ def test_sort(self): self.expect_render( t, { - "table": self.source, "sorts": [{"column": "X", "direction": "DESC", "is_abs": False}], }, ) @@ -208,7 +198,6 @@ def test_sort(self): self.expect_render( t, { - "table": self.source, "sorts": [ {"column": "X", "direction": "ASC", "is_abs": False}, {"column": "Y", "direction": "DESC", "is_abs": False}, @@ -221,7 +210,6 @@ def test_sort(self): self.expect_render( t, { - "table": self.source, "sorts": [ {"column": "X", "direction": "DESC", "is_abs": False}, {"column": "Y", "direction": "ASC", "is_abs": False},