Commit Graph

1422 Commits

Author SHA1 Message Date
Masen Furer
7f0fb41752
REFLEX_USE_NPM escape hatch to opt out of bun
In some unsupported environments, we need to just not use bun. Further
investigation needed.
2024-05-14 17:01:28 -07:00
Elijah
d3723dbd3e remove dead code 2024-05-14 13:46:41 +00:00
Elijah
3d4129d9c1 precommit 2024-05-14 13:45:33 +00:00
ElijahAhianyo
9c5078595c Throw Warning for Projects Created in OneDrive on Windows 2024-05-14 13:38:58 +00: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
Masen Furer
7fee5d9e8d
Radix 3.0 tweaks (#3257)
* radix themes progress: expose `max` prop

It doesn't work yet, but PR filed for radix-ui/themes:
https://github.com/radix-ui/themes/pull/492

* Move `progress` and `toast` to `_x`

[REF-2779] Expose skeleton and data_list in top level namespace.
2024-05-08 14:02:37 -07:00
benedikt-bartscher
1324947f3c
minor test exp_not_equal fixup (#3256) 2024-05-08 13:34:17 -07:00
benedikt-bartscher
38c46ec4d5
copy background task marker (#3255) 2024-05-08 13:31:20 -07:00
Thomas Brandého
bdcbe006a2
update blank template (#3219)
* update blank template

* update CONTRIBUTING.md

* adjust min_height of main stack

* simplify stuff

* fix import order for blank template and tell ruff to ignore it
2024-05-08 13:30:14 -07:00
Elijah Ahianyo
1d093486b9
[REF-2622] Throw warning for incompatible uvicorn version on windows (#3246) 2024-05-08 10:52:37 -07:00
benedikt-bartscher
f0a772d08c
fix screenshot filenames (#3241) 2024-05-07 19:31:37 -07:00
Masen Furer
6b8a6f353b
icon_button: Icon size should be specified as int pixels, not str (#3247) 2024-05-07 19:31:01 -07:00
Masen Furer
ea0f490030
[REF-2764] dep update 0.5.0 (#3245)
* upgrade to latest pip for in_docker_test_script.sh

* Bump gunicorn to 22.0.0 (security)

Changelog: https://docs.gunicorn.org/en/stable/news.html#id1

use utime to notify workers liveness
migrate setup to pyproject.toml
fix numerous security vulnerabilities in HTTP parser (closing some request smuggling vectors)
parsing additional requests is no longer attempted past unsupported request framing
on HTTP versions < 1.1 support for chunked transfer is refused (only used in exploits)
requests conflicting configured or passed SCRIPT_NAME now produce a verbose error
Trailer fields are no longer inspected for headers indicating secure scheme
support Python 3.12

** Breaking changes **
minimum version is Python 3.7
the limitations on valid characters in the HTTP method have been bounded to Internet Standards
requests specifying unsupported transfer coding (order) are refused by default (rare)
HTTP methods are no longer casefolded by default (IANA method registry contains none affected)
HTTP methods containing the number sign (#) are no longer accepted by default (rare)
HTTP versions < 1.0 or >= 2.0 are no longer accepted by default (rare, only HTTP/1.1 is supported)
HTTP versions consisting of multiple digits or containing a prefix/suffix are no longer accepted
HTTP header field names Gunicorn cannot safely map to variables are silently dropped, as in other software
HTTP headers with empty field name are refused by default (no legitimate use cases, used in exploits)
requests with both Transfer-Encoding and Content-Length are refused by default (such a message might indicate an attempt to perform request smuggling)
empty transfer codings are no longer permitted (reportedly seen with really old & broken proxies)

** SECURITY **
fix CVE-2024-1135

* Remove TYPE_CHECKING guard for pydantic v1 imports

Retain TYPE_CHECKING guard in v1 fallback to force pyright into pydantic.v1 namespace

* Run unit tests with pydantic v1 now that v2 is installed via poetry
2024-05-07 15:15:52 -07:00
Nikhil Rao
940afb2c92
Remove deprecations for 0.5.0 (#3222) 2024-05-07 08:55:42 -07:00
Masen Furer
aa8858b113
Expose color_scheme on TabsTrigger (#3112) 2024-05-06 18:36:44 -07:00
benedikt-bartscher
185ec31a71
do not access state __subclasses__, prevent issues with AppHarness (#3143) 2024-05-06 18:35:25 -07:00
Masen Furer
83371d51d3
[REF-2658] Alembic should use batch mode for autogenerate (#3223) 2024-05-06 18:34:55 -07:00
benedikt-bartscher
b3c06bd139
prevent issues with #3214 (#3237) 2024-05-06 18:34:16 -07:00
Thomas Brandého
57476966f3
add_style api (#3202) 2024-05-06 16:59:11 -07:00
PeterYusuke
d68792f7b3
Add Japanese README.md file (#3234) 2024-05-06 10:50:02 -07:00
Elijah Ahianyo
0838e5ac6a
[REF-2676][REF-2751] Windows Skip ARM devices on bun install + Telemetry (#3212) 2024-05-06 09:50:05 -07:00
Elijah Ahianyo
9c7dbdbc72
[REF-2643] Throw Errors for duplicate Routes (#3155) 2024-05-03 12:15:40 -07:00
Elijah Ahianyo
24d15acae6
Windows Pin Version followup (Use Windows Install Link) (#3193) 2024-05-03 12:14:22 -07:00
Thomas Brandého
a7355962fd
prevent shadowing of computed vars (#3221) 2024-05-03 12:13:57 -07:00
Thomas Brandého
1817c30e22
add toast component (#3186) 2024-05-03 12:09:11 -07:00
Nikhil Rao
7903a1020d
Clean up config and app API (#3197) 2024-05-02 18:15:28 -07:00
Elijah Ahianyo
db47d39979
Windows --frontend-only fix ctrl + c (#3181) 2024-05-01 17:40:27 -07:00
Masen Furer
c636c91c9c
[REF-2273] Implement .setvar special EventHandler (#3163)
* Allow EventHandler args to be partially applied

When an EventHandler is called with an incomplete set of args it creates a
partial EventSpec. This change allows Component._create_event_chain to apply
remaining args from an args_spec to an existing EventSpec to make it
functional.

Instead of requiring the use of `lambda` functions to pass arguments to an
EventHandler, they can now be passed directly and any remaining args defined in
the event trigger will be applied after those.

* [REF-2273] Implement `.setvar` special EventHandler

All State subclasses will now have a special `setvar` EventHandler which
appears in the autocomplete drop down, passes static analysis, and canbe used
to set State Vars in response to event triggers.

Before:
    rx.input(value=State.a, on_change=State.set_a)

After:
    rx.input(value=State.a, on_change=State.setvar("a"))

This reduces the "magic" because `setvar` is statically defined on all State
subclasses.

* Catch invalid Var names and types at compile time

* Add test cases for State.setvar

* Use a proper redis-compatible token
2024-05-01 17:13:55 -07:00
benedikt-bartscher
9ead091fec
Improved get_attribute_access_type tests (#3180)
* test get_attribute_access_type against attrs

* add union and hybrid_property tests
2024-05-01 17:13:23 -07:00
Masen Furer
aeca983290
Allow StatefulComponent to also be rendered via __str__ (#3211)
This makes it easier to implement React "render functions" when wrapping
components that require children to be a callable.
2024-05-01 17:03:40 -07:00
khhan0130
be93b1280c
Update CodeBlock class to accept rx.color in custom_style (#3168) 2024-05-01 14:48:33 -07:00
Elijah Ahianyo
93c4f5024e
Windows Pin Bun version (#3192) 2024-05-01 14:47:03 -07:00
Masen Furer
19d8f6c752
[REF-2523] Implement new public Component API (#3203) 2024-05-01 14:46:27 -07:00
benedikt-bartscher
e31b458a69
allow optional props with None default value (#3179) 2024-05-01 13:33:38 -07:00
benedikt-bartscher
73e9123733
migrate deprecated redis.close to redis.aclose (#3199) 2024-05-01 12:05:00 -07:00
Martin Xu
fe731e385d
custom component install as editable mode (#3200) 2024-04-30 18:12:16 -07:00