Compare commits
2 Commits
main
...
add-suppor
Author | SHA1 | Date | |
---|---|---|---|
![]() |
49001ba7c8 | ||
![]() |
327c11899c |
@ -15,13 +15,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
{% for package, version in dev_dependencies.items() %}
|
{% for package, version in dev_dependencies.items() %}
|
||||||
"{{ package }}": "{{ version }}"{% if not loop.last %},{% endif %}
|
"{{ package }}": "{{ version }}"{% if not loop.last %},{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
},
|
|
||||||
"overrides": {
|
|
||||||
{% for package, version in overrides.items() %}
|
|
||||||
"{{ package }}": "{{ version }}"{% if not loop.last %},{% endif %}
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,9 +11,7 @@ from reflex.vars.base import Var, get_unique_variable_name
|
|||||||
class AutoScroll(Div):
|
class AutoScroll(Div):
|
||||||
"""A div that automatically scrolls to the bottom when new content is added."""
|
"""A div that automatically scrolls to the bottom when new content is added."""
|
||||||
|
|
||||||
_memoization_mode = MemoizationMode(
|
_memoization_mode = MemoizationMode(disposition=MemoizationDisposition.ALWAYS)
|
||||||
disposition=MemoizationDisposition.ALWAYS, recursive=False
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, *children, **props):
|
def create(cls, *children, **props):
|
||||||
@ -46,6 +44,7 @@ class AutoScroll(Div):
|
|||||||
"""
|
"""
|
||||||
ref_name = self.get_ref()
|
ref_name = self.get_ref()
|
||||||
return [
|
return [
|
||||||
|
"const containerRef = useRef(null);",
|
||||||
"const wasNearBottom = useRef(false);",
|
"const wasNearBottom = useRef(false);",
|
||||||
"const hadScrollbar = useRef(false);",
|
"const hadScrollbar = useRef(false);",
|
||||||
f"""
|
f"""
|
||||||
@ -86,8 +85,6 @@ useEffect(() => {{
|
|||||||
const container = {ref_name}.current;
|
const container = {ref_name}.current;
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
scrollToBottomIfNeeded();
|
|
||||||
|
|
||||||
// Create ResizeObserver to detect height changes
|
// Create ResizeObserver to detect height changes
|
||||||
const resizeObserver = new ResizeObserver(() => {{
|
const resizeObserver = new ResizeObserver(() => {{
|
||||||
scrollToBottomIfNeeded();
|
scrollToBottomIfNeeded();
|
||||||
|
@ -195,7 +195,3 @@ class PackageJson(SimpleNamespace):
|
|||||||
"postcss": "8.5.1",
|
"postcss": "8.5.1",
|
||||||
"postcss-import": "16.1.0",
|
"postcss-import": "16.1.0",
|
||||||
}
|
}
|
||||||
OVERRIDES = {
|
|
||||||
# This should always match the `react` version in DEPENDENCIES for recharts compatibility.
|
|
||||||
"react-is": "19.0.0"
|
|
||||||
}
|
|
||||||
|
@ -846,7 +846,6 @@ def _compile_package_json():
|
|||||||
},
|
},
|
||||||
dependencies=constants.PackageJson.DEPENDENCIES,
|
dependencies=constants.PackageJson.DEPENDENCIES,
|
||||||
dev_dependencies=constants.PackageJson.DEV_DEPENDENCIES,
|
dev_dependencies=constants.PackageJson.DEV_DEPENDENCIES,
|
||||||
overrides=constants.PackageJson.OVERRIDES,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,11 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from reflex.constants.base import Dirs
|
from reflex.constants.base import Dirs
|
||||||
from reflex.utils.exceptions import PrimitiveUnserializableToJSONError, VarTypeError
|
from reflex.utils.exceptions import (
|
||||||
|
PrimitiveUnserializableToJSONError,
|
||||||
|
VarTypeError,
|
||||||
|
VarValueError,
|
||||||
|
)
|
||||||
from reflex.utils.imports import ImportDict, ImportVar
|
from reflex.utils.imports import ImportDict, ImportVar
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
@ -530,6 +534,56 @@ class NumberVar(Var[NUMBER_T], python_types=(int, float)):
|
|||||||
"""
|
"""
|
||||||
return issubclass(self._var_type, int)
|
return issubclass(self._var_type, int)
|
||||||
|
|
||||||
|
def __format__(self, format_spec: str) -> str:
|
||||||
|
"""Format the number.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
format_spec: The format specifier.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The formatted number.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
VarValueError: If the format specifier is not supported.
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
format_spec
|
||||||
|
and format_spec[-1] == "f"
|
||||||
|
and format_spec[0] == "."
|
||||||
|
and format_spec[1:-1].isdigit()
|
||||||
|
):
|
||||||
|
how_many_decimals = int(format_spec[1:-1])
|
||||||
|
return (
|
||||||
|
f"{get_decimal_string_operation(self, Var.create(how_many_decimals))}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if format_spec:
|
||||||
|
raise VarValueError(
|
||||||
|
(
|
||||||
|
"Unknown format code '{}' for object of type 'NumberVar'. It is only supported to use '.f' for float numbers."
|
||||||
|
"If possible, use computed variables instead: https://reflex.dev/docs/vars/computed-vars/"
|
||||||
|
).format(format_spec)
|
||||||
|
)
|
||||||
|
|
||||||
|
return super().__format__(format_spec)
|
||||||
|
|
||||||
|
|
||||||
|
@var_operation
|
||||||
|
def get_decimal_string_operation(value: NumberVar, decimals: NumberVar):
|
||||||
|
"""Get the decimal string of the number.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value: The number.
|
||||||
|
decimals: The number of decimals.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The decimal string of the number.
|
||||||
|
"""
|
||||||
|
return var_operation_return(
|
||||||
|
js_expression=f"({value}.toFixed({decimals}))",
|
||||||
|
var_type=str,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def binary_number_operation(
|
def binary_number_operation(
|
||||||
func: Callable[[NumberVar, NumberVar], str],
|
func: Callable[[NumberVar, NumberVar], str],
|
||||||
|
Loading…
Reference in New Issue
Block a user