Skip to content

Commit 0f4e776

Browse files
committed
undefined
1 parent 0fbae91 commit 0f4e776

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2857
-2754
lines changed

plugins/ui/src/deephaven/ui/_internal/utils.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
JavaTime,
1616
LocalDateConvertible,
1717
LocalDate,
18+
Undefined,
19+
UNDEFINED,
1820
)
1921

2022
T = TypeVar("T")
@@ -36,6 +38,17 @@
3638
}
3739

3840

41+
def is_nullish(value: Any) -> bool:
42+
"""
43+
Check if a value is None or Undefined.
44+
Args:
45+
value: The value to check.
46+
Returns:
47+
Whether the value is nullish.
48+
"""
49+
return value is None or value is UNDEFINED
50+
51+
3952
def get_component_name(component: Any) -> str:
4053
"""
4154
Get the name of the component
@@ -163,7 +176,7 @@ def remove_empty_keys(dict: dict[str, Any]) -> dict[str, Any]:
163176
Returns:
164177
The dict with keys removed.
165178
"""
166-
return {k: v for k, v in dict.items() if v is not None}
179+
return {k: v for k, v in dict.items() if v is not UNDEFINED}
167180

168181

169182
def _wrapped_callable(
@@ -481,7 +494,7 @@ def _get_first_set_key(props: dict[str, Any], sequence: Sequence[str]) -> str |
481494
The first non-None prop, or None if all props are None.
482495
"""
483496
for key in sequence:
484-
if props.get(key) is not None:
497+
if not is_nullish(props.get(key)):
485498
return key
486499
return None
487500

@@ -666,11 +679,11 @@ def convert_date_props(
666679
The converted props.
667680
"""
668681
for key in simple_date_props:
669-
if props.get(key) is not None:
682+
if not is_nullish(props.get(key)):
670683
props[key] = _convert_to_java_date(props[key])
671684

672685
for key in date_range_props:
673-
if props.get(key) is not None:
686+
if not is_nullish(props.get(key)):
674687
props[key] = convert_date_range(props[key], _convert_to_java_date)
675688

676689
# the simple props must be converted before this to simplify the callable conversion
@@ -680,25 +693,25 @@ def convert_date_props(
680693
# Local Dates will default to DAY but we need to default to SECOND for the other types
681694
if (
682695
granularity_key is not None
683-
and props.get(granularity_key) is None
696+
and is_nullish(props.get(granularity_key))
684697
and converter != to_j_local_date
685698
):
686699
props[granularity_key] = "SECOND"
687700

688701
# now that the converter is set, we can convert simple props to strings
689702
for key in simple_date_props:
690-
if props.get(key) is not None:
703+
if not is_nullish(props.get(key)):
691704
props[key] = str(props[key])
692705

693706
# and convert the date range props to strings
694707
for key in date_range_props:
695-
if props.get(key) is not None:
708+
if not is_nullish(props.get(key)):
696709
props[key] = convert_date_range(props[key], str)
697710

698711
# wrap the date callable with the convert
699712
# if there are date range props, we need to convert as a date range
700713
for key in callable_date_props:
701-
if props.get(key) is not None:
714+
if not is_nullish(props.get(key)):
702715
if not callable(props[key]):
703716
raise TypeError(f"{key} must be a callable")
704717
if len(date_range_props) > 0:
@@ -730,20 +743,20 @@ def convert_time_props(
730743
The converted props.
731744
"""
732745
for key in simple_time_props:
733-
if props.get(key) is not None:
746+
if not is_nullish(props.get(key)):
734747
props[key] = _convert_to_java_time(props[key])
735748

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

739752
# now that the converter is set, we can convert simple props to strings
740753
for key in simple_time_props:
741-
if props.get(key) is not None:
754+
if not is_nullish(props.get(key)):
742755
props[key] = str(props[key])
743756

744757
# wrap the date callable with the convert
745758
for key in callable_time_props:
746-
if props.get(key) is not None:
759+
if not is_nullish(props.get(key)):
747760
if not callable(props[key]):
748761
raise TypeError(f"{key} must be a callable")
749762
props[key] = _wrap_time_callable(props[key], converter)

plugins/ui/src/deephaven/ui/components/action_button.py

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -22,76 +22,77 @@
2222

2323
from .basic import component_element
2424
from ..elements import Element
25+
from ..types import Undefined, UNDEFINED
2526

2627
ActionButtonElement = Element
2728

2829

2930
def action_button(
3031
*children: Any,
3132
type: ButtonType = "button",
32-
on_press: PressEventCallable | None = None,
33-
on_press_start: PressEventCallable | None = None,
34-
on_press_end: PressEventCallable | None = None,
35-
on_press_up: PressEventCallable | None = None,
36-
on_press_change: Callable[[bool], None] | None = None,
37-
on_focus: FocusEventCallable | None = None,
38-
on_blur: FocusEventCallable | None = None,
39-
on_focus_change: Callable[[bool], None] | None = None,
40-
on_key_down: KeyboardEventCallable | None = None,
41-
on_key_up: KeyboardEventCallable | None = None,
42-
auto_focus: bool | None = None,
43-
is_disabled: bool | None = None,
44-
is_quiet: bool | None = None,
45-
static_color: StaticColor | None = None,
46-
flex: LayoutFlex | None = None,
47-
flex_grow: float | None = None,
48-
flex_shrink: float | None = None,
49-
flex_basis: DimensionValue | None = None,
50-
align_self: AlignSelf | None = None,
51-
justify_self: JustifySelf | None = None,
52-
order: int | None = None,
53-
grid_area: str | None = None,
54-
grid_row: str | None = None,
55-
grid_row_start: str | None = None,
56-
grid_row_end: str | None = None,
57-
grid_column: str | None = None,
58-
grid_column_start: str | None = None,
59-
grid_column_end: str | None = None,
60-
margin: DimensionValue | None = None,
61-
margin_top: DimensionValue | None = None,
62-
margin_bottom: DimensionValue | None = None,
63-
margin_start: DimensionValue | None = None,
64-
margin_end: DimensionValue | None = None,
65-
margin_x: DimensionValue | None = None,
66-
margin_y: DimensionValue | None = None,
67-
width: DimensionValue | None = None,
68-
height: DimensionValue | None = None,
69-
min_width: DimensionValue | None = None,
70-
min_height: DimensionValue | None = None,
71-
max_width: DimensionValue | None = None,
72-
max_height: DimensionValue | None = None,
73-
position: Position | None = None,
74-
top: DimensionValue | None = None,
75-
bottom: DimensionValue | None = None,
76-
start: DimensionValue | None = None,
77-
end: DimensionValue | None = None,
78-
left: DimensionValue | None = None,
79-
right: DimensionValue | None = None,
80-
z_index: int | None = None,
81-
is_hidden: bool | None = None,
82-
id: str | None = None,
83-
exclude_from_tab_order: bool | None = None,
84-
aria_expanded: AriaExpanded | None = None,
85-
aria_haspopup: AriaHasPopup | None = None,
86-
aria_controls: str | None = None,
87-
aria_label: str | None = None,
88-
aria_labelledby: str | None = None,
89-
aria_describedby: str | None = None,
90-
aria_pressed: AriaPressed | None = None,
91-
aria_details: str | None = None,
92-
UNSAFE_class_name: str | None = None,
93-
UNSAFE_style: CSSProperties | None = None,
94-
key: str | None = None,
33+
on_press: PressEventCallable | Undefined = UNDEFINED,
34+
on_press_start: PressEventCallable | Undefined = UNDEFINED,
35+
on_press_end: PressEventCallable | Undefined = UNDEFINED,
36+
on_press_up: PressEventCallable | Undefined = UNDEFINED,
37+
on_press_change: Callable[[bool], None] | Undefined = UNDEFINED,
38+
on_focus: FocusEventCallable | Undefined = UNDEFINED,
39+
on_blur: FocusEventCallable | Undefined = UNDEFINED,
40+
on_focus_change: Callable[[bool], None] | Undefined = UNDEFINED,
41+
on_key_down: KeyboardEventCallable | Undefined = UNDEFINED,
42+
on_key_up: KeyboardEventCallable | Undefined = UNDEFINED,
43+
auto_focus: bool | Undefined = UNDEFINED,
44+
is_disabled: bool | Undefined = UNDEFINED,
45+
is_quiet: bool | Undefined = UNDEFINED,
46+
static_color: StaticColor | Undefined = UNDEFINED,
47+
flex: LayoutFlex | Undefined = UNDEFINED,
48+
flex_grow: float | Undefined = UNDEFINED,
49+
flex_shrink: float | Undefined = UNDEFINED,
50+
flex_basis: DimensionValue | Undefined = UNDEFINED,
51+
align_self: AlignSelf | Undefined = UNDEFINED,
52+
justify_self: JustifySelf | Undefined = UNDEFINED,
53+
order: int | Undefined = UNDEFINED,
54+
grid_area: str | Undefined = UNDEFINED,
55+
grid_row: str | Undefined = UNDEFINED,
56+
grid_row_start: str | Undefined = UNDEFINED,
57+
grid_row_end: str | Undefined = UNDEFINED,
58+
grid_column: str | Undefined = UNDEFINED,
59+
grid_column_start: str | Undefined = UNDEFINED,
60+
grid_column_end: str | Undefined = UNDEFINED,
61+
margin: DimensionValue | Undefined = UNDEFINED,
62+
margin_top: DimensionValue | Undefined = UNDEFINED,
63+
margin_bottom: DimensionValue | Undefined = UNDEFINED,
64+
margin_start: DimensionValue | Undefined = UNDEFINED,
65+
margin_end: DimensionValue | Undefined = UNDEFINED,
66+
margin_x: DimensionValue | Undefined = UNDEFINED,
67+
margin_y: DimensionValue | Undefined = UNDEFINED,
68+
width: DimensionValue | Undefined = UNDEFINED,
69+
height: DimensionValue | Undefined = UNDEFINED,
70+
min_width: DimensionValue | Undefined = UNDEFINED,
71+
min_height: DimensionValue | Undefined = UNDEFINED,
72+
max_width: DimensionValue | Undefined = UNDEFINED,
73+
max_height: DimensionValue | Undefined = UNDEFINED,
74+
position: Position | Undefined = UNDEFINED,
75+
top: DimensionValue | Undefined = UNDEFINED,
76+
bottom: DimensionValue | Undefined = UNDEFINED,
77+
start: DimensionValue | Undefined = UNDEFINED,
78+
end: DimensionValue | Undefined = UNDEFINED,
79+
left: DimensionValue | Undefined = UNDEFINED,
80+
right: DimensionValue | Undefined = UNDEFINED,
81+
z_index: int | Undefined = UNDEFINED,
82+
is_hidden: bool | Undefined = UNDEFINED,
83+
id: str | Undefined = UNDEFINED,
84+
exclude_from_tab_order: bool | Undefined = UNDEFINED,
85+
aria_expanded: AriaExpanded | Undefined = UNDEFINED,
86+
aria_haspopup: AriaHasPopup | Undefined = UNDEFINED,
87+
aria_controls: str | Undefined = UNDEFINED,
88+
aria_label: str | Undefined = UNDEFINED,
89+
aria_labelledby: str | Undefined = UNDEFINED,
90+
aria_describedby: str | Undefined = UNDEFINED,
91+
aria_pressed: AriaPressed | Undefined = UNDEFINED,
92+
aria_details: str | Undefined = UNDEFINED,
93+
UNSAFE_class_name: str | Undefined = UNDEFINED,
94+
UNSAFE_style: CSSProperties | Undefined = UNDEFINED,
95+
key: str | Undefined = UNDEFINED,
9596
) -> ActionButtonElement:
9697
"""
9798
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.

plugins/ui/src/deephaven/ui/components/action_group.py

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -18,73 +18,81 @@
1818
)
1919
from .basic import component_element
2020
from ..elements import Element
21-
from ..types import ActionGroupDensity, SelectedKeys, SelectionMode, Key, Selection
21+
from ..types import (
22+
ActionGroupDensity,
23+
SelectedKeys,
24+
SelectionMode,
25+
Key,
26+
Selection,
27+
Undefined,
28+
UNDEFINED,
29+
)
2230

2331

2432
def action_group(
2533
*children: Any,
26-
is_emphasized: bool | None = None,
27-
density: ActionGroupDensity | None = "regular",
28-
is_justified: bool | None = None,
29-
is_quiet: bool | None = None,
30-
static_color: StaticColor | None = None,
31-
overflow_mode: OverflowMode | None = "wrap",
32-
button_label_behavior: ButtonLabelBehavior | None = "show",
33-
summary_icon: Element | None = None,
34-
orientation: Orientation | None = "horizontal",
35-
disabled_keys: Iterable[str] | None = None,
36-
is_disabled: bool | None = None,
37-
selection_mode: SelectionMode | None = None,
38-
disallow_empty_selection: bool | None = None,
39-
selected_keys: SelectedKeys | Iterable[str] | None = None,
40-
default_selected_keys: SelectedKeys | Iterable[str] | None = None,
41-
on_action: Callable[[str], None] | None = None,
42-
on_change: Callable[[Key], None] | None = None,
43-
on_selection_change: Callable[[Selection], None] | None = None,
44-
flex: LayoutFlex | None = None,
45-
flex_grow: float | None = None,
46-
flex_shrink: float | None = None,
47-
flex_basis: DimensionValue | None = None,
48-
align_self: AlignSelf | None = None,
49-
justify_self: JustifySelf | None = None,
50-
order: int | None = None,
51-
grid_area: str | None = None,
52-
grid_row: str | None = None,
53-
grid_column: str | None = None,
54-
grid_column_start: str | None = None,
55-
grid_column_end: str | None = None,
56-
grid_row_start: str | None = None,
57-
grid_row_end: str | None = None,
58-
margin: DimensionValue | None = None,
59-
margin_top: DimensionValue | None = None,
60-
margin_bottom: DimensionValue | None = None,
61-
margin_start: DimensionValue | None = None,
62-
margin_end: DimensionValue | None = None,
63-
margin_x: DimensionValue | None = None,
64-
margin_y: DimensionValue | None = None,
65-
width: DimensionValue | None = None,
66-
height: DimensionValue | None = None,
67-
min_width: DimensionValue | None = None,
68-
min_height: DimensionValue | None = None,
69-
max_width: DimensionValue | None = None,
70-
max_height: DimensionValue | None = None,
71-
position: Position | None = None,
72-
top: DimensionValue | None = None,
73-
bottom: DimensionValue | None = None,
74-
left: DimensionValue | None = None,
75-
right: DimensionValue | None = None,
76-
start: DimensionValue | None = None,
77-
end: DimensionValue | None = None,
78-
z_index: int | None = None,
79-
is_hidden: bool | None = None,
80-
id: str | None = None,
81-
aria_label: str | None = None,
82-
aria_labelledby: str | None = None,
83-
aria_describedby: str | None = None,
84-
aria_details: str | None = None,
85-
UNSAFE_class_name: str | None = None,
86-
UNSAFE_style: CSSProperties | None = None,
87-
key: str | None = None,
34+
is_emphasized: bool | Undefined = UNDEFINED,
35+
density: ActionGroupDensity | Undefined = "regular",
36+
is_justified: bool | Undefined = UNDEFINED,
37+
is_quiet: bool | Undefined = UNDEFINED,
38+
static_color: StaticColor | Undefined = UNDEFINED,
39+
overflow_mode: OverflowMode | Undefined = "wrap",
40+
button_label_behavior: ButtonLabelBehavior | Undefined = "show",
41+
summary_icon: Element | Undefined = UNDEFINED,
42+
orientation: Orientation | Undefined = "horizontal",
43+
disabled_keys: Iterable[str] | Undefined = UNDEFINED,
44+
is_disabled: bool | Undefined = UNDEFINED,
45+
selection_mode: SelectionMode | Undefined = UNDEFINED,
46+
disallow_empty_selection: bool | Undefined = UNDEFINED,
47+
selected_keys: SelectedKeys | Iterable[str] | Undefined = UNDEFINED,
48+
default_selected_keys: SelectedKeys | Iterable[str] | Undefined = UNDEFINED,
49+
on_action: Callable[[str], None] | Undefined = UNDEFINED,
50+
on_change: Callable[[Key], None] | Undefined = UNDEFINED,
51+
on_selection_change: Callable[[Selection], None] | Undefined = UNDEFINED,
52+
flex: LayoutFlex | Undefined = UNDEFINED,
53+
flex_grow: float | Undefined = UNDEFINED,
54+
flex_shrink: float | Undefined = UNDEFINED,
55+
flex_basis: DimensionValue | Undefined = UNDEFINED,
56+
align_self: AlignSelf | Undefined = UNDEFINED,
57+
justify_self: JustifySelf | Undefined = UNDEFINED,
58+
order: int | Undefined = UNDEFINED,
59+
grid_area: str | Undefined = UNDEFINED,
60+
grid_row: str | Undefined = UNDEFINED,
61+
grid_column: str | Undefined = UNDEFINED,
62+
grid_column_start: str | Undefined = UNDEFINED,
63+
grid_column_end: str | Undefined = UNDEFINED,
64+
grid_row_start: str | Undefined = UNDEFINED,
65+
grid_row_end: str | Undefined = UNDEFINED,
66+
margin: DimensionValue | Undefined = UNDEFINED,
67+
margin_top: DimensionValue | Undefined = UNDEFINED,
68+
margin_bottom: DimensionValue | Undefined = UNDEFINED,
69+
margin_start: DimensionValue | Undefined = UNDEFINED,
70+
margin_end: DimensionValue | Undefined = UNDEFINED,
71+
margin_x: DimensionValue | Undefined = UNDEFINED,
72+
margin_y: DimensionValue | Undefined = UNDEFINED,
73+
width: DimensionValue | Undefined = UNDEFINED,
74+
height: DimensionValue | Undefined = UNDEFINED,
75+
min_width: DimensionValue | Undefined = UNDEFINED,
76+
min_height: DimensionValue | Undefined = UNDEFINED,
77+
max_width: DimensionValue | Undefined = UNDEFINED,
78+
max_height: DimensionValue | Undefined = UNDEFINED,
79+
position: Position | Undefined = UNDEFINED,
80+
top: DimensionValue | Undefined = UNDEFINED,
81+
bottom: DimensionValue | Undefined = UNDEFINED,
82+
left: DimensionValue | Undefined = UNDEFINED,
83+
right: DimensionValue | Undefined = UNDEFINED,
84+
start: DimensionValue | Undefined = UNDEFINED,
85+
end: DimensionValue | Undefined = UNDEFINED,
86+
z_index: int | Undefined = UNDEFINED,
87+
is_hidden: bool | Undefined = UNDEFINED,
88+
id: str | Undefined = UNDEFINED,
89+
aria_label: str | Undefined = UNDEFINED,
90+
aria_labelledby: str | Undefined = UNDEFINED,
91+
aria_describedby: str | Undefined = UNDEFINED,
92+
aria_details: str | Undefined = UNDEFINED,
93+
UNSAFE_class_name: str | Undefined = UNDEFINED,
94+
UNSAFE_style: CSSProperties | Undefined = UNDEFINED,
95+
key: str | Undefined = UNDEFINED,
8896
) -> Element:
8997
"""
9098
An action grouping of action items that are related to each other.

0 commit comments

Comments
 (0)