reflex 0.6.7a1__py3-none-any.whl → 0.6.8__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.
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +2 -4
- reflex/.templates/jinja/web/pages/custom_component.js.jinja2 +3 -4
- reflex/.templates/jinja/web/pages/index.js.jinja2 +2 -3
- reflex/.templates/jinja/web/pages/macros.js.jinja2 +38 -0
- reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +4 -16
- reflex/.templates/jinja/web/utils/context.js.jinja2 +1 -1
- reflex/.templates/web/utils/state.js +9 -4
- reflex/app.py +12 -10
- reflex/compiler/compiler.py +2 -2
- reflex/compiler/templates.py +41 -0
- reflex/compiler/utils.py +1 -1
- reflex/components/base/bare.py +7 -3
- reflex/components/component.py +78 -116
- reflex/components/core/banner.py +1 -1
- reflex/components/core/breakpoints.py +1 -1
- reflex/components/datadisplay/code.py +14 -10
- reflex/components/datadisplay/dataeditor.py +1 -1
- reflex/components/datadisplay/dataeditor.pyi +1 -1
- reflex/components/el/elements/forms.py +7 -5
- reflex/components/el/elements/metadata.py +1 -1
- reflex/components/lucide/icon.py +142 -19
- reflex/components/lucide/icon.pyi +141 -18
- reflex/components/markdown/markdown.py +3 -2
- reflex/components/plotly/plotly.py +3 -3
- reflex/components/plotly/plotly.pyi +3 -3
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/themes/layout/center.pyi +1 -1
- reflex/components/radix/themes/layout/flex.py +1 -1
- reflex/components/radix/themes/layout/flex.pyi +1 -1
- reflex/components/radix/themes/layout/grid.py +1 -1
- reflex/components/radix/themes/layout/grid.pyi +1 -1
- reflex/components/radix/themes/layout/spacer.pyi +1 -1
- reflex/components/radix/themes/layout/stack.pyi +3 -3
- reflex/components/radix/themes/typography/link.py +1 -1
- reflex/components/recharts/cartesian.py +2 -2
- reflex/components/recharts/cartesian.pyi +6 -6
- reflex/components/recharts/charts.py +2 -2
- reflex/components/recharts/polar.py +2 -2
- reflex/components/recharts/polar.pyi +2 -2
- reflex/components/sonner/toast.py +1 -1
- reflex/constants/base.py +1 -1
- reflex/constants/compiler.py +1 -0
- reflex/event.py +96 -1
- reflex/experimental/client_state.py +42 -20
- reflex/istate/data.py +3 -3
- reflex/model.py +4 -5
- reflex/page.py +1 -1
- reflex/reflex.py +8 -1
- reflex/state.py +116 -12
- reflex/testing.py +3 -3
- reflex/utils/exceptions.py +4 -0
- reflex/utils/prerequisites.py +37 -20
- reflex/utils/processes.py +2 -2
- reflex/utils/pyi_generator.py +2 -2
- reflex/utils/telemetry.py +6 -4
- reflex/vars/base.py +15 -4
- reflex/vars/sequence.py +37 -0
- {reflex-0.6.7a1.dist-info → reflex-0.6.8.dist-info}/METADATA +2 -2
- {reflex-0.6.7a1.dist-info → reflex-0.6.8.dist-info}/RECORD +62 -61
- {reflex-0.6.7a1.dist-info → reflex-0.6.8.dist-info}/LICENSE +0 -0
- {reflex-0.6.7a1.dist-info → reflex-0.6.8.dist-info}/WHEEL +0 -0
- {reflex-0.6.7a1.dist-info → reflex-0.6.8.dist-info}/entry_points.txt +0 -0
reflex/components/component.py
CHANGED
|
@@ -23,6 +23,8 @@ from typing import (
|
|
|
23
23
|
Union,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
+
from typing_extensions import deprecated
|
|
27
|
+
|
|
26
28
|
import reflex.state
|
|
27
29
|
from reflex.base import Base
|
|
28
30
|
from reflex.compiler.templates import STATEFUL_COMPONENT
|
|
@@ -43,17 +45,13 @@ from reflex.constants.state import FRONTEND_EVENT_STATE
|
|
|
43
45
|
from reflex.event import (
|
|
44
46
|
EventCallback,
|
|
45
47
|
EventChain,
|
|
46
|
-
EventChainVar,
|
|
47
48
|
EventHandler,
|
|
48
49
|
EventSpec,
|
|
49
50
|
EventVar,
|
|
50
|
-
call_event_fn,
|
|
51
|
-
call_event_handler,
|
|
52
|
-
get_handler_args,
|
|
53
51
|
no_args_event_spec,
|
|
54
52
|
)
|
|
55
53
|
from reflex.style import Style, format_as_emotion
|
|
56
|
-
from reflex.utils import format, imports, types
|
|
54
|
+
from reflex.utils import console, format, imports, types
|
|
57
55
|
from reflex.utils.imports import (
|
|
58
56
|
ImmutableParsedImportDict,
|
|
59
57
|
ImportDict,
|
|
@@ -104,7 +102,7 @@ class BaseComponent(Base, ABC):
|
|
|
104
102
|
"""
|
|
105
103
|
|
|
106
104
|
@abstractmethod
|
|
107
|
-
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
105
|
+
def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
|
|
108
106
|
"""Get the reflex internal hooks for the component and its children.
|
|
109
107
|
|
|
110
108
|
Returns:
|
|
@@ -112,7 +110,7 @@ class BaseComponent(Base, ABC):
|
|
|
112
110
|
"""
|
|
113
111
|
|
|
114
112
|
@abstractmethod
|
|
115
|
-
def _get_all_hooks(self) -> dict[str, None]:
|
|
113
|
+
def _get_all_hooks(self) -> dict[str, VarData | None]:
|
|
116
114
|
"""Get the React hooks for this component.
|
|
117
115
|
|
|
118
116
|
Returns:
|
|
@@ -493,8 +491,7 @@ class Component(BaseComponent, ABC):
|
|
|
493
491
|
)
|
|
494
492
|
# Check if the key is an event trigger.
|
|
495
493
|
if key in component_specific_triggers:
|
|
496
|
-
|
|
497
|
-
kwargs["event_triggers"][key] = self._create_event_chain(
|
|
494
|
+
kwargs["event_triggers"][key] = EventChain.create(
|
|
498
495
|
value=value, # type: ignore
|
|
499
496
|
args_spec=component_specific_triggers[key],
|
|
500
497
|
key=key,
|
|
@@ -548,6 +545,7 @@ class Component(BaseComponent, ABC):
|
|
|
548
545
|
# Construct the component.
|
|
549
546
|
super().__init__(*args, **kwargs)
|
|
550
547
|
|
|
548
|
+
@deprecated("Use rx.EventChain.create instead.")
|
|
551
549
|
def _create_event_chain(
|
|
552
550
|
self,
|
|
553
551
|
args_spec: types.ArgsSpec | Sequence[types.ArgsSpec],
|
|
@@ -569,82 +567,18 @@ class Component(BaseComponent, ABC):
|
|
|
569
567
|
|
|
570
568
|
Returns:
|
|
571
569
|
The event chain.
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
else:
|
|
585
|
-
raise ValueError(
|
|
586
|
-
f"Invalid event chain: {value!s} of type {value._var_type}"
|
|
587
|
-
)
|
|
588
|
-
elif isinstance(value, EventChain):
|
|
589
|
-
# Trust that the caller knows what they're doing passing an EventChain directly
|
|
590
|
-
return value
|
|
591
|
-
|
|
592
|
-
# If the input is a single event handler, wrap it in a list.
|
|
593
|
-
if isinstance(value, (EventHandler, EventSpec)):
|
|
594
|
-
value = [value]
|
|
595
|
-
|
|
596
|
-
# If the input is a list of event handlers, create an event chain.
|
|
597
|
-
if isinstance(value, List):
|
|
598
|
-
events: List[Union[EventSpec, EventVar]] = []
|
|
599
|
-
for v in value:
|
|
600
|
-
if isinstance(v, (EventHandler, EventSpec)):
|
|
601
|
-
# Call the event handler to get the event.
|
|
602
|
-
events.append(call_event_handler(v, args_spec, key=key))
|
|
603
|
-
elif isinstance(v, Callable):
|
|
604
|
-
# Call the lambda to get the event chain.
|
|
605
|
-
result = call_event_fn(v, args_spec, key=key)
|
|
606
|
-
if isinstance(result, Var):
|
|
607
|
-
raise ValueError(
|
|
608
|
-
f"Invalid event chain: {v}. Cannot use a Var-returning "
|
|
609
|
-
"lambda inside an EventChain list."
|
|
610
|
-
)
|
|
611
|
-
events.extend(result)
|
|
612
|
-
elif isinstance(v, EventVar):
|
|
613
|
-
events.append(v)
|
|
614
|
-
else:
|
|
615
|
-
raise ValueError(f"Invalid event: {v}")
|
|
616
|
-
|
|
617
|
-
# If the input is a callable, create an event chain.
|
|
618
|
-
elif isinstance(value, Callable):
|
|
619
|
-
result = call_event_fn(value, args_spec, key=key)
|
|
620
|
-
if isinstance(result, Var):
|
|
621
|
-
# Recursively call this function if the lambda returned an EventChain Var.
|
|
622
|
-
return self._create_event_chain(args_spec, result, key=key)
|
|
623
|
-
events = [*result]
|
|
624
|
-
|
|
625
|
-
# Otherwise, raise an error.
|
|
626
|
-
else:
|
|
627
|
-
raise ValueError(f"Invalid event chain: {value}")
|
|
628
|
-
|
|
629
|
-
# Add args to the event specs if necessary.
|
|
630
|
-
events = [
|
|
631
|
-
(e.with_args(get_handler_args(e)) if isinstance(e, EventSpec) else e)
|
|
632
|
-
for e in events
|
|
633
|
-
]
|
|
634
|
-
|
|
635
|
-
# Return the event chain.
|
|
636
|
-
if isinstance(args_spec, Var):
|
|
637
|
-
return EventChain(
|
|
638
|
-
events=events,
|
|
639
|
-
args_spec=None,
|
|
640
|
-
event_actions={},
|
|
641
|
-
)
|
|
642
|
-
else:
|
|
643
|
-
return EventChain(
|
|
644
|
-
events=events,
|
|
645
|
-
args_spec=args_spec,
|
|
646
|
-
event_actions={},
|
|
647
|
-
)
|
|
570
|
+
"""
|
|
571
|
+
console.deprecate(
|
|
572
|
+
"Component._create_event_chain",
|
|
573
|
+
"Use rx.EventChain.create instead.",
|
|
574
|
+
deprecation_version="0.6.8",
|
|
575
|
+
removal_version="0.7.0",
|
|
576
|
+
)
|
|
577
|
+
return EventChain.create(
|
|
578
|
+
value=value, # type: ignore
|
|
579
|
+
args_spec=args_spec,
|
|
580
|
+
key=key,
|
|
581
|
+
)
|
|
648
582
|
|
|
649
583
|
def get_event_triggers(
|
|
650
584
|
self,
|
|
@@ -1086,18 +1020,22 @@ class Component(BaseComponent, ABC):
|
|
|
1086
1020
|
event_args.append(spec)
|
|
1087
1021
|
yield event_trigger, event_args
|
|
1088
1022
|
|
|
1089
|
-
def _get_vars(
|
|
1023
|
+
def _get_vars(
|
|
1024
|
+
self, include_children: bool = False, ignore_ids: set[int] | None = None
|
|
1025
|
+
) -> Iterator[Var]:
|
|
1090
1026
|
"""Walk all Vars used in this component.
|
|
1091
1027
|
|
|
1092
1028
|
Args:
|
|
1093
1029
|
include_children: Whether to include Vars from children.
|
|
1030
|
+
ignore_ids: The ids to ignore.
|
|
1094
1031
|
|
|
1095
|
-
|
|
1032
|
+
Yields:
|
|
1096
1033
|
Each var referenced by the component (props, styles, event handlers).
|
|
1097
1034
|
"""
|
|
1098
|
-
|
|
1035
|
+
ignore_ids = ignore_ids or set()
|
|
1036
|
+
vars: List[Var] | None = getattr(self, "__vars", None)
|
|
1099
1037
|
if vars is not None:
|
|
1100
|
-
|
|
1038
|
+
yield from vars
|
|
1101
1039
|
vars = self.__vars = []
|
|
1102
1040
|
# Get Vars associated with event trigger arguments.
|
|
1103
1041
|
for _, event_vars in self._get_vars_from_event_triggers(self.event_triggers):
|
|
@@ -1141,12 +1079,15 @@ class Component(BaseComponent, ABC):
|
|
|
1141
1079
|
# Get Vars associated with children.
|
|
1142
1080
|
if include_children:
|
|
1143
1081
|
for child in self.children:
|
|
1144
|
-
if not isinstance(child, Component):
|
|
1082
|
+
if not isinstance(child, Component) or id(child) in ignore_ids:
|
|
1145
1083
|
continue
|
|
1146
|
-
|
|
1084
|
+
ignore_ids.add(id(child))
|
|
1085
|
+
child_vars = child._get_vars(
|
|
1086
|
+
include_children=include_children, ignore_ids=ignore_ids
|
|
1087
|
+
)
|
|
1147
1088
|
vars.extend(child_vars)
|
|
1148
1089
|
|
|
1149
|
-
|
|
1090
|
+
yield from vars
|
|
1150
1091
|
|
|
1151
1092
|
def _event_trigger_values_use_state(self) -> bool:
|
|
1152
1093
|
"""Check if the values of a component's event trigger use state.
|
|
@@ -1338,7 +1279,7 @@ class Component(BaseComponent, ABC):
|
|
|
1338
1279
|
"""
|
|
1339
1280
|
_imports = {}
|
|
1340
1281
|
|
|
1341
|
-
if self._get_ref_hook():
|
|
1282
|
+
if self._get_ref_hook() is not None:
|
|
1342
1283
|
# Handle hooks needed for attaching react refs to DOM nodes.
|
|
1343
1284
|
_imports.setdefault("react", set()).add(ImportVar(tag="useRef"))
|
|
1344
1285
|
_imports.setdefault(f"$/{Dirs.STATE_PATH}", set()).add(
|
|
@@ -1454,7 +1395,7 @@ class Component(BaseComponent, ABC):
|
|
|
1454
1395
|
}}
|
|
1455
1396
|
}}, []);"""
|
|
1456
1397
|
|
|
1457
|
-
def _get_ref_hook(self) ->
|
|
1398
|
+
def _get_ref_hook(self) -> Var | None:
|
|
1458
1399
|
"""Generate the ref hook for the component.
|
|
1459
1400
|
|
|
1460
1401
|
Returns:
|
|
@@ -1462,11 +1403,12 @@ class Component(BaseComponent, ABC):
|
|
|
1462
1403
|
"""
|
|
1463
1404
|
ref = self.get_ref()
|
|
1464
1405
|
if ref is not None:
|
|
1465
|
-
return (
|
|
1466
|
-
f"const {ref} = useRef(null); {Var(_js_expr=ref)._as_ref()!s} = {ref};"
|
|
1406
|
+
return Var(
|
|
1407
|
+
f"const {ref} = useRef(null); {Var(_js_expr=ref)._as_ref()!s} = {ref};",
|
|
1408
|
+
_var_data=VarData(position=Hooks.HookPosition.INTERNAL),
|
|
1467
1409
|
)
|
|
1468
1410
|
|
|
1469
|
-
def _get_vars_hooks(self) -> dict[str, None]:
|
|
1411
|
+
def _get_vars_hooks(self) -> dict[str, VarData | None]:
|
|
1470
1412
|
"""Get the hooks required by vars referenced in this component.
|
|
1471
1413
|
|
|
1472
1414
|
Returns:
|
|
@@ -1479,27 +1421,38 @@ class Component(BaseComponent, ABC):
|
|
|
1479
1421
|
vars_hooks.update(
|
|
1480
1422
|
var_data.hooks
|
|
1481
1423
|
if isinstance(var_data.hooks, dict)
|
|
1482
|
-
else {
|
|
1424
|
+
else {
|
|
1425
|
+
k: VarData(position=Hooks.HookPosition.INTERNAL)
|
|
1426
|
+
for k in var_data.hooks
|
|
1427
|
+
}
|
|
1483
1428
|
)
|
|
1484
1429
|
return vars_hooks
|
|
1485
1430
|
|
|
1486
|
-
def _get_events_hooks(self) -> dict[str, None]:
|
|
1431
|
+
def _get_events_hooks(self) -> dict[str, VarData | None]:
|
|
1487
1432
|
"""Get the hooks required by events referenced in this component.
|
|
1488
1433
|
|
|
1489
1434
|
Returns:
|
|
1490
1435
|
The hooks for the events.
|
|
1491
1436
|
"""
|
|
1492
|
-
return
|
|
1437
|
+
return (
|
|
1438
|
+
{Hooks.EVENTS: VarData(position=Hooks.HookPosition.INTERNAL)}
|
|
1439
|
+
if self.event_triggers
|
|
1440
|
+
else {}
|
|
1441
|
+
)
|
|
1493
1442
|
|
|
1494
|
-
def _get_special_hooks(self) -> dict[str, None]:
|
|
1443
|
+
def _get_special_hooks(self) -> dict[str, VarData | None]:
|
|
1495
1444
|
"""Get the hooks required by special actions referenced in this component.
|
|
1496
1445
|
|
|
1497
1446
|
Returns:
|
|
1498
1447
|
The hooks for special actions.
|
|
1499
1448
|
"""
|
|
1500
|
-
return
|
|
1449
|
+
return (
|
|
1450
|
+
{Hooks.AUTOFOCUS: VarData(position=Hooks.HookPosition.INTERNAL)}
|
|
1451
|
+
if self.autofocus
|
|
1452
|
+
else {}
|
|
1453
|
+
)
|
|
1501
1454
|
|
|
1502
|
-
def _get_hooks_internal(self) -> dict[str, None]:
|
|
1455
|
+
def _get_hooks_internal(self) -> dict[str, VarData | None]:
|
|
1503
1456
|
"""Get the React hooks for this component managed by the framework.
|
|
1504
1457
|
|
|
1505
1458
|
Downstream components should NOT override this method to avoid breaking
|
|
@@ -1510,7 +1463,7 @@ class Component(BaseComponent, ABC):
|
|
|
1510
1463
|
"""
|
|
1511
1464
|
return {
|
|
1512
1465
|
**{
|
|
1513
|
-
hook:
|
|
1466
|
+
str(hook): VarData(position=Hooks.HookPosition.INTERNAL)
|
|
1514
1467
|
for hook in [self._get_ref_hook(), self._get_mount_lifecycle_hook()]
|
|
1515
1468
|
if hook is not None
|
|
1516
1469
|
},
|
|
@@ -1559,7 +1512,7 @@ class Component(BaseComponent, ABC):
|
|
|
1559
1512
|
"""
|
|
1560
1513
|
return
|
|
1561
1514
|
|
|
1562
|
-
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
1515
|
+
def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
|
|
1563
1516
|
"""Get the reflex internal hooks for the component and its children.
|
|
1564
1517
|
|
|
1565
1518
|
Returns:
|
|
@@ -1574,7 +1527,7 @@ class Component(BaseComponent, ABC):
|
|
|
1574
1527
|
|
|
1575
1528
|
return code
|
|
1576
1529
|
|
|
1577
|
-
def _get_all_hooks(self) -> dict[str, None]:
|
|
1530
|
+
def _get_all_hooks(self) -> dict[str, VarData | None]:
|
|
1578
1531
|
"""Get the React hooks for this component and its children.
|
|
1579
1532
|
|
|
1580
1533
|
Returns:
|
|
@@ -1582,6 +1535,9 @@ class Component(BaseComponent, ABC):
|
|
|
1582
1535
|
"""
|
|
1583
1536
|
code = {}
|
|
1584
1537
|
|
|
1538
|
+
# Add the internal hooks for this component.
|
|
1539
|
+
code.update(self._get_hooks_internal())
|
|
1540
|
+
|
|
1585
1541
|
# Add the hook code for this component.
|
|
1586
1542
|
hooks = self._get_hooks()
|
|
1587
1543
|
if hooks is not None:
|
|
@@ -1737,7 +1693,7 @@ class CustomComponent(Component):
|
|
|
1737
1693
|
|
|
1738
1694
|
# Handle event chains.
|
|
1739
1695
|
if types._issubclass(type_, EventChain):
|
|
1740
|
-
value =
|
|
1696
|
+
value = EventChain.create(
|
|
1741
1697
|
value=value,
|
|
1742
1698
|
args_spec=event_triggers_in_component_declaration.get(
|
|
1743
1699
|
key, no_args_event_spec
|
|
@@ -1862,19 +1818,25 @@ class CustomComponent(Component):
|
|
|
1862
1818
|
for name, prop in self.props.items()
|
|
1863
1819
|
]
|
|
1864
1820
|
|
|
1865
|
-
def _get_vars(
|
|
1821
|
+
def _get_vars(
|
|
1822
|
+
self, include_children: bool = False, ignore_ids: set[int] | None = None
|
|
1823
|
+
) -> Iterator[Var]:
|
|
1866
1824
|
"""Walk all Vars used in this component.
|
|
1867
1825
|
|
|
1868
1826
|
Args:
|
|
1869
1827
|
include_children: Whether to include Vars from children.
|
|
1828
|
+
ignore_ids: The ids to ignore.
|
|
1870
1829
|
|
|
1871
|
-
|
|
1830
|
+
Yields:
|
|
1872
1831
|
Each var referenced by the component (props, styles, event handlers).
|
|
1873
1832
|
"""
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1833
|
+
ignore_ids = ignore_ids or set()
|
|
1834
|
+
yield from super()._get_vars(
|
|
1835
|
+
include_children=include_children, ignore_ids=ignore_ids
|
|
1836
|
+
)
|
|
1837
|
+
yield from filter(lambda prop: isinstance(prop, Var), self.props.values())
|
|
1838
|
+
yield from self.get_component(self)._get_vars(
|
|
1839
|
+
include_children=include_children, ignore_ids=ignore_ids
|
|
1878
1840
|
)
|
|
1879
1841
|
|
|
1880
1842
|
@lru_cache(maxsize=None) # noqa
|
|
@@ -2277,7 +2239,7 @@ class StatefulComponent(BaseComponent):
|
|
|
2277
2239
|
)
|
|
2278
2240
|
return trigger_memo
|
|
2279
2241
|
|
|
2280
|
-
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
2242
|
+
def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
|
|
2281
2243
|
"""Get the reflex internal hooks for the component and its children.
|
|
2282
2244
|
|
|
2283
2245
|
Returns:
|
|
@@ -2285,7 +2247,7 @@ class StatefulComponent(BaseComponent):
|
|
|
2285
2247
|
"""
|
|
2286
2248
|
return {}
|
|
2287
2249
|
|
|
2288
|
-
def _get_all_hooks(self) -> dict[str, None]:
|
|
2250
|
+
def _get_all_hooks(self) -> dict[str, VarData | None]:
|
|
2289
2251
|
"""Get the React hooks for this component.
|
|
2290
2252
|
|
|
2291
2253
|
Returns:
|
|
@@ -2403,7 +2365,7 @@ class MemoizationLeaf(Component):
|
|
|
2403
2365
|
The memoization leaf
|
|
2404
2366
|
"""
|
|
2405
2367
|
comp = super().create(*children, **props)
|
|
2406
|
-
if comp._get_all_hooks()
|
|
2368
|
+
if comp._get_all_hooks():
|
|
2407
2369
|
comp._memoization_mode = cls._memoization_mode.copy(
|
|
2408
2370
|
update={"disposition": MemoizationDisposition.ALWAYS}
|
|
2409
2371
|
)
|
reflex/components/core/banner.py
CHANGED
|
@@ -241,7 +241,7 @@ class WifiOffPulse(Icon):
|
|
|
241
241
|
size=props.pop("size", 32),
|
|
242
242
|
z_index=props.pop("z_index", 9999),
|
|
243
243
|
position=props.pop("position", "fixed"),
|
|
244
|
-
bottom=props.pop("
|
|
244
|
+
bottom=props.pop("bottom", "33px"),
|
|
245
245
|
right=props.pop("right", "33px"),
|
|
246
246
|
animation=LiteralVar.create(f"{pulse_var} 1s infinite"),
|
|
247
247
|
**props,
|
|
@@ -58,7 +58,7 @@ class Breakpoints(Dict[K, V]):
|
|
|
58
58
|
|
|
59
59
|
Args:
|
|
60
60
|
custom: Custom mapping using CSS values or variables.
|
|
61
|
-
initial: Styling when in the
|
|
61
|
+
initial: Styling when in the initial width
|
|
62
62
|
xs: Styling when in the extra-small width
|
|
63
63
|
sm: Styling when in the small width
|
|
64
64
|
md: Styling when in the medium width
|
|
@@ -445,7 +445,7 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
445
445
|
dark=Theme.one_dark,
|
|
446
446
|
)
|
|
447
447
|
|
|
448
|
-
# react-syntax-highlighter
|
|
448
|
+
# react-syntax-highlighter doesn't have an explicit "light" or "dark" theme so we use one-light and one-dark
|
|
449
449
|
# themes respectively to ensure code compatibility.
|
|
450
450
|
if "theme" in props and not isinstance(props["theme"], Var):
|
|
451
451
|
props["theme"] = getattr(Theme, format.to_snake_case(props["theme"])) # type: ignore
|
|
@@ -502,8 +502,8 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
502
502
|
|
|
503
503
|
theme = self.theme
|
|
504
504
|
|
|
505
|
-
out.add_props(style=theme).remove_props("theme", "code"
|
|
506
|
-
children=self.code,
|
|
505
|
+
out.add_props(style=theme).remove_props("theme", "code").add_props(
|
|
506
|
+
children=self.code,
|
|
507
507
|
)
|
|
508
508
|
|
|
509
509
|
return out
|
|
@@ -512,20 +512,25 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
512
512
|
return ["can_copy", "copy_button"]
|
|
513
513
|
|
|
514
514
|
@classmethod
|
|
515
|
-
def _get_language_registration_hook(cls) -> str:
|
|
515
|
+
def _get_language_registration_hook(cls, language_var: Var = _LANGUAGE) -> str:
|
|
516
516
|
"""Get the hook to register the language.
|
|
517
517
|
|
|
518
|
+
Args:
|
|
519
|
+
language_var: The const/literal Var of the language module to import.
|
|
520
|
+
For markdown, uses the default placeholder _LANGUAGE. For direct use,
|
|
521
|
+
a LiteralStringVar should be passed via the language prop.
|
|
522
|
+
|
|
518
523
|
Returns:
|
|
519
524
|
The hook to register the language.
|
|
520
525
|
"""
|
|
521
526
|
return f"""
|
|
522
|
-
if ({
|
|
527
|
+
if ({language_var!s}) {{
|
|
523
528
|
(async () => {{
|
|
524
529
|
try {{
|
|
525
|
-
const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{
|
|
526
|
-
SyntaxHighlighter.registerLanguage({
|
|
530
|
+
const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{language_var!s}}}`);
|
|
531
|
+
SyntaxHighlighter.registerLanguage({language_var!s}, module.default);
|
|
527
532
|
}} catch (error) {{
|
|
528
|
-
console.error(`Error importing language module for ${{{
|
|
533
|
+
console.error(`Error importing language module for ${{{language_var!s}}}:`, error);
|
|
529
534
|
}}
|
|
530
535
|
}})();
|
|
531
536
|
}}
|
|
@@ -547,8 +552,7 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
547
552
|
The hooks for the component.
|
|
548
553
|
"""
|
|
549
554
|
return [
|
|
550
|
-
|
|
551
|
-
self._get_language_registration_hook(),
|
|
555
|
+
self._get_language_registration_hook(language_var=self.language),
|
|
552
556
|
]
|
|
553
557
|
|
|
554
558
|
|
|
@@ -219,7 +219,7 @@ class DataEditor(NoSSRComponent):
|
|
|
219
219
|
# The minimum width a column can be resized to.
|
|
220
220
|
min_column_width: Var[int]
|
|
221
221
|
|
|
222
|
-
#
|
|
222
|
+
# Determines the height of each row.
|
|
223
223
|
row_height: Var[int]
|
|
224
224
|
|
|
225
225
|
# Kind of row markers.
|
|
@@ -291,7 +291,7 @@ class DataEditor(NoSSRComponent):
|
|
|
291
291
|
max_column_auto_width: The maximum width a column can be automatically sized to.
|
|
292
292
|
max_column_width: The maximum width a column can be resized to.
|
|
293
293
|
min_column_width: The minimum width a column can be resized to.
|
|
294
|
-
row_height:
|
|
294
|
+
row_height: Determines the height of each row.
|
|
295
295
|
row_markers: Kind of row markers.
|
|
296
296
|
row_marker_start_index: Changes the starting index for row markers.
|
|
297
297
|
row_marker_width: Sets the width of row markers in pixels, if unset row markers will automatically size.
|
|
@@ -182,9 +182,7 @@ class Form(BaseHTML):
|
|
|
182
182
|
props["handle_submit_unique_name"] = ""
|
|
183
183
|
form = super().create(*children, **props)
|
|
184
184
|
form.handle_submit_unique_name = md5(
|
|
185
|
-
str(
|
|
186
|
-
"utf-8"
|
|
187
|
-
)
|
|
185
|
+
str(form._get_all_hooks()).encode("utf-8")
|
|
188
186
|
).hexdigest()
|
|
189
187
|
return form
|
|
190
188
|
|
|
@@ -252,8 +250,12 @@ class Form(BaseHTML):
|
|
|
252
250
|
)
|
|
253
251
|
return form_refs
|
|
254
252
|
|
|
255
|
-
def _get_vars(
|
|
256
|
-
|
|
253
|
+
def _get_vars(
|
|
254
|
+
self, include_children: bool = True, ignore_ids: set[int] | None = None
|
|
255
|
+
) -> Iterator[Var]:
|
|
256
|
+
yield from super()._get_vars(
|
|
257
|
+
include_children=include_children, ignore_ids=ignore_ids
|
|
258
|
+
)
|
|
257
259
|
yield from self._get_form_refs().values()
|
|
258
260
|
|
|
259
261
|
def _exclude_props(self) -> list[str]:
|
|
@@ -81,7 +81,7 @@ class Title(Element):
|
|
|
81
81
|
tag = "title"
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
# Had to be named with an underscore so it
|
|
84
|
+
# Had to be named with an underscore so it doesn't conflict with reflex.style Style in pyi
|
|
85
85
|
class StyleEl(Element):
|
|
86
86
|
"""Display the style element."""
|
|
87
87
|
|