reflex 0.8.2__py3-none-any.whl → 0.8.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

Files changed (41) hide show
  1. reflex/.templates/web/utils/state.js +7 -2
  2. reflex/__init__.py +1 -0
  3. reflex/__init__.pyi +2 -0
  4. reflex/app.py +8 -11
  5. reflex/compiler/compiler.py +10 -38
  6. reflex/components/base/error_boundary.py +6 -5
  7. reflex/components/base/meta.pyi +4 -256
  8. reflex/components/core/__init__.py +1 -0
  9. reflex/components/core/__init__.pyi +3 -0
  10. reflex/components/core/window_events.py +104 -0
  11. reflex/components/core/window_events.pyi +84 -0
  12. reflex/components/el/__init__.pyi +4 -0
  13. reflex/components/el/elements/__init__.py +1 -0
  14. reflex/components/el/elements/__init__.pyi +5 -0
  15. reflex/components/el/elements/forms.py +4 -2
  16. reflex/components/el/elements/metadata.pyi +2 -0
  17. reflex/components/el/elements/typography.py +7 -0
  18. reflex/components/el/elements/typography.pyi +246 -0
  19. reflex/components/lucide/icon.py +303 -292
  20. reflex/components/lucide/icon.pyi +303 -292
  21. reflex/components/radix/themes/components/separator.py +4 -4
  22. reflex/components/radix/themes/components/separator.pyi +3 -3
  23. reflex/components/recharts/recharts.py +2 -2
  24. reflex/components/sonner/toast.py +1 -1
  25. reflex/constants/installer.py +1 -1
  26. reflex/event.py +71 -10
  27. reflex/model.py +55 -0
  28. reflex/plugins/base.py +2 -2
  29. reflex/reflex.py +33 -0
  30. reflex/route.py +4 -4
  31. reflex/state.py +9 -4
  32. reflex/utils/console.py +3 -3
  33. reflex/utils/exec.py +22 -6
  34. reflex/utils/format.py +1 -1
  35. reflex/utils/processes.py +28 -38
  36. reflex/utils/types.py +1 -1
  37. {reflex-0.8.2.dist-info → reflex-0.8.3.dist-info}/METADATA +1 -1
  38. {reflex-0.8.2.dist-info → reflex-0.8.3.dist-info}/RECORD +41 -39
  39. {reflex-0.8.2.dist-info → reflex-0.8.3.dist-info}/WHEEL +0 -0
  40. {reflex-0.8.2.dist-info → reflex-0.8.3.dist-info}/entry_points.txt +0 -0
  41. {reflex-0.8.2.dist-info → reflex-0.8.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,104 @@
1
+ """Window event listener component for Reflex."""
2
+
3
+ import reflex as rx
4
+ from reflex.components.base.fragment import Fragment
5
+ from reflex.constants.compiler import Hooks
6
+ from reflex.event import key_event, no_args_event_spec
7
+ from reflex.vars.base import Var, VarData
8
+ from reflex.vars.object import ObjectVar
9
+
10
+
11
+ def _on_resize_spec() -> tuple[Var[int], Var[int]]:
12
+ """Args spec for the on_resize event trigger.
13
+
14
+ Returns:
15
+ A tuple containing window width and height variables.
16
+ """
17
+ return (Var("window.innerWidth"), Var("window.innerHeight"))
18
+
19
+
20
+ def _on_scroll_spec() -> tuple[Var[float], Var[float]]:
21
+ """Args spec for the on_scroll event trigger.
22
+
23
+ Returns:
24
+ A tuple containing window scroll X and Y position variables.
25
+ """
26
+ return (Var("window.scrollX"), Var("window.scrollY"))
27
+
28
+
29
+ def _on_visibility_change_spec() -> tuple[Var[bool]]:
30
+ """Args spec for the on_visibility_change event trigger.
31
+
32
+ Returns:
33
+ A tuple containing the document hidden state variable.
34
+ """
35
+ return (Var("document.hidden"),)
36
+
37
+
38
+ def _on_storage_spec(e: ObjectVar) -> tuple[Var[str], Var[str], Var[str], Var[str]]:
39
+ """Args spec for the on_storage event trigger.
40
+
41
+ Args:
42
+ e: The storage event.
43
+
44
+ Returns:
45
+ A tuple containing key, old value, new value, and URL variables.
46
+ """
47
+ return (e.key.to(str), e.oldValue.to(str), e.newValue.to(str), e.url.to(str))
48
+
49
+
50
+ class WindowEventListener(Fragment):
51
+ """A component that listens for window events."""
52
+
53
+ # Event handlers
54
+ on_resize: rx.EventHandler[_on_resize_spec]
55
+ on_scroll: rx.EventHandler[_on_scroll_spec]
56
+ on_focus: rx.EventHandler[no_args_event_spec]
57
+ on_blur: rx.EventHandler[no_args_event_spec]
58
+ on_visibility_change: rx.EventHandler[_on_visibility_change_spec]
59
+ on_before_unload: rx.EventHandler[no_args_event_spec]
60
+ on_key_down: rx.EventHandler[key_event]
61
+ on_popstate: rx.EventHandler[no_args_event_spec]
62
+ on_storage: rx.EventHandler[_on_storage_spec]
63
+
64
+ def _exclude_props(self) -> list[str]:
65
+ """Exclude event handler props from being passed to Fragment.
66
+
67
+ Returns:
68
+ List of prop names to exclude from the Fragment.
69
+ """
70
+ return [*super()._exclude_props(), *self.event_triggers.keys()]
71
+
72
+ def add_hooks(self) -> list[str | Var[str]]:
73
+ """Add hooks to register window event listeners.
74
+
75
+ Returns:
76
+ The hooks to add to the component.
77
+ """
78
+ hooks = []
79
+
80
+ for prop_name, event_trigger in self.event_triggers.items():
81
+ # Get JS event name: remove on_ prefix and underscores
82
+ event_name = prop_name.removeprefix("on_").replace("_", "")
83
+
84
+ hook_expr = f"""
85
+ useEffect(() => {{
86
+ if (typeof window === 'undefined') return;
87
+
88
+ window.addEventListener('{event_name}', {event_trigger});
89
+ return () => window.removeEventListener('{event_name}', {event_trigger});
90
+ }}, []);
91
+ """
92
+
93
+ hooks.append(
94
+ Var(
95
+ hook_expr,
96
+ _var_type="str",
97
+ _var_data=VarData(position=Hooks.HookPosition.POST_TRIGGER),
98
+ )
99
+ )
100
+
101
+ return hooks
102
+
103
+
104
+ window_event_listener = WindowEventListener.create
@@ -0,0 +1,84 @@
1
+ """Stub file for reflex/components/core/window_events.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ from collections.abc import Mapping, Sequence
7
+ from typing import Any
8
+
9
+ from reflex.components.base.fragment import Fragment
10
+ from reflex.components.core.breakpoints import Breakpoints
11
+ from reflex.event import EventType, KeyInputInfo, PointerEventInfo
12
+ from reflex.vars.base import Var
13
+
14
+ class WindowEventListener(Fragment):
15
+ def add_hooks(self) -> list[str | Var[str]]: ...
16
+ @classmethod
17
+ def create(
18
+ cls,
19
+ *children,
20
+ style: Sequence[Mapping[str, Any]]
21
+ | Mapping[str, Any]
22
+ | Var[Mapping[str, Any]]
23
+ | Breakpoints
24
+ | None = None,
25
+ key: Any | None = None,
26
+ id: Any | None = None,
27
+ ref: Var | None = None,
28
+ class_name: Any | None = None,
29
+ autofocus: bool | None = None,
30
+ custom_attrs: dict[str, Var | Any] | None = None,
31
+ on_before_unload: EventType[()] | None = None,
32
+ on_blur: EventType[()] | None = None,
33
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
34
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
35
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
36
+ on_focus: EventType[()] | None = None,
37
+ on_key_down: EventType[()]
38
+ | EventType[str]
39
+ | EventType[str, KeyInputInfo]
40
+ | None = None,
41
+ on_mount: EventType[()] | None = None,
42
+ on_mouse_down: EventType[()] | None = None,
43
+ on_mouse_enter: EventType[()] | None = None,
44
+ on_mouse_leave: EventType[()] | None = None,
45
+ on_mouse_move: EventType[()] | None = None,
46
+ on_mouse_out: EventType[()] | None = None,
47
+ on_mouse_over: EventType[()] | None = None,
48
+ on_mouse_up: EventType[()] | None = None,
49
+ on_popstate: EventType[()] | None = None,
50
+ on_resize: EventType[()] | EventType[int] | EventType[int, int] | None = None,
51
+ on_scroll: EventType[()]
52
+ | EventType[float]
53
+ | EventType[float, float]
54
+ | None = None,
55
+ on_scroll_end: EventType[()] | None = None,
56
+ on_storage: EventType[()]
57
+ | EventType[str]
58
+ | EventType[str, str]
59
+ | EventType[str, str, str]
60
+ | EventType[str, str, str, str]
61
+ | None = None,
62
+ on_unmount: EventType[()] | None = None,
63
+ on_visibility_change: EventType[()] | EventType[bool] | None = None,
64
+ **props,
65
+ ) -> WindowEventListener:
66
+ """Create the component.
67
+
68
+ Args:
69
+ *children: The children of the component.
70
+ on_resize: Event handlers
71
+ style: The style of the component.
72
+ key: A unique key for the component.
73
+ id: The id for the component.
74
+ ref: The Var to pass as the ref to the component.
75
+ class_name: The class name for the component.
76
+ autofocus: Whether the component should take the focus once the page is loaded
77
+ custom_attrs: custom attribute
78
+ **props: The props of the component.
79
+
80
+ Returns:
81
+ The component.
82
+ """
83
+
84
+ window_event_listener = WindowEventListener.create
@@ -239,6 +239,7 @@ from .elements.typography import (
239
239
  Dl,
240
240
  Dt,
241
241
  Figcaption,
242
+ Figure,
242
243
  Hr,
243
244
  Ins,
244
245
  Li,
@@ -253,6 +254,7 @@ from .elements.typography import (
253
254
  dl,
254
255
  dt,
255
256
  figcaption,
257
+ figure,
256
258
  hr,
257
259
  ins,
258
260
  li,
@@ -307,6 +309,7 @@ __all__ = [
307
309
  "Embed",
308
310
  "Fieldset",
309
311
  "Figcaption",
312
+ "Figure",
310
313
  "Footer",
311
314
  "Form",
312
315
  "G",
@@ -424,6 +427,7 @@ __all__ = [
424
427
  "embed",
425
428
  "fieldset",
426
429
  "figcaption",
430
+ "figure",
427
431
  "footer",
428
432
  "form",
429
433
  "g",
@@ -125,6 +125,7 @@ _MAPPING = {
125
125
  "dl",
126
126
  "dt",
127
127
  "figcaption",
128
+ "figure",
128
129
  "hr",
129
130
  "ol",
130
131
  "li",
@@ -237,6 +237,7 @@ from .typography import (
237
237
  Dl,
238
238
  Dt,
239
239
  Figcaption,
240
+ Figure,
240
241
  Hr,
241
242
  Ins,
242
243
  Li,
@@ -251,6 +252,7 @@ from .typography import (
251
252
  dl,
252
253
  dt,
253
254
  figcaption,
255
+ figure,
254
256
  hr,
255
257
  ins,
256
258
  li,
@@ -374,6 +376,7 @@ _MAPPING = {
374
376
  "dl",
375
377
  "dt",
376
378
  "figcaption",
379
+ "figure",
377
380
  "hr",
378
381
  "ol",
379
382
  "li",
@@ -443,6 +446,7 @@ __all__ = [
443
446
  "Embed",
444
447
  "Fieldset",
445
448
  "Figcaption",
449
+ "Figure",
446
450
  "Footer",
447
451
  "Form",
448
452
  "G",
@@ -559,6 +563,7 @@ __all__ = [
559
563
  "embed",
560
564
  "fieldset",
561
565
  "figcaption",
566
+ "figure",
562
567
  "footer",
563
568
  "form",
564
569
  "g",
@@ -466,11 +466,13 @@ class Input(BaseInput):
466
466
  if cls is Input:
467
467
  input_type = props.get("type")
468
468
 
469
- if input_type == "checkbox":
469
+ if isinstance(input_type, str) and input_type == "checkbox":
470
470
  # Checkbox inputs should use the CheckboxInput class
471
471
  return CheckboxInput.create(*children, **props)
472
472
 
473
- if input_type == "number" or input_type == "range":
473
+ if isinstance(input_type, str) and (
474
+ input_type == "number" or input_type == "range"
475
+ ):
474
476
  # Number inputs should use the ValueNumberInput class
475
477
  return ValueNumberInput.create(*children, **props)
476
478
 
@@ -803,6 +803,7 @@ class Meta(BaseHTML):
803
803
  content: Var[str] | str | None = None,
804
804
  http_equiv: Var[str] | str | None = None,
805
805
  name: Var[str] | str | None = None,
806
+ property: Var[str] | str | None = None,
806
807
  access_key: Var[str] | str | None = None,
807
808
  auto_capitalize: Literal[
808
809
  "characters", "none", "off", "on", "sentences", "words"
@@ -1018,6 +1019,7 @@ class Meta(BaseHTML):
1018
1019
  content: Defines the content of the metadata
1019
1020
  http_equiv: Provides an HTTP header for the information/value of the content attribute
1020
1021
  name: Specifies a name for the metadata
1022
+ property: The type of metadata value.
1021
1023
  access_key: Provides a hint for generating a keyboard shortcut for the current element.
1022
1024
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1023
1025
  content_editable: Indicates whether the element's content is editable.
@@ -46,6 +46,12 @@ class Figcaption(BaseHTML):
46
46
  tag = "figcaption"
47
47
 
48
48
 
49
+ class Figure(BaseHTML):
50
+ """Display the figure element."""
51
+
52
+ tag = "figure"
53
+
54
+
49
55
  class Hr(BaseHTML):
50
56
  """Display the hr element."""
51
57
 
@@ -132,6 +138,7 @@ div = Div.create
132
138
  dl = Dl.create
133
139
  dt = Dt.create
134
140
  figcaption = Figcaption.create
141
+ figure = Figure.create
135
142
  hr = Hr.create
136
143
  li = Li.create
137
144
  ol = Ol.create
@@ -1484,6 +1484,251 @@ class Figcaption(BaseHTML):
1484
1484
  The component.
1485
1485
  """
1486
1486
 
1487
+ class Figure(BaseHTML):
1488
+ @classmethod
1489
+ def create(
1490
+ cls,
1491
+ *children,
1492
+ access_key: Var[str] | str | None = None,
1493
+ auto_capitalize: Literal[
1494
+ "characters", "none", "off", "on", "sentences", "words"
1495
+ ]
1496
+ | Var[Literal["characters", "none", "off", "on", "sentences", "words"]]
1497
+ | None = None,
1498
+ content_editable: Literal["inherit", "plaintext-only", False, True]
1499
+ | Var[Literal["inherit", "plaintext-only", False, True]]
1500
+ | None = None,
1501
+ context_menu: Var[str] | str | None = None,
1502
+ dir: Var[str] | str | None = None,
1503
+ draggable: Var[bool] | bool | None = None,
1504
+ enter_key_hint: Literal[
1505
+ "done", "enter", "go", "next", "previous", "search", "send"
1506
+ ]
1507
+ | Var[Literal["done", "enter", "go", "next", "previous", "search", "send"]]
1508
+ | None = None,
1509
+ hidden: Var[bool] | bool | None = None,
1510
+ input_mode: Literal[
1511
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
1512
+ ]
1513
+ | Var[
1514
+ Literal[
1515
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
1516
+ ]
1517
+ ]
1518
+ | None = None,
1519
+ item_prop: Var[str] | str | None = None,
1520
+ lang: Var[str] | str | None = None,
1521
+ role: Literal[
1522
+ "alert",
1523
+ "alertdialog",
1524
+ "application",
1525
+ "article",
1526
+ "banner",
1527
+ "button",
1528
+ "cell",
1529
+ "checkbox",
1530
+ "columnheader",
1531
+ "combobox",
1532
+ "complementary",
1533
+ "contentinfo",
1534
+ "definition",
1535
+ "dialog",
1536
+ "directory",
1537
+ "document",
1538
+ "feed",
1539
+ "figure",
1540
+ "form",
1541
+ "grid",
1542
+ "gridcell",
1543
+ "group",
1544
+ "heading",
1545
+ "img",
1546
+ "link",
1547
+ "list",
1548
+ "listbox",
1549
+ "listitem",
1550
+ "log",
1551
+ "main",
1552
+ "marquee",
1553
+ "math",
1554
+ "menu",
1555
+ "menubar",
1556
+ "menuitem",
1557
+ "menuitemcheckbox",
1558
+ "menuitemradio",
1559
+ "navigation",
1560
+ "none",
1561
+ "note",
1562
+ "option",
1563
+ "presentation",
1564
+ "progressbar",
1565
+ "radio",
1566
+ "radiogroup",
1567
+ "region",
1568
+ "row",
1569
+ "rowgroup",
1570
+ "rowheader",
1571
+ "scrollbar",
1572
+ "search",
1573
+ "searchbox",
1574
+ "separator",
1575
+ "slider",
1576
+ "spinbutton",
1577
+ "status",
1578
+ "switch",
1579
+ "tab",
1580
+ "table",
1581
+ "tablist",
1582
+ "tabpanel",
1583
+ "term",
1584
+ "textbox",
1585
+ "timer",
1586
+ "toolbar",
1587
+ "tooltip",
1588
+ "tree",
1589
+ "treegrid",
1590
+ "treeitem",
1591
+ ]
1592
+ | Var[
1593
+ Literal[
1594
+ "alert",
1595
+ "alertdialog",
1596
+ "application",
1597
+ "article",
1598
+ "banner",
1599
+ "button",
1600
+ "cell",
1601
+ "checkbox",
1602
+ "columnheader",
1603
+ "combobox",
1604
+ "complementary",
1605
+ "contentinfo",
1606
+ "definition",
1607
+ "dialog",
1608
+ "directory",
1609
+ "document",
1610
+ "feed",
1611
+ "figure",
1612
+ "form",
1613
+ "grid",
1614
+ "gridcell",
1615
+ "group",
1616
+ "heading",
1617
+ "img",
1618
+ "link",
1619
+ "list",
1620
+ "listbox",
1621
+ "listitem",
1622
+ "log",
1623
+ "main",
1624
+ "marquee",
1625
+ "math",
1626
+ "menu",
1627
+ "menubar",
1628
+ "menuitem",
1629
+ "menuitemcheckbox",
1630
+ "menuitemradio",
1631
+ "navigation",
1632
+ "none",
1633
+ "note",
1634
+ "option",
1635
+ "presentation",
1636
+ "progressbar",
1637
+ "radio",
1638
+ "radiogroup",
1639
+ "region",
1640
+ "row",
1641
+ "rowgroup",
1642
+ "rowheader",
1643
+ "scrollbar",
1644
+ "search",
1645
+ "searchbox",
1646
+ "separator",
1647
+ "slider",
1648
+ "spinbutton",
1649
+ "status",
1650
+ "switch",
1651
+ "tab",
1652
+ "table",
1653
+ "tablist",
1654
+ "tabpanel",
1655
+ "term",
1656
+ "textbox",
1657
+ "timer",
1658
+ "toolbar",
1659
+ "tooltip",
1660
+ "tree",
1661
+ "treegrid",
1662
+ "treeitem",
1663
+ ]
1664
+ ]
1665
+ | None = None,
1666
+ slot: Var[str] | str | None = None,
1667
+ spell_check: Var[bool] | bool | None = None,
1668
+ tab_index: Var[int] | int | None = None,
1669
+ title: Var[str] | str | None = None,
1670
+ style: Sequence[Mapping[str, Any]]
1671
+ | Mapping[str, Any]
1672
+ | Var[Mapping[str, Any]]
1673
+ | Breakpoints
1674
+ | None = None,
1675
+ key: Any | None = None,
1676
+ id: Any | None = None,
1677
+ ref: Var | None = None,
1678
+ class_name: Any | None = None,
1679
+ autofocus: bool | None = None,
1680
+ custom_attrs: dict[str, Var | Any] | None = None,
1681
+ on_blur: EventType[()] | None = None,
1682
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
1683
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
1684
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
1685
+ on_focus: EventType[()] | None = None,
1686
+ on_mount: EventType[()] | None = None,
1687
+ on_mouse_down: EventType[()] | None = None,
1688
+ on_mouse_enter: EventType[()] | None = None,
1689
+ on_mouse_leave: EventType[()] | None = None,
1690
+ on_mouse_move: EventType[()] | None = None,
1691
+ on_mouse_out: EventType[()] | None = None,
1692
+ on_mouse_over: EventType[()] | None = None,
1693
+ on_mouse_up: EventType[()] | None = None,
1694
+ on_scroll: EventType[()] | None = None,
1695
+ on_scroll_end: EventType[()] | None = None,
1696
+ on_unmount: EventType[()] | None = None,
1697
+ **props,
1698
+ ) -> Figure:
1699
+ """Create the component.
1700
+
1701
+ Args:
1702
+ *children: The children of the component.
1703
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1704
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1705
+ content_editable: Indicates whether the element's content is editable.
1706
+ context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
1707
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
1708
+ draggable: Defines whether the element can be dragged.
1709
+ enter_key_hint: Hints what media types the media element is able to play.
1710
+ hidden: Defines whether the element is hidden.
1711
+ input_mode: Defines the type of the element.
1712
+ item_prop: Defines the name of the element for metadata purposes.
1713
+ lang: Defines the language used in the element.
1714
+ role: Defines the role of the element.
1715
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
1716
+ spell_check: Defines whether the element may be checked for spelling errors.
1717
+ tab_index: Defines the position of the current element in the tabbing order.
1718
+ title: Defines a tooltip for the element.
1719
+ style: The style of the component.
1720
+ key: A unique key for the component.
1721
+ id: The id for the component.
1722
+ ref: The Var to pass as the ref to the component.
1723
+ class_name: The class name for the component.
1724
+ autofocus: Whether the component should take the focus once the page is loaded
1725
+ custom_attrs: custom attribute
1726
+ **props: The props of the component.
1727
+
1728
+ Returns:
1729
+ The component.
1730
+ """
1731
+
1487
1732
  class Hr(BaseHTML):
1488
1733
  @classmethod
1489
1734
  def create(
@@ -3713,6 +3958,7 @@ div = Div.create
3713
3958
  dl = Dl.create
3714
3959
  dt = Dt.create
3715
3960
  figcaption = Figcaption.create
3961
+ figure = Figure.create
3716
3962
  hr = Hr.create
3717
3963
  li = Li.create
3718
3964
  ol = Ol.create