From 82256aa3a2bd2952e8f846a554806f29a6adb507 Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Tue, 16 Jul 2024 22:51:17 -0500 Subject: [PATCH] feat: UI.Table density prop --- plugins/ui/src/deephaven/ui/components/table.py | 4 ++++ plugins/ui/src/js/src/elements/UITable/UITable.tsx | 3 +++ plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx | 1 + 3 files changed, 8 insertions(+) diff --git a/plugins/ui/src/deephaven/ui/components/table.py b/plugins/ui/src/deephaven/ui/components/table.py index 74ed187fa..0a0e67f55 100644 --- a/plugins/ui/src/deephaven/ui/components/table.py +++ b/plugins/ui/src/deephaven/ui/components/table.py @@ -1,4 +1,5 @@ from __future__ import annotations +from typing import Literal from deephaven.table import Table from ..elements import UITable @@ -31,6 +32,7 @@ def table( frozen_columns: list[ColumnName] | None = None, hidden_columns: list[ColumnName] | None = None, column_groups: list[ColumnGroup] | None = None, + density: Literal["compact", "normal", "spacious"] | None = None, context_menu: ( ResolvableContextMenuItem | list[ResolvableContextMenuItem] | None ) = None, @@ -70,6 +72,8 @@ def table( column_groups: Columns to group together by default. The groups will be shown in the table header. Group names must be unique within the column and group names. Groups may be nested by providing the group name as a child of another group. + density: The density of the data displayed in the table. + One of "compact", "normal", or "spacious". context_menu: The context menu items to show when a cell is right clicked. May contain action items or submenu items. May also be a function that receives the cell data and returns the context menu items or None. diff --git a/plugins/ui/src/js/src/elements/UITable/UITable.tsx b/plugins/ui/src/js/src/elements/UITable/UITable.tsx index 5ddd256c1..5bf353c3d 100644 --- a/plugins/ui/src/js/src/elements/UITable/UITable.tsx +++ b/plugins/ui/src/js/src/elements/UITable/UITable.tsx @@ -42,6 +42,7 @@ export function UITable({ frozenColumns, hiddenColumns, columnGroups, + density, contextMenu, contextHeaderMenu, }: UITableProps): JSX.Element | null { @@ -170,6 +171,7 @@ export function UITable({ reverseType: reverse ? TableUtils.REVERSE_TYPE.POST_SORT : TableUtils.REVERSE_TYPE.NONE, + density, settings, onContextMenu, }) satisfies Partial, @@ -181,6 +183,7 @@ export function UITable({ hydratedSorts, hydratedQuickFilters, reverse, + density, settings, onContextMenu, ] diff --git a/plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx b/plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx index f282cdfd8..119352d72 100644 --- a/plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx +++ b/plugins/ui/src/js/src/elements/UITable/UITableUtils.tsx @@ -73,6 +73,7 @@ export type UITableProps = { frozenColumns?: string[]; hiddenColumns?: string[]; columnGroups?: dh.ColumnGroup[]; + density?: 'compact' | 'normal' | 'spacious'; contextMenu?: ResolvableUIContextItem | ResolvableUIContextItem[]; contextHeaderMenu?: ResolvableUIContextItem | ResolvableUIContextItem[]; };