Commit Graph

587 Commits

Author SHA1 Message Date
Samarth Bhadane
59047303c9
/health endpoint for K8 Liveness and Readiness probes (#3855)
* Added API Endpoint

* Added API Endpoint

* Added Unit Tests

* Added Unit Tests

* main

* Apply suggestions from Code Review

* Fix Ruff Formatting

* Update Socket Events

* Async Functions
2024-09-03 18:34:03 -07:00
Khaleel Al-Adhami
c07a983f05
add var_operation and move some operations to the new style (#3841)
* add var_operations and move some operations to the new style

* change bound style

* can't assume int anymore

* slice is not hashable (how did this work bef)

* convert to int explicitly

* move the rest of the operations to new style

* fix bool guess type

* forgot to precommit dangit

* add type ignore to bool for now
2024-09-03 11:39:05 -07:00
Khaleel Al-Adhami
629850162a
implement disk state manager (#3826)
* implement disk state manager

* put states inside of a folder

* return root state all the time

* factor out code

* add docs for token expiration

* cache states directory

* call absolute on web directory

* change dir to app path when testing the backend

* remove accidental 🥒

* test disk for now

* modify schema

* only serialize specific stuff

* fix issue in types

* what is a kilometer

* create folder if it doesn't exist in write

* this code hates me

* check if the file isn't empty

* add try except clause

* add check for directory again
2024-08-30 17:26:10 -07:00
Masen Furer
356deb5457
[REF-3589] raise EventHandlerArgMismatch when event handler args don't match spec (#3853)
* test_component: improve valid/invalid event trigger tests

Add test cases for event triggers defined as annotations.

Add additional cases around lambda returning different values.

Improve assertions for invalid tests (each line needs its own `pytest.raises`).

More invalid test cases.

* [REF-3589] raise EventHandlerArgMismatch when event handler args don't match spec

Improve error message for common issue.

Previously when the event handler arguments didn't match the spec, the
traceback resulted in:

```
OSError: could not get source code
```

Now this problem is traceable as a distinct error condition and users are
empowered to debug their code and reference the documentation (to be updated)
for further information.

* raise EventFnArgMismatch when lambda args don't match event trigger spec

Improve error message for another common issue encountered in the reflex framework.

Previous error message was

```
TypeError: index.<locals>.<lambda>() takes 0 positional arguments but 1 was given
```

* Fix up lambda test cases

* call_event_fn: adjust number of args for bound methods
2024-08-29 16:05:15 -07:00
Elijah Ahianyo
e6080a7707
[REF-3568][REF-3569]Remove deprecations (#3852)
* Remove deprecations

* remove prop conversion

* fix tests

* fix slight issue

* fix darglint
2024-08-29 15:46:18 -07:00
benedikt-bartscher
dd6feff13f
Get attribute access type fix (#3803)
* add failing test

* catch unhandled NotImplementedError
2024-08-29 09:45:24 -07:00
Khaleel Al-Adhami
ea15b184c0
fully migrate vars into new system (#3743)
* fully migrate vars into new system

* i hate rufffff (no i don't)

* fix silly pright issues (except colormode and state)

* remove all instances of Var.create

* create immutable callable var and get rid of more base vars

* implement hash for all functions

* get reflex-web to compile

* get it to compile reflex-web successfully

* fix tests

* fix pyi

* use override from typing_extension

* put plotly inside of a catch

* dicts are unusable sadly

* fix silly mistake

* overload equals to special case immutable var

* improve test_cond

* solve more CI issues, down to 94 failures

* down to 20 errors

* down to 13 errors

* pass all testcases

* fix pyright issues

* reorder things

* use get origin more

* use fixed_type logic

* various optimizations

* go back to passing test cases

* use less boilerplate

* remove unnecessary print message

* remove weird comment

* add test for html issue

* add type ignore

* fix another silly issue

* override get all var data for var operations call

* make integration tests pass

* fix immutable call var

* better logic for finding parent class

* use even better logic for finding state wrt computedvar

* only choose the ones that are defined in the same module

* small dict to large dict

* [REF-3591] Remove chakra-related files from immutable vars PR (#3821)

* Add comments to html metadata component (#3731)

* fix: add verification for path /404 (#3723)

Co-authored-by: coolstorm <manas.gupta@fampay.in>

* Use the new state name when setting `is_hydrated` to false (#3738)

* Use `._is_mutable()` to account for parent state proxy (#3739)

When a parent state proxy is set, also allow child StateProxy._self_mutable to
override the parent's `_is_mutable()`.

* bump to 0.5.9 (#3746)

* add message when installing requirements.txt is needed for chosen template during init (#3750)

* #3752 bugfix add domain for XAxis (#3764)

* fix appharness app_source typing (#3777)

* fix import clash between connectionToaster and hooks.useState (#3749)

* use different registry when in china, fixes #3700 (#3702)

* do not reload compilation if using local app in AppHarness (#3790)

* do not reload if using local app

* Update reflex/testing.py

Co-authored-by: Masen Furer <m_github@0x26.net>

---------

Co-authored-by: Masen Furer <m_github@0x26.net>

* Bump memory on relevant actions (#3781)

Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>

* [REF-3334] Validate Toast Props (#3793)

* [REF-3536][REF-3537][REF-3541] Move chakra components into its repo(reflex-chakra) (#3798)

* fix get_uuid_string_var (#3795)

* minor State cleanup (#3768)

* Fix code wrap in markdown (#3755)

---------

Co-authored-by: Alek Petuskey <alek@pynecone.io>
Co-authored-by: Manas Gupta <53006261+Manas1820@users.noreply.github.com>
Co-authored-by: coolstorm <manas.gupta@fampay.in>
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
Co-authored-by: Shubhankar Dimri <dimrishubhi@gmail.com>
Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
Co-authored-by: Elijah Ahianyo <elijahahianyo@gmail.com>

* pyproject.toml: bump to 0.6.0a1

* pyproject.toml: depend on reflex-chakra>=0.6.0a

New Var system support in reflex-chakra 0.6.0a1

* poetry.lock: relock dependencies

* integration: bump listening timeout to 1200 seconds

* integration: bump listening timeout to 1800 seconds

* Use cached_var_no_lock to avoid ImmutableVar deadlocks (#3835)

* Use cached_var_no_lock to avoid ImmutableVar deadlocks

ImmutableVar subclasses will always return the same value for a _var_name or
_get_all_var_data so there is no need to use a per-class lock to protect a
cached attribute on an instance, and doing so actually is observed to cause
deadlocks when a particular _cached_var_name creates new LiteralVar instances
and attempts to serialize them.

* remove unused module global

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Alek Petuskey <alek@pynecone.io>
Co-authored-by: Manas Gupta <53006261+Manas1820@users.noreply.github.com>
Co-authored-by: coolstorm <manas.gupta@fampay.in>
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
Co-authored-by: Shubhankar Dimri <dimrishubhi@gmail.com>
Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
Co-authored-by: Elijah Ahianyo <elijahahianyo@gmail.com>
2024-08-26 13:28:18 -07:00
Elijah Ahianyo
1f3779f40e
[REF-3536][REF-3537][REF-3541] Move chakra components into its repo(reflex-chakra) (#3798) 2024-08-19 13:41:31 -07:00
Elijah Ahianyo
4190a79835
[REF-3334] Validate Toast Props (#3793) 2024-08-15 09:30:32 -07:00
Khaleel Al-Adhami
ad14f38329
add type hinting to existing types (#3729)
* add type hinting to existing types

* dang it darglint

* i cannot
2024-07-31 12:01:17 -07:00
benedikt-bartscher
129adc941a
add test for initial state dict (#3727) 2024-07-31 11:37:53 -07:00
Khaleel Al-Adhami
1c400043c6
[REF-3328] Implement __getitem__ for ArrayVar (#3705)
* half of the way there

* implement __getitem__ for array

* add some tests

* add fixes to pyright

* fix default factory

* implement array operations

* format code

* fix pyright issue

* give up

* add object operations

* add test for merge

* pyright 🥺

* use str isntead of _var_name

Co-authored-by: Masen Furer <m_github@0x26.net>

* wrong var_type

* make to much nicer

* add subclass checking

* enhance types

* use builtin list type

* improve typing even more

* i'm awaiting october

* use even better typing

* add hash, json, and guess type method

* fix pyright issues

* add a test and fix lots of errors

* fix pyright once again

* add type inference to list

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-07-30 15:38:32 -07:00
Masen Furer
06833f6d8d
[REF-3203] Find a DOM event-like object in addEvents (#3706) 2024-07-29 17:17:51 -07:00
Khaleel Al-Adhami
ede5cd1f2c
[REF-3321] implement var operation decorator (#3698)
* implement var operation decorator

* use older syntax

* use cast and older syntax

* use something even simpler

* add some tests

* use old union tactics

* that's not how you do things

* implement arithmetic operations while we're at it

* add test

* even more operations

* can't use __bool__

* thanos snap

* forgot ruff

* use default factory

* dang it darglint

* i know i should have done that but

* convert values into literalvars

* make test pass

* use older union tactics

* add test to string var

* pright why do you hate me 🥺
2024-07-25 09:34:14 -07:00
Masen Furer
0845d2ee76
[REF-3184] [REF-3339] Background task locking improvements (#3696)
* [REF-3184] Raise exception when encountering nested `async with self` blocks

Avoid deadlock when the background task already holds the mutation lock for a
given state.

* [REF-3339] get_state from background task links to StateProxy

When calling `get_state` from a background task, the resulting state instance
is wrapped in a StateProxy that is bound to the original StateProxy and shares
the same async context, lock, and mutability flag.

* If StateProxy has a _self_parent_state_proxy, retrieve the correct substate

* test_state fixup
2024-07-23 15:28:38 -07:00
Thomas Brandého
b9927b6f49
notifying frontend about backend error looks better (#3491) 2024-07-23 13:58:15 -07:00
Khaleel Al-Adhami
ea016314b0
[REF-3227] implement more literal vars (#3687)
* implement more literal vars

* fix super issue

* pyright has a bug i think

* oh we changed that

* fix docs

* literalize vars recursively

* do what masen told me :D

* use dynamic keys

* forgot .create

* adjust _var_value

* dang it darglint

* add test for serializing literal vars into js exprs

* fix silly mistake

* add  handling for var and none

* use create safe

* is none bruh

* implement function vars and do various modification

* fix None issue

* clear a lot of creates that did nothing

* add tests to function vars

* added simple fix smh

* use fconcat to make an even more complicated test
2024-07-22 12:45:23 -07:00
Khaleel Al-Adhami
458cbfac59
[REF-3228] implement LiteralStringVar and format/retrieval mechanism (#3669)
* implement LiteralStringVar and format/retrieval mechanism

* use create safe

* add cached properties to ConcatVarOperation

* fix caches

* also include self

* fix inconsistencies in typings

* use default factory not default

* add missing docstring

* experiment with immutable var data

* solve pydantic issues

* add sorted function

* missing docs

* forgot ellipses

* give up on frozen

* dang it darglint

* fix string serialization bugs and remove unused code

* add returns statement

* whitespace moment

* add simple test for string concat

* export ConcatVarOperation
2024-07-17 17:01:27 -07:00
Masen Furer
0ed895cde7
debounce: pass through key and special_props (#3655)
These fields on the base Component were not being carried onto the
DebounceInput component (to be passed to the child).

Discovered while testing #3653
2024-07-12 13:27:19 -07:00
Khaleel Al-Adhami
d4d077818c
[REF-3225] implement __format__ for immutable vars (#3617)
* implement format for immutable vars

* add some basic test

* make reference only after formatting

* win over pyright

* hopefully now pyright doesn't hate me

* forgot some _var_data

* i don't know how imports work

* use f_string var and remove assignments from pyi file

* override post_init to not break immutability

* add create_safe and test for it
2024-07-11 11:19:38 -07:00
benedikt-bartscher
3039b54a75
add module prefix to generated state names (#3214)
* add module prefix to state names

* fix state names in test_app

* update state names in test_state

* fix state names in test_var

* fix state name in test_component

* fix state names in test_format

* fix state names in test_foreach

* fix state names in test_cond

* fix state names in test_datatable

* fix state names in test_colors

* fix state names in test_script

* fix state names in test_match

* fix state name in event1 fixture

* fix pyright and darglint

* fix state names in state_tree

* fix state names in redis only test

* fix state names in test_client_storage

* fix state name in js template

* add `get_state_name` and `get_full_state_name` helpers for `AppHarness`

* fix state names in test_dynamic_routes

* use new state name helpers in test_client_storage

* fix state names in test_event_actions

* fix state names in test_event_chain

* fix state names in test_upload

* fix state name in test_login_flow

* fix state names in test_input

* fix state names in test_form_submit

* ruff

* validate state module names

* wtf is going on here?

* remove comments leftover from refactoring

* adjust new test_add_style_embedded_vars

* fix state name in state.js

* fix integration/test_client_state.py

new SessionStorage feature was added with more full state names that need to be formatted in

* fix pre-commit issues in test_client_storage.py

* adjust test_computed_vars

* adjust safe-guards

* fix redis tests with new exception state

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-07-11 11:13:57 -07:00
Jishnu N
690b719437
[REF-3160] fix rx.Var._replace raise TypeError on invalid kwargs (#3625)
* fix: unexpected kwargs raise type error, on _replace

* add: docstring for _replace, test for invalid kwargs replace

* add: parametrize var for replace test

* fix: computed_var _replace with invalid kwargs
2024-07-09 11:19:29 -07:00
benedikt-bartscher
d621115f9b
add Bare SQLAlchemy mutation tracking, improve typing (#3628) 2024-07-09 11:13:28 -07:00
Maxim Vlah
772a3ef893
Catch unhandled errors on both frontend and backend (#3572) 2024-07-08 19:26:11 -07:00
benedikt-bartscher
6d3321284c
fix sqla python_type issues, add tests (#3613) 2024-07-08 19:21:08 -07:00
benedikt-bartscher
b7651e214b
add computed backend vars (#3573)
* add computed backend vars

* finish computed backend vars, add tests

* fix token for AppHarness with redis state manager

* fix timing issues

* add unit tests for computed backend vars

* automagically mark cvs with _ prefix as backend var

* fully migrate backend computed vars

* rename is_backend_variable to is_backend_base_variable

* add integration test for implicit backend cv, adjust comments

* replace expensive backend var check at runtime

* keep stuff together

* simplify backend var check method, consistent naming, improve test typing

* fix: do not convert properties to cvs

* add test for property

* fix cached_properties with _ prefix in state cls
2024-06-28 17:01:07 -07:00
benedikt-bartscher
bcc7a61452
improve backend var determination (#3587)
* cleanup reserved backend var check

* cleanup backend var determination mess

* add tests for hidden and class methods
2024-06-28 14:07:39 -07:00
benedikt-bartscher
a6bdaf1bbe
fix var dependency over properties (#3588) 2024-06-28 12:48:28 -07:00
benedikt-bartscher
33d7ec1f04
copy backend vars from mixins (#3580)
* copy backend vars from mixins

* fix and improve backend var mixin test
2024-06-28 10:42:41 -07:00
benedikt-bartscher
a7e4594fdc
Deprecate cached var (#3582)
* deprecate cached_var partial

* migrate cached_var to var(cache=True)

* fix darglint (typo)
2024-06-28 10:14:55 -07:00
benedikt-bartscher
44d27f9e4c
do not validate non-cached var deps (#3576)
* do not validate non-cached var deps

* further improve Exceptions for misconfigured var deps
2024-06-27 17:00:55 -07:00
benedikt-bartscher
8e66c9b3c7
classvars should not be backend vars (#3578)
* classvars should not be backend vars

* cleanup RESERVED_BACKEND_VAR_NAMES
2024-06-27 16:03:36 -07:00
Elijah Ahianyo
31bd75ff39
[REF-3185][REF-3180]Dont escape backticks in JS string interpolation (#3566)
* Dont escape backticks in JS string interpolation

* add unit tests

* Fix darglint

* add a note to re-visit after new Var API is implemented

* tests should have a good meaning
2024-06-26 13:23:07 -07:00
benedikt-bartscher
9d71bcbbb5
bare sqlalchemy session + tests (#3522)
* add bare sqlalchemy session, Closes #3512

* expose sqla_session at module level, add tests, improve typing

* fix table name

* add model_registry fixture, improve typing

* did not meant to push this

* add docstring to model_registry

* do not expose sqla_session in reflex namespace
2024-06-25 15:29:01 +02:00
benedikt-bartscher
41efe12e9a
Validate ComputedVar dependencies, add tests (#3527) 2024-06-24 16:11:42 -07:00
Elijah Ahianyo
f037df0977
[REF-3056] Config knob for redis StateManager expiration times (#3523) 2024-06-24 16:03:30 -07:00
Thomas Brandého
0d39237b3c
upgrade to latest ruff (#3497)
* upgrade to latest ruff

* try to fix dep review

* try to fix dep review (2)

* upgrade black

* upgrade black (2)

* update allowed dependencies

* update allowed dependencies (2)

* update allowed dependencies (3)

* wait between interim and final in yield test

* remove previous commit, increase delay between yield

* forgot to save on the time.sleep(1) removal

* fix integration (maybe?)

* fix pyi?

* what even is going on

* what is realityi?

* test another fix for app harness

* try to wait even longer?

* force uvloop to be optional

* downpin fastapi < 0.111, remove changes to test
2024-06-19 12:32:13 +02:00
Thomas Brandého
ed05f57fc9
Make .web configurable with REFLEX_WEB_WORKDIR (#3462) 2024-06-17 16:17:00 -04:00
Elijah Ahianyo
69e4bbc301
[REF-2830] server side events and stateless components should not require not require a backend (#3475)
* `rx.color_mode.icon`, `rx.color_mode.button` and `rx.color_mode.switch` should not require a backend`

* remove print statement

* unit tests and precommit fix

* add unit tests

* change logic to check if event handlers actually contain state. Also delay websocket object check in state.js so server side events can get executed for stateless apps

* make sure events are not queued for server side events particularly ones that call queueEvents(clear_local_storage, clear_cookies, remove_local_storage, remove_cookies) when the app is stateless(no ws)

* fix unit tests

* fix broken unit tests in test_app

* modify socket check in processEvent to only return if socket exists and theres any event in the queue that requires state

* Apply suggestions from code review

make queueEvent call async

Co-authored-by: Masen Furer <m_github@0x26.net>

* await queueEventIfSocketExists

* Revert "await queueEventIfSocketExists"

This reverts commit 9ef8070b87.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-06-14 09:48:53 -07:00
Thomas Brandého
462b023019
use add_imports everywhere (#3448) 2024-06-12 09:26:45 -07:00
Elijah Ahianyo
8c8156f3aa
[REF-3016] Allow special characters in upload ID (#3449) 2024-06-12 09:21:21 -07:00
Alexander Morgan
ad3134413b
Make better/less use of dict.keys() calls (#3455) 2024-06-07 14:28:44 -07:00
benedikt-bartscher
e42d4ed9ef
[REF-3009] type transforming serializers (#3227)
* wip type transforming serializers

* old python sucks

* typing fixups

* Expose the `to` parameter on `rx.serializer` for type conversion

Serializers can also return a tuple of `(serialized_value, type)`, if both ways
are specified, then the returned value MUST match the `to` parameter.

When initializing a new rx.Var, if `_var_is_string` is not specified and the serializer returns a `str` type, then mark `_var_is_string=True` to indicate that the Var should be treated like a string literal.

Include datetime, color, types, and paths as "serializing to str" type.

Avoid other changes at this point to reduce fallout from this change:

  Notably, the `serialize_str` function does NOT cast to `str`, which
  would cause existing code to treat all Var initialized with a str as a
  str literal even though this was NOT the default before.

Update test cases to accomodate these changes.

* Raise deprecation warning for rx.Var.create with string literal

In the future, we will treat strings as string literals in the JS code. To get
a Var that is not treated like a string, pass _var_is_string=False.

This will allow our serializers to automatically identify cast string literals
with less special cases (and the special cases need to be explicitly
identified).

* Add test case for mismatched serialized types

* fix old python

* Remove serializer returning a tuple feature

Simplify the logic; instead of making a wrapper function that returns
a tuple, just save the type conversions in a separate global.

* Reset the LRU cache when adding new serializers

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-06-07 09:50:10 -07:00
Masen Furer
765f349f02
[REF-3004] Use relative path to stylesheet for postcss-import compat (#3435)
* test_tailwind: include custom stylesheet

* [REF-3004] Use relative path to stylesheet for postcss-import compat

postcss-import balls all of the CSS up into a single file, which happens at
compile time. So, replace the `@/` with `../public` so the import paths can be
resolved relative to the `styles` directory.

* test_compiler: fix compile_stylesheets expectations

* Use constants.Dirs.PUBLIC instead of "public"
2024-06-05 10:02:05 -07:00
Masen Furer
b04e3a6ce9
[REF-1356] Track changes applied to Base subclass via helper method. (#2242) 2024-05-31 14:58:58 -07:00
HongyuHansonYao
d9e718d7bd
Layout property not pushed through on rx.plotly (#3394)
* init fix

* Update reflex/components/plotly/plotly.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* plotly: treat `data` as a `dict`-type Var in _render

this allows the data to be passed directly as a figure or from a state var

* removed width height prop as they are no longer needed

* updated

* reverted some of the changes

* fixed unit tests

* regen pyi

---------

Co-authored-by: Hongyu Yao <hongyuyao@hongyus-mbp-3.lan>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Hongyu Yao <hongyuyao@Hongyus-MacBook-Pro-3.local>
2024-05-31 11:48:43 -07:00
Elijah Ahianyo
34bf25071a
[REF-2821]Improve Dynamic Imports (#3345)
* Improve import times

* add lazy loading to rx.el

* add lazy loading to reflex core components

* minor refactor

* Get imports working with reflex web

* get imports to work with all reflex examples

* refactor to define imports only in the root.

* lint

* deadcode remove

* update poetry deps

* unit tests fix

* app_harness fix

* app_harness fix

* pyi file generate

* pyi file generate

* sort pyi order

* fix pyi

* fix docker ci

* rework pyi-generator

* generate pyi for __init__ files

* test pyright

* test pyright ci

* partial pyright fix

* more pyright fix

* pyright fix

* fix pyi_generator

* add rx.serializer and others

* add future annotation import which fixes container CI, then also load recharts lazily

* add new pyi files

* pyright fix

* minor fixes for reflex-web and flexdown

* forward references for py38

* ruff fix

* pyi fix

* unit tests fix

* reduce coverage to 68%

* reduce coverage to 67%

* reduce coverage to 66%as a workaround to coverage's rounding issue

* reduce coverage to 66%as a workaround to coverage's rounding issue

* exclude lazy_loader dependency review checks.

* its lazy-loader

* Add docstrings and regenerate pyi files

* add link

* address Pr comments

* CI fix

* partially address PR comments.

* edit docstrings and fix integration tests

* fix typo in docstring

* pyi fix
2024-05-31 16:43:10 +00:00
abulvenz
6c6eaaa55f
External assets (#3220) 2024-05-28 09:39:25 -07:00
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
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
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
Thomas Brandého
47043ae787
throw error for componentstate in foreach (#3243) 2024-05-15 17:59:23 -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
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
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
Nikhil Rao
940afb2c92
Remove deprecations for 0.5.0 (#3222) 2024-05-07 08:55:42 -07:00
Masen Furer
83371d51d3
[REF-2658] Alembic should use batch mode for autogenerate (#3223) 2024-05-06 18:34:55 -07:00
Thomas Brandého
57476966f3
add_style api (#3202) 2024-05-06 16:59:11 -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
Nikhil Rao
7903a1020d
Clean up config and app API (#3197) 2024-05-02 18:15:28 -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
khhan0130
be93b1280c
Update CodeBlock class to accept rx.color in custom_style (#3168) 2024-05-01 14:48:33 -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
Masen Furer
b7e85ecec4
[REF-2574] Default width for Stack (+children) and default padding for container (#3104) 2024-04-30 13:15:57 -07:00
Masen Furer
3564df7620
Implement throttle and debounce as event actions (#3091) 2024-04-26 17:28:51 -07:00
benedikt-bartscher
c2017b295e
Improved get_attribute_access_type (#3156) 2024-04-26 17:28:30 -07:00
Masen Furer
0a8aaea599
[REF-2682] Foreach over dict uses Tuple arg value (#3160)
* test_foreach: assert on arg _var_type

* [REF-2682] Foreach over dict uses Tuple arg value

When iterating over a Var with _var_type dict, the resulting arg value
_var_type should be Tuple[key, value] so it can be correctly used with other
var operations.

Fix #3157

* Correct _var_type for iteration over Tuple of multiple types

The arg value when iterating over a tuple could be any of the possible values
mentioned in the annotation.

When only one type is used, the Union collapses to the base type, at least in py3.11

* Add comments
2024-04-25 09:10:55 -07:00
Thomas Brandého
ac36bfc6ea
Radix 3.0 (#3159) 2024-04-25 08:33:29 -07:00
Ogidi Ifechukwu
ce2bd2286e
Refactor upload component and add styled upload component (#3035) 2024-04-24 13:45:22 -07:00
Jirka Borovec
4d567b7ec1
ruff-format: unify Black with Ruff v0.1 (#2837)
* ruff-format: unify Black with Ruff

* ruff lint.

* v0.1.0

* run precommit

* hand fixing

* fix `not isinstance(...)`

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

* rev isinstance(...) with noqa

* exclude = ["*.pyi"]

* apply precommit

* apply format

* revert pyi

* fixing

* Fix or

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

* Update reflex/components/datadisplay/code.pyi

* Apply suggestions from code review

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

* Update tests/components/core/test_colors.py

* Update reflex/app.py

* Update reflex/app.py

* Update benchmarks/test_benchmark_compile_pages.py

* Update benchmarks/test_benchmark_compile_pages.py

* Update benchmarks/test_benchmark_compile_pages.py

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-04-23 14:40:06 -07:00
Elijah Ahianyo
8e4d6a4781
[REF-2636]Improve Error message for unsupported event trigger (#3147)
* Improve Error message for unsupported event trigger

* typo fix

* fix ci

* add tests

* Update reflex/components/component.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* fix typo

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-04-23 14:36:26 -07:00
Martin Xu
c567334c92
allow set in var.contains (#3113)
* allow set in var.contains

* fix UT
2024-04-18 20:00:18 -07:00
Masen Furer
fc0be257a3
Fix annotated EventHandler (#3076) 2024-04-11 15:34:00 -07:00
Elijah Ahianyo
04ab2b9a71
[REF-2524] Tuple unpacking should apply at component level (#3062) 2024-04-11 14:04:19 -07:00
Masen Furer
1a11941577
[REF-2392] Expose next.config.js transpilePackages key (#3006) 2024-04-11 13:50:42 -07:00
Masen Furer
d7abcd45de
Force pydantic v1 for sqlmodel compatibility (#3026) 2024-04-11 13:42:30 -07:00
wassaf shahzad
9073a2781b
added serializer for enums (#3058) 2024-04-09 21:13:43 -07:00
Elijah Ahianyo
fdc944e002
Literal Error Formatting (#3037) 2024-04-08 11:29:40 -07:00
Martin Xu
5274f04b66
[REF-2296] Rename recursive functions (#2999) 2024-04-04 09:26:31 -07:00
Thomas Brandého
bf0ebb8d09
Lendemor/improve coverage (#2988)
* add more tests

* add tests to raise coverage

* more tests, bump coverage to 73

* fix up icon_button test

* fix darglint for app.py

* fix utcnow usage warning

* set threshold to 72

* fix timestamp

* fix unit tests for linux-redis

* removed commented code and put a TODO
2024-04-04 14:31:43 +02:00
Thomas Brandého
34ee07ecd1
use dict instead of set to store hooks (#2995) 2024-04-03 17:13:42 -07:00
Elijah Ahianyo
d43a85bab2
Unpack component tuples in a fragment (#2985) 2024-04-03 10:44:04 -07:00
Aman Salwan
0e221f0984
Logic for removing the 'None' property along with its corresponding test case. (#2969) 2024-04-02 11:37:05 -07:00
Martin Xu
6d400eddc9
Revert "[REF-2269] Add add_imports API for component class (#2937)" (#2978)
This reverts commit 8edd1dfdc9.
2024-04-01 15:57:03 -07:00
Thomas Brandého
0af4770180
generate pyi files when building/publishing 3rd party component (#2945)
* build pyi files when building/publishing 3rd party

* fix typo in workflow

* add future annotation

* add tests to pass coverage check

* add more unit tests

* omit pyi_generator from test coverage

* change black from dev deps to direct deps

* remake all pyi

* format pyi if black is present, return as if otherwise

* fix requested changes

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-29 09:54:21 -07:00
Masen Furer
55b0fb36e8
[REF-2219] Avoid refetching states that are already cached (#2953)
* Add test_get_state_from_sibling_not_cached

A better unit test to catch issues with refetching parent states
and calculating the wrong parent state names to fetch.

* _determine_missing_parent_states: correctly generate state names

Prepend only the previous state name to the current relative_parent_state_name
instead of joining all of the previous state names together.

* [REF-2219] Avoid refetching states that are already cached

The already cached states may have unsaved changes which can be wiped out if
they are refetched from redis in the middle of handling an event.

If the root state already knows about one of the potentially missing states,
then use the instance that is already cached.

Fix #2851
2024-03-29 09:42:25 -07:00
Malte Klemm
86526cba51
[REF-2127] Loosen requirements (#2796)
* Remove upper bounds of most dependencies.

Also adds a import try except block for pydantic.v1 and relocks.

Keep black and ruff to not mess to much with current formatting

Make pyright see the right import as long as constraint still lock pydantiv v1

Down pin pytest-asyncio again due to known issue

Fix upload handler with latest versions of fastapi

Change comment

* Add changed lockfile

* Set max versions for deps

* Revert app.pyi

---------

Co-authored-by: Malte Klemm <malte.klemm@blueyonder.com>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
2024-03-29 09:26:53 -07:00
Masen Furer
5510eaf820
[REF-2265] ComponentState: scaffold for copying State per Component instance (#2923)
* [REF-2265] ComponentState: scaffold for copying State per Component instance

Define a base ComponentState which can be used to easily create copies of the
given State definition (Vars and EventHandlers) that are tied to a particular
instance of a Component (returned by get_component)

* Define `State` field on `Component` for typing compatibility.

This is an Optional field of Type[State] and is populated by ComponentState.

* Add integration/test_component_state.py

Create two independent counters and increment them separately

* Add unit test for ComponentState
2024-03-29 09:22:25 -07:00
Martin Xu
f372402ee4
[REF-2272] Support declaring EventHandlers directly in component (#2952) 2024-03-29 06:26:07 -07:00
Martin Xu
68c56a9811
[REF-2168] Add share options to custom component commands (#2883)
* add command to share custom component info for gallery

* cleanup

* tested

* Update custom_components.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* reorder the questions

* ask user to verify info before publishing

* remove questions already captured in pyproject.toml

* no need to cache form inputs since not many questions

* tested

* cleanup

* delete test

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-28 15:13:37 -07:00
Martin Xu
8edd1dfdc9
[REF-2269] Add add_imports API for component class (#2937) 2024-03-28 11:03:26 -07:00
Thomas Brandého
1810288007
remove inheritance from Flex for list components (#2936) 2024-03-28 10:58:36 -07:00
Masen Furer
b788890696
[REF-2089] Use dill instead of cloudpickle for serialization (#2922)
* Use dill instead of cloudpickle for serialization

* smaller size pickles
* support dynamically defined states
* avoid issues with unpickleable globals

* pyproject: add dill, remove cloudpickle

* poetry.lock: relock dependencies

* Dynamically convert EventHandler to functools.partial

Instead of converting the functions up front and assigning them to the
instance, unbox the function from the EventHandler when it is requested via
__getattribute__. This reduces the size of the per-instance pickle, because
event handler bodies do not need to be included.

* Improve checking for cython_function_or_method

Because pydantic can be installed without cython, only use the workaround in
the case where the BaseModel.validate function is NOT a FunctionType,
indicating it's a cython function.

* Serialize all State subclasses by reference
2024-03-27 13:47:33 -07:00
Thomas Brandého
f19a6a8c8d
use radix box instead of chakra one for responsive elements (#2921) 2024-03-25 15:16:48 -07:00
Masen Furer
432fcd4a5b
Account for imports of @rx.memo components for frontend package installation (#2863)
* CustomComponent ignores the annotation type in favor of the passed value

Do not require rx.memo wrapped functions to have 100% correct annotations.

* test_custom_component_get_imports: test imports from wrapped custom components

* Account for imports of custom components for frontend installation

Create new ImportVar that only install the package to avoid rendering the
imports in the page that contains the custom component itself.

* Handle Imports that should never be installed

* Fix up double negative logic

* Perf Optimization: use the imports we already calculate during compile

Instead of augmenting _get_imports with a weird, slow, recursive crawl and
dictionary reconstruction, just use the imports that we compile into the
components.js file to install frontend packages needed by the custom
components.

Same effect, but adds essentially zero overhead to the compilation.
2024-03-15 09:59:59 -07:00
Thomas Brandého
92db402539
telemetry refactor + unit tests (#2786) 2024-03-13 12:38:54 -07:00
Masen Furer
c809107d09
[REF-2158] Enable state when on_load or event_triggers are set. (#2815)
* [REF-2158] Enable state when `on_load` or event_triggers are set.

Basically all events in a reflex app require the backend to be up, even the
built-in server side events round trip to the backend and require "state" even
if no user-defined state classes are declared.

test_app_state_determination: checking that state is enabled at the right time

* Clear out DECORATED_PAGES when initializing a new app
2024-03-08 17:34:09 -08:00
Martin Xu
bf297e2f5b
[REF-2141] Custom component command improvements (#2807)
* add custom component command improvements

* fix test

* fix regex to include both single/double quotes
2024-03-07 20:42:22 -08:00
benedikt-bartscher
19a5cdd408
Track state usage (#2441)
* rebase

* pass include_children kwarg in radix FormRoot

* respect include_children

* ruff fixes

* readd statemanager init, run pyi gen

* minor performance imporovements, fix for state changes

* fix pyi and pyright

* pass include_children for chakra

* remove old state detection

* add test for unused states in stateless app

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-07 14:25:55 -08:00
Masen Furer
4f12d2e269
Fix infinite recursion when a substate named "state" has a computed var (#2778)
* test_potentially_dirty_substates: when a state named State should be computed

Catch a regression introduced in 0.4.3a1

* _potentially_dirty_substates: qualify substate name

When looking up substate classes, ensure the qualified name is used to avoid
issues with same-named substates.
2024-03-04 13:13:08 -08:00
macmoritz
9e0452beb0
pass lang and custom_attrs from app to html root (#2697)
* pass lang and custom_attrs from app to html root

* fix some pre-commit errors and try adding lang

* fix tests

* really fix test

* cleanup with @benedikt-bartscher

* fix props and tests

* use str instead of var

* change typing of html_custom_attrs to not allow Vars
2024-03-03 13:51:20 -08:00
wassaf shahzad
0a18eaa28b
DRAFT PR - Added code for computed backend vars (#2540)
* added code for computed backend vars

* fixed formatting issues

* fix small bug

* fixes ruff issue

* fixed black issue

* augment test for backend computed var

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-02-29 13:00:41 -08:00
benedikt-bartscher
2d56441a28
fix black+ruff (#2750) 2024-02-28 14:51:50 -08:00
Amir Molavi
842c7e6882
Add config to rx.plotly component (#2745) 2024-02-28 12:44:33 -08:00
Masen Furer
deae662e2a
[REF-1988] API to Get instance of Arbitrary State class (#2678)
* WiP get_state

* Refactor get_state fast path

Rudimentary protection for state instance access from a background task
(StateProxy)

* retain dirty substate marking per `_mark_dirty` call to avoid test changes

* Find common ancestor by part instead of by character

Fix StateProxy for substates and parent_state attributes (have to handle in
__getattr__, not property)

Fix type annotation for `get_state`

* test_state: workflow test for `get_state` functionality

* Do not reset _always_dirty_substates when adding vars

Reset the substate tracking only when the class is instantiated.

* test_state_tree: test substate access in a larger state tree

Ensure that `get_state` returns the proper "branch" of the state tree depending
on what substate is requested.

* test_format: fixup broken tests from adding substates of TestState

* Fix flaky integration tests with more polling

* AppHarness: reset _always_dirty_substates on rx.State

* RuntimeError unless State is instantiated with _reflex_internal_init=True

Avoid user errors trying to directly instantiate State classes

* Helper functions for _substate_key and _split_substate_key

Unify the implementation of generating and decoding the token + state name
format used for redis state sharding.

* StateManagerRedis: use create_task in get_state and set_state

read and write substates concurrently (allow redis to shine)

* test_state_inheritance: use polling cuz life too short for flaky tests

kthnxbai ❤️

* Move _is_testing_env to reflex.utils.exec.is_testing_env

Reuse the code in app.py

* Break up `BaseState.get_state` and friends into separate methods

* Add test case for pre-fetching cached var dependency

* Move on_load_internal and update_vars_internal to substates

Avoid loading the entire state tree to process these common internal events. If
the state tree is very large, this allow page navigation to occur more quickly.

Pre-fetch substates that contain cached vars, as they may need to be recomputed
if certain vars change.

* Do not copy ROUTER_DATA into all substates.

This is a waste of time and memory, and can be handled via a special case in
__getattribute__

* Track whether State instance _was_touched

Avoid wasting time serializing states that have no modifications

* Do not persist states in `StateManagerRedis.get_state`

Wait until the state is actually modified, and then persist it as part of `set_state`.

Factor out common logic into helper methods for readability and to reduce
duplication of common logic.

To avoid having to recursively call `get_state`, which would require persisting
the instance and then getting it again, some of the initialization logic
regarding parent_state and substates is duplicated when creating a new
instance. This is for performance reasons.

* Remove stray print()

* context.js.jinja2: fix check for empty local storage / cookie vars

* Add comments for onLoadInternalEvent and initialEvents

* nit: typo

* split _get_was_touched into _update_was_touched

Improve clarity in cases where _get_was_touched was being called for its side
effects only.

* Remove extraneous information from incorrect State instantiation error

* Update missing redis exception message
2024-02-27 13:02:08 -08:00
Masen Furer
350a051a45
[REF-1741] Disallow routes with /api prefix (#2711) 2024-02-26 19:34:51 -08:00
Thomas Brandého
0464a7723e
remove chakra from markdown component_map (#2709) 2024-02-26 19:34:22 -08:00
wassaf shahzad
4d3d9aa717
added accent option in color (#2713) 2024-02-25 19:47:56 -08:00
benedikt-bartscher
95287e7a98
fix type of value2 (#2708) 2024-02-24 13:56:48 -08:00
benedikt-bartscher
93f402c773
Initial values for computed vars (#2670)
* initial values for computed vars draft

* add tests, add computed_var overloads

* fix darglint

* pass initial to substates when calling dict

* add tests for for child states

* format black

* allow None as initial value

* rename runtime_only to raises_at_runtime

* cleanup unused arguments of ComputedVars

* refactor cached_var to be partial of computed_var
2024-02-24 13:45:07 -08:00
Masen Furer
953495775d
[REF-2045] Implement __reduce_ex__ for MutableProxy (#2688)
* test_state: augment modify_state test for writing MutableProxy

If the object contains a MutableProxy inside of it, then we get a pickling
error.

* Implement __reduce_ex__ for MutableProxy

Pass through `__reduce_ex__` onto the wrapped instance to strip it off when
cloudpickling to redis.

* base: get_value actually works with a str key

Unless the key isn't a field on the model, then it falls back to the previous
behavior of just returning the given key as is... why does it do this? I don't
know.
2024-02-22 10:14:14 -08:00
Masen Furer
756bf9b0f4
[REF-1885] Shard Substates when serializing to Redis (#2574)
* Move sharding internal to StateManager

Avoid leaking sharding implementation details all over the State class and
breaking the API

* WiP StateManager based sharding

* Copy the state __dict__ when serializing to avoid breaking the instance

* State tests need to pass the correct substate token for redis

* state: when getting parent_state, set top_level=False

ensure that we don't end up with a broken tree

* test_app: get tests passing with redis by passing the correct token

refactor upload tests to suck less

* test_client_storage: look up substate key

* state.py: pass static checks

* test_dynamic_routes: working with redis state shard

* Update the remaining AppHarness tests to pass {token}_{state.get_full_name()}

* test_app: pass all tokens with state suffix

* StateManagerRedis: clean up commentary
2024-02-21 01:50:25 -08:00
wassaf shahzad
0b771db10a
fixed bug in var type for iterable types (#2617)
* fixed bug in var type for iterable types

* added test cases

* formatting issue

* fixed black formatting  issues
2024-02-20 15:02:20 -08:00
Masen Furer
3350fa0388
Component: translate underscore suffix for props supported by chakra (#2636)
* Component: translate underscore suffix for props supported by chakra

type_ becomes type
min_ becomes min
max_ becomes max
id_ becomes id

The deprecation warning is only displayed when the underscore suffix prop is
passed and the non-underscore suffix prop is defined on the given component.

* Rename type_ to type in accordion and scroll_area

All of the new radix components avoid the underscore suffix names where
possible.

* Update deprecation warning wording

* Refactor for readability

* Do not raise deprecation warning for `id_`

id is kind of a special prop because it exists on all components

* Add test case for deprecating underscore suffix props
2024-02-15 20:46:06 -08:00
Nikhil Rao
7240f8ee6f
Handle component namespaces in global styles (#2630) 2024-02-15 16:03:10 -08:00
Masen Furer
f12746d859
Inherit _rename_props from parent classes (#2613)
Ensure that _rename_props from base classes add to the list of _rename_props in subclasses.

Add a test case to validate this behavior.
2024-02-14 14:36:01 -08:00
invrainbow
e729a315f8
Fix fstrings being escaped improperly (#2571) 2024-02-13 14:32:44 -08:00
Elijah Ahianyo
5e9b472d1b
[REF-1919] Valid Children/parents to allow Foreach,Cond,Match and Fragment (#2591) 2024-02-13 14:22:22 -08:00
Masen Furer
4206afeb7b
[REF-1958] Remove shadowed radix css props (#2590)
* style: shorthand replacements need camelCase

Avoid warning on terminal and in browser console from using kebab-case CSS
props with emotion.

* _rename_props only replace prop name once

In case the value also contains the prop name, we don't want to replace it
multiple times.

* pyi_generator: ignore _rename_props in create signature

* Avoid shadowing CSS prop `display` and `gap`

Replace usages of `gap` with `spacing` to retain Radix sizing number system,
while allowing users to specify a responsive `gap` using CSS units.

Remove `display` props from radix components, allowing `display` to accept
responsive lists.

* checkbox: apply `gap` to `flex` if provided

* Remove _rename_props from .create signatures

* Fix spacing prop in blank template

* Fixup tests after changing style shorthand to return camelCase
2024-02-13 10:06:28 -08:00
invrainbow
61234ae164
Fix operator precedence (#2573) 2024-02-12 19:30:25 -08:00
Masen Furer
58b5e2f5bd
Merge remote-tracking branch 'origin/main' into reflex-0.4.0 2024-02-09 19:38:35 -08:00
Elijah Ahianyo
ccc9c32c95
Get rx.color working with fstrings (#2562)
* fix for rx.color working with fstrings

* Fix fstrings issues
2024-02-09 17:06:55 -08:00
Masen Furer
78c54b3486
Use rx.el.img as rx.image (#2558)
* Use rx.el.img as rx.image

* Update test_image to work with plain rx.el.img
2024-02-08 14:44:53 -08:00
Masen Furer
d28109f4c4
Merge remote-tracking branch 'origin/main' into reflex-0.4.0 2024-02-08 11:54:02 -08:00
Elijah Ahianyo
601dd34792
rx.color to work with conditional vars (#2546) 2024-02-08 11:45:15 -08:00
Masen Furer
b607531318
Unbreak tests after recent changes in main (p2) 2024-02-08 10:46:40 -08:00
Masen Furer
c596651de6
Fix pre-commit issues introduced from merging origin/main 2024-02-08 10:28:45 -08:00
Masen Furer
c124650082
Merge remote-tracking branch 'origin/main' into reflex-0.4.0 2024-02-07 13:53:39 -08:00
Elijah Ahianyo
ce867d2f81
Support for Shorthand css props. (#2547) 2024-02-07 12:05:04 -08:00
Nikhil Rao
eacd534137
Increase debounce timeout to 300ms (#2541) 2024-02-07 11:55:43 -08:00
Nikhil Rao
e2c3081d1e
Remove focus-visible package (#2535) 2024-02-06 11:36:12 -08:00
Masen Furer
660113fcf9
Merge remote-tracking branch 'origin/main' into reflex-0.4.0 2024-02-05 11:41:40 -08:00
Masen Furer
f99c48806a
Top-level namespace tweaks (#2523)
* pyi_generator: always ignore files starting with `tests`

* Move CodeBlock out of chakra namespace

* Expose additional names in the top-level namespace

* code pyi fixup

* expose input and quote at the top-level

* add text_field to top-level namespace (maybe)

* fixup chakra code.pyi

* Remove `text_field` from top level namespace

* Remove top-level big C Cond

* fixup top level pyi
2024-02-05 11:14:02 -08:00
Alek Petuskey
5589cbbfc2
Refactor rx.color (#2522)
* Refactor

* Lint

* Change name space to top level

* Update test

* Lint

* Fix pyright

* Update pyi

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
2024-02-04 15:39:07 -08:00
Nikhil Rao
05d1be2182
Move core components to radix namespace (#2506) 2024-02-02 14:26:46 -08:00
Nikhil Rao
5176a7cb14
Support component create methods as keys in global styles (#2498) 2024-01-31 12:25:18 -08:00
jackie-pc
80c9eb34e4
Rework telemetry to support installation_id (#2480) 2024-01-31 11:39:48 -08:00
wassaf shahzad
84a2bb9671
Added Environmental variable REFLEX_DIR (#2457) 2024-01-30 18:18:29 -08:00
Elijah Ahianyo
d2fd0d3b92
[REF-1742] Radio group prop types fix (#2452) 2024-01-30 18:14:20 -08:00
Tianze
209c5fab7b
Tabs validate parent is proper tab container (#2463) 2024-01-30 11:45:00 -08:00
Masen Furer
bece5bdb44
[REF-1632] Apply rx.App styles to Radix Themes root div (#2481) 2024-01-29 16:58:05 -08:00
Nikhil Rao
01c2a1ed7d
Set correct type when indexing into Var[str] (#2469)
* Index into strings

* Write tests
2024-01-28 21:57:02 -08:00
Nikhil Rao
d68de02bc8
Revert "Individually Import Chakra Packages (#2405)" (#2472) 2024-01-28 15:39:59 -08:00
Alek Petuskey
670faf291a
[WIP] rx.color (#2443)
* Color module intial commit

* Improvments

* Update reflex/constants/colors.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* Comments+tests

* Fix import

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
2024-01-28 14:06:08 -08:00
wassaf shahzad
069892d8ee
fixed issue with hypens (#2450) 2024-01-26 14:14:46 -08:00
Alek Petuskey
00a8054850
Individually Import Chakra Packages (#2405)
* Base lib switch

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
2024-01-25 10:22:46 -08:00
Elijah Ahianyo
5f1751acc2
Vardata for rx.Match (#2439) 2024-01-24 14:55:49 -08:00
Yummy-Yums
82aca76cd3
test_telemetry fails for Python Version 3.11.0rc1 (#2431)
* initial commit

* ruff updated formatting
2024-01-24 12:30:22 -08:00
Masen Furer
9446a1e99f
[REF-1705] Do not overwrite Var attributes during format (#2421) 2024-01-19 15:17:00 -08:00
Alek Petuskey
d466c2aaa2
Radix Accordion (#2310) 2024-01-18 14:20:21 -08:00
jackie-pc
2c270585ab
Skip frontend packages install if previously done (#2400) 2024-01-16 17:52:28 -08:00
benedikt-bartscher
1aca1b677f
fix is_backend_variable for dunder prefixed variables (#2391) 2024-01-16 17:37:05 -08:00
Elijah Ahianyo
abfc099779
rx.match component (#2318)
* initial commit

* add more tests

* refactor match jinja template

* add docstrings

* cleanup

* possible fix for pyright

* fix conflicts

* fix conflicts again

* comments

* fixed bug from review

* fix tests

* address PR comment

* fix tests

* type error improvement

* formatting

* darglint fix

* more tests

* stringify switch condition and cases as js doesnt support complex types(lists and dicts) in switch cases.

* Update reflex/vars.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* change usages

* Precommit fix

---------

Co-authored-by: Alek Petuskey <alek@pynecone.io>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
2024-01-04 09:48:18 -08:00
Masen Furer
414a879879
Handle VarData roundtrip when encoded value contains newline (#2350) 2024-01-03 09:46:22 -08:00
Jishnu N
c5c42665eb
add: reflex init app name validator (#2336) 2023-12-28 00:07:55 -08:00
Masen Furer
0211e9a0e5
Avoid passing props to lists and list items (#2326) 2023-12-21 15:58:45 -08:00
Nikhil Rao
93c97383d9
Refactor chakra components into separate folder (#2315) 2023-12-21 09:52:08 -08:00
Nikhil Rao
cfb9d44e0c
Apply default theme to apps (#2320) 2023-12-20 15:17:49 -08:00
Nikhil Rao
5d21f0ca60
Add high-level API for accordion (#2285) 2023-12-18 17:21:49 -08:00
jackie-pc
7388617b72
apps should no longer call "app.compile()" (#2291) 2023-12-18 16:06:21 -08:00
Martin Xu
9da65b9a9a
[REF-1464] Handle requirements.txt encoding (#2284) 2023-12-14 14:25:40 -08:00
Elijah Ahianyo
9629b59617
DataFrame Serializer fix (#2281) 2023-12-12 14:03:40 -08:00
benedikt-bartscher
f90982ea06
use redis-py url syntax for redis_url (#2267)
* use redis-py url syntax for redis_url

* port is optional

* Add StateManagerRedis.close method

The close helper method always calls `close_connection_pool=True` so that all
outstanding redis operations can be stopped before changing event loops.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2023-12-12 10:54:10 -08:00
Masen Furer
e52267477c
[REF-1417] Convert underscore-prefixed style props to pseudo selector (#2266) 2023-12-11 13:37:57 -08:00
Thomas Brandého
caf32605ca
add next/image and next-video in next namespace (#2223) 2023-12-07 10:38:47 -08:00
Masen Furer
0bbae2d3d5
[REF-1404] router_data not updated when processing events (#2255) 2023-12-04 16:45:22 -08:00
Masen Furer
60147dec65
[REF-201] Separate on_load handler from initial hydration (#1847) 2023-11-30 12:21:15 -08:00
Elijah Ahianyo
e3ee98098a
RED-1052/rx.State as Base State (#2146) 2023-11-29 09:43:33 -08:00
Martin Xu
f8395b1fd6
Separate out the hosting CLI from main repo (#2165) 2023-11-28 15:20:06 -08:00
Masen Furer
3deb2cec93
code_block responds to color mode by default (#2228) 2023-11-28 13:24:38 -08:00
Masen Furer
0c55723df4
[REF-1158] Move chakra-only deps to chakra lib (#2171) 2023-11-28 00:04:07 -08:00
Masen Furer
ee87e62efa
[REF-1035] Track ComputedVar dependency per class (#2067) 2023-11-27 18:17:53 -08:00
Masen Furer
527437cf23
[REF-144] Add context in each component to prevent rerenders (#2198) 2023-11-27 16:05:59 -08:00
Thomas Brandého
8fc254041b
fix name for import var when is default and add tests (#2214) 2023-11-26 12:46:43 -08:00
Masen Furer
1603144c7d
[REF-889] useContext per substate (#2149) 2023-11-21 11:52:06 -08:00
Nikhil Rao
e9437ad941
Use singleton app provider to speed up compiles (#2172) 2023-11-20 18:11:24 -08:00
Elijah Ahianyo
714edb3cde
REF-1202: Upgrade bun version if it differs from reflex set version (#2206) 2023-11-20 15:21:17 -08:00
Elijah Ahianyo
7f810ece21
To camel case fix (#2205) 2023-11-20 11:33:48 -08:00
Nikhil Rao
c3e652b8c1
Speed up reflex CLI imports (#2185) 2023-11-17 12:31:07 -08:00
Thomas Brandého
1a83f85783
_valid_children and _invalid_children accessible from class (#2192) 2023-11-17 12:30:18 -08:00
Masen Furer
7eccc6d988
[REF-723+] Upload with progress and cancellation (#1899) 2023-11-16 15:46:13 -08:00
Martin Xu
adb26787c8
Hosting CLI: remove requirements generation when init, add back timeout for deploy command, remove deploy legacy command (#2179) 2023-11-15 16:23:34 -08:00
Masen Furer
f3929f47e3
form: only pass handleSubmit when on_submit is defined (#2162) 2023-11-13 23:27:42 -08:00
Nikhil Rao
33e4816950
Lazy import modules in reflex (#2144) 2023-11-13 19:48:12 -08:00
Elijah Ahianyo
ea22452b27
Reduce Syntax highlighter footprint (#2037) 2023-11-13 12:47:55 -08:00
Thomas Brandého
39cc1b2f12
Upgrade to NextJS 14 (#2142) 2023-11-13 09:52:51 -08:00
Elijah Ahianyo
7a04652a6a
Revert "Bun as runtime on Mac and Linux (#2138)" (#2153) 2023-11-09 13:01:48 -08:00
Elijah Ahianyo
4d6fa9b823
Bun as runtime on Mac and Linux (#2138) 2023-11-08 16:22:02 -08:00
Thomas Brandého
c835ad0737
fix to_snake_case and add tests (#2133) 2023-11-06 12:13:28 -08:00
Nikhil Rao
e703d87450
Set unique index vars in rx.foreach (#2126) 2023-11-03 16:20:42 -07:00
Martin Xu
4c97b4c4c0
Hosting CLI: use http endpoint to return deploy milestones (#2085) 2023-11-03 12:13:46 -07:00
Martin Xu
4a526620ac
[REF-1042] Hosting CLI: check the user selected app name (#2102) 2023-11-02 14:34:10 -07:00
SandeshPyakurel
5e2ce46ddb
Typos fixed in multiple files (#2090) 2023-10-31 13:43:25 -07:00
Masen Furer
56476d0a86
Expose DOM event actions on EventHandler, EventSpec, and EventChain (stopPropagation) (#1891)
* Expose preventDefault and stopPropagation for DOM events

All EventHandler, EventSpec, and EventChain can now carry these extra
"event_actions" that will be applied inside the frontend code when an event is
triggered from the DOM.

Fix #1621
Fix REF-675

* Test cases (and fixes) for "event_actions"

* form: from __future__ import annotations

for py38, py39 compat

* Revert overzealous merge conflict resolution
2023-10-31 11:42:42 -07:00
Martin Xu
e9cf822460
CLI will not set auto/stop setting for deployment (#2040)
* do not set autostart/autostop as default on CLI

* cli feedback

* fix test

* clean up last few messages

* catch general exception for export and exit
2023-10-26 17:47:22 -07:00
Alek Petuskey
70a6b5f2d3
Autogenerating Dependencies During Deployment (#2033) 2023-10-26 17:32:58 -07:00