Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allows keys to be set in props #810

Merged
merged 29 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
72df595
fix: allows keys to be set in props
wusteven815 Sep 6, 2024
580a72e
fix: define generate_key for UITable
wusteven815 Sep 6, 2024
ceb0a54
fix: use Optional for 3.8 and 3.9
wusteven815 Sep 6, 2024
9062589
feat: experimental key prop decorator
wusteven815 Sep 6, 2024
44e7d6c
feat: experimental key prop decorator v2
wusteven815 Sep 6, 2024
1c17db0
feat: experimental element maker
wusteven815 Sep 9, 2024
9261c58
fix: use Dict for 3.8 and 3.9
wusteven815 Sep 9, 2024
3d2d7d1
fix: use Optional for 3.8 and 3.9
wusteven815 Sep 9, 2024
666052b
fix: use correct element name
wusteven815 Sep 10, 2024
e04fdd8
Merge branch 'deephaven:main' into 731-add-key-prop
wusteven815 Sep 10, 2024
5e90fed
feat: add docstring and key prop
wusteven815 Sep 11, 2024
97a4cb5
fix: use future annotations
wusteven815 Sep 11, 2024
979731d
feat: add all props
wusteven815 Sep 11, 2024
653c6af
fix: use title case instead of snake
wusteven815 Sep 11, 2024
8c139cc
Merge branch 'deephaven:main' into 731-add-key-prop
wusteven815 Sep 13, 2024
1890bfe
update prop description
wusteven815 Sep 17, 2024
0a0cf37
revert flex
wusteven815 Sep 17, 2024
fcf64d2
revert experiments
wusteven815 Sep 17, 2024
74ce8e2
use future annotation instead of optional
wusteven815 Sep 17, 2024
d840e10
add key to props
wusteven815 Sep 18, 2024
ff31aae
add key prop to components
wusteven815 Sep 18, 2024
a36ae23
add missing docs
wusteven815 Sep 18, 2024
17f363a
Merge branch 'deephaven:main' into 731-add-key-prop
wusteven815 Sep 18, 2024
b57ea8b
add key desc for fragment
wusteven815 Sep 18, 2024
ec3290b
remove kwargs
wusteven815 Sep 18, 2024
2516177
remove render map
wusteven815 Sep 18, 2024
2804408
remove generate_key method
wusteven815 Sep 19, 2024
08b8993
add e2e
wusteven815 Sep 19, 2024
b0e4602
Merge branch 'deephaven:main' into 731-add-key-prop
wusteven815 Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/action_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def action_button(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> 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 Expand Up @@ -161,6 +162,7 @@ def action_button(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The rendered ActionButton element.
Expand Down Expand Up @@ -231,4 +233,5 @@ def action_button(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/action_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def action_group(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
An action grouping of action items that are related to each other.
Expand Down Expand Up @@ -152,6 +153,7 @@ def action_group(
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.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"ActionGroup",
Expand Down Expand Up @@ -217,4 +219,5 @@ def action_group(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/action_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def action_menu(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases.
Expand Down Expand Up @@ -147,6 +148,7 @@ def action_menu(
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.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
f"ActionMenu",
Expand Down Expand Up @@ -207,4 +209,5 @@ def action_menu(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def button(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.
Expand Down Expand Up @@ -170,6 +171,7 @@ def button(
aria_details: The details of the current element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The rendered button component.
Expand Down Expand Up @@ -248,4 +250,5 @@ def button(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/button_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def button_group(
id: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
A button group is a grouping of button whose actions are related to each other.
Expand Down Expand Up @@ -101,6 +102,7 @@ def button_group(
id: The unique identifier of the element.
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.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"ButtonGroup",
Expand Down Expand Up @@ -147,4 +149,5 @@ def button_group(
id=id,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def checkbox(
aria_errormessage: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
Checkboxes allow users to select multiple items from a list of individual items, or to mark one individual item as selected.
Expand Down Expand Up @@ -153,6 +154,7 @@ def checkbox(
aria_errormessage: The id of the element that provides error information for the current element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The rendered checkbox.
Expand Down Expand Up @@ -226,4 +228,5 @@ def checkbox(
aria_errormessage=aria_errormessage,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
7 changes: 5 additions & 2 deletions plugins/ui/src/deephaven/ui/components/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
from .basic import component_element


def column(*children: Any, width: float | None = None, **kwargs: Any):
def column(
*children: Any, width: float | None = None, key: str | None = None, **kwargs: Any
):
"""
A column is a container that can be used to group elements.
Each element will be placed below its prior sibling.

Args:
children: Elements to render in the column.
width: The percent width of the column relative to other children of its parent. If not provided, the column will be sized automatically.
key: A unique identifier used by React to render elements in a list.
wusteven815 marked this conversation as resolved.
Show resolved Hide resolved
"""
return component_element("Column", *children, width=width, **kwargs)
return component_element("Column", *children, width=width, key=key, **kwargs)
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/combo_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def combo_box(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> ComboBoxElement:
"""
A combo box that can be used to search or select from a list. Children should be one of five types:
Expand Down Expand Up @@ -231,6 +232,7 @@ def combo_box(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The rendered ComboBox.
Expand Down
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def content(
id: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
Content represents the primary content within a Spectrum container.
Expand Down Expand Up @@ -99,6 +100,7 @@ def content(
id: The unique identifier of the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"Content",
Expand Down Expand Up @@ -142,4 +144,5 @@ def content(
id=id,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/contextual_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def contextual_help(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
A contextual help is a quiet action button that triggers an informational popover.
Expand Down Expand Up @@ -127,6 +128,7 @@ def contextual_help(
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.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"ContextualHelp",
Expand Down Expand Up @@ -183,4 +185,5 @@ def contextual_help(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/date_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def date_field(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> DateFieldElement:
"""
A date field allows the user to select a date.
Expand Down Expand Up @@ -251,6 +252,7 @@ def date_field(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The date field element.
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/date_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def date_picker(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> DatePickerElement:
"""
A date picker allows the user to select a date.
Expand Down Expand Up @@ -265,6 +266,7 @@ def date_picker(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The date picker element.
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/date_range_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def date_range_picker(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> DatePickerElement:
"""
A date range picker allows the user to select a range of dates.
Expand Down Expand Up @@ -268,6 +269,7 @@ def date_range_picker(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.

Returns:
The date range picker element.
Expand Down
5 changes: 3 additions & 2 deletions plugins/ui/src/deephaven/ui/components/flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def flex(
gap: DimensionValue | None = "size-100",
column_gap: DimensionValue | None = None,
row_gap: DimensionValue | None = None,
**props: Any,
key: str | None = None,
):
"""
Base Flex component for laying out children in a flexbox.
Expand All @@ -39,6 +39,7 @@ def flex(
gap: The space to display between both rows and columns of children.
column_gap: The space to display between columns of children.
row_gap: The space to display between rows of children.
key: A unique identifier used by React to render elements in a list
"""
return component_element(
"Flex",
Expand All @@ -52,5 +53,5 @@ def flex(
gap=gap,
column_gap=column_gap,
row_gap=row_gap,
**props,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def form(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
Forms allow users to enter data that can be submitted while providing alignment and styling for form fields
Expand Down Expand Up @@ -158,6 +159,7 @@ def form(
aria_details: The details for the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"Form",
Expand Down Expand Up @@ -226,4 +228,5 @@ def form(
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
5 changes: 3 additions & 2 deletions plugins/ui/src/deephaven/ui/components/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from .basic import component_element


def fragment(*children: Any):
def fragment(*children: Any, key: str | None = None):
"""
A React.Fragment: https://react.dev/reference/react/Fragment.
Used to group elements together without a wrapper node.

Args:
*children: The children in the fragment.
key: A unique identifier used by React to render elements in a list.
"""
return component_element("Fragment", children=children)
return component_element("Fragment", children=children, key=key)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def grid(
id: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
A layout container using CSS grid. Supports Spectrum dimensions as values to ensure consistent and adaptive sizing and spacing.
Expand Down Expand Up @@ -130,6 +131,7 @@ def grid(
id: The unique identifier of the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"Grid",
Expand Down Expand Up @@ -186,4 +188,5 @@ def grid(
id=id,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
3 changes: 3 additions & 0 deletions plugins/ui/src/deephaven/ui/components/heading.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def heading(
id: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
A layout container using CSS grid. Supports Spectrum dimensions as values to ensure consistent and adaptive sizing and spacing.
Expand Down Expand Up @@ -105,6 +106,7 @@ def heading(
id: The unique identifier of the element.
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.
"""
return component_element(
"Heading",
Expand Down Expand Up @@ -150,4 +152,5 @@ def heading(
id=id,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
key=key,
)
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def icon(
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
key: str | None = None,
) -> Element:
"""
Get a Deephaven icon by name.
Expand Down Expand Up @@ -113,6 +114,7 @@ def icon(
id: The unique identifier of the element.
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.
key: A unique identifier used by React to render elements in a list.
"""

children, props = create_props(locals())
Expand Down
Loading
Loading