Skip to content

Commit

Permalink
add review change
Browse files Browse the repository at this point in the history
  • Loading branch information
wusteven815 committed Nov 12, 2024
1 parent ee210e5 commit 0a33478
Show file tree
Hide file tree
Showing 62 changed files with 2,811 additions and 2,816 deletions.
35 changes: 12 additions & 23 deletions plugins/ui/src/deephaven/ui/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
JavaTime,
LocalDateConvertible,
LocalDate,
UndefinedType,
Undefined,
UNDEFINED,
)

T = TypeVar("T")
Expand All @@ -38,17 +38,6 @@
}


def is_nullish(value: Any) -> bool:
"""
Check if a value is None or Undefined.
Args:
value: The value to check.
Returns:
Whether the value is nullish.
"""
return value is None or value is UNDEFINED


def get_component_name(component: Any) -> str:
"""
Get the name of the component
Expand Down Expand Up @@ -176,7 +165,7 @@ def remove_empty_keys(dict: dict[str, Any]) -> dict[str, Any]:
Returns:
The dict with keys removed.
"""
return {k: v for k, v in dict.items() if v is not UNDEFINED}
return {k: v for k, v in dict.items() if v is not Undefined}


def _wrapped_callable(
Expand Down Expand Up @@ -494,7 +483,7 @@ def _get_first_set_key(props: dict[str, Any], sequence: Sequence[str]) -> str |
The first non-None prop, or None if all props are None.
"""
for key in sequence:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
return key
return None

Expand Down Expand Up @@ -679,11 +668,11 @@ def convert_date_props(
The converted props.
"""
for key in simple_date_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = _convert_to_java_date(props[key])

for key in date_range_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = convert_date_range(props[key], _convert_to_java_date)

# the simple props must be converted before this to simplify the callable conversion
Expand All @@ -693,25 +682,25 @@ def convert_date_props(
# Local Dates will default to DAY but we need to default to SECOND for the other types
if (
granularity_key is not None
and is_nullish(props.get(granularity_key))
and props.get(granularity_key) == Undefined
and converter != to_j_local_date
):
props[granularity_key] = "SECOND"

# now that the converter is set, we can convert simple props to strings
for key in simple_date_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = str(props[key])

# and convert the date range props to strings
for key in date_range_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = convert_date_range(props[key], str)

# wrap the date callable with the convert
# if there are date range props, we need to convert as a date range
for key in callable_date_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
if not callable(props[key]):
raise TypeError(f"{key} must be a callable")
if len(date_range_props) > 0:
Expand Down Expand Up @@ -743,20 +732,20 @@ def convert_time_props(
The converted props.
"""
for key in simple_time_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = _convert_to_java_time(props[key])

# the simple props must be converted before this to simplify the callable conversion
converter = _prioritized_time_callable_converter(props, priority, default_converter)

# now that the converter is set, we can convert simple props to strings
for key in simple_time_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
props[key] = str(props[key])

# wrap the date callable with the convert
for key in callable_time_props:
if not is_nullish(props.get(key)):
if props.get(key) != Undefined:
if not callable(props[key]):
raise TypeError(f"{key} must be a callable")
props[key] = _wrap_time_callable(props[key], converter)
Expand Down
128 changes: 64 additions & 64 deletions plugins/ui/src/deephaven/ui/components/action_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,77 @@

from .basic import component_element
from ..elements import Element
from ..types import Undefined, UNDEFINED
from ..types import UndefinedType, Undefined

ActionButtonElement = Element


def action_button(
*children: Any,
type: ButtonType = "button",
on_press: PressEventCallable | Undefined = UNDEFINED,
on_press_start: PressEventCallable | Undefined = UNDEFINED,
on_press_end: PressEventCallable | Undefined = UNDEFINED,
on_press_up: PressEventCallable | Undefined = UNDEFINED,
on_press_change: Callable[[bool], None] | Undefined = UNDEFINED,
on_focus: FocusEventCallable | Undefined = UNDEFINED,
on_blur: FocusEventCallable | Undefined = UNDEFINED,
on_focus_change: Callable[[bool], None] | Undefined = UNDEFINED,
on_key_down: KeyboardEventCallable | Undefined = UNDEFINED,
on_key_up: KeyboardEventCallable | Undefined = UNDEFINED,
auto_focus: bool | Undefined = UNDEFINED,
is_disabled: bool | Undefined = UNDEFINED,
is_quiet: bool | Undefined = UNDEFINED,
static_color: StaticColor | Undefined = UNDEFINED,
flex: LayoutFlex | Undefined = UNDEFINED,
flex_grow: float | Undefined = UNDEFINED,
flex_shrink: float | Undefined = UNDEFINED,
flex_basis: DimensionValue | Undefined = UNDEFINED,
align_self: AlignSelf | Undefined = UNDEFINED,
justify_self: JustifySelf | Undefined = UNDEFINED,
order: int | Undefined = UNDEFINED,
grid_area: str | Undefined = UNDEFINED,
grid_row: str | Undefined = UNDEFINED,
grid_row_start: str | Undefined = UNDEFINED,
grid_row_end: str | Undefined = UNDEFINED,
grid_column: str | Undefined = UNDEFINED,
grid_column_start: str | Undefined = UNDEFINED,
grid_column_end: str | Undefined = UNDEFINED,
margin: DimensionValue | Undefined = UNDEFINED,
margin_top: DimensionValue | Undefined = UNDEFINED,
margin_bottom: DimensionValue | Undefined = UNDEFINED,
margin_start: DimensionValue | Undefined = UNDEFINED,
margin_end: DimensionValue | Undefined = UNDEFINED,
margin_x: DimensionValue | Undefined = UNDEFINED,
margin_y: DimensionValue | Undefined = UNDEFINED,
width: DimensionValue | Undefined = UNDEFINED,
height: DimensionValue | Undefined = UNDEFINED,
min_width: DimensionValue | Undefined = UNDEFINED,
min_height: DimensionValue | Undefined = UNDEFINED,
max_width: DimensionValue | Undefined = UNDEFINED,
max_height: DimensionValue | Undefined = UNDEFINED,
position: Position | Undefined = UNDEFINED,
top: DimensionValue | Undefined = UNDEFINED,
bottom: DimensionValue | Undefined = UNDEFINED,
start: DimensionValue | Undefined = UNDEFINED,
end: DimensionValue | Undefined = UNDEFINED,
left: DimensionValue | Undefined = UNDEFINED,
right: DimensionValue | Undefined = UNDEFINED,
z_index: int | Undefined = UNDEFINED,
is_hidden: bool | Undefined = UNDEFINED,
id: str | Undefined = UNDEFINED,
exclude_from_tab_order: bool | Undefined = UNDEFINED,
aria_expanded: AriaExpanded | Undefined = UNDEFINED,
aria_haspopup: AriaHasPopup | Undefined = UNDEFINED,
aria_controls: str | Undefined = UNDEFINED,
aria_label: str | Undefined = UNDEFINED,
aria_labelledby: str | Undefined = UNDEFINED,
aria_describedby: str | Undefined = UNDEFINED,
aria_pressed: AriaPressed | Undefined = UNDEFINED,
aria_details: str | Undefined = UNDEFINED,
UNSAFE_class_name: str | Undefined = UNDEFINED,
UNSAFE_style: CSSProperties | Undefined = UNDEFINED,
key: str | Undefined = UNDEFINED,
on_press: PressEventCallable | UndefinedType = Undefined,
on_press_start: PressEventCallable | UndefinedType = Undefined,
on_press_end: PressEventCallable | UndefinedType = Undefined,
on_press_up: PressEventCallable | UndefinedType = Undefined,
on_press_change: Callable[[bool], None] | UndefinedType = Undefined,
on_focus: FocusEventCallable | UndefinedType = Undefined,
on_blur: FocusEventCallable | UndefinedType = Undefined,
on_focus_change: Callable[[bool], None] | UndefinedType = Undefined,
on_key_down: KeyboardEventCallable | UndefinedType = Undefined,
on_key_up: KeyboardEventCallable | UndefinedType = Undefined,
auto_focus: bool | UndefinedType = Undefined,
is_disabled: bool | UndefinedType = Undefined,
is_quiet: bool | UndefinedType = Undefined,
static_color: StaticColor | UndefinedType = Undefined,
flex: LayoutFlex | UndefinedType = Undefined,
flex_grow: float | UndefinedType = Undefined,
flex_shrink: float | UndefinedType = Undefined,
flex_basis: DimensionValue | UndefinedType = Undefined,
align_self: AlignSelf | UndefinedType = Undefined,
justify_self: JustifySelf | UndefinedType = Undefined,
order: int | UndefinedType = Undefined,
grid_area: str | UndefinedType = Undefined,
grid_row: str | UndefinedType = Undefined,
grid_row_start: str | UndefinedType = Undefined,
grid_row_end: str | UndefinedType = Undefined,
grid_column: str | UndefinedType = Undefined,
grid_column_start: str | UndefinedType = Undefined,
grid_column_end: str | UndefinedType = Undefined,
margin: DimensionValue | UndefinedType = Undefined,
margin_top: DimensionValue | UndefinedType = Undefined,
margin_bottom: DimensionValue | UndefinedType = Undefined,
margin_start: DimensionValue | UndefinedType = Undefined,
margin_end: DimensionValue | UndefinedType = Undefined,
margin_x: DimensionValue | UndefinedType = Undefined,
margin_y: DimensionValue | UndefinedType = Undefined,
width: DimensionValue | UndefinedType = Undefined,
height: DimensionValue | UndefinedType = Undefined,
min_width: DimensionValue | UndefinedType = Undefined,
min_height: DimensionValue | UndefinedType = Undefined,
max_width: DimensionValue | UndefinedType = Undefined,
max_height: DimensionValue | UndefinedType = Undefined,
position: Position | UndefinedType = Undefined,
top: DimensionValue | UndefinedType = Undefined,
bottom: DimensionValue | UndefinedType = Undefined,
start: DimensionValue | UndefinedType = Undefined,
end: DimensionValue | UndefinedType = Undefined,
left: DimensionValue | UndefinedType = Undefined,
right: DimensionValue | UndefinedType = Undefined,
z_index: int | UndefinedType = Undefined,
is_hidden: bool | UndefinedType = Undefined,
id: str | UndefinedType = Undefined,
exclude_from_tab_order: bool | UndefinedType = Undefined,
aria_expanded: AriaExpanded | UndefinedType = Undefined,
aria_haspopup: AriaHasPopup | UndefinedType = Undefined,
aria_controls: str | UndefinedType = Undefined,
aria_label: str | UndefinedType = Undefined,
aria_labelledby: str | UndefinedType = Undefined,
aria_describedby: str | UndefinedType = Undefined,
aria_pressed: AriaPressed | UndefinedType = Undefined,
aria_details: str | UndefinedType = Undefined,
UNSAFE_class_name: str | UndefinedType = Undefined,
UNSAFE_style: CSSProperties | UndefinedType = Undefined,
key: str | UndefinedType = Undefined,
) -> ActionButtonElement:
"""
ActionButtons allow users to perform an action. They're used for similar, task-based options within a workflow, and are ideal for interfaces where buttons aren't meant to draw a lot of attention.
Expand Down
126 changes: 63 additions & 63 deletions plugins/ui/src/deephaven/ui/components/action_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,75 +24,75 @@
SelectionMode,
Key,
Selection,
UndefinedType,
Undefined,
UNDEFINED,
)


def action_group(
*children: Any,
is_emphasized: bool | Undefined = UNDEFINED,
density: ActionGroupDensity | Undefined = "regular",
is_justified: bool | Undefined = UNDEFINED,
is_quiet: bool | Undefined = UNDEFINED,
static_color: StaticColor | Undefined = UNDEFINED,
overflow_mode: OverflowMode | Undefined = "wrap",
button_label_behavior: ButtonLabelBehavior | Undefined = "show",
summary_icon: Element | Undefined = UNDEFINED,
orientation: Orientation | Undefined = "horizontal",
disabled_keys: Iterable[str] | Undefined = UNDEFINED,
is_disabled: bool | Undefined = UNDEFINED,
selection_mode: SelectionMode | Undefined = UNDEFINED,
disallow_empty_selection: bool | Undefined = UNDEFINED,
selected_keys: SelectedKeys | Iterable[str] | Undefined = UNDEFINED,
default_selected_keys: SelectedKeys | Iterable[str] | Undefined = UNDEFINED,
on_action: Callable[[str], None] | Undefined = UNDEFINED,
on_change: Callable[[Key], None] | Undefined = UNDEFINED,
on_selection_change: Callable[[Selection], None] | Undefined = UNDEFINED,
flex: LayoutFlex | Undefined = UNDEFINED,
flex_grow: float | Undefined = UNDEFINED,
flex_shrink: float | Undefined = UNDEFINED,
flex_basis: DimensionValue | Undefined = UNDEFINED,
align_self: AlignSelf | Undefined = UNDEFINED,
justify_self: JustifySelf | Undefined = UNDEFINED,
order: int | Undefined = UNDEFINED,
grid_area: str | Undefined = UNDEFINED,
grid_row: str | Undefined = UNDEFINED,
grid_column: str | Undefined = UNDEFINED,
grid_column_start: str | Undefined = UNDEFINED,
grid_column_end: str | Undefined = UNDEFINED,
grid_row_start: str | Undefined = UNDEFINED,
grid_row_end: str | Undefined = UNDEFINED,
margin: DimensionValue | Undefined = UNDEFINED,
margin_top: DimensionValue | Undefined = UNDEFINED,
margin_bottom: DimensionValue | Undefined = UNDEFINED,
margin_start: DimensionValue | Undefined = UNDEFINED,
margin_end: DimensionValue | Undefined = UNDEFINED,
margin_x: DimensionValue | Undefined = UNDEFINED,
margin_y: DimensionValue | Undefined = UNDEFINED,
width: DimensionValue | Undefined = UNDEFINED,
height: DimensionValue | Undefined = UNDEFINED,
min_width: DimensionValue | Undefined = UNDEFINED,
min_height: DimensionValue | Undefined = UNDEFINED,
max_width: DimensionValue | Undefined = UNDEFINED,
max_height: DimensionValue | Undefined = UNDEFINED,
position: Position | Undefined = UNDEFINED,
top: DimensionValue | Undefined = UNDEFINED,
bottom: DimensionValue | Undefined = UNDEFINED,
left: DimensionValue | Undefined = UNDEFINED,
right: DimensionValue | Undefined = UNDEFINED,
start: DimensionValue | Undefined = UNDEFINED,
end: DimensionValue | Undefined = UNDEFINED,
z_index: int | Undefined = UNDEFINED,
is_hidden: bool | Undefined = UNDEFINED,
id: str | Undefined = UNDEFINED,
aria_label: str | Undefined = UNDEFINED,
aria_labelledby: str | Undefined = UNDEFINED,
aria_describedby: str | Undefined = UNDEFINED,
aria_details: str | Undefined = UNDEFINED,
UNSAFE_class_name: str | Undefined = UNDEFINED,
UNSAFE_style: CSSProperties | Undefined = UNDEFINED,
key: str | Undefined = UNDEFINED,
is_emphasized: bool | UndefinedType = Undefined,
density: ActionGroupDensity | UndefinedType = "regular",
is_justified: bool | UndefinedType = Undefined,
is_quiet: bool | UndefinedType = Undefined,
static_color: StaticColor | UndefinedType = Undefined,
overflow_mode: OverflowMode | UndefinedType = "wrap",
button_label_behavior: ButtonLabelBehavior | UndefinedType = "show",
summary_icon: Element | UndefinedType = Undefined,
orientation: Orientation | UndefinedType = "horizontal",
disabled_keys: Iterable[str] | UndefinedType = Undefined,
is_disabled: bool | UndefinedType = Undefined,
selection_mode: SelectionMode | UndefinedType = Undefined,
disallow_empty_selection: bool | UndefinedType = Undefined,
selected_keys: SelectedKeys | Iterable[str] | UndefinedType = Undefined,
default_selected_keys: SelectedKeys | Iterable[str] | UndefinedType = Undefined,
on_action: Callable[[str], None] | UndefinedType = Undefined,
on_change: Callable[[Key], None] | UndefinedType = Undefined,
on_selection_change: Callable[[Selection], None] | UndefinedType = Undefined,
flex: LayoutFlex | UndefinedType = Undefined,
flex_grow: float | UndefinedType = Undefined,
flex_shrink: float | UndefinedType = Undefined,
flex_basis: DimensionValue | UndefinedType = Undefined,
align_self: AlignSelf | UndefinedType = Undefined,
justify_self: JustifySelf | UndefinedType = Undefined,
order: int | UndefinedType = Undefined,
grid_area: str | UndefinedType = Undefined,
grid_row: str | UndefinedType = Undefined,
grid_column: str | UndefinedType = Undefined,
grid_column_start: str | UndefinedType = Undefined,
grid_column_end: str | UndefinedType = Undefined,
grid_row_start: str | UndefinedType = Undefined,
grid_row_end: str | UndefinedType = Undefined,
margin: DimensionValue | UndefinedType = Undefined,
margin_top: DimensionValue | UndefinedType = Undefined,
margin_bottom: DimensionValue | UndefinedType = Undefined,
margin_start: DimensionValue | UndefinedType = Undefined,
margin_end: DimensionValue | UndefinedType = Undefined,
margin_x: DimensionValue | UndefinedType = Undefined,
margin_y: DimensionValue | UndefinedType = Undefined,
width: DimensionValue | UndefinedType = Undefined,
height: DimensionValue | UndefinedType = Undefined,
min_width: DimensionValue | UndefinedType = Undefined,
min_height: DimensionValue | UndefinedType = Undefined,
max_width: DimensionValue | UndefinedType = Undefined,
max_height: DimensionValue | UndefinedType = Undefined,
position: Position | UndefinedType = Undefined,
top: DimensionValue | UndefinedType = Undefined,
bottom: DimensionValue | UndefinedType = Undefined,
left: DimensionValue | UndefinedType = Undefined,
right: DimensionValue | UndefinedType = Undefined,
start: DimensionValue | UndefinedType = Undefined,
end: DimensionValue | UndefinedType = Undefined,
z_index: int | UndefinedType = Undefined,
is_hidden: bool | UndefinedType = Undefined,
id: str | UndefinedType = Undefined,
aria_label: str | UndefinedType = Undefined,
aria_labelledby: str | UndefinedType = Undefined,
aria_describedby: str | UndefinedType = Undefined,
aria_details: str | UndefinedType = Undefined,
UNSAFE_class_name: str | UndefinedType = Undefined,
UNSAFE_style: CSSProperties | UndefinedType = Undefined,
key: str | UndefinedType = Undefined,
) -> Element:
"""
An action grouping of action items that are related to each other.
Expand Down
Loading

0 comments on commit 0a33478

Please sign in to comment.