|
@@ -17,7 +17,9 @@ from typing import (
|
|
|
overload,
|
|
|
)
|
|
|
|
|
|
+from reflex.constants.base import Dirs
|
|
|
from reflex.utils.exceptions import VarTypeError
|
|
|
+from reflex.utils.imports import ImportDict, ImportVar
|
|
|
|
|
|
from .base import (
|
|
|
CustomVarOperationReturn,
|
|
@@ -1098,6 +1100,11 @@ class ToBooleanVarOperation(ToOperation, BooleanVar):
|
|
|
_default_var_type: ClassVar[Type] = bool
|
|
|
|
|
|
|
|
|
+_IS_TRUE_IMPORT: ImportDict = {
|
|
|
+ f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
@var_operation
|
|
|
def boolify(value: Var):
|
|
|
"""Convert the value to a boolean.
|
|
@@ -1109,8 +1116,9 @@ def boolify(value: Var):
|
|
|
The boolean value.
|
|
|
"""
|
|
|
return var_operation_return(
|
|
|
- js_expression=f"Boolean({value})",
|
|
|
+ js_expression=f"isTrue({value})",
|
|
|
var_type=bool,
|
|
|
+ var_data=VarData(imports=_IS_TRUE_IMPORT),
|
|
|
)
|
|
|
|
|
|
|