From deed825f1a52d62344d08a3fcd649f4197dee19a Mon Sep 17 00:00:00 2001 From: Akshat Jawne Date: Wed, 22 May 2024 08:45:19 -0600 Subject: [PATCH 1/4] Fix commit error --- .../src/deephaven/ui/components/__init__.py | 3 +- .../deephaven/ui/components/action_group.py | 221 ++++++++++++++++++ .../src/deephaven/ui/components/list_view.py | 4 +- .../ui/components/spectrum/events.py | 1 + .../ui/components/spectrum/layout.py | 2 + plugins/ui/src/deephaven/ui/types/types.py | 17 +- 6 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 plugins/ui/src/deephaven/ui/components/action_group.py diff --git a/plugins/ui/src/deephaven/ui/components/__init__.py b/plugins/ui/src/deephaven/ui/components/__init__.py index 09efe6596..87d40df2f 100644 --- a/plugins/ui/src/deephaven/ui/components/__init__.py +++ b/plugins/ui/src/deephaven/ui/components/__init__.py @@ -9,6 +9,7 @@ from .column import column from .stack import stack from .picker import picker +from .action_group import action_group from .section import section from .item import item from .list_view import list_view @@ -21,7 +22,7 @@ __all__ = [ "action_button", - "button", + "action_group" "button", "button_group", "checkbox", "column", diff --git a/plugins/ui/src/deephaven/ui/components/action_group.py b/plugins/ui/src/deephaven/ui/components/action_group.py new file mode 100644 index 000000000..651a95027 --- /dev/null +++ b/plugins/ui/src/deephaven/ui/components/action_group.py @@ -0,0 +1,221 @@ +from __future__ import annotations +from numbers import Number +from typing import Any, Callable, Iterable +from plugins.ui.src.deephaven.ui.components.spectrum.events import ( + ButtonLabelBehavior, + Orientation, + StaticColor, +) +from plugins.ui.src.deephaven.ui.elements import BaseElement +from plugins.ui.src.deephaven.ui.types.types import ( + ActionGroupDensity, + SelectedKeys, + SelectionMode, +) +from .spectrum.layout import ( + AlignSelf, + CSSProperties, + DimensionValue, + JustifySelf, + LayoutFlex, + OverflowMode, + Position, +) +from ..elements import Element + + +def action_group( + *children: Any, + is_emphasized: bool | None = None, + density: ActionGroupDensity | None = "regular", + is_justified: bool | None = None, + is_quiet: bool | None = None, + static_color: StaticColor | None = None, + overflow_mode: OverflowMode | None = "wrap", + button_label_behavior: ButtonLabelBehavior | None = "show", + summary_icon: Element | None = None, + orientation: Orientation | None = "horizontal", + items: Iterable[object] | None = None, + disabled_keys: Iterable[str] | None = None, + is_disabled: bool | None = None, + selection_mode: SelectionMode | None = None, + disallow_empty_selection: bool | None = None, + selected_keys: SelectedKeys | Iterable[str] | None = None, + default_selected_keys: SelectedKeys | Iterable[str] | None = None, + on_action: Callable[[str], None] | None = None, + on_selection_change: Callable[[str], None] | None = None, + flex: LayoutFlex | None = None, + flex_grow: Number | None = None, + flex_shrink: Number | None = None, + flex_basis: DimensionValue | None = None, + align_self: AlignSelf | None = None, + justify_self: JustifySelf | None = None, + order: Number | None = None, + grid_area: str | None = None, + grid_row: str | None = None, + grid_column: str | None = None, + grid_column_start: str | None = None, + grid_column_end: str | None = None, + grid_row_start: str | None = None, + grid_row_end: str | None = None, + margin: DimensionValue | None = None, + margin_top: DimensionValue | None = None, + margin_bottom: DimensionValue | None = None, + margin_start: DimensionValue | None = None, + margin_end: DimensionValue | None = None, + margin_x: DimensionValue | None = None, + margin_y: DimensionValue | None = None, + width: DimensionValue | None = None, + height: DimensionValue | None = None, + min_width: DimensionValue | None = None, + min_height: DimensionValue | None = None, + max_width: DimensionValue | None = None, + max_height: DimensionValue | None = None, + position: Position | None = None, + top: DimensionValue | None = None, + bottom: DimensionValue | None = None, + left: DimensionValue | None = None, + right: DimensionValue | None = None, + start: DimensionValue | None = None, + end: DimensionValue | None = None, + z_index: Number | None = None, + is_hidden: bool | None = None, + id: str | None = None, + aria_label: str | None = None, + aria_labelledby: str | None = None, + aria_describedby: str | None = None, + aria_details: str | None = None, + UNSAFE_class_name: str | None = None, + UNSAFE_style: CSSProperties | None = None, +) -> Element: + """ + A contextual help is a quiet action button that triggers an informational popover. + Args: + *children: The children of the contextual help popover. + is_emphasized: An list of Item elements or a function. If the latter, a list of items must be provided using the items prop. + density: Sets the amount of space between buttons. + is_justified: Whether the ActionButtons should be justified in their container. + is_quiet: Whether ActionButtons should use the quiet style. + static_color: The static color style to apply. Useful when the ActionGroup appears over a color background. + overflow_mode: The behavior of the ActionGroup when the buttons do not fit in the available space. + button_label_behaviour: Defines when the text within the buttons should be hidden and only the icon should be shown. + summary_icon: The icon displayed in the dropdown menu button when a selectable ActionGroup is collapsed. + orientation: The axis the ActionGroup should align with. + items: A list of items to display as children. Must be used with a function as the sole child. + disabled_keys: A list of keys to disable. + is_disabled: Whether the ActionGroup is disabled. Shows that a selection exists, but is not available in that circumstance. + selection_mode: The type of selection that is allowed in the collection. + disallow_empty_selection: Whether the collection allows empty selection. + selected_keys: The currently selected keys in the collection (controlled). + default_selected_keys: The initial selected keys in the collection (uncontrolled). + on_action: Invoked when an action is taken on a child. Especially useful when selectionMode is none. The sole argument key is the key for the item. + on_selection_change: Handler that is called when the selection changes. + flex: When used in a flex layout, specifies how the element will grow or shrink to fit the space available. + flex_grow: When used in a flex layout, specifies how the element will grow to fit the space available. + flex_shrink: When used in a flex layout, specifies how the element will shrink to fit the space available. + flex_basis: When used in a flex layout, specifies the initial main size of the element. + align_self: Overrides the alignItems property of a flex or grid container. + justify_self: Species how the element is justified inside a flex or grid container. + order: The layout order for the element within a flex or grid container. + grid_area: When used in a grid layout specifies, specifies the named grid area that the element should be placed in within the grid. + grid_row: When used in a grid layout, specifies the row the element should be placed in within the grid. + grid_column: When used in a grid layout, specifies the column the element should be placed in within the grid. + grid_row_start: When used in a grid layout, specifies the starting row to span within the grid. + grid_row_end: When used in a grid layout, specifies the ending row to span within the grid. + grid_column_start: When used in a grid layout, specifies the starting column to span within the grid. + grid_column_end: When used in a grid layout, specifies the ending column to span within the grid. + margin: The margin for all four sides of the element. + margin_top: The margin for the top side of the element. + margin_bottom: The margin for the bottom side of the element. + margin_start: The margin for the logical start side of the element, depending on layout direction. + margin_end: The margin for the logical end side of the element, depending on layout direction. + margin_x: The margin for the left and right sides of the element. + margin_y: The margin for the top and bottom sides of the element. + width: The width of the element. + height: The height of the element. + min_width: The minimum width of the element. + min_height: The minimum height of the element. + max_width: The maximum width of the element. + max_height: The maximum height of the element. + position: Specifies how the element is position. + top: The top position of the element. + bottom: The bottom position of the element. + left: The left position of the element. + right: The right position of the element. + start: The logical start position of the element, depending on layout direction. + end: The logical end position of the element, depending on layout direction. + z_index: The stacking order for the element + is_hidden: Hides the element. + id: The unique identifier of the element. + aria-label: Defines a string value that labels the current element. + aria-labelledby: Identifies the element (or elements) that labels the current element. + aria-describedby: Identifies the element (or elements) that describes the object. + aria-details: Identifies the element (or elements) that provide a detailed, extended description for the object. + UNSAFE_class_name: Set the CSS className for the element. Only use as a last resort. Use style props instead. + UNSAFE_style: Set the inline style for the element. Only use as a last resort. Use style props instead. + """ + return BaseElement( + "deephaven.ui.components.ActionGroup", + *children, + is_emphasized=is_emphasized, + density=density, + is_justified=is_justified, + is_quiet=is_quiet, + static_color=static_color, + overflow_mode=overflow_mode, + button_label_behavior=button_label_behavior, + summary_icon=summary_icon, + orientation=orientation, + items=items, + disabled_keys=disabled_keys, + is_disabled=is_disabled, + selection_mode=selection_mode, + disallow_empty_selection=disallow_empty_selection, + selected_keys=selected_keys, + default_selected_keys=default_selected_keys, + on_action=on_action, + on_selection_change=on_selection_change, + flex=flex, + flex_grow=flex_grow, + flex_shrink=flex_shrink, + flex_basis=flex_basis, + align_self=align_self, + justify_self=justify_self, + order=order, + grid_area=grid_area, + grid_row=grid_row, + grid_column=grid_column, + grid_column_start=grid_column_start, + grid_column_end=grid_column_end, + grid_row_start=grid_row_start, + grid_row_end=grid_row_end, + margin=margin, + margin_top=margin_top, + margin_bottom=margin_bottom, + margin_start=margin_start, + margin_end=margin_end, + margin_x=margin_x, + margin_y=margin_y, + width=width, + height=height, + min_width=min_width, + min_height=min_height, + max_width=max_width, + max_height=max_height, + position=position, + top=top, + bottom=bottom, + left=left, + right=right, + start=start, + end=end, + z_index=z_index, + is_hidden=is_hidden, + id=id, + aria_label=aria_label, + aria_labelledby=aria_labelledby, + aria_describedby=aria_describedby, + aria_details=aria_details, + UNSAFE_class_name=UNSAFE_class_name, + UNSAFE_style=UNSAFE_style, + ) diff --git a/plugins/ui/src/deephaven/ui/components/list_view.py b/plugins/ui/src/deephaven/ui/components/list_view.py index 752d06f2a..5bd2f50e9 100644 --- a/plugins/ui/src/deephaven/ui/components/list_view.py +++ b/plugins/ui/src/deephaven/ui/components/list_view.py @@ -8,7 +8,7 @@ from ..elements import BaseElement, Element from .._internal.utils import create_props, unpack_item_table_source from .item import Item -from ..types import Density, Selection, SelectionMode +from ..types import ListViewDensity, Selection, SelectionMode ListViewElement = Element @@ -23,7 +23,7 @@ def list_view( *children: Item | Table | ItemTableSource, - density: Density | None = "COMPACT", + density: ListViewDensity | None = "COMPACT", default_selected_keys: Selection | None = None, selected_keys: Selection | None = None, selection_mode: SelectionMode | None = "MULTIPLE", diff --git a/plugins/ui/src/deephaven/ui/components/spectrum/events.py b/plugins/ui/src/deephaven/ui/components/spectrum/events.py index eaf61adee..ad0e9a46e 100644 --- a/plugins/ui/src/deephaven/ui/components/spectrum/events.py +++ b/plugins/ui/src/deephaven/ui/components/spectrum/events.py @@ -98,6 +98,7 @@ class PressEvent(TypedDict): StaticColor = Literal["white", "black"] ButtonType = Literal["button", "submit", "reset"] +ButtonLabelBehavior = Literal["show", "collapse", "hide"] ButtonVariant = Literal[ "accent", "primary", "secondary", "negative", "cta", "overBackground" ] diff --git a/plugins/ui/src/deephaven/ui/components/spectrum/layout.py b/plugins/ui/src/deephaven/ui/components/spectrum/layout.py index 83f8073a0..0a6099d0e 100644 --- a/plugins/ui/src/deephaven/ui/components/spectrum/layout.py +++ b/plugins/ui/src/deephaven/ui/components/spectrum/layout.py @@ -104,6 +104,8 @@ "stretch", ] +OverflowMode = Literal["wrap", "collapse"] + Number = Union[int, float] LayoutFlex = Union[str, Number, bool] diff --git a/plugins/ui/src/deephaven/ui/types/types.py b/plugins/ui/src/deephaven/ui/types/types.py index ee6948a87..a0b320ee5 100644 --- a/plugins/ui/src/deephaven/ui/types/types.py +++ b/plugins/ui/src/deephaven/ui/types/types.py @@ -1,7 +1,18 @@ import datetime import pandas import numpy -from typing import Any, Dict, Literal, Union, List, Tuple, Callable, TypedDict, Sequence +from typing import ( + Any, + Dict, + Iterable, + Literal, + Union, + List, + Tuple, + Callable, + TypedDict, + Sequence, +) from deephaven import SortDirection from deephaven.dtypes import DType @@ -111,6 +122,7 @@ class RowDataValue(CellData): Stringable = Union[str, int, float, bool] Key = Stringable ActionKey = Key +SelectedKeys = Literal["all"] LocalDate = DType Instant = DType ZonedDateTime = DType @@ -139,6 +151,7 @@ class RowDataValue(CellData): ZonedDateTimeConvertible, ] Granularity = Literal["DAY", "HOUR", "MINUTE", "SECOND"] -Density = Literal["COMPACT", "NORMAL", "SPACIOUS"] +ListViewDensity = Literal["COMPACT", "NORMAL", "SPACIOUS"] +ActionGroupDensity = Literal["compact", "regular"] Dependencies = Union[Tuple[Any], List[Any]] Selection = Sequence[Key] From db178623163efe0ec8871b8c54518014406695a9 Mon Sep 17 00:00:00 2001 From: Akshat Jawne Date: Wed, 22 May 2024 08:47:25 -0600 Subject: [PATCH 2/4] Fix init file --- plugins/ui/src/deephaven/ui/components/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/ui/src/deephaven/ui/components/__init__.py b/plugins/ui/src/deephaven/ui/components/__init__.py index 87d40df2f..a91a717a9 100644 --- a/plugins/ui/src/deephaven/ui/components/__init__.py +++ b/plugins/ui/src/deephaven/ui/components/__init__.py @@ -22,7 +22,8 @@ __all__ = [ "action_button", - "action_group" "button", + "action_group", + "button", "button_group", "checkbox", "column", From 9e37da00927f96d618f4ef9dc0e45d3bcfe3b487 Mon Sep 17 00:00:00 2001 From: Akshat Jawne Date: Wed, 22 May 2024 08:54:35 -0600 Subject: [PATCH 3/4] Modify import statements in action_group --- plugins/ui/src/deephaven/ui/components/action_group.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/ui/src/deephaven/ui/components/action_group.py b/plugins/ui/src/deephaven/ui/components/action_group.py index 651a95027..d90e672c7 100644 --- a/plugins/ui/src/deephaven/ui/components/action_group.py +++ b/plugins/ui/src/deephaven/ui/components/action_group.py @@ -1,13 +1,13 @@ from __future__ import annotations from numbers import Number from typing import Any, Callable, Iterable -from plugins.ui.src.deephaven.ui.components.spectrum.events import ( +from ..components.spectrum.events import ( ButtonLabelBehavior, Orientation, StaticColor, ) -from plugins.ui.src.deephaven.ui.elements import BaseElement -from plugins.ui.src.deephaven.ui.types.types import ( +from ..elements import Element, BaseElement +from ..types import ( ActionGroupDensity, SelectedKeys, SelectionMode, @@ -21,7 +21,6 @@ OverflowMode, Position, ) -from ..elements import Element def action_group( From a1ec475836d7141756148d60f90c8f1285e0f491 Mon Sep 17 00:00:00 2001 From: Akshat Jawne Date: Fri, 24 May 2024 08:20:47 -0600 Subject: [PATCH 4/4] remove items and fix description of component --- plugins/ui/src/deephaven/ui/components/action_group.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/ui/src/deephaven/ui/components/action_group.py b/plugins/ui/src/deephaven/ui/components/action_group.py index d90e672c7..758f0df6c 100644 --- a/plugins/ui/src/deephaven/ui/components/action_group.py +++ b/plugins/ui/src/deephaven/ui/components/action_group.py @@ -34,7 +34,6 @@ def action_group( button_label_behavior: ButtonLabelBehavior | None = "show", summary_icon: Element | None = None, orientation: Orientation | None = "horizontal", - items: Iterable[object] | None = None, disabled_keys: Iterable[str] | None = None, is_disabled: bool | None = None, selection_mode: SelectionMode | None = None, @@ -88,10 +87,10 @@ def action_group( UNSAFE_style: CSSProperties | None = None, ) -> Element: """ - A contextual help is a quiet action button that triggers an informational popover. + An action grouping of action items that are related to each other. Args: *children: The children of the contextual help popover. - is_emphasized: An list of Item elements or a function. If the latter, a list of items must be provided using the items prop. + is_emphasized: Whether the action buttons should be displayed with emphasized style. density: Sets the amount of space between buttons. is_justified: Whether the ActionButtons should be justified in their container. is_quiet: Whether ActionButtons should use the quiet style. @@ -100,7 +99,6 @@ def action_group( button_label_behaviour: Defines when the text within the buttons should be hidden and only the icon should be shown. summary_icon: The icon displayed in the dropdown menu button when a selectable ActionGroup is collapsed. orientation: The axis the ActionGroup should align with. - items: A list of items to display as children. Must be used with a function as the sole child. disabled_keys: A list of keys to disable. is_disabled: Whether the ActionGroup is disabled. Shows that a selection exists, but is not available in that circumstance. selection_mode: The type of selection that is allowed in the collection. @@ -165,7 +163,6 @@ def action_group( button_label_behavior=button_label_behavior, summary_icon=summary_icon, orientation=orientation, - items=items, disabled_keys=disabled_keys, is_disabled=is_disabled, selection_mode=selection_mode,