From 3a5d3bc2c1e75873364afa40a0f16002c7980790 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 17 Jan 2024 12:53:33 -0800 Subject: [PATCH 01/10] Avatar: fix docstring --- reflex/components/radix/themes/components/avatar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/radix/themes/components/avatar.py b/reflex/components/radix/themes/components/avatar.py index f2f154433a..c0949db602 100644 --- a/reflex/components/radix/themes/components/avatar.py +++ b/reflex/components/radix/themes/components/avatar.py @@ -13,7 +13,7 @@ class Avatar(CommonMarginProps, RadixThemesComponent): - """A toggle switch alternative to the checkbox.""" + """An image element with a fallback for representing the user.""" tag = "Avatar" From 3d9b7416f8b202dd0a1b176bbc0701266fcb8840 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 17 Jan 2024 13:08:21 -0800 Subject: [PATCH 02/10] badge: update docstring --- reflex/components/radix/themes/components/badge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/radix/themes/components/badge.py b/reflex/components/radix/themes/components/badge.py index 46abff91d4..9822e254a4 100644 --- a/reflex/components/radix/themes/components/badge.py +++ b/reflex/components/radix/themes/components/badge.py @@ -13,7 +13,7 @@ class Badge(el.Span, CommonMarginProps, RadixThemesComponent): - """A toggle switch alternative to the checkbox.""" + """A stylized badge element.""" tag = "Badge" From f6a636637952ef85c19dda90c48292479a374c19 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 17 Jan 2024 14:43:25 -0800 Subject: [PATCH 03/10] Scrollarea: update docstring --- reflex/components/radix/themes/components/scrollarea.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/radix/themes/components/scrollarea.py b/reflex/components/radix/themes/components/scrollarea.py index ba3573e8c2..783de70ec9 100644 --- a/reflex/components/radix/themes/components/scrollarea.py +++ b/reflex/components/radix/themes/components/scrollarea.py @@ -11,7 +11,7 @@ class ScrollArea(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """Custom styled, cross-browser scrollable area using native functionality.""" tag = "ScrollArea" From 076101d6b5faa05bee6d2d6e721152fa638e1983 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 17 Jan 2024 15:22:41 -0800 Subject: [PATCH 04/10] table: fix docstrings --- reflex/components/radix/themes/components/table.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reflex/components/radix/themes/components/table.py b/reflex/components/radix/themes/components/table.py index 0723a86fe0..deec08d293 100644 --- a/reflex/components/radix/themes/components/table.py +++ b/reflex/components/radix/themes/components/table.py @@ -11,7 +11,7 @@ class TableRoot(el.Table, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A semantic table for presenting tabular data.""" tag = "Table.Root" @@ -23,13 +23,13 @@ class TableRoot(el.Table, CommonMarginProps, RadixThemesComponent): class TableHeader(el.Thead, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """The header of the table defines column names and other non-data elements.""" tag = "Table.Header" class TableRow(el.Tr, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A row containing table cells.""" tag = "Table.Row" @@ -38,7 +38,7 @@ class TableRow(el.Tr, CommonMarginProps, RadixThemesComponent): class TableColumnHeaderCell(el.Th, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A table cell that is semantically treated as a column header.""" tag = "Table.ColumnHeaderCell" @@ -50,13 +50,13 @@ class TableColumnHeaderCell(el.Th, CommonMarginProps, RadixThemesComponent): class TableBody(el.Tbody, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """The body of the table contains the data rows.""" tag = "Table.Body" class TableCell(el.Td, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A cell containing data.""" tag = "Table.Cell" @@ -68,7 +68,7 @@ class TableCell(el.Td, CommonMarginProps, RadixThemesComponent): class TableRowHeaderCell(el.Th, CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A table cell that is semantically treated as a row header.""" tag = "Table.RowHeaderCell" From 38858131c0aed5e3ed59a3a658c1a2a5ed061aba Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 17 Jan 2024 17:06:18 -0800 Subject: [PATCH 05/10] button: rename color to color_scheme --- reflex/components/radix/themes/components/button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/radix/themes/components/button.py b/reflex/components/radix/themes/components/button.py index 8fb158f6c4..738ee6a2fe 100644 --- a/reflex/components/radix/themes/components/button.py +++ b/reflex/components/radix/themes/components/button.py @@ -30,7 +30,7 @@ class Button(el.Button, CommonMarginProps, RadixThemesComponent): variant: Var[LiteralVariant] # Override theme color for button - color: Var[LiteralAccentColor] + color_scheme: Var[LiteralAccentColor] # Whether to render the button with higher contrast color against background high_contrast: Var[bool] From 7216626a80d7744b89f5fdfab67e3622c52da4c2 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 18 Jan 2024 21:39:15 -0800 Subject: [PATCH 06/10] radio_group: update docstrings --- .../components/radix/themes/components/radiogroup.py | 10 +++++----- .../components/radix/themes/components/radiogroup.pyi | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reflex/components/radix/themes/components/radiogroup.py b/reflex/components/radix/themes/components/radiogroup.py index 78c29c0700..2cb56e13a0 100644 --- a/reflex/components/radix/themes/components/radiogroup.py +++ b/reflex/components/radix/themes/components/radiogroup.py @@ -11,7 +11,7 @@ class RadioGroupRoot(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """A set of interactive radio buttons where only one can be selected at a time.""" tag = "RadioGroup.Root" @@ -22,12 +22,12 @@ class RadioGroupRoot(CommonMarginProps, RadixThemesComponent): variant: Var[Literal["classic", "surface", "soft"]] # The color of the radio group - color: Var[LiteralAccentColor] + color_scheme: Var[LiteralAccentColor] # Whether to render the radio group with higher contrast color against background high_contrast: Var[bool] - # The controlled value of the radio item to check. Should be used in conjunction with onValueChange. + # The controlled value of the radio item to check. Should be used in conjunction with on_value_change. value: Var[str] # The initial value of checked radio item. Should be used in conjunction with onValueChange. @@ -61,11 +61,11 @@ def get_event_triggers(self) -> Dict[str, Any]: class RadioGroupItem(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """An item in the group that can be checked.""" tag = "RadioGroup.Item" - # The value of the radio item to check. Should be used in conjunction with onCheckedChange. + # The value of the radio item to check. Should be used in conjunction with on_value_change. value: Var[str] # When true, prevents the user from interacting with the radio item. diff --git a/reflex/components/radix/themes/components/radiogroup.pyi b/reflex/components/radix/themes/components/radiogroup.pyi index 658c228c6e..5abf8347b6 100644 --- a/reflex/components/radix/themes/components/radiogroup.pyi +++ b/reflex/components/radix/themes/components/radiogroup.pyi @@ -416,7 +416,7 @@ class RadioGroupItem(CommonMarginProps, RadixThemesComponent): *children: Child components. color: map to CSS default color property. color_scheme: map to radix color property. - value: The value of the radio item to check. Should be used in conjunction with onCheckedChange. + value: The value of the radio item to check. Should be used in conjunction with on_value_change. disabled: When true, prevents the user from interacting with the radio item. required: When true, indicates that the user must check the radio item before the owning form can be submitted. m: Margin: "0" - "9" From 7be39b67aa8807f4b1215192fd1c2906800d9c16 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 19 Jan 2024 09:43:04 -0800 Subject: [PATCH 07/10] [REF-1705] Do not overwrite Var attributes during format If the values given to `format_cond` are already Var, do NOT mutate the attributes since subsequent usages of the same Var may be adversely affected. Add test cases for `is_prop=True` path of `format_cond`, where this bug was hiding. --- reflex/utils/format.py | 22 +++++---- tests/utils/test_format.py | 95 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 14 deletions(-) diff --git a/reflex/utils/format.py b/reflex/utils/format.py index 46fa41436e..d79fc1e50d 100644 --- a/reflex/utils/format.py +++ b/reflex/utils/format.py @@ -255,16 +255,20 @@ def format_cond( # Format prop conds. if is_prop: - prop1 = Var.create_safe( - true_value, - _var_is_string=type(true_value) is str, - ) - prop1._var_is_local = True - prop2 = Var.create_safe( - false_value, - _var_is_string=type(false_value) is str, + if not isinstance(true_value, Var): + true_value = Var.create_safe( + true_value, + _var_is_string=type(true_value) is str, + ) + prop1 = true_value._replace( + _var_is_local=True, ) - prop2._var_is_local = True + if not isinstance(false_value, Var): + false_value = Var.create_safe( + false_value, + _var_is_string=type(false_value) is str, + ) + prop2 = false_value._replace(_var_is_local=True) prop1, prop2 = str(prop1), str(prop2) # avoid f-string semantics for Var return f"{cond} ? {prop1} : {prop2}".replace("{", "").replace("}", "") diff --git a/tests/utils/test_format.py b/tests/utils/test_format.py index 8c62f734a0..bd8319a517 100644 --- a/tests/utils/test_format.py +++ b/tests/utils/test_format.py @@ -276,22 +276,107 @@ def test_format_route(route: str, format_case: bool, expected: bool): @pytest.mark.parametrize( - "condition,true_value,false_value,expected", + "condition,true_value,false_value,is_prop,expected", [ - ("cond", "", '""', '{isTrue(cond) ? : ""}'), - ("cond", "", "", "{isTrue(cond) ? : }"), + ("cond", "", '""', False, '{isTrue(cond) ? : ""}'), + ("cond", "", "", False, "{isTrue(cond) ? : }"), + ( + "cond", + Var.create_safe(""), + "", + False, + "{isTrue(cond) ? : }", + ), + ( + "cond", + Var.create_safe(""), + Var.create_safe(""), + False, + "{isTrue(cond) ? : }", + ), + ( + "cond", + Var.create_safe("", _var_is_local=False), + Var.create_safe(""), + False, + "{isTrue(cond) ? ${} : }", + ), + ( + "cond", + Var.create_safe("", _var_is_string=True), + Var.create_safe(""), + False, + "{isTrue(cond) ? {``} : }", + ), + ("cond", "", '""', True, 'isTrue(cond) ? `` : `""`'), + ("cond", "", "", True, "isTrue(cond) ? `` : ``"), + ( + "cond", + Var.create_safe(""), + "", + True, + "isTrue(cond) ? : ``", + ), + ( + "cond", + Var.create_safe(""), + Var.create_safe(""), + True, + "isTrue(cond) ? : ", + ), + ( + "cond", + Var.create_safe("", _var_is_local=False), + Var.create_safe(""), + True, + "isTrue(cond) ? : ", + ), + ( + "cond", + Var.create_safe(""), + Var.create_safe("", _var_is_local=False), + True, + "isTrue(cond) ? : ", + ), + ( + "cond", + Var.create_safe("", _var_is_string=True), + Var.create_safe(""), + True, + "isTrue(cond) ? `` : ", + ), ], ) -def test_format_cond(condition: str, true_value: str, false_value: str, expected: str): +def test_format_cond( + condition: str, + true_value: str | Var, + false_value: str | Var, + is_prop: bool, + expected: str, +): """Test formatting a cond. Args: condition: The condition to check. true_value: The value to return if the condition is true. false_value: The value to return if the condition is false. + is_prop: Whether the values are rendered as props or not. expected: The expected output string. """ - assert format.format_cond(condition, true_value, false_value) == expected + orig_true_value = ( + true_value._replace() if isinstance(true_value, Var) else Var.create_safe("") + ) + orig_false_value = ( + false_value._replace() if isinstance(false_value, Var) else Var.create_safe("") + ) + + assert format.format_cond(condition, true_value, false_value, is_prop) == expected + + # Ensure the formatting operation didn't change the original Var + if isinstance(true_value, Var): + assert true_value.equals(orig_true_value) + if isinstance(false_value, Var): + assert false_value.equals(orig_false_value) @pytest.mark.parametrize( From c625d60ffcee22195e1effda1d535b6374eb86bd Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 19 Jan 2024 13:21:32 -0800 Subject: [PATCH 08/10] select: update docstrings --- .../components/radix/themes/components/select.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reflex/components/radix/themes/components/select.py b/reflex/components/radix/themes/components/select.py index 432d15cfd2..c63ab423c5 100644 --- a/reflex/components/radix/themes/components/select.py +++ b/reflex/components/radix/themes/components/select.py @@ -16,7 +16,7 @@ class SelectRoot(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """Displays a list of options for the user to pick from, triggered by a button.""" tag = "Select.Root" @@ -58,7 +58,7 @@ def get_event_triggers(self) -> Dict[str, Any]: class SelectTrigger(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """The button that toggles the select.""" tag = "Select.Trigger" @@ -76,7 +76,7 @@ class SelectTrigger(CommonMarginProps, RadixThemesComponent): class SelectContent(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """The component that pops out when the select is open.""" tag = "Select.Content" @@ -119,13 +119,13 @@ def get_event_triggers(self) -> Dict[str, Any]: class SelectGroup(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """Used to group multiple items.""" tag = "Select.Group" class SelectItem(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """The component that contains the select items.""" tag = "Select.Item" @@ -137,13 +137,13 @@ class SelectItem(CommonMarginProps, RadixThemesComponent): class SelectLabel(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """Used to render the label of a group, it isn't focusable using arrow keys.""" tag = "Select.Label" class SelectSeparator(CommonMarginProps, RadixThemesComponent): - """Trigger an action or event, such as submitting a form or displaying a dialog.""" + """Used to visually separate items in the Select.""" tag = "Select.Separator" From 11515a2f6589ecc39f27ef3046a5fced6cac8287 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 23 Jan 2024 14:44:22 -0800 Subject: [PATCH 09/10] radiogroup: update pyi --- reflex/components/radix/themes/components/radiogroup.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reflex/components/radix/themes/components/radiogroup.pyi b/reflex/components/radix/themes/components/radiogroup.pyi index 2cdde7831c..287b7ca310 100644 --- a/reflex/components/radix/themes/components/radiogroup.pyi +++ b/reflex/components/radix/themes/components/radiogroup.pyi @@ -224,7 +224,7 @@ class RadioGroupRoot(CommonMarginProps, RadixThemesComponent): size: The size of the radio group: "1" | "2" | "3" variant: The variant of the radio group high_contrast: Whether to render the radio group with higher contrast color against background - value: The controlled value of the radio item to check. Should be used in conjunction with onValueChange. + value: The controlled value of the radio item to check. Should be used in conjunction with on_value_change. default_value: The initial value of checked radio item. Should be used in conjunction with onValueChange. disabled: Whether the radio group is disabled name: The name of the group. Submitted with its owning form as part of a name/value pair. @@ -478,7 +478,7 @@ class HighLevelRadioGroup(RadioGroupRoot): Literal["classic", "surface", "soft"], ] ] = None, - color: Optional[ + color_scheme: Optional[ Union[ Var[ Literal[ @@ -660,9 +660,9 @@ class HighLevelRadioGroup(RadioGroupRoot): gap: The gap between the items of the radio group. size: The size of the radio group: "1" | "2" | "3" variant: The variant of the radio group - color: The color of the radio group + color_scheme: The color of the radio group high_contrast: Whether to render the radio group with higher contrast color against background - value: The controlled value of the radio item to check. Should be used in conjunction with onValueChange. + value: The controlled value of the radio item to check. Should be used in conjunction with on_value_change. default_value: The initial value of checked radio item. Should be used in conjunction with onValueChange. disabled: Whether the radio group is disabled name: The name of the group. Submitted with its owning form as part of a name/value pair. From 9968642d13586e3c57ed084ab036fdd6f8195048 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 23 Jan 2024 15:13:02 -0800 Subject: [PATCH 10/10] scripts/integration.sh: bump timeout to 900 to avoid flake --- scripts/integration.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/integration.sh b/scripts/integration.sh index ef56fd165f..dc8b5d5537 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -34,4 +34,4 @@ if [ -f /proc/$pid/winpid ]; then echo "Windows detected, passing winpid $pid to port waiter" fi -python scripts/wait_for_listening_port.py $check_ports --timeout=600 --server-pid "$pid" +python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid"