Commit Graph

1603 Commits

Author SHA1 Message Date
abulvenz
7c2056e960
feat: Optionally comparing fields in Var.contains, e.g. on rx.Base based types. (#3375)
* feat: Optionally comparing fields, e.g. on rx.Base based types.

* feat: Minimally invasive change.
Leave the current implementation as is. Added test.

* fix: Supporting old-school python versions.

* fix: Adding masenf's suggestions to use var instead of string.
2024-05-24 17:16:26 -07:00
Masen Furer
51d3b2cb21
url quote the str data passed to rx.download (#3381) 2024-05-24 09:44:09 -07:00
Masen Furer
653f00b046
[REF-2878] Map fontFamily to fontFamily and --default-font-family (#3380)
When setting the font_family prop for a component, also set the radix token
`--default-font-family` so that child radix components will inherit the font.
2024-05-23 15:54:39 -07:00
benedikt-bartscher
d96f051486
set config.deploy_url during AppHarness tests (#3359) 2024-05-23 09:23:07 -07:00
Masen Furer
ed39c27bfb
[REF-2915] ComponentState subclasses are always treated as mixin (#3372)
Always treat ComponentState subclasses as mixin, and explicitly pass
`mixin=False` in `.create` classmethod when intentionally creating a substate.

This allows a "base" ComponentState to have subclasses that also work as
ComponentState themselves.

Fix #3368
2024-05-22 16:12:33 -07:00
Thomas Brandého
956a526b20
add support for lifespan tasks (#3312)
* add support for lifespan tasks

* allow passing args to lifespan task

* add message to the cancel call

* allow asynccontextmanager as lifespan tasks

* Fix integration.utils.SessionStorage

Previously the SessionStorage util was just looking in localStorage, but the
tests didn't catch it because they were asserting the token was not None,
rather than asserting it was truthy.

Fixed here, because I'm using this structure in the new lifespan test.

* If the lifespan task or context takes "app" parameter, pass the FastAPI instance.

* test_lifespan: end to end test for register_lifespan_task

* In py3.8, Task.cancel takes no args

* test_lifespan: use polling to make the test more robust

Fix CI failure

* Do not allow task_args for better composability

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-22 12:07:03 -07:00
benedikt-bartscher
0b613d5d3b
do not check attribute type for var internals (#3357) 2024-05-22 11:35:42 -07:00
Angelina Sheyko
0c0dde127f
Added config for number of gunicorn workers (#3351) 2024-05-22 11:31:15 -07:00
owlur
6976fe6145
Update Korean README.md and synchronize code with the latest version (#3337) 2024-05-21 19:37:21 -07:00
Masen Furer
3e5bf00ba2
Bump to 0.5.1 (#3364) 2024-05-21 17:17:48 -07:00
Thomas Brandého
4bda3eb233
add style for orientation=vertical in tabs (#3332) 2024-05-21 16:21:46 -07:00
Santiago Botero
d40d992670
Update Spanish README.md (#3330) 2024-05-21 14:51:50 -07:00
seewind
f961e2daa0
#3321: Update Chinese README.md (#3350) 2024-05-21 14:50:36 -07:00
Eric Brown
d50be7eab1
Use twine environment variables if set (#3353) 2024-05-21 14:43:49 -07:00
Nikhil Rao
ff985aee22
Suppress runtime warnings (#3354) 2024-05-21 12:34:25 -07:00
Nikhil Rao
ec72448b8b
Catch more errors in frontend/backend (#3346) 2024-05-20 16:55:41 -07:00
benedikt-bartscher
656914edef
fix rx.cond with ComputedVars and use union type (#3336) 2024-05-19 12:14:46 -07:00
Eric Brown
b614e38047
Add some minimal validation of pyproject.toml (#3339) 2024-05-19 12:13:24 -07:00
Thomas Brandého
590d86ebf4
update README to use 0.5.0 (#3313) 2024-05-17 16:29:38 -07:00
Thomas Brandého
9ba179410b
wip connection toaster (#3242)
* wip connection toaster

* never duplicate toast for websocket-error

* wip update banner

* clean up PR

* fix for 3.8

* update pyi

* ConnectionToaster tweaks

* Use `has_too_many_connection_errors` to avoid showing the banner immediately
* Increase toast duration to avoid frequent, distracting flashing of the toast
* Automatically dismiss the toast when the connection comes back up
* Include `close_button` for user to dismiss the toast
* If the user dismisses the toast, do not show it again until the connection comes back and drops again
* Use `connection_error` var instead of a custom util_hook to get the message

* ConnectionPulser: hide behind toast

* Hide the connection pulser behind the toast (33x33)
* Add a title (tooltip) that shows the connection error

* Re-add connection pulser to default overlay_component

If the user dismisses the toast, we still want to indicate that the backend is
actually down.

* Fix pre-commit issue from main

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-16 22:08:32 -07:00
Santiago Botero
99d59104ad
Add end line in .gitignore (#3309) 2024-05-16 13:22:44 -07:00
Masen Furer
bc6f0f70cb
Support replacing route on redirect (#3072)
* Support replacing route on redirect

Support next/router `.replace` interface to change page without creating a
history entry.

* test_event: include test cases for new "replace" kwarg
2024-05-16 13:21:40 -07:00
Masen Furer
89352ac10e
rx._x.client_state: react useState Var integration for frontend and backend (#3269)
New experimental feature to create client-side react state vars, save them in
the global `refs` object and access them in frontend rendering/event triggers
as well on the backend via call_script.
2024-05-16 13:20:26 -07:00
Thomas Brandého
47043ae787
throw error for componentstate in foreach (#3243) 2024-05-15 17:59:23 -07:00
benedikt-bartscher
48c504666e
properly replace ComputedVars (#3254)
* properly replace ComputedVars

* provide dummy override decorator for older python versions

* adjust pyi

* fix darglint

* cleanup var_data for computed vars inherited from mixin

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-15 15:01:14 -07:00
Masen Furer
c5f32db756
[REF-2787] add_hooks supports Var-wrapped hooks (#3248)
* [REF-2787] add_hooks supports Var-wrapped hooks

* Fix VarData definition in .pyi file to allow removal of type ignore comments
* Var.create and Var.create_safe accept _var_data parameter
* Replace instances where a set of imports was being passed to VarData
* Update code throughout reduce use of `._replace` to add VarData

* Fixup: user hooks _var_data.imports will never be iterable, just a single ImportDict
2024-05-15 14:59:45 -07:00
benedikt-bartscher
d96baac7d9
typed mixins and ComponentState (#3196)
* typed mixins

* implicit mixin=True kwarg for ComponentState subclasses

* fix: always init other subclasses

* adjust tests: all mixins support base vars now
2024-05-15 12:07:41 -07:00
benedikt-bartscher
87a3ddea7f
allow passing kwargs and options to selenium webdriver (#2894)
* allow passing kwargs to selenium webdriver

* always create driver options, add x11 class to chromium

* add driver_option_args
2024-05-15 11:58:10 -07:00
Eric Brown
30c8a07ba8
Adds dependency review action to verify allowed licensed dependencies (#3306)
This change will add a new action to scan the dependency's licenses
for any that may not be allowed for this project.

The pip-licenses command was run to get a dump of all the licenses
associated with this repo and put into the allow-licenses list.
Normally, you might only want to use deny-licenses list, but for
packages like Redis, there is no defined SPDX identifier for it.

Note: this list will require future maintenance as dependencies get
added that are not already in the allow list.

https://spdx.org/licenses/
https://github.com/raimon49/pip-licenses

Related to issue #2901

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
2024-05-15 11:55:18 -07:00
Yummy-Yums
efa9fcd6d5
FIX - Error: img is a self-closing tag and must neither have children nor use dangerouslySetInnerHTML. (#3307)
* fixed errors

* fix CI errors

* CI fix again

* used ruff formatting

* pyi fix

* fix app harness

---------

Co-authored-by: Elijah <elijahahianyo@gmail.com>
2024-05-15 11:52:50 -07:00
Elijah Ahianyo
ccc40e0c8d
Bump Bun version (#3281) 2024-05-15 11:57:11 +02:00
Eric Brown
bd3df68bef
Mirgrate from pip to uv (#3285)
In order to improve build time performance, this change switches
usage of pip to uv. The uv command is a pip alternative promising
much faster installs of Python packages.

For more information on uv, see:
https://github.com/astral-sh/uv

Closes: #2748

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
2024-05-15 11:56:16 +02:00
Masen Furer
76c8b2dfbd
Get action, cancel, on_dismiss and on_auto_close working for rx.toast (#3216)
* Get `action` and `cancel` working for rx.toast

Respect defaults set in ToastProvider toast_options when firing a toast with
it's own ToastProps set.

* Update reflex/components/sonner/toast.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Move queueEvent formatting into rx.utils.format module

Implement on_auto_close and on_dismiss callbacks inside ToastProps

* Update rx.call_script to use new format.format_queue_events

Replace duplicate logic in rx.call_script for handling the callback function.

* Move PropsBase to reflex.components.props

This base class will be exposed via rx._x.PropsBase and can be shared by other
wrapped components that need to pass a JS object full of extra props.

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-05-15 11:54:52 +02:00
Elijah Ahianyo
89a83ecd42
[REF-2803] Add imports benchmarks (#3272) 2024-05-14 23:19:46 -07:00
Elijah Ahianyo
ea5a3d44e7
[REF-2814]Throw Warning for Projects Created in OneDrive on Windows (#3304)
* Throw Warning for Projects Created in OneDrive on Windows

* precommit

* remove dead code

* REFLEX_USE_NPM escape hatch to opt out of bun

In some unsupported environments, we need to just not use bun. Further
investigation needed.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-14 18:47:08 -07:00
Masen Furer
1e9ccecea0
Restore the rx.color_mode.switch (#3294)
This was tentatively removed for 0.5.0 without a deprecation period, so adding
it back to avoid immediate breakage in existing apps.
2024-05-13 16:01:53 -07:00
Eric Brown
bff4464a9c
Typo in contact email address (#3292)
The demo template includes a drop down menu item named Contact
has an email address to the founders. However, the email address
includes an extraneous = character in the domain part making it
invalid.

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
2024-05-13 15:37:45 -07:00
Masen Furer
dfdf03f029
Only import PyiGenerator when needed (#3291)
Speed up reflex invocation time for `--help` by 1s
2024-05-13 15:37:34 -07:00
Masen Furer
6bbd0eee8a
accordion: unify border radius specification (#3290) 2024-05-13 15:37:24 -07:00
Masen Furer
7de89ac589
pyproject: bump version to 0.5.0 (#3287) 2024-05-13 15:37:09 -07:00
Eric Brown
998d06518c
Automatically label bug report issues with bug tag (#3288)
This change automatically sets the label on an issue
to `bug` if opened using the bug report template.

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
2024-05-13 22:47:45 +02:00
Masen Furer
3715462eb4
Allow Component.add_style to return a regular dict (#3264)
* Allow `Component.add_style` to return a regular dict

It's more convenient to allow returning a regular dict without having to import
and wrap the value in `rx.style.Style`.

If the dict contains any Var or encoded VarData f-strings, these will be picked
up when the plain dicts are passed to Style.update().

Because Style.update already merges VarData, there is no reason to explicitly
merge it again in this function; this change keeps the merging logic inside the
Style class.

* Test for Style.update with existing Style with _var_data and kwargs

Should retain the _var_data from the original Style instance

* style: Avoid losing VarData in Style.update

If a Style class with _var_data is passed to `Style.update` along with kwargs,
then the _var_data was lost in the double-splat dictionary expansion.

Instead, only apply the kwargs to an existing or new Style instance to retain
_var_data and properly convert values.

* add_style return annotation is Dict[str, Any]

* nit: use lowercase dict in annotation
2024-05-10 20:25:04 -07:00
Martin Xu
aa2cf80f70
[REF-2774] Send runtime error in telemetry (#3276) 2024-05-10 18:15:03 -07:00
Masen Furer
b95e02a805
rx.accordion customizability overhaul (#3266)
* rx.accordion customizability overhaul

* fix low contrast font in "classic" variant
* relative font sizing, so setting font_size on the root works now
* use CSS vars wherever possible to make downstream styling easier
* optional dividers between accordion items
* support `radius`
* support `duration` and `easing` for controlling the animation
* fix animation jank while keeping padding_y
* lookup `data-variant` via CSS instead of passing props in python
* fix "surface" variant to use `--accent-surface` as radix intended

* Restore default variant: "classic"

* Fix accordion primitive radius
2024-05-10 16:50:02 -07:00
Martin Xu
2789f32134
[REF-2774] Add ReflexError and subclasses, send in telemetry (#3271) 2024-05-10 12:12:42 -07:00
Martin Xu
4e959694a1
enable telemetry for frontend package download subprocess (#3270) 2024-05-10 10:17:10 -07:00
seewind
0238ee96df
#3185 fix tailwind.config.js: support corePlugins, important, prefix, separator (#3260) 2024-05-09 15:05:35 -07:00
Masen Furer
d767dc5fc7
[REF-2802] Foreach should respect modifications to children (#3263)
* Unit tests for add_style and component styles with foreach

The styles should be correctly applied for components that are rendered as part
of a foreach.

* [REF-2802] Foreach should respect modifications to children

Components are mutable, and there is logic that depends on walking through the
component tree and making modifications to components along the way. These
modifications _must_ be respected by foreach for consistency.

Modifications necessary to fix the bug:

* Change the hash function in `_render` to get a hash over the render_fn's
  `__code__` object. This way we get a stable hash without having to call the
  render function with bogus values.
* Call the render function once during `create` and save the result as a child
  of the Foreach component (tree walks will modify this instance).
* Directly render the original (and possibly modified) child component instead
  of calling the render_fn again and creating a new component instance at
  render time.

Additional changes because they're nice:

* Deprecate passing `**props` to `rx.foreach`. No one should have been
  doing this anyway, because it just does not work in any reasonable way.
* Raise `ForeachVarError` when the iterable type is Any
* Raise `ForeachRenderError` when the render function does not take 1 or 2 args.
* Link to the foreach component docs when either of those errors are hit.
* Change the `iterable` arg in `create` to accept `Var[Iterable] | Iterable`
  for better typing support (and remove some type: ignore comments)
* Simplify `_render` and `render` methods -- remove unused and potentially
  confusing code.

* Fixup: `to_bytes` requires `byteorder` arg before py3.11
2024-05-09 15:04:26 -07:00
Masen Furer
554d0d03d2
form: default width="100%" (#3261) 2024-05-09 13:11:54 -07:00
Masen Furer
6fb254ae3d
[REF-2789] Graceful deprecation of rx.input.root and rx.input.input (#3249)
* [REF-2789] Graceful deprecation of rx.input.root and rx.input.input

Handle previously valid code where rx.input.root wrapped
rx.input/rx.input.input and rx.input.slot.

Raise deprecation warnings with hints about how to refactor code.

Copy props from rx.input.root to children inputs and apply any rx.input.slot
components to children inputs in an attempt to keep existing code working as
best as possible.

Fix DebounceInput:
  * pass children through (for rx.input.slots)
  * pass _rename_props through (for color_scheme)

* Fix for case where `rx.input.root` had event triggers

Fix for case where `rx.input.root` had no input children
2024-05-08 14:39:22 -07:00