diff --git a/.coveragerc b/.coveragerc index 9e66f2146..d505ff27e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -11,7 +11,7 @@ omit = [report] show_missing = true # TODO bump back to 79 -fail_under = 60 +fail_under = 70 precision = 2 # Regexes for lines to exclude from consideration diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b849dd328..0971c728b 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -81,19 +81,11 @@ jobs: matrix: # Show OS combos first in GUI os: [ubuntu-latest, windows-latest, macos-12] - python-version: ['3.8.18', '3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.10.13', '3.11.5', '3.12.0'] exclude: - os: windows-latest python-version: '3.10.13' - - os: windows-latest - python-version: '3.9.18' - - os: windows-latest - python-version: '3.8.18' # keep only one python version for MacOS - - os: macos-latest - python-version: '3.8.18' - - os: macos-latest - python-version: '3.9.18' - os: macos-latest python-version: '3.10.13' - os: macos-12 @@ -101,11 +93,7 @@ jobs: include: - os: windows-latest python-version: '3.10.11' - - os: windows-latest - python-version: '3.9.13' - - os: windows-latest - python-version: '3.8.10' - + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/integration_app_harness.yml b/.github/workflows/integration_app_harness.yml index e92fdb6d0..93412aa71 100644 --- a/.github/workflows/integration_app_harness.yml +++ b/.github/workflows/integration_app_harness.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: state_manager: ['redis', 'memory'] - python-version: ['3.8.18', '3.11.5', '3.12.0'] + python-version: ['3.11.5', '3.12.0'] runs-on: ubuntu-latest services: # Label used to access the service container diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 58f7a668a..289a7b2f1 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -43,21 +43,14 @@ jobs: matrix: # Show OS combos first in GUI os: [ubuntu-latest, windows-latest, macos-12] - python-version: ['3.8.18', '3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.10.13', '3.11.5', '3.12.0'] exclude: - os: windows-latest python-version: '3.10.13' - - os: windows-latest - python-version: '3.9.18' - - os: windows-latest - python-version: '3.8.18' include: - os: windows-latest python-version: '3.10.11' - - os: windows-latest - python-version: '3.9.13' - - os: windows-latest - python-version: '3.8.10' + runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/integration_tests_wsl.yml b/.github/workflows/integration_tests_wsl.yml index 6750fcd46..ea62268b1 100644 --- a/.github/workflows/integration_tests_wsl.yml +++ b/.github/workflows/integration_tests_wsl.yml @@ -37,13 +37,15 @@ jobs: path: reflex-examples - uses: Vampire/setup-wsl@v3 + with: + distribution: Ubuntu-24.04 - name: Install Python shell: wsl-bash {0} run: | apt update apt install -y python3 python3-pip curl dos2unix zip unzip - + - name: Install Poetry shell: wsl-bash {0} run: | diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f49a9b279..f15434193 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -28,22 +28,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-12] - python-version: ['3.8.18', '3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.10.13', '3.11.5', '3.12.0'] # Windows is a bit behind on Python version availability in Github exclude: - os: windows-latest python-version: '3.10.13' - - os: windows-latest - python-version: '3.9.18' - - os: windows-latest - python-version: '3.8.18' include: - os: windows-latest python-version: '3.10.11' - - os: windows-latest - python-version: '3.9.13' - - os: windows-latest - python-version: '3.8.10' runs-on: ${{ matrix.os }} # Service containers to run with `runner-job` services: diff --git a/.gitignore b/.gitignore index bbaa8f0c9..0f7d9e5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ assets/external/* dist/* examples/ +.web .idea .vscode .coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e57c0a249..6db8e1a04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ Here is a quick guide on how to run Reflex repo locally so you can start contrib **Prerequisites:** -- Python >= 3.8 +- Python >= 3.10 - Poetry version >= 1.4.0 and add it to your path (see [Poetry Docs](https://python-poetry.org/docs/#installation) for more info). **1. Fork this repository:** diff --git a/README.md b/README.md index 2c5b14087..d3f22bb54 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ ### **✨ Performant, customizable web apps in pure Python. Deploy in seconds. ✨** [![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex) -![tests](https://github.com/pynecone-io/pynecone/actions/workflows/integration.yml/badge.svg) ![versions](https://img.shields.io/pypi/pyversions/reflex.svg) [![Documentation](https://img.shields.io/badge/Documentation%20-Introduction%20-%20%23007ec6)](https://reflex.dev/docs/getting-started/introduction) [![Discord](https://img.shields.io/discord/1029853095527727165?color=%237289da&label=Discord)](https://discord.gg/T5WSbC2YtQ) @@ -35,7 +34,7 @@ See our [architecture page](https://reflex.dev/blog/2024-03-21-reflex-architectu ## ⚙️ Installation -Open a terminal and run (Requires Python 3.8+): +Open a terminal and run (Requires Python 3.10+): ```bash pip install reflex diff --git a/benchmarks/test_benchmark_compile_pages.py b/benchmarks/test_benchmark_compile_pages.py index 33404bca7..4448bca45 100644 --- a/benchmarks/test_benchmark_compile_pages.py +++ b/benchmarks/test_benchmark_compile_pages.py @@ -130,7 +130,6 @@ def render_multiple_pages(app, num: int): def AppWithOnePage(): """A reflex app with one page.""" - import reflex_chakra as rc from rxconfig import config # type: ignore import reflex as rx @@ -145,7 +144,7 @@ def AppWithOnePage(): def index() -> rx.Component: return rx.center( - rc.input( + rx.input( id="token", value=State.router.session.client_token, is_read_only=True ), rx.vstack( diff --git a/docker-example/README.md b/docker-example/README.md index 8ac32421d..552dba950 100644 --- a/docker-example/README.md +++ b/docker-example/README.md @@ -1,133 +1,30 @@ -# Reflex Docker Container +# Reflex Docker Examples -This example describes how to create and use a container image for Reflex with your own code. +This directory contains several examples of how to deploy Reflex apps using docker. -## Update Requirements +In all cases, ensure that your `requirements.txt` file is up to date and +includes the `reflex` package. -The `requirements.txt` includes the reflex package which is needed to install -Reflex framework. If you use additional packages in your project you have to add -this in the `requirements.txt` first. Copy the `Dockerfile`, `.dockerignore` and -the `requirements.txt` file in your project folder. +## `simple-two-port` -## Build Simple Reflex Container Image +The most basic production deployment exposes two HTTP ports and relies on an +existing load balancer to forward the traffic appropriately. -The main `Dockerfile` is intended to build a very simple, single container deployment that runs -the Reflex frontend and backend together, exposing ports 3000 and 8000. +## `simple-one-port` -To build your container image run the following command: +This deployment exports the frontend statically and serves it via a single HTTP +port using Caddy. This is useful for platforms that only support a single port +or where running a node server in the container is undesirable. -```bash -docker build -t reflex-app:latest . -``` +## `production-compose` -## Start Container Service +This deployment is intended for use with a standalone VPS that is only hosting a +single Reflex app. It provides the entire stack in a single `compose.yaml` +including a webserver, one or more backend instances, redis, and a postgres +database. -Finally, you can start your Reflex container service as follows: +## `production-app-platform` -```bash -docker run -it --rm -p 3000:3000 -p 8000:8000 --name app reflex-app:latest -``` - -It may take a few seconds for the service to become available. - -Access your app at http://localhost:3000. - -Note that this container has _no persistence_ and will lose all data when -stopped. You can use bind mounts or named volumes to persist the database and -uploaded_files directories as needed. - -# Production Service with Docker Compose and Caddy - -An example production deployment uses automatic TLS with Caddy serving static files -for the frontend and proxying requests to both the frontend and backend. - -Copy the following files to your project directory: - * `compose.yaml` - * `compose.prod.yaml` - * `compose.tools.yaml` - * `prod.Dockerfile` - * `Caddy.Dockerfile` - * `Caddyfile` - -The production app container, based on `prod.Dockerfile`, builds and exports the -frontend statically (to be served by Caddy). The resulting image only runs the -backend service. - -The `webserver` service, based on `Caddy.Dockerfile`, copies the static frontend -and `Caddyfile` into the container to configure the reverse proxy routes that will -forward requests to the backend service. Caddy will automatically provision TLS -for localhost or the domain specified in the environment variable `DOMAIN`. - -This type of deployment should use less memory and be more performant since -nodejs is not required at runtime. - -## Customize `Caddyfile` (optional) - -If the app uses additional backend API routes, those should be added to the -`@backend_routes` path matcher to ensure they are forwarded to the backend. - -## Build Reflex Production Service - -During build, set `DOMAIN` environment variable to the domain where the app will -be hosted! (Do not include http or https, it will always use https). - -**If `DOMAIN` is not provided, the service will default to `localhost`.** - -```bash -DOMAIN=example.com docker compose build -``` - -This will build both the `app` service from the `prod.Dockerfile` and the `webserver` -service via `Caddy.Dockerfile`. - -## Run Reflex Production Service - -```bash -DOMAIN=example.com docker compose up -``` - -The app should be available at the specified domain via HTTPS. Certificate -provisioning will occur automatically and may take a few minutes. - -### Data Persistence - -Named docker volumes are used to persist the app database (`db-data`), -uploaded_files (`upload-data`), and caddy TLS keys and certificates -(`caddy-data`). - -## More Robust Deployment - -For a more robust deployment, consider bringing the service up with -`compose.prod.yaml` which includes postgres database and redis cache, allowing -the backend to run with multiple workers and service more requests. - -```bash -DOMAIN=example.com docker compose -f compose.yaml -f compose.prod.yaml up -d -``` - -Postgres uses its own named docker volume for data persistence. - -## Admin Tools - -When needed, the services in `compose.tools.yaml` can be brought up, providing -graphical database administration (Adminer on http://localhost:8080) and a -redis cache browser (redis-commander on http://localhost:8081). It is not recommended -to deploy these services if they are not in active use. - -```bash -DOMAIN=example.com docker compose -f compose.yaml -f compose.prod.yaml -f compose.tools.yaml up -d -``` - -# Container Hosting - -Most container hosting services automatically terminate TLS and expect the app -to be listening on a single port (typically `$PORT`). - -To host a Reflex app on one of these platforms, like Google Cloud Run, Render, -Railway, etc, use `app.Dockerfile` to build a single image containing a reverse -proxy that will serve that frontend as static files and proxy requests to the -backend for specific endpoints. - -If the chosen platform does not support buildx and thus heredoc, you can copy -the Caddyfile configuration into a separate Caddyfile in the root of the -project. +This example deployment is intended for use with App hosting platforms, like +Azure, AWS, or Google Cloud Run. It is the backend of the deployment, which +depends on a separately hosted redis instance and static frontend deployment. \ No newline at end of file diff --git a/docker-example/production-app-platform/.dockerignore b/docker-example/production-app-platform/.dockerignore new file mode 100644 index 000000000..ea66a51f5 --- /dev/null +++ b/docker-example/production-app-platform/.dockerignore @@ -0,0 +1,5 @@ +.web +.git +__pycache__/* +Dockerfile +uploaded_files diff --git a/docker-example/production-app-platform/Dockerfile b/docker-example/production-app-platform/Dockerfile new file mode 100644 index 000000000..b0f6c69fc --- /dev/null +++ b/docker-example/production-app-platform/Dockerfile @@ -0,0 +1,65 @@ +# This docker file is intended to be used with container hosting services +# +# After deploying this image, get the URL pointing to the backend service +# and run API_URL=https://path-to-my-container.example.com reflex export frontend +# then copy the contents of `frontend.zip` to your static file server (github pages, s3, etc). +# +# Azure Static Web App example: +# npx @azure/static-web-apps-cli deploy --env production --app-location .web/_static +# +# For dynamic routes to function properly, ensure that 404s are redirected to /404 on the +# static file host (for github pages, this works out of the box; remember to create .nojekyll). +# +# For azure static web apps, add `staticwebapp.config.json` to to `.web/_static` with the following: +# { +# "responseOverrides": { +# "404": { +# "rewrite": "/404.html" +# } +# } +# } +# +# Note: many container hosting platforms require amd64 images, so when building on an M1 Mac +# for example, pass `docker build --platform=linux/amd64 ...` + +# Stage 1: init +FROM python:3.11 as init + +ARG uv=/root/.cargo/bin/uv + +# Install `uv` for faster package boostrapping +ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh +RUN /install.sh && rm /install.sh + +# Copy local context to `/app` inside container (see .dockerignore) +WORKDIR /app +COPY . . +RUN mkdir -p /app/data /app/uploaded_files + +# Create virtualenv which will be copied into final container +ENV VIRTUAL_ENV=/app/.venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" +RUN $uv venv + +# Install app requirements and reflex inside virtualenv +RUN $uv pip install -r requirements.txt + +# Deploy templates and prepare app +RUN reflex init + +# Stage 2: copy artifacts into slim image +FROM python:3.11-slim +WORKDIR /app +RUN adduser --disabled-password --home /app reflex +COPY --chown=reflex --from=init /app /app +# Install libpq-dev for psycopg2 (skip if not using postgres). +RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* +USER reflex +ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 + +# Needed until Reflex properly passes SIGTERM on backend. +STOPSIGNAL SIGKILL + +# Always apply migrations before starting the backend. +CMD [ -d alembic ] && reflex db migrate; \ + exec reflex run --env prod --backend-only --backend-port ${PORT:-8000} diff --git a/docker-example/production-app-platform/README.md b/docker-example/production-app-platform/README.md new file mode 100644 index 000000000..ad54f814f --- /dev/null +++ b/docker-example/production-app-platform/README.md @@ -0,0 +1,113 @@ +# production-app-platform + +This example deployment is intended for use with App hosting platforms, like +Azure, AWS, or Google Cloud Run. + +## Architecture + +The production deployment consists of a few pieces: + * Backend container - built by `Dockerfile` Runs the Reflex backend + service on port 8000 and is scalable to multiple instances. + * Redis container - A single instance the standard `redis` docker image should + share private networking with the backend + * Static frontend - HTML/CSS/JS files that are hosted via a CDN or static file + server. This is not included in the docker image. + +## Deployment + +These general steps do not cover the specifics of each platform, but all platforms should +support the concepts described here. + +### Vnet + +All containers in the deployment should be hooked up to the same virtual private +network so they can access the redis service and optionally the database server. +The vnet should not be exposed to the internet, use an ingress rule to terminate +TLS at the load balancer and forward the traffic to a backend service replica. + +### Redis + +Deploy a `redis` instance on the vnet. + +### Backend + +The backend is built by the `Dockerfile` in this directory. When deploying the +backend, be sure to set REDIS_URL=redis://internal-redis-hostname to connect to +the redis service. + +### Ingress + +Configure the load balancer for the app to forward traffic to port 8000 on the +backend service replicas. Most platforms will generate an ingress hostname +automatically. Make sure when you access the ingress endpoint on `/ping` that it +returns "pong", indicating that the backend is up an available. + +### Frontend + +The frontend should be hosted on a static file server or CDN. + +**Important**: when exporting the frontend, set the API_URL environment variable +to the ingress hostname of the backend service. + +If you will host the frontend from a path other than the root, set the +`FRONTEND_PATH` environment variable appropriately when exporting the frontend. + +Most static hosts will automatically use the `/404.html` file to handle 404 +errors. _This is essential for dynamic routes to work correctly._ Ensure that +missing routes return the `/404.html` content to the user if this is not the +default behavior. + +_For Github Pages_: ensure the file `.nojekyll` is present in the root of the repo +to avoid special processing of underscore-prefix directories, like `_next`. + +## Platform Notes + +The following sections are currently a work in progress and may be incomplete. + +### Azure + +In the Azure load balancer, per-message deflate is not supported. Add the following +to your `rxconfig.py` to workaround this issue. + +```python +import uvicorn.workers + +import reflex as rx + + +class NoWSPerMessageDeflate(uvicorn.workers.UvicornH11Worker): + CONFIG_KWARGS = { + **uvicorn.workers.UvicornH11Worker.CONFIG_KWARGS, + "ws_per_message_deflate": False, + } + + +config = rx.Config( + app_name="my_app", + gunicorn_worker_class="rxconfig.NoWSPerMessageDeflate", +) +``` + +#### Persistent Storage + +If you need to use a database or upload files, you cannot save them to the +container volume. Use Azure Files and mount it into the container at /app/uploaded_files. + +#### Resource Types + +* Create a new vnet with 10.0.0.0/16 + * Create a new subnet for redis, database, and containers +* Deploy redis as a Container Instances +* Deploy database server as "Azure Database for PostgreSQL" + * Create a new database for the app + * Set db-url as a secret containing the db user/password connection string +* Deploy Storage account for uploaded files + * Enable access from the vnet and container subnet + * Create a new file share + * In the environment, create a new files share (get the storage key) +* Deploy the backend as a Container App + * Create a custom Container App Environment linked up to the same vnet as the redis container. + * Set REDIS_URL and DB_URL environment variables + * Add the volume from the environment + * Add the volume mount to the container +* Deploy the frontend as a Static Web App \ No newline at end of file diff --git a/docker-example/.dockerignore b/docker-example/production-compose/.dockerignore similarity index 100% rename from docker-example/.dockerignore rename to docker-example/production-compose/.dockerignore diff --git a/docker-example/Caddy.Dockerfile b/docker-example/production-compose/Caddy.Dockerfile similarity index 100% rename from docker-example/Caddy.Dockerfile rename to docker-example/production-compose/Caddy.Dockerfile diff --git a/docker-example/Caddyfile b/docker-example/production-compose/Caddyfile similarity index 100% rename from docker-example/Caddyfile rename to docker-example/production-compose/Caddyfile diff --git a/docker-example/prod.Dockerfile b/docker-example/production-compose/Dockerfile similarity index 91% rename from docker-example/prod.Dockerfile rename to docker-example/production-compose/Dockerfile index 2cde12ca0..f73473df7 100644 --- a/docker-example/prod.Dockerfile +++ b/docker-example/production-compose/Dockerfile @@ -42,10 +42,11 @@ COPY --chown=reflex --from=init /app /app # Install libpq-dev for psycopg2 (skip if not using postgres). RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* USER reflex -ENV PATH="/app/.venv/bin:$PATH" +ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 # Needed until Reflex properly passes SIGTERM on backend. STOPSIGNAL SIGKILL # Always apply migrations before starting the backend. -CMD reflex db migrate && reflex run --env prod --backend-only +CMD [ -d alembic ] && reflex db migrate; \ + exec reflex run --env prod --backend-only diff --git a/docker-example/production-compose/README.md b/docker-example/production-compose/README.md new file mode 100644 index 000000000..87222327e --- /dev/null +++ b/docker-example/production-compose/README.md @@ -0,0 +1,75 @@ +# production-compose + +This example production deployment uses automatic TLS with Caddy serving static +files for the frontend and proxying requests to both the frontend and backend. +It is intended for use with a standalone VPS that is only hosting a single +Reflex app. + +The production app container (`Dockerfile`), builds and exports the frontend +statically (to be served by Caddy). The resulting image only runs the backend +service. + +The `webserver` service, based on `Caddy.Dockerfile`, copies the static frontend +and `Caddyfile` into the container to configure the reverse proxy routes that will +forward requests to the backend service. Caddy will automatically provision TLS +for localhost or the domain specified in the environment variable `DOMAIN`. + +This type of deployment should use less memory and be more performant since +nodejs is not required at runtime. + +## Customize `Caddyfile` (optional) + +If the app uses additional backend API routes, those should be added to the +`@backend_routes` path matcher to ensure they are forwarded to the backend. + +## Build Reflex Production Service + +During build, set `DOMAIN` environment variable to the domain where the app will +be hosted! (Do not include http or https, it will always use https). + +**If `DOMAIN` is not provided, the service will default to `localhost`.** + +```bash +DOMAIN=example.com docker compose build +``` + +This will build both the `app` service from the `prod.Dockerfile` and the `webserver` +service via `Caddy.Dockerfile`. + +## Run Reflex Production Service + +```bash +DOMAIN=example.com docker compose up +``` + +The app should be available at the specified domain via HTTPS. Certificate +provisioning will occur automatically and may take a few minutes. + +### Data Persistence + +Named docker volumes are used to persist the app database (`db-data`), +uploaded_files (`upload-data`), and caddy TLS keys and certificates +(`caddy-data`). + +## More Robust Deployment + +For a more robust deployment, consider bringing the service up with +`compose.prod.yaml` which includes postgres database and redis cache, allowing +the backend to run with multiple workers and service more requests. + +```bash +DOMAIN=example.com docker compose -f compose.yaml -f compose.prod.yaml up -d +``` + +Postgres uses its own named docker volume for data persistence. + +## Admin Tools + +When needed, the services in `compose.tools.yaml` can be brought up, providing +graphical database administration (Adminer on http://localhost:8080) and a +redis cache browser (redis-commander on http://localhost:8081). It is not recommended +to deploy these services if they are not in active use. + +```bash +DOMAIN=example.com docker compose -f compose.yaml -f compose.prod.yaml -f compose.tools.yaml up -d +``` \ No newline at end of file diff --git a/docker-example/compose.prod.yaml b/docker-example/production-compose/compose.prod.yaml similarity index 100% rename from docker-example/compose.prod.yaml rename to docker-example/production-compose/compose.prod.yaml diff --git a/docker-example/compose.tools.yaml b/docker-example/production-compose/compose.tools.yaml similarity index 100% rename from docker-example/compose.tools.yaml rename to docker-example/production-compose/compose.tools.yaml diff --git a/docker-example/compose.yaml b/docker-example/production-compose/compose.yaml similarity index 96% rename from docker-example/compose.yaml rename to docker-example/production-compose/compose.yaml index 8c2f97ba6..de79c0778 100644 --- a/docker-example/compose.yaml +++ b/docker-example/production-compose/compose.yaml @@ -12,7 +12,6 @@ services: DB_URL: sqlite:///data/reflex.db build: context: . - dockerfile: prod.Dockerfile volumes: - db-data:/app/data - upload-data:/app/uploaded_files diff --git a/docker-example/requirements.txt b/docker-example/requirements.txt deleted file mode 100644 index fc29504eb..000000000 --- a/docker-example/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -reflex diff --git a/docker-example/simple-one-port/.dockerignore b/docker-example/simple-one-port/.dockerignore new file mode 100644 index 000000000..ea66a51f5 --- /dev/null +++ b/docker-example/simple-one-port/.dockerignore @@ -0,0 +1,5 @@ +.web +.git +__pycache__/* +Dockerfile +uploaded_files diff --git a/docker-example/simple-one-port/Caddyfile b/docker-example/simple-one-port/Caddyfile new file mode 100644 index 000000000..13d94ce8e --- /dev/null +++ b/docker-example/simple-one-port/Caddyfile @@ -0,0 +1,14 @@ +:{$PORT} + +encode gzip + +@backend_routes path /_event/* /ping /_upload /_upload/* +handle @backend_routes { + reverse_proxy localhost:8000 +} + +root * /srv +route { + try_files {path} {path}/ /404.html + file_server +} \ No newline at end of file diff --git a/docker-example/app.Dockerfile b/docker-example/simple-one-port/Dockerfile similarity index 67% rename from docker-example/app.Dockerfile rename to docker-example/simple-one-port/Dockerfile index 4aae2f31d..4cd7e9a18 100644 --- a/docker-example/app.Dockerfile +++ b/docker-example/simple-one-port/Dockerfile @@ -10,31 +10,13 @@ FROM python:3.11 ARG PORT=8080 # Only set for local/direct access. When TLS is used, the API_URL is assumed to be the same as the frontend. ARG API_URL -ENV PORT=$PORT API_URL=${API_URL:-http://localhost:$PORT} +ENV PORT=$PORT API_URL=${API_URL:-http://localhost:$PORT} REDIS_URL=redis://localhost PYTHONUNBUFFERED=1 -# Install Caddy server inside image -RUN apt-get update -y && apt-get install -y caddy && rm -rf /var/lib/apt/lists/* +# Install Caddy and redis server inside image +RUN apt-get update -y && apt-get install -y caddy redis-server && rm -rf /var/lib/apt/lists/* WORKDIR /app -# Create a simple Caddyfile to serve as reverse proxy -RUN cat > Caddyfile < rx.Component: return rx.vstack( - rc.input( + rx.input( id="token", value=State.router.session.client_token, is_read_only=True ), rx.heading(State.counter, id="counter"), - rc.input( + rx.input( id="iterations", placeholder="Iterations", value=State.iterations.to_string(), # type: ignore @@ -155,6 +161,11 @@ def BackgroundTask(): on_click=OtherState.get_other_state, id="increment-from-other-state", ), + rx.button( + "Yield in Async with Self", + on_click=State.yield_in_async_with_self, + id="yield-in-async-with-self", + ), rx.button("Reset", on_click=State.reset_counter, id="reset"), ) @@ -334,3 +345,30 @@ def test_get_state( increment_button.click() assert background_task._poll_for(lambda: counter.text == "13", timeout=5) + + +def test_yield_in_async_with_self( + background_task: AppHarness, + driver: WebDriver, + token: str, +): + """Test that yielding inside async with self does not disable mutability. + + Args: + background_task: harness for BackgroundTask app. + driver: WebDriver instance. + token: The token for the connected client. + """ + assert background_task.app_instance is not None + + # get a reference to all buttons + yield_in_async_with_self_button = driver.find_element( + By.ID, "yield-in-async-with-self" + ) + + # get a reference to the counter + counter = driver.find_element(By.ID, "counter") + assert background_task._poll_for(lambda: counter.text == "0", timeout=5) + + yield_in_async_with_self_button.click() + assert background_task._poll_for(lambda: counter.text == "2", timeout=5) diff --git a/integration/test_client_storage.py b/integration/test_client_storage.py index e88d2fa14..e4a38a15b 100644 --- a/integration/test_client_storage.py +++ b/integration/test_client_storage.py @@ -17,8 +17,6 @@ from . import utils def ClientSide(): """App for testing client-side state.""" - import reflex_chakra as rc - import reflex as rx class ClientSideState(rx.State): @@ -72,18 +70,18 @@ def ClientSide(): def index(): return rx.fragment( - rc.input( + rx.input( value=ClientSideState.router.session.client_token, is_read_only=True, id="token", ), - rc.input( + rx.input( placeholder="state var", value=ClientSideState.state_var, on_change=ClientSideState.set_state_var, # type: ignore id="state_var", ), - rc.input( + rx.input( placeholder="input value", value=ClientSideState.input_value, on_change=ClientSideState.set_input_value, # type: ignore @@ -313,7 +311,6 @@ async def test_client_side_state( # no cookies should be set yet! assert not driver.get_cookies() local_storage_items = local_storage.items() - local_storage_items.pop("chakra-ui-color-mode", None) local_storage_items.pop("last_compiled_time", None) assert not local_storage_items @@ -429,7 +426,6 @@ async def test_client_side_state( assert f"{sub_state_name}.c3" not in cookie_info_map(driver) local_storage_items = local_storage.items() - local_storage_items.pop("chakra-ui-color-mode", None) local_storage_items.pop("last_compiled_time", None) assert local_storage_items.pop(f"{sub_state_name}.l1") == "l1 value" assert local_storage_items.pop(f"{sub_state_name}.l2") == "l2 value" diff --git a/integration/test_dynamic_routes.py b/integration/test_dynamic_routes.py index 0ce4ef2c9..5ba0b7bda 100644 --- a/integration/test_dynamic_routes.py +++ b/integration/test_dynamic_routes.py @@ -17,13 +17,10 @@ def DynamicRoute(): """App for testing dynamic routes.""" from typing import List - import reflex_chakra as rc - import reflex as rx class DynamicState(rx.State): order: List[str] = [] - page_id: str = "" def on_load(self): self.order.append(f"{self.router.page.path}-{self.page_id or 'no page id'}") @@ -42,13 +39,13 @@ def DynamicRoute(): def index(): return rx.fragment( - rc.input( + rx.input( value=DynamicState.router.session.client_token, is_read_only=True, id="token", ), - rc.input(value=DynamicState.page_id, is_read_only=True, id="page_id"), - rc.input( + rx.input(value=rx.State.page_id, is_read_only=True, id="page_id"), # type: ignore + rx.input( value=DynamicState.router.page.raw_path, is_read_only=True, id="raw_path", @@ -61,22 +58,80 @@ def DynamicRoute(): id="link_page_next", # type: ignore ), rx.link("missing", href="/missing", id="link_missing"), - rc.list( + rx.list( # type: ignore rx.foreach( DynamicState.order, # type: ignore - lambda i: rc.list_item(rx.text(i)), + lambda i: rx.list_item(rx.text(i)), ), ), ) + class ArgState(rx.State): + """The app state.""" + + @rx.var + def arg(self) -> int: + return int(self.arg_str or 0) + + class ArgSubState(ArgState): + @rx.var(cache=True) + def cached_arg(self) -> int: + return self.arg + + @rx.var(cache=True) + def cached_arg_str(self) -> str: + return self.arg_str + + @rx.page(route="/arg/[arg_str]") + def arg() -> rx.Component: + return rx.vstack( + rx.data_list.root( + rx.data_list.item( + rx.data_list.label("rx.State.arg_str (dynamic)"), + rx.data_list.value(rx.State.arg_str, id="state-arg_str"), # type: ignore + ), + rx.data_list.item( + rx.data_list.label("ArgState.arg_str (dynamic) (inherited)"), + rx.data_list.value(ArgState.arg_str, id="argstate-arg_str"), # type: ignore + ), + rx.data_list.item( + rx.data_list.label("ArgState.arg"), + rx.data_list.value(ArgState.arg, id="argstate-arg"), + ), + rx.data_list.item( + rx.data_list.label("ArgSubState.arg_str (dynamic) (inherited)"), + rx.data_list.value(ArgSubState.arg_str, id="argsubstate-arg_str"), # type: ignore + ), + rx.data_list.item( + rx.data_list.label("ArgSubState.arg (inherited)"), + rx.data_list.value(ArgSubState.arg, id="argsubstate-arg"), + ), + rx.data_list.item( + rx.data_list.label("ArgSubState.cached_arg"), + rx.data_list.value( + ArgSubState.cached_arg, id="argsubstate-cached_arg" + ), + ), + rx.data_list.item( + rx.data_list.label("ArgSubState.cached_arg_str"), + rx.data_list.value( + ArgSubState.cached_arg_str, id="argsubstate-cached_arg_str" + ), + ), + ), + rx.link("+", href=f"/arg/{ArgState.arg + 1}", id="next-page"), + align="center", + height="100vh", + ) + @rx.page(route="/redirect-page/[page_id]", on_load=DynamicState.on_load_redir) # type: ignore def redirect_page(): return rx.fragment(rx.text("redirecting...")) app = rx.App(state=rx.State) - app.add_page(index) app.add_page(index, route="/page/[page_id]", on_load=DynamicState.on_load) # type: ignore app.add_page(index, route="/static/x", on_load=DynamicState.on_load) # type: ignore + app.add_page(index) app.add_custom_404_page(on_load=DynamicState.on_load) # type: ignore @@ -305,3 +360,50 @@ async def test_on_load_navigate_non_dynamic( link.click() assert urlsplit(driver.current_url).path == "/static/x/" await poll_for_order(["/static/x-no page id", "/static/x-no page id"]) + + +@pytest.mark.asyncio +async def test_render_dynamic_arg( + dynamic_route: AppHarness, + driver: WebDriver, +): + """Assert that dynamic arg var is rendered correctly in different contexts. + + Args: + dynamic_route: harness for DynamicRoute app. + driver: WebDriver instance. + """ + assert dynamic_route.app_instance is not None + with poll_for_navigation(driver): + driver.get(f"{dynamic_route.frontend_url}/arg/0") + + def assert_content(expected: str, expect_not: str): + ids = [ + "state-arg_str", + "argstate-arg", + "argstate-arg_str", + "argsubstate-arg_str", + "argsubstate-arg", + "argsubstate-cached_arg", + "argsubstate-cached_arg_str", + ] + for id in ids: + el = driver.find_element(By.ID, id) + assert el + assert ( + dynamic_route.poll_for_content(el, exp_not_equal=expect_not) == expected + ) + + assert_content("0", "") + next_page_link = driver.find_element(By.ID, "next-page") + assert next_page_link + with poll_for_navigation(driver): + next_page_link.click() + assert driver.current_url == f"{dynamic_route.frontend_url}/arg/1/" + assert_content("1", "0") + next_page_link = driver.find_element(By.ID, "next-page") + assert next_page_link + with poll_for_navigation(driver): + next_page_link.click() + assert driver.current_url == f"{dynamic_route.frontend_url}/arg/2/" + assert_content("2", "1") diff --git a/integration/test_event_actions.py b/integration/test_event_actions.py index 5845d80f1..499478a1c 100644 --- a/integration/test_event_actions.py +++ b/integration/test_event_actions.py @@ -16,8 +16,6 @@ def TestEventAction(): """App for testing event_actions.""" from typing import List, Optional - import reflex_chakra as rc - import reflex as rx class EventActionState(rx.State): @@ -55,7 +53,7 @@ def TestEventAction(): def index(): return rx.vstack( - rc.input( + rx.input( value=EventActionState.router.session.client_token, is_read_only=True, id="token", @@ -148,10 +146,10 @@ def TestEventAction(): 200 ).stop_propagation, ), - rc.list( + rx.list( # type: ignore rx.foreach( EventActionState.order, # type: ignore - rc.list_item, + rx.list_item, ), ), on_click=EventActionState.on_click("outer"), # type: ignore diff --git a/integration/test_event_chain.py b/integration/test_event_chain.py index cdef575a1..740fc71a3 100644 --- a/integration/test_event_chain.py +++ b/integration/test_event_chain.py @@ -18,8 +18,6 @@ def EventChain(): import time from typing import List - import reflex_chakra as rc - import reflex as rx # repeated here since the outer global isn't exported into the App module @@ -129,7 +127,7 @@ def EventChain(): app = rx.App(state=rx.State) - token_input = rc.input( + token_input = rx.input( value=State.router.session.client_token, is_read_only=True, id="token" ) @@ -137,7 +135,7 @@ def EventChain(): def index(): return rx.fragment( token_input, - rc.input(value=State.interim_value, is_read_only=True, id="interim_value"), + rx.input(value=State.interim_value, is_read_only=True, id="interim_value"), rx.button( "Return Event", id="return_event", diff --git a/integration/test_form_submit.py b/integration/test_form_submit.py index acc6bca96..a020a7e15 100644 --- a/integration/test_form_submit.py +++ b/integration/test_form_submit.py @@ -20,8 +20,6 @@ def FormSubmit(form_component): """ from typing import Dict, List - import reflex_chakra as rc - import reflex as rx class FormState(rx.State): @@ -37,28 +35,29 @@ def FormSubmit(form_component): @app.add_page def index(): return rx.vstack( - rc.input( + rx.input( value=FormState.router.session.client_token, is_read_only=True, id="token", ), eval(form_component)( rx.vstack( - rc.input(id="name_input"), - rx.hstack(rc.pin_input(length=4, id="pin_input")), - rc.number_input(id="number_input"), + rx.input(id="name_input"), rx.checkbox(id="bool_input"), rx.switch(id="bool_input2"), rx.checkbox(id="bool_input3"), rx.switch(id="bool_input4"), rx.slider(id="slider_input", default_value=[50], width="100%"), - rc.range_slider(id="range_input"), rx.radio(["option1", "option2"], id="radio_input"), rx.radio(FormState.var_options, id="radio_input_var"), - rc.select(["option1", "option2"], id="select_input"), - rc.select(FormState.var_options, id="select_input_var"), + rx.select( + ["option1", "option2"], + name="select_input", + default_value="option1", + ), + rx.select(FormState.var_options, id="select_input_var"), rx.text_area(id="text_area_input"), - rc.input( + rx.input( id="debounce_input", debounce_timeout=0, on_change=rx.console_log, @@ -81,8 +80,6 @@ def FormSubmitName(form_component): """ from typing import Dict, List - import reflex_chakra as rc - import reflex as rx class FormState(rx.State): @@ -98,22 +95,19 @@ def FormSubmitName(form_component): @app.add_page def index(): return rx.vstack( - rc.input( + rx.input( value=FormState.router.session.client_token, is_read_only=True, id="token", ), eval(form_component)( rx.vstack( - rc.input(name="name_input"), - rx.hstack(rc.pin_input(length=4, name="pin_input")), - rc.number_input(name="number_input"), + rx.input(name="name_input"), rx.checkbox(name="bool_input"), rx.switch(name="bool_input2"), rx.checkbox(name="bool_input3"), rx.switch(name="bool_input4"), rx.slider(name="slider_input", default_value=[50], width="100%"), - rc.range_slider(name="range_input"), rx.radio(FormState.options, name="radio_input"), rx.select( FormState.options, @@ -121,21 +115,13 @@ def FormSubmitName(form_component): default_value=FormState.options[0], ), rx.text_area(name="text_area_input"), - rc.input_group( - rc.input_left_element(rx.icon(tag="chevron_right")), - rc.input( - name="debounce_input", - debounce_timeout=0, - on_change=rx.console_log, - ), - rc.input_right_element(rx.icon(tag="chevron_left")), - ), - rc.button_group( - rx.button("Submit", type_="submit"), - rx.icon_button(FormState.val, icon=rx.icon(tag="plus")), - variant="outline", - is_attached=True, + rx.input( + name="debounce_input", + debounce_timeout=0, + on_change=rx.console_log, ), + rx.button("Submit", type_="submit"), + rx.icon_button(FormState.val, icon=rx.icon(tag="plus")), ), on_submit=FormState.form_submit, custom_attrs={"action": "/invalid"}, @@ -152,16 +138,12 @@ def FormSubmitName(form_component): functools.partial(FormSubmitName, form_component="rx.form.root"), functools.partial(FormSubmit, form_component="rx.el.form"), functools.partial(FormSubmitName, form_component="rx.el.form"), - functools.partial(FormSubmit, form_component="rc.form"), - functools.partial(FormSubmitName, form_component="rc.form"), ], ids=[ "id-radix", "name-radix", "id-html", "name-html", - "id-chakra", - "name-chakra", ], ) def form_submit(request, tmp_path_factory) -> Generator[AppHarness, None, None]: @@ -224,16 +206,6 @@ async def test_submit(driver, form_submit: AppHarness): name_input = driver.find_element(by, "name_input") name_input.send_keys("foo") - pin_inputs = driver.find_elements(By.CLASS_NAME, "chakra-pin-input") - pin_values = ["8", "1", "6", "4"] - for i, pin_input in enumerate(pin_inputs): - pin_input.send_keys(pin_values[i]) - - number_input = driver.find_element(By.CLASS_NAME, "chakra-numberinput") - buttons = number_input.find_elements(By.XPATH, "//div[@role='button']") - for _ in range(3): - buttons[1].click() - checkbox_input = driver.find_element(By.XPATH, "//button[@role='checkbox']") checkbox_input.click() @@ -275,15 +247,12 @@ async def test_submit(driver, form_submit: AppHarness): print(form_data) assert form_data["name_input"] == "foo" - assert form_data["pin_input"] == pin_values - assert form_data["number_input"] == "-3" assert form_data["bool_input"] assert form_data["bool_input2"] assert not form_data.get("bool_input3", False) assert not form_data.get("bool_input4", False) assert form_data["slider_input"] == "50" - assert form_data["range_input"] == ["25", "75"] assert form_data["radio_input"] == "option2" assert form_data["select_input"] == "option1" assert form_data["text_area_input"] == "Some\nText" diff --git a/integration/test_server_side_event.py b/integration/test_server_side_event.py index 8687b0f32..ee5e8dbc0 100644 --- a/integration/test_server_side_event.py +++ b/integration/test_server_side_event.py @@ -11,8 +11,6 @@ from reflex.testing import AppHarness def ServerSideEvent(): """App with inputs set via event handlers and set_value.""" - import reflex_chakra as rc - import reflex as rx class SSState(rx.State): @@ -41,12 +39,12 @@ def ServerSideEvent(): @app.add_page def index(): return rx.fragment( - rc.input( + rx.input( id="token", value=SSState.router.session.client_token, is_read_only=True ), - rc.input(default_value="a", id="a"), - rc.input(default_value="b", id="b"), - rc.input(default_value="c", id="c"), + rx.input(default_value="a", id="a"), + rx.input(default_value="b", id="b"), + rx.input(default_value="c", id="c"), rx.button( "Clear Immediate", id="clear_immediate", diff --git a/integration/test_table.py b/integration/test_table.py index d28798a98..09004a874 100644 --- a/integration/test_table.py +++ b/integration/test_table.py @@ -10,91 +10,47 @@ from reflex.testing import AppHarness def Table(): """App using table component.""" - from typing import List - - import reflex_chakra as rc - import reflex as rx - class TableState(rx.State): - rows: List[List[str]] = [ - ["John", "30", "New York"], - ["Jane", "31", "San Fransisco"], - ["Joe", "32", "Los Angeles"], - ] - - headers: List[str] = ["Name", "Age", "Location"] - - footers: List[str] = ["footer1", "footer2", "footer3"] - - caption: str = "random caption" - app = rx.App(state=rx.State) @app.add_page def index(): return rx.center( - rc.input( + rx.input( id="token", - value=TableState.router.session.client_token, + value=rx.State.router.session.client_token, is_read_only=True, ), - rc.table_container( - rc.table( - headers=TableState.headers, - rows=TableState.rows, - footers=TableState.footers, - caption=TableState.caption, - variant="striped", - color_scheme="blue", - width="100%", + rx.table.root( + rx.table.header( + rx.table.row( + rx.table.column_header_cell("Name"), + rx.table.column_header_cell("Age"), + rx.table.column_header_cell("Location"), + ), ), + rx.table.body( + rx.table.row( + rx.table.row_header_cell("John"), + rx.table.cell(30), + rx.table.cell("New York"), + ), + rx.table.row( + rx.table.row_header_cell("Jane"), + rx.table.cell(31), + rx.table.cell("San Fransisco"), + ), + rx.table.row( + rx.table.row_header_cell("Joe"), + rx.table.cell(32), + rx.table.cell("Los Angeles"), + ), + ), + width="100%", ), ) - @app.add_page - def another(): - return rx.center( - rc.table_container( - rc.table( # type: ignore - rc.thead( # type: ignore - rc.tr( # type: ignore - rc.th("Name"), - rc.th("Age"), - rc.th("Location"), - ) - ), - rc.tbody( # type: ignore - rc.tr( # type: ignore - rc.td("John"), - rc.td(30), - rc.td("New York"), - ), - rc.tr( # type: ignore - rc.td("Jane"), - rc.td(31), - rc.td("San Francisco"), - ), - rc.tr( # type: ignore - rc.td("Joe"), - rc.td(32), - rc.td("Los Angeles"), - ), - ), - rc.tfoot( # type: ignore - rc.tr( - rc.td("footer1"), - rc.td("footer2"), - rc.td("footer3"), - ) # type: ignore - ), - rc.table_caption("random caption"), - variant="striped", - color_scheme="teal", - ) - ) - ) - @pytest.fixture() def table(tmp_path_factory) -> Generator[AppHarness, None, None]: @@ -138,23 +94,20 @@ def driver(table: AppHarness): driver.quit() -@pytest.mark.parametrize("route", ["", "/another"]) -def test_table(driver, table: AppHarness, route): +def test_table(driver, table: AppHarness): """Test that a table component is rendered properly. Args: driver: Selenium WebDriver open to the app table: Harness for Table app - route: Page route or path. """ - driver.get(f"{table.frontend_url}/{route}") assert table.app_instance is not None, "app is not running" thead = driver.find_element(By.TAG_NAME, "thead") # poll till page is fully loaded. table.poll_for_content(element=thead) # check headers - assert thead.find_element(By.TAG_NAME, "tr").text == "NAME AGE LOCATION" + assert thead.find_element(By.TAG_NAME, "tr").text == "Name Age Location" # check first row value assert ( driver.find_element(By.TAG_NAME, "tbody") @@ -162,12 +115,3 @@ def test_table(driver, table: AppHarness, route): .text == "John 30 New York" ) - # check footer - assert ( - driver.find_element(By.TAG_NAME, "tfoot") - .find_element(By.TAG_NAME, "tr") - .text.lower() - == "footer1 footer2 footer3" - ) - # check caption - assert driver.find_element(By.TAG_NAME, "caption").text == "random caption" diff --git a/integration/test_tailwind.py b/integration/test_tailwind.py index a3d90e645..bda664a1c 100644 --- a/integration/test_tailwind.py +++ b/integration/test_tailwind.py @@ -27,8 +27,6 @@ def TailwindApp( """ from pathlib import Path - import reflex_chakra as rc - import reflex as rx class UnusedState(rx.State): @@ -36,7 +34,7 @@ def TailwindApp( def index(): return rx.el.div( - rc.text(paragraph_text, class_name=paragraph_class_name), + rx.text(paragraph_text, class_name=paragraph_class_name), rx.el.p(paragraph_text, class_name=paragraph_class_name), rx.text(paragraph_text, as_="p", class_name=paragraph_class_name), rx.el.div("Test external stylesheet", class_name="external"), @@ -109,7 +107,7 @@ def test_tailwind_app(tailwind_app: AppHarness, tailwind_disabled: bool): assert len(paragraphs) == 3 for p in paragraphs: assert tailwind_app.poll_for_content(p, exp_not_equal="") == PARAGRAPH_TEXT - assert p.value_of_css_property("font-family") == '"monospace"' + assert p.value_of_css_property("font-family") == "monospace" if tailwind_disabled: # expect default color, not "text-red-500" from tailwind utility class assert p.value_of_css_property("color") not in TEXT_RED_500_COLOR diff --git a/integration/test_upload.py b/integration/test_upload.py index 1f8b39efc..813313462 100644 --- a/integration/test_upload.py +++ b/integration/test_upload.py @@ -16,8 +16,6 @@ def UploadFile(): """App for testing dynamic routes.""" from typing import Dict, List - import reflex_chakra as rc - import reflex as rx class UploadState(rx.State): @@ -46,7 +44,7 @@ def UploadFile(): def index(): return rx.vstack( - rc.input( + rx.input( value=UploadState.router.session.client_token, is_read_only=True, id="token", diff --git a/integration/test_var_operations.py b/integration/test_var_operations.py index 7a8f5473a..cae56e1a8 100644 --- a/integration/test_var_operations.py +++ b/integration/test_var_operations.py @@ -14,11 +14,12 @@ def VarOperations(): """App with var operations.""" from typing import Dict, List - import reflex_chakra as rc - import reflex as rx - from reflex.ivars.base import LiteralVar - from reflex.ivars.sequence import ArrayVar + from reflex.vars.base import LiteralVar + from reflex.vars.sequence import ArrayVar + + class Object(rx.Base): + str: str = "hello" class VarOperationState(rx.State): int_var1: int = 10 @@ -29,6 +30,7 @@ def VarOperations(): list1: List = [1, 2] list2: List = [3, 4] list3: List = ["first", "second", "third"] + list4: List = [Object(name="obj_1"), Object(name="obj_2")] str_var1: str = "first" str_var2: str = "second" str_var3: str = "ThIrD" @@ -474,6 +476,7 @@ def VarOperations(): rx.text( VarOperationState.list1.contains(1).to_string(), id="list_contains" ), + rx.text(VarOperationState.list4.pluck("name").to_string(), id="list_pluck"), rx.text(VarOperationState.list1.reverse().to_string(), id="list_reverse"), # LIST, INT rx.text( @@ -547,10 +550,7 @@ def VarOperations(): VarOperationState.html_str, id="html_str", ), - rc.highlight( - "second", - query=[VarOperationState.str_var2], - ), + rx.el.mark("second"), rx.text(ArrayVar.range(2, 5).join(","), id="list_join_range1"), rx.text(ArrayVar.range(2, 10, 2).join(","), id="list_join_range2"), rx.text(ArrayVar.range(5, 0, -1).join(","), id="list_join_range3"), @@ -588,6 +588,16 @@ def VarOperations(): int_var2=VarOperationState.int_var2, id="memo_comp_nested", ), + # foreach in a match + rx.box( + rx.match( + VarOperationState.list3.length(), + (0, rx.text("No choices")), + (1, rx.text("One choice")), + rx.foreach(VarOperationState.list3, lambda choice: rx.text(choice)), + ), + id="foreach_in_match", + ), ) @@ -749,6 +759,7 @@ def test_var_operations(driver, var_operations: AppHarness): ("list_and_list", "[3,4]"), ("list_or_list", "[1,2]"), ("list_contains", "true"), + ("list_pluck", '["obj_1","obj_2"]'), ("list_reverse", "[2,1]"), ("list_join", "firstsecondthird"), ("list_join_comma", "first,second,third"), @@ -784,6 +795,8 @@ def test_var_operations(driver, var_operations: AppHarness): # rx.memo component with state ("memo_comp", "1210"), ("memo_comp_nested", "345"), + # foreach in a match + ("foreach_in_match", "first\nsecond\nthird"), ] for tag, expected in tests: diff --git a/poetry.lock b/poetry.lock index c67e72d6a..d3a63110b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -12,8 +12,6 @@ files = [ ] [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.9\""} -importlib-resources = {version = "*", markers = "python_version < \"3.9\""} Mako = "*" SQLAlchemy = ">=1.3.0" typing-extensions = ">=4" @@ -32,18 +30,15 @@ files = [ {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} - [[package]] name = "anyio" -version = "4.4.0" +version = "4.5.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ - {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, - {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"}, + {file = "anyio-4.5.0-py3-none-any.whl", hash = "sha256:fdeb095b7cc5a5563175eedd926ec4ae55413bb4be5770c424af0ba46ccb4a78"}, + {file = "anyio-4.5.0.tar.gz", hash = "sha256:c5a275fe5ca0afd788001f58fca1e69e29ce706d746e317d660e21f70c530ef9"}, ] [package.dependencies] @@ -53,9 +48,9 @@ sniffio = ">=1.1" typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] -doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] -test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] -trio = ["trio (>=0.23)"] +doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.21.0b1)"] +trio = ["trio (>=0.26.1)"] [[package]] name = "async-timeout" @@ -126,13 +121,13 @@ files = [ [[package]] name = "build" -version = "1.2.1" +version = "1.2.2" description = "A simple, correct Python build frontend" optional = false python-versions = ">=3.8" files = [ - {file = "build-1.2.1-py3-none-any.whl", hash = "sha256:75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4"}, - {file = "build-1.2.1.tar.gz", hash = "sha256:526263f4870c26f26c433545579475377b2b7588b6f1eac76a001e873ae3e19d"}, + {file = "build-1.2.2-py3-none-any.whl", hash = "sha256:277ccc71619d98afdd841a0e96ac9fe1593b823af481d3b0cea748e8894e0613"}, + {file = "build-1.2.2.tar.gz", hash = "sha256:119b2fb462adef986483438377a13b2f42064a2a3a4161f24a0cca698a07ac8c"}, ] [package.dependencies] @@ -151,89 +146,89 @@ virtualenv = ["virtualenv (>=20.0.35)"] [[package]] name = "certifi" -version = "2024.7.4" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, - {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, + {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, + {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, ] [[package]] name = "cffi" -version = "1.17.0" +version = "1.17.1" description = "Foreign Function Interface for Python calling C code." optional = false python-versions = ">=3.8" files = [ - {file = "cffi-1.17.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f9338cc05451f1942d0d8203ec2c346c830f8e86469903d5126c1f0a13a2bcbb"}, - {file = "cffi-1.17.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a0ce71725cacc9ebf839630772b07eeec220cbb5f03be1399e0457a1464f8e1a"}, - {file = "cffi-1.17.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c815270206f983309915a6844fe994b2fa47e5d05c4c4cef267c3b30e34dbe42"}, - {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d6bdcd415ba87846fd317bee0774e412e8792832e7805938987e4ede1d13046d"}, - {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8a98748ed1a1df4ee1d6f927e151ed6c1a09d5ec21684de879c7ea6aa96f58f2"}, - {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0a048d4f6630113e54bb4b77e315e1ba32a5a31512c31a273807d0027a7e69ab"}, - {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24aa705a5f5bd3a8bcfa4d123f03413de5d86e497435693b638cbffb7d5d8a1b"}, - {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:856bf0924d24e7f93b8aee12a3a1095c34085600aa805693fb7f5d1962393206"}, - {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:4304d4416ff032ed50ad6bb87416d802e67139e31c0bde4628f36a47a3164bfa"}, - {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:331ad15c39c9fe9186ceaf87203a9ecf5ae0ba2538c9e898e3a6967e8ad3db6f"}, - {file = "cffi-1.17.0-cp310-cp310-win32.whl", hash = "sha256:669b29a9eca6146465cc574659058ed949748f0809a2582d1f1a324eb91054dc"}, - {file = "cffi-1.17.0-cp310-cp310-win_amd64.whl", hash = "sha256:48b389b1fd5144603d61d752afd7167dfd205973a43151ae5045b35793232aa2"}, - {file = "cffi-1.17.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c5d97162c196ce54af6700949ddf9409e9833ef1003b4741c2b39ef46f1d9720"}, - {file = "cffi-1.17.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5ba5c243f4004c750836f81606a9fcb7841f8874ad8f3bf204ff5e56332b72b9"}, - {file = "cffi-1.17.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bb9333f58fc3a2296fb1d54576138d4cf5d496a2cc118422bd77835e6ae0b9cb"}, - {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:435a22d00ec7d7ea533db494da8581b05977f9c37338c80bc86314bec2619424"}, - {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d1df34588123fcc88c872f5acb6f74ae59e9d182a2707097f9e28275ec26a12d"}, - {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:df8bb0010fdd0a743b7542589223a2816bdde4d94bb5ad67884348fa2c1c67e8"}, - {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8b5b9712783415695663bd463990e2f00c6750562e6ad1d28e072a611c5f2a6"}, - {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ffef8fd58a36fb5f1196919638f73dd3ae0db1a878982b27a9a5a176ede4ba91"}, - {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:4e67d26532bfd8b7f7c05d5a766d6f437b362c1bf203a3a5ce3593a645e870b8"}, - {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:45f7cd36186db767d803b1473b3c659d57a23b5fa491ad83c6d40f2af58e4dbb"}, - {file = "cffi-1.17.0-cp311-cp311-win32.whl", hash = "sha256:a9015f5b8af1bb6837a3fcb0cdf3b874fe3385ff6274e8b7925d81ccaec3c5c9"}, - {file = "cffi-1.17.0-cp311-cp311-win_amd64.whl", hash = "sha256:b50aaac7d05c2c26dfd50c3321199f019ba76bb650e346a6ef3616306eed67b0"}, - {file = "cffi-1.17.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aec510255ce690d240f7cb23d7114f6b351c733a74c279a84def763660a2c3bc"}, - {file = "cffi-1.17.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2770bb0d5e3cc0e31e7318db06efcbcdb7b31bcb1a70086d3177692a02256f59"}, - {file = "cffi-1.17.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:db9a30ec064129d605d0f1aedc93e00894b9334ec74ba9c6bdd08147434b33eb"}, - {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a47eef975d2b8b721775a0fa286f50eab535b9d56c70a6e62842134cf7841195"}, - {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f3e0992f23bbb0be00a921eae5363329253c3b86287db27092461c887b791e5e"}, - {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6107e445faf057c118d5050560695e46d272e5301feffda3c41849641222a828"}, - {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb862356ee9391dc5a0b3cbc00f416b48c1b9a52d252d898e5b7696a5f9fe150"}, - {file = "cffi-1.17.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c1c13185b90bbd3f8b5963cd8ce7ad4ff441924c31e23c975cb150e27c2bf67a"}, - {file = "cffi-1.17.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:17c6d6d3260c7f2d94f657e6872591fe8733872a86ed1345bda872cfc8c74885"}, - {file = "cffi-1.17.0-cp312-cp312-win32.whl", hash = "sha256:c3b8bd3133cd50f6b637bb4322822c94c5ce4bf0d724ed5ae70afce62187c492"}, - {file = "cffi-1.17.0-cp312-cp312-win_amd64.whl", hash = "sha256:dca802c8db0720ce1c49cce1149ff7b06e91ba15fa84b1d59144fef1a1bc7ac2"}, - {file = "cffi-1.17.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6ce01337d23884b21c03869d2f68c5523d43174d4fc405490eb0091057943118"}, - {file = "cffi-1.17.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cab2eba3830bf4f6d91e2d6718e0e1c14a2f5ad1af68a89d24ace0c6b17cced7"}, - {file = "cffi-1.17.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:14b9cbc8f7ac98a739558eb86fabc283d4d564dafed50216e7f7ee62d0d25377"}, - {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b00e7bcd71caa0282cbe3c90966f738e2db91e64092a877c3ff7f19a1628fdcb"}, - {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:41f4915e09218744d8bae14759f983e466ab69b178de38066f7579892ff2a555"}, - {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e4760a68cab57bfaa628938e9c2971137e05ce48e762a9cb53b76c9b569f1204"}, - {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:011aff3524d578a9412c8b3cfaa50f2c0bd78e03eb7af7aa5e0df59b158efb2f"}, - {file = "cffi-1.17.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:a003ac9edc22d99ae1286b0875c460351f4e101f8c9d9d2576e78d7e048f64e0"}, - {file = "cffi-1.17.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ef9528915df81b8f4c7612b19b8628214c65c9b7f74db2e34a646a0a2a0da2d4"}, - {file = "cffi-1.17.0-cp313-cp313-win32.whl", hash = "sha256:70d2aa9fb00cf52034feac4b913181a6e10356019b18ef89bc7c12a283bf5f5a"}, - {file = "cffi-1.17.0-cp313-cp313-win_amd64.whl", hash = "sha256:b7b6ea9e36d32582cda3465f54c4b454f62f23cb083ebc7a94e2ca6ef011c3a7"}, - {file = "cffi-1.17.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:964823b2fc77b55355999ade496c54dde161c621cb1f6eac61dc30ed1b63cd4c"}, - {file = "cffi-1.17.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:516a405f174fd3b88829eabfe4bb296ac602d6a0f68e0d64d5ac9456194a5b7e"}, - {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dec6b307ce928e8e112a6bb9921a1cb00a0e14979bf28b98e084a4b8a742bd9b"}, - {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e4094c7b464cf0a858e75cd14b03509e84789abf7b79f8537e6a72152109c76e"}, - {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2404f3de742f47cb62d023f0ba7c5a916c9c653d5b368cc966382ae4e57da401"}, - {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3aa9d43b02a0c681f0bfbc12d476d47b2b2b6a3f9287f11ee42989a268a1833c"}, - {file = "cffi-1.17.0-cp38-cp38-win32.whl", hash = "sha256:0bb15e7acf8ab35ca8b24b90af52c8b391690ef5c4aec3d31f38f0d37d2cc499"}, - {file = "cffi-1.17.0-cp38-cp38-win_amd64.whl", hash = "sha256:93a7350f6706b31f457c1457d3a3259ff9071a66f312ae64dc024f049055f72c"}, - {file = "cffi-1.17.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1a2ddbac59dc3716bc79f27906c010406155031a1c801410f1bafff17ea304d2"}, - {file = "cffi-1.17.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6327b572f5770293fc062a7ec04160e89741e8552bf1c358d1a23eba68166759"}, - {file = "cffi-1.17.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dbc183e7bef690c9abe5ea67b7b60fdbca81aa8da43468287dae7b5c046107d4"}, - {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5bdc0f1f610d067c70aa3737ed06e2726fd9d6f7bfee4a351f4c40b6831f4e82"}, - {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6d872186c1617d143969defeadac5a904e6e374183e07977eedef9c07c8953bf"}, - {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0d46ee4764b88b91f16661a8befc6bfb24806d885e27436fdc292ed7e6f6d058"}, - {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f76a90c345796c01d85e6332e81cab6d70de83b829cf1d9762d0a3da59c7932"}, - {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0e60821d312f99d3e1569202518dddf10ae547e799d75aef3bca3a2d9e8ee693"}, - {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:eb09b82377233b902d4c3fbeeb7ad731cdab579c6c6fda1f763cd779139e47c3"}, - {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:24658baf6224d8f280e827f0a50c46ad819ec8ba380a42448e24459daf809cf4"}, - {file = "cffi-1.17.0-cp39-cp39-win32.whl", hash = "sha256:0fdacad9e0d9fc23e519efd5ea24a70348305e8d7d85ecbb1a5fa66dc834e7fb"}, - {file = "cffi-1.17.0-cp39-cp39-win_amd64.whl", hash = "sha256:7cbc78dc018596315d4e7841c8c3a7ae31cc4d638c9b627f87d52e8abaaf2d29"}, - {file = "cffi-1.17.0.tar.gz", hash = "sha256:f3157624b7558b914cb039fd1af735e5e8049a87c817cc215109ad1c8779df76"}, + {file = "cffi-1.17.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:df8b1c11f177bc2313ec4b2d46baec87a5f3e71fc8b45dab2ee7cae86d9aba14"}, + {file = "cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8f2cdc858323644ab277e9bb925ad72ae0e67f69e804f4898c070998d50b1a67"}, + {file = "cffi-1.17.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:edae79245293e15384b51f88b00613ba9f7198016a5948b5dddf4917d4d26382"}, + {file = "cffi-1.17.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45398b671ac6d70e67da8e4224a065cec6a93541bb7aebe1b198a61b58c7b702"}, + {file = "cffi-1.17.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ad9413ccdeda48c5afdae7e4fa2192157e991ff761e7ab8fdd8926f40b160cc3"}, + {file = "cffi-1.17.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5da5719280082ac6bd9aa7becb3938dc9f9cbd57fac7d2871717b1feb0902ab6"}, + {file = "cffi-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2bb1a08b8008b281856e5971307cc386a8e9c5b625ac297e853d36da6efe9c17"}, + {file = "cffi-1.17.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:045d61c734659cc045141be4bae381a41d89b741f795af1dd018bfb532fd0df8"}, + {file = "cffi-1.17.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:6883e737d7d9e4899a8a695e00ec36bd4e5e4f18fabe0aca0efe0a4b44cdb13e"}, + {file = "cffi-1.17.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6b8b4a92e1c65048ff98cfe1f735ef8f1ceb72e3d5f0c25fdb12087a23da22be"}, + {file = "cffi-1.17.1-cp310-cp310-win32.whl", hash = "sha256:c9c3d058ebabb74db66e431095118094d06abf53284d9c81f27300d0e0d8bc7c"}, + {file = "cffi-1.17.1-cp310-cp310-win_amd64.whl", hash = "sha256:0f048dcf80db46f0098ccac01132761580d28e28bc0f78ae0d58048063317e15"}, + {file = "cffi-1.17.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a45e3c6913c5b87b3ff120dcdc03f6131fa0065027d0ed7ee6190736a74cd401"}, + {file = "cffi-1.17.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:30c5e0cb5ae493c04c8b42916e52ca38079f1b235c2f8ae5f4527b963c401caf"}, + {file = "cffi-1.17.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f75c7ab1f9e4aca5414ed4d8e5c0e303a34f4421f8a0d47a4d019ceff0ab6af4"}, + {file = "cffi-1.17.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a1ed2dd2972641495a3ec98445e09766f077aee98a1c896dcb4ad0d303628e41"}, + {file = "cffi-1.17.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:46bf43160c1a35f7ec506d254e5c890f3c03648a4dbac12d624e4490a7046cd1"}, + {file = "cffi-1.17.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a24ed04c8ffd54b0729c07cee15a81d964e6fee0e3d4d342a27b020d22959dc6"}, + {file = "cffi-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:610faea79c43e44c71e1ec53a554553fa22321b65fae24889706c0a84d4ad86d"}, + {file = "cffi-1.17.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a9b15d491f3ad5d692e11f6b71f7857e7835eb677955c00cc0aefcd0669adaf6"}, + {file = "cffi-1.17.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:de2ea4b5833625383e464549fec1bc395c1bdeeb5f25c4a3a82b5a8c756ec22f"}, + {file = "cffi-1.17.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b"}, + {file = "cffi-1.17.1-cp311-cp311-win32.whl", hash = "sha256:85a950a4ac9c359340d5963966e3e0a94a676bd6245a4b55bc43949eee26a655"}, + {file = "cffi-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:caaf0640ef5f5517f49bc275eca1406b0ffa6aa184892812030f04c2abf589a0"}, + {file = "cffi-1.17.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:805b4371bf7197c329fcb3ead37e710d1bca9da5d583f5073b799d5c5bd1eee4"}, + {file = "cffi-1.17.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:733e99bc2df47476e3848417c5a4540522f234dfd4ef3ab7fafdf555b082ec0c"}, + {file = "cffi-1.17.1-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1257bdabf294dceb59f5e70c64a3e2f462c30c7ad68092d01bbbfb1c16b1ba36"}, + {file = "cffi-1.17.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da95af8214998d77a98cc14e3a3bd00aa191526343078b530ceb0bd710fb48a5"}, + {file = "cffi-1.17.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d63afe322132c194cf832bfec0dc69a99fb9bb6bbd550f161a49e9e855cc78ff"}, + {file = "cffi-1.17.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f79fc4fc25f1c8698ff97788206bb3c2598949bfe0fef03d299eb1b5356ada99"}, + {file = "cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b62ce867176a75d03a665bad002af8e6d54644fad99a3c70905c543130e39d93"}, + {file = "cffi-1.17.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:386c8bf53c502fff58903061338ce4f4950cbdcb23e2902d86c0f722b786bbe3"}, + {file = "cffi-1.17.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4ceb10419a9adf4460ea14cfd6bc43d08701f0835e979bf821052f1805850fe8"}, + {file = "cffi-1.17.1-cp312-cp312-win32.whl", hash = "sha256:a08d7e755f8ed21095a310a693525137cfe756ce62d066e53f502a83dc550f65"}, + {file = "cffi-1.17.1-cp312-cp312-win_amd64.whl", hash = "sha256:51392eae71afec0d0c8fb1a53b204dbb3bcabcb3c9b807eedf3e1e6ccf2de903"}, + {file = "cffi-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f3a2b4222ce6b60e2e8b337bb9596923045681d71e5a082783484d845390938e"}, + {file = "cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0984a4925a435b1da406122d4d7968dd861c1385afe3b45ba82b750f229811e2"}, + {file = "cffi-1.17.1-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d01b12eeeb4427d3110de311e1774046ad344f5b1a7403101878976ecd7a10f3"}, + {file = "cffi-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:706510fe141c86a69c8ddc029c7910003a17353970cff3b904ff0686a5927683"}, + {file = "cffi-1.17.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de55b766c7aa2e2a3092c51e0483d700341182f08e67c63630d5b6f200bb28e5"}, + {file = "cffi-1.17.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c59d6e989d07460165cc5ad3c61f9fd8f1b4796eacbd81cee78957842b834af4"}, + {file = "cffi-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd398dbc6773384a17fe0d3e7eeb8d1a21c2200473ee6806bb5e6a8e62bb73dd"}, + {file = "cffi-1.17.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3edc8d958eb099c634dace3c7e16560ae474aa3803a5df240542b305d14e14ed"}, + {file = "cffi-1.17.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:72e72408cad3d5419375fc87d289076ee319835bdfa2caad331e377589aebba9"}, + {file = "cffi-1.17.1-cp313-cp313-win32.whl", hash = "sha256:e03eab0a8677fa80d646b5ddece1cbeaf556c313dcfac435ba11f107ba117b5d"}, + {file = "cffi-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a"}, + {file = "cffi-1.17.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:636062ea65bd0195bc012fea9321aca499c0504409f413dc88af450b57ffd03b"}, + {file = "cffi-1.17.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c7eac2ef9b63c79431bc4b25f1cd649d7f061a28808cbc6c47b534bd789ef964"}, + {file = "cffi-1.17.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e221cf152cff04059d011ee126477f0d9588303eb57e88923578ace7baad17f9"}, + {file = "cffi-1.17.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:31000ec67d4221a71bd3f67df918b1f88f676f1c3b535a7eb473255fdc0b83fc"}, + {file = "cffi-1.17.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6f17be4345073b0a7b8ea599688f692ac3ef23ce28e5df79c04de519dbc4912c"}, + {file = "cffi-1.17.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2b1fac190ae3ebfe37b979cc1ce69c81f4e4fe5746bb401dca63a9062cdaf1"}, + {file = "cffi-1.17.1-cp38-cp38-win32.whl", hash = "sha256:7596d6620d3fa590f677e9ee430df2958d2d6d6de2feeae5b20e82c00b76fbf8"}, + {file = "cffi-1.17.1-cp38-cp38-win_amd64.whl", hash = "sha256:78122be759c3f8a014ce010908ae03364d00a1f81ab5c7f4a7a5120607ea56e1"}, + {file = "cffi-1.17.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b2ab587605f4ba0bf81dc0cb08a41bd1c0a5906bd59243d56bad7668a6fc6c16"}, + {file = "cffi-1.17.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:28b16024becceed8c6dfbc75629e27788d8a3f9030691a1dbf9821a128b22c36"}, + {file = "cffi-1.17.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1d599671f396c4723d016dbddb72fe8e0397082b0a77a4fab8028923bec050e8"}, + {file = "cffi-1.17.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca74b8dbe6e8e8263c0ffd60277de77dcee6c837a3d0881d8c1ead7268c9e576"}, + {file = "cffi-1.17.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87"}, + {file = "cffi-1.17.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:98e3969bcff97cae1b2def8ba499ea3d6f31ddfdb7635374834cf89a1a08ecf0"}, + {file = "cffi-1.17.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdf5ce3acdfd1661132f2a9c19cac174758dc2352bfe37d98aa7512c6b7178b3"}, + {file = "cffi-1.17.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9755e4345d1ec879e3849e62222a18c7174d65a6a92d5b346b1863912168b595"}, + {file = "cffi-1.17.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:f1e22e8c4419538cb197e4dd60acc919d7696e5ef98ee4da4e01d3f8cfa4cc5a"}, + {file = "cffi-1.17.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c03e868a0b3bc35839ba98e74211ed2b05d2119be4e8a0f224fba9384f1fe02e"}, + {file = "cffi-1.17.1-cp39-cp39-win32.whl", hash = "sha256:e31ae45bc2e29f6b2abd0de1cc3b9d5205aa847cafaecb8af1476a609a2f6eb7"}, + {file = "cffi-1.17.1-cp39-cp39-win_amd64.whl", hash = "sha256:d016c76bdd850f3c626af19b0542c9677ba156e4ee4fccfdd7848803533ef662"}, + {file = "cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824"}, ] [package.dependencies] @@ -463,38 +458,38 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "43.0.0" +version = "43.0.1" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = ">=3.7" files = [ - {file = "cryptography-43.0.0-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:64c3f16e2a4fc51c0d06af28441881f98c5d91009b8caaff40cf3548089e9c74"}, - {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3dcdedae5c7710b9f97ac6bba7e1052b95c7083c9d0e9df96e02a1932e777895"}, - {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d9a1eca329405219b605fac09ecfc09ac09e595d6def650a437523fcd08dd22"}, - {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ea9e57f8ea880eeea38ab5abf9fbe39f923544d7884228ec67d666abd60f5a47"}, - {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:9a8d6802e0825767476f62aafed40532bd435e8a5f7d23bd8b4f5fd04cc80ecf"}, - {file = "cryptography-43.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:cc70b4b581f28d0a254d006f26949245e3657d40d8857066c2ae22a61222ef55"}, - {file = "cryptography-43.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:4a997df8c1c2aae1e1e5ac49c2e4f610ad037fc5a3aadc7b64e39dea42249431"}, - {file = "cryptography-43.0.0-cp37-abi3-win32.whl", hash = "sha256:6e2b11c55d260d03a8cf29ac9b5e0608d35f08077d8c087be96287f43af3ccdc"}, - {file = "cryptography-43.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:31e44a986ceccec3d0498e16f3d27b2ee5fdf69ce2ab89b52eaad1d2f33d8778"}, - {file = "cryptography-43.0.0-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:7b3f5fe74a5ca32d4d0f302ffe6680fcc5c28f8ef0dc0ae8f40c0f3a1b4fca66"}, - {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ac1955ce000cb29ab40def14fd1bbfa7af2017cca696ee696925615cafd0dce5"}, - {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:299d3da8e00b7e2b54bb02ef58d73cd5f55fb31f33ebbf33bd00d9aa6807df7e"}, - {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ee0c405832ade84d4de74b9029bedb7b31200600fa524d218fc29bfa371e97f5"}, - {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:cb013933d4c127349b3948aa8aaf2f12c0353ad0eccd715ca789c8a0f671646f"}, - {file = "cryptography-43.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fdcb265de28585de5b859ae13e3846a8e805268a823a12a4da2597f1f5afc9f0"}, - {file = "cryptography-43.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:2905ccf93a8a2a416f3ec01b1a7911c3fe4073ef35640e7ee5296754e30b762b"}, - {file = "cryptography-43.0.0-cp39-abi3-win32.whl", hash = "sha256:47ca71115e545954e6c1d207dd13461ab81f4eccfcb1345eac874828b5e3eaaf"}, - {file = "cryptography-43.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:0663585d02f76929792470451a5ba64424acc3cd5227b03921dab0e2f27b1709"}, - {file = "cryptography-43.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2c6d112bf61c5ef44042c253e4859b3cbbb50df2f78fa8fae6747a7814484a70"}, - {file = "cryptography-43.0.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:844b6d608374e7d08f4f6e6f9f7b951f9256db41421917dfb2d003dde4cd6b66"}, - {file = "cryptography-43.0.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:51956cf8730665e2bdf8ddb8da0056f699c1a5715648c1b0144670c1ba00b48f"}, - {file = "cryptography-43.0.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:aae4d918f6b180a8ab8bf6511a419473d107df4dbb4225c7b48c5c9602c38c7f"}, - {file = "cryptography-43.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:232ce02943a579095a339ac4b390fbbe97f5b5d5d107f8a08260ea2768be8cc2"}, - {file = "cryptography-43.0.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:5bcb8a5620008a8034d39bce21dc3e23735dfdb6a33a06974739bfa04f853947"}, - {file = "cryptography-43.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:08a24a7070b2b6804c1940ff0f910ff728932a9d0e80e7814234269f9d46d069"}, - {file = "cryptography-43.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:e9c5266c432a1e23738d178e51c2c7a5e2ddf790f248be939448c0ba2021f9d1"}, - {file = "cryptography-43.0.0.tar.gz", hash = "sha256:b88075ada2d51aa9f18283532c9f60e72170041bba88d7f37e49cbb10275299e"}, + {file = "cryptography-43.0.1-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:8385d98f6a3bf8bb2d65a73e17ed87a3ba84f6991c155691c51112075f9ffc5d"}, + {file = "cryptography-43.0.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:27e613d7077ac613e399270253259d9d53872aaf657471473ebfc9a52935c062"}, + {file = "cryptography-43.0.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:68aaecc4178e90719e95298515979814bda0cbada1256a4485414860bd7ab962"}, + {file = "cryptography-43.0.1-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:de41fd81a41e53267cb020bb3a7212861da53a7d39f863585d13ea11049cf277"}, + {file = "cryptography-43.0.1-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f98bf604c82c416bc829e490c700ca1553eafdf2912a91e23a79d97d9801372a"}, + {file = "cryptography-43.0.1-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:61ec41068b7b74268fa86e3e9e12b9f0c21fcf65434571dbb13d954bceb08042"}, + {file = "cryptography-43.0.1-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:014f58110f53237ace6a408b5beb6c427b64e084eb451ef25a28308270086494"}, + {file = "cryptography-43.0.1-cp37-abi3-win32.whl", hash = "sha256:2bd51274dcd59f09dd952afb696bf9c61a7a49dfc764c04dd33ef7a6b502a1e2"}, + {file = "cryptography-43.0.1-cp37-abi3-win_amd64.whl", hash = "sha256:666ae11966643886c2987b3b721899d250855718d6d9ce41b521252a17985f4d"}, + {file = "cryptography-43.0.1-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:ac119bb76b9faa00f48128b7f5679e1d8d437365c5d26f1c2c3f0da4ce1b553d"}, + {file = "cryptography-43.0.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bbcce1a551e262dfbafb6e6252f1ae36a248e615ca44ba302df077a846a8806"}, + {file = "cryptography-43.0.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58d4e9129985185a06d849aa6df265bdd5a74ca6e1b736a77959b498e0505b85"}, + {file = "cryptography-43.0.1-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:d03a475165f3134f773d1388aeb19c2d25ba88b6a9733c5c590b9ff7bbfa2e0c"}, + {file = "cryptography-43.0.1-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:511f4273808ab590912a93ddb4e3914dfd8a388fed883361b02dea3791f292e1"}, + {file = "cryptography-43.0.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:80eda8b3e173f0f247f711eef62be51b599b5d425c429b5d4ca6a05e9e856baa"}, + {file = "cryptography-43.0.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:38926c50cff6f533f8a2dae3d7f19541432610d114a70808f0926d5aaa7121e4"}, + {file = "cryptography-43.0.1-cp39-abi3-win32.whl", hash = "sha256:a575913fb06e05e6b4b814d7f7468c2c660e8bb16d8d5a1faf9b33ccc569dd47"}, + {file = "cryptography-43.0.1-cp39-abi3-win_amd64.whl", hash = "sha256:d75601ad10b059ec832e78823b348bfa1a59f6b8d545db3a24fd44362a1564cb"}, + {file = "cryptography-43.0.1-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:ea25acb556320250756e53f9e20a4177515f012c9eaea17eb7587a8c4d8ae034"}, + {file = "cryptography-43.0.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:c1332724be35d23a854994ff0b66530119500b6053d0bd3363265f7e5e77288d"}, + {file = "cryptography-43.0.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:fba1007b3ef89946dbbb515aeeb41e30203b004f0b4b00e5e16078b518563289"}, + {file = "cryptography-43.0.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:5b43d1ea6b378b54a1dc99dd8a2b5be47658fe9a7ce0a58ff0b55f4b43ef2b84"}, + {file = "cryptography-43.0.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:88cce104c36870d70c49c7c8fd22885875d950d9ee6ab54df2745f83ba0dc365"}, + {file = "cryptography-43.0.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:9d3cdb25fa98afdd3d0892d132b8d7139e2c087da1712041f6b762e4f807cc96"}, + {file = "cryptography-43.0.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:e710bf40870f4db63c3d7d929aa9e09e4e7ee219e703f949ec4073b4294f6172"}, + {file = "cryptography-43.0.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7c05650fe8023c5ed0d46793d4b7d7e6cd9c04e68eabe5b0aeea836e37bdcec2"}, + {file = "cryptography-43.0.1.tar.gz", hash = "sha256:203e92a75716d8cfb491dc47c79e17d0d9207ccffcbcb35f598fbe463ae3444d"}, ] [package.dependencies] @@ -507,7 +502,7 @@ nox = ["nox"] pep8test = ["check-sdist", "click", "mypy", "ruff"] sdist = ["build"] ssh = ["bcrypt (>=3.1.5)"] -test = ["certifi", "cryptography-vectors (==43.0.0)", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] +test = ["certifi", "cryptography-vectors (==43.0.1)", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] test-randomorder = ["pytest-randomly"] [[package]] @@ -560,11 +555,14 @@ files = [ [[package]] name = "docutils" -version = "0.20.1" +version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false -python-versions = "*" -files = [] +python-versions = ">=3.9" +files = [ + {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, + {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, +] [[package]] name = "exceptiongroup" @@ -582,104 +580,113 @@ test = ["pytest (>=6)"] [[package]] name = "fastapi" -version = "0.110.3" +version = "0.115.0" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" optional = false python-versions = ">=3.8" files = [ - {file = "fastapi-0.110.3-py3-none-any.whl", hash = "sha256:fd7600612f755e4050beb74001310b5a7e1796d149c2ee363124abdfa0289d32"}, - {file = "fastapi-0.110.3.tar.gz", hash = "sha256:555700b0159379e94fdbfc6bb66a0f1c43f4cf7060f25239af3d84b63a656626"}, + {file = "fastapi-0.115.0-py3-none-any.whl", hash = "sha256:17ea427674467486e997206a5ab25760f6b09e069f099b96f5b55a32fb6f1631"}, + {file = "fastapi-0.115.0.tar.gz", hash = "sha256:f93b4ca3529a8ebc6fc3fcf710e5efa8de3df9b41570958abf1d97d843138004"}, ] [package.dependencies] pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0" -starlette = ">=0.37.2,<0.38.0" +starlette = ">=0.37.2,<0.39.0" typing-extensions = ">=4.8.0" [package.extras] -all = ["email_validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.7)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.7)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "jinja2 (>=2.11.2)", "python-multipart (>=0.0.7)", "uvicorn[standard] (>=0.12.0)"] [[package]] name = "filelock" -version = "3.15.4" +version = "3.16.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.15.4-py3-none-any.whl", hash = "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7"}, - {file = "filelock-3.15.4.tar.gz", hash = "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb"}, + {file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"}, + {file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"}, ] [package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)", "virtualenv (>=20.26.2)"] -typing = ["typing-extensions (>=4.8)"] +docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4.1)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"] +typing = ["typing-extensions (>=4.12.2)"] [[package]] name = "greenlet" -version = "3.0.3" +version = "3.1.0" description = "Lightweight in-process concurrent programming" optional = false python-versions = ">=3.7" files = [ - {file = "greenlet-3.0.3-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:9da2bd29ed9e4f15955dd1595ad7bc9320308a3b766ef7f837e23ad4b4aac31a"}, - {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d353cadd6083fdb056bb46ed07e4340b0869c305c8ca54ef9da3421acbdf6881"}, - {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dca1e2f3ca00b84a396bc1bce13dd21f680f035314d2379c4160c98153b2059b"}, - {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3ed7fb269f15dc662787f4119ec300ad0702fa1b19d2135a37c2c4de6fadfd4a"}, - {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd4f49ae60e10adbc94b45c0b5e6a179acc1736cf7a90160b404076ee283cf83"}, - {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:73a411ef564e0e097dbe7e866bb2dda0f027e072b04da387282b02c308807405"}, - {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7f362975f2d179f9e26928c5b517524e89dd48530a0202570d55ad6ca5d8a56f"}, - {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:649dde7de1a5eceb258f9cb00bdf50e978c9db1b996964cd80703614c86495eb"}, - {file = "greenlet-3.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:68834da854554926fbedd38c76e60c4a2e3198c6fbed520b106a8986445caaf9"}, - {file = "greenlet-3.0.3-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:b1b5667cced97081bf57b8fa1d6bfca67814b0afd38208d52538316e9422fc61"}, - {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:52f59dd9c96ad2fc0d5724107444f76eb20aaccb675bf825df6435acb7703559"}, - {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:afaff6cf5200befd5cec055b07d1c0a5a06c040fe5ad148abcd11ba6ab9b114e"}, - {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe754d231288e1e64323cfad462fcee8f0288654c10bdf4f603a39ed923bef33"}, - {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2797aa5aedac23af156bbb5a6aa2cd3427ada2972c828244eb7d1b9255846379"}, - {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b7f009caad047246ed379e1c4dbcb8b020f0a390667ea74d2387be2998f58a22"}, - {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c5e1536de2aad7bf62e27baf79225d0d64360d4168cf2e6becb91baf1ed074f3"}, - {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:894393ce10ceac937e56ec00bb71c4c2f8209ad516e96033e4b3b1de270e200d"}, - {file = "greenlet-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:1ea188d4f49089fc6fb283845ab18a2518d279c7cd9da1065d7a84e991748728"}, - {file = "greenlet-3.0.3-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:70fb482fdf2c707765ab5f0b6655e9cfcf3780d8d87355a063547b41177599be"}, - {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4d1ac74f5c0c0524e4a24335350edad7e5f03b9532da7ea4d3c54d527784f2e"}, - {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:149e94a2dd82d19838fe4b2259f1b6b9957d5ba1b25640d2380bea9c5df37676"}, - {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:15d79dd26056573940fcb8c7413d84118086f2ec1a8acdfa854631084393efcc"}, - {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:881b7db1ebff4ba09aaaeae6aa491daeb226c8150fc20e836ad00041bcb11230"}, - {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fcd2469d6a2cf298f198f0487e0a5b1a47a42ca0fa4dfd1b6862c999f018ebbf"}, - {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1f672519db1796ca0d8753f9e78ec02355e862d0998193038c7073045899f305"}, - {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2516a9957eed41dd8f1ec0c604f1cdc86758b587d964668b5b196a9db5bfcde6"}, - {file = "greenlet-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:bba5387a6975598857d86de9eac14210a49d554a77eb8261cc68b7d082f78ce2"}, - {file = "greenlet-3.0.3-cp37-cp37m-macosx_11_0_universal2.whl", hash = "sha256:5b51e85cb5ceda94e79d019ed36b35386e8c37d22f07d6a751cb659b180d5274"}, - {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:daf3cb43b7cf2ba96d614252ce1684c1bccee6b2183a01328c98d36fcd7d5cb0"}, - {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99bf650dc5d69546e076f413a87481ee1d2d09aaaaaca058c9251b6d8c14783f"}, - {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2dd6e660effd852586b6a8478a1d244b8dc90ab5b1321751d2ea15deb49ed414"}, - {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3391d1e16e2a5a1507d83e4a8b100f4ee626e8eca43cf2cadb543de69827c4c"}, - {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1f145462f1fa6e4a4ae3c0f782e580ce44d57c8f2c7aae1b6fa88c0b2efdb41"}, - {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1a7191e42732df52cb5f39d3527217e7ab73cae2cb3694d241e18f53d84ea9a7"}, - {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0448abc479fab28b00cb472d278828b3ccca164531daab4e970a0458786055d6"}, - {file = "greenlet-3.0.3-cp37-cp37m-win32.whl", hash = "sha256:b542be2440edc2d48547b5923c408cbe0fc94afb9f18741faa6ae970dbcb9b6d"}, - {file = "greenlet-3.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:01bc7ea167cf943b4c802068e178bbf70ae2e8c080467070d01bfa02f337ee67"}, - {file = "greenlet-3.0.3-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:1996cb9306c8595335bb157d133daf5cf9f693ef413e7673cb07e3e5871379ca"}, - {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ddc0f794e6ad661e321caa8d2f0a55ce01213c74722587256fb6566049a8b04"}, - {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c9db1c18f0eaad2f804728c67d6c610778456e3e1cc4ab4bbd5eeb8e6053c6fc"}, - {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7170375bcc99f1a2fbd9c306f5be8764eaf3ac6b5cb968862cad4c7057756506"}, - {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b66c9c1e7ccabad3a7d037b2bcb740122a7b17a53734b7d72a344ce39882a1b"}, - {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:098d86f528c855ead3479afe84b49242e174ed262456c342d70fc7f972bc13c4"}, - {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:81bb9c6d52e8321f09c3d165b2a78c680506d9af285bfccbad9fb7ad5a5da3e5"}, - {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:fd096eb7ffef17c456cfa587523c5f92321ae02427ff955bebe9e3c63bc9f0da"}, - {file = "greenlet-3.0.3-cp38-cp38-win32.whl", hash = "sha256:d46677c85c5ba00a9cb6f7a00b2bfa6f812192d2c9f7d9c4f6a55b60216712f3"}, - {file = "greenlet-3.0.3-cp38-cp38-win_amd64.whl", hash = "sha256:419b386f84949bf0e7c73e6032e3457b82a787c1ab4a0e43732898a761cc9dbf"}, - {file = "greenlet-3.0.3-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:da70d4d51c8b306bb7a031d5cff6cc25ad253affe89b70352af5f1cb68e74b53"}, - {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:086152f8fbc5955df88382e8a75984e2bb1c892ad2e3c80a2508954e52295257"}, - {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d73a9fe764d77f87f8ec26a0c85144d6a951a6c438dfe50487df5595c6373eac"}, - {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b7dcbe92cc99f08c8dd11f930de4d99ef756c3591a5377d1d9cd7dd5e896da71"}, - {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1551a8195c0d4a68fac7a4325efac0d541b48def35feb49d803674ac32582f61"}, - {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:64d7675ad83578e3fc149b617a444fab8efdafc9385471f868eb5ff83e446b8b"}, - {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b37eef18ea55f2ffd8f00ff8fe7c8d3818abd3e25fb73fae2ca3b672e333a7a6"}, - {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:77457465d89b8263bca14759d7c1684df840b6811b2499838cc5b040a8b5b113"}, - {file = "greenlet-3.0.3-cp39-cp39-win32.whl", hash = "sha256:57e8974f23e47dac22b83436bdcf23080ade568ce77df33159e019d161ce1d1e"}, - {file = "greenlet-3.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:c5ee858cfe08f34712f548c3c363e807e7186f03ad7a5039ebadb29e8c6be067"}, - {file = "greenlet-3.0.3.tar.gz", hash = "sha256:43374442353259554ce33599da8b692d5aa96f8976d567d4badf263371fbe491"}, + {file = "greenlet-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a814dc3100e8a046ff48faeaa909e80cdb358411a3d6dd5293158425c684eda8"}, + {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a771dc64fa44ebe58d65768d869fcfb9060169d203446c1d446e844b62bdfdca"}, + {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0e49a65d25d7350cca2da15aac31b6f67a43d867448babf997fe83c7505f57bc"}, + {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2cd8518eade968bc52262d8c46727cfc0826ff4d552cf0430b8d65aaf50bb91d"}, + {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76dc19e660baea5c38e949455c1181bc018893f25372d10ffe24b3ed7341fb25"}, + {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c0a5b1c22c82831f56f2f7ad9bbe4948879762fe0d59833a4a71f16e5fa0f682"}, + {file = "greenlet-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2651dfb006f391bcb240635079a68a261b227a10a08af6349cba834a2141efa1"}, + {file = "greenlet-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3e7e6ef1737a819819b1163116ad4b48d06cfdd40352d813bb14436024fcda99"}, + {file = "greenlet-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:ffb08f2a1e59d38c7b8b9ac8083c9c8b9875f0955b1e9b9b9a965607a51f8e54"}, + {file = "greenlet-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9730929375021ec90f6447bff4f7f5508faef1c02f399a1953870cdb78e0c345"}, + {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:713d450cf8e61854de9420fb7eea8ad228df4e27e7d4ed465de98c955d2b3fa6"}, + {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c3446937be153718250fe421da548f973124189f18fe4575a0510b5c928f0cc"}, + {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1ddc7bcedeb47187be74208bc652d63d6b20cb24f4e596bd356092d8000da6d6"}, + {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:44151d7b81b9391ed759a2f2865bbe623ef00d648fed59363be2bbbd5154656f"}, + {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6cea1cca3be76c9483282dc7760ea1cc08a6ecec1f0b6ca0a94ea0d17432da19"}, + {file = "greenlet-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:619935a44f414274a2c08c9e74611965650b730eb4efe4b2270f91df5e4adf9a"}, + {file = "greenlet-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:221169d31cada333a0c7fd087b957c8f431c1dba202c3a58cf5a3583ed973e9b"}, + {file = "greenlet-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:01059afb9b178606b4b6e92c3e710ea1635597c3537e44da69f4531e111dd5e9"}, + {file = "greenlet-3.1.0-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:24fc216ec7c8be9becba8b64a98a78f9cd057fd2dc75ae952ca94ed8a893bf27"}, + {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3d07c28b85b350564bdff9f51c1c5007dfb2f389385d1bc23288de51134ca303"}, + {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:243a223c96a4246f8a30ea470c440fe9db1f5e444941ee3c3cd79df119b8eebf"}, + {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26811df4dc81271033a7836bc20d12cd30938e6bd2e9437f56fa03da81b0f8fc"}, + {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9d86401550b09a55410f32ceb5fe7efcd998bd2dad9e82521713cb148a4a15f"}, + {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:26d9c1c4f1748ccac0bae1dbb465fb1a795a75aba8af8ca871503019f4285e2a"}, + {file = "greenlet-3.1.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:cd468ec62257bb4544989402b19d795d2305eccb06cde5da0eb739b63dc04665"}, + {file = "greenlet-3.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a53dfe8f82b715319e9953330fa5c8708b610d48b5c59f1316337302af5c0811"}, + {file = "greenlet-3.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:28fe80a3eb673b2d5cc3b12eea468a5e5f4603c26aa34d88bf61bba82ceb2f9b"}, + {file = "greenlet-3.1.0-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:76b3e3976d2a452cba7aa9e453498ac72240d43030fdc6d538a72b87eaff52fd"}, + {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:655b21ffd37a96b1e78cc48bf254f5ea4b5b85efaf9e9e2a526b3c9309d660ca"}, + {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c6f4c2027689093775fd58ca2388d58789009116844432d920e9147f91acbe64"}, + {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:76e5064fd8e94c3f74d9fd69b02d99e3cdb8fc286ed49a1f10b256e59d0d3a0b"}, + {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6a4bf607f690f7987ab3291406e012cd8591a4f77aa54f29b890f9c331e84989"}, + {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:037d9ac99540ace9424cb9ea89f0accfaff4316f149520b4ae293eebc5bded17"}, + {file = "greenlet-3.1.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:90b5bbf05fe3d3ef697103850c2ce3374558f6fe40fd57c9fac1bf14903f50a5"}, + {file = "greenlet-3.1.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:726377bd60081172685c0ff46afbc600d064f01053190e4450857483c4d44484"}, + {file = "greenlet-3.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:d46d5069e2eeda111d6f71970e341f4bd9aeeee92074e649ae263b834286ecc0"}, + {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81eeec4403a7d7684b5812a8aaa626fa23b7d0848edb3a28d2eb3220daddcbd0"}, + {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4a3dae7492d16e85ea6045fd11cb8e782b63eac8c8d520c3a92c02ac4573b0a6"}, + {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4b5ea3664eed571779403858d7cd0a9b0ebf50d57d2cdeafc7748e09ef8cd81a"}, + {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a22f4e26400f7f48faef2d69c20dc055a1f3043d330923f9abe08ea0aecc44df"}, + {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:13ff8c8e54a10472ce3b2a2da007f915175192f18e6495bad50486e87c7f6637"}, + {file = "greenlet-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9671e7282d8c6fcabc32c0fb8d7c0ea8894ae85cee89c9aadc2d7129e1a9954"}, + {file = "greenlet-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:184258372ae9e1e9bddce6f187967f2e08ecd16906557c4320e3ba88a93438c3"}, + {file = "greenlet-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:a0409bc18a9f85321399c29baf93545152d74a49d92f2f55302f122007cfda00"}, + {file = "greenlet-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9eb4a1d7399b9f3c7ac68ae6baa6be5f9195d1d08c9ddc45ad559aa6b556bce6"}, + {file = "greenlet-3.1.0-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:a8870983af660798dc1b529e1fd6f1cefd94e45135a32e58bd70edd694540f33"}, + {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cfcfb73aed40f550a57ea904629bdaf2e562c68fa1164fa4588e752af6efdc3f"}, + {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f9482c2ed414781c0af0b35d9d575226da6b728bd1a720668fa05837184965b7"}, + {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d58ec349e0c2c0bc6669bf2cd4982d2f93bf067860d23a0ea1fe677b0f0b1e09"}, + {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd65695a8df1233309b701dec2539cc4b11e97d4fcc0f4185b4a12ce54db0491"}, + {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:665b21e95bc0fce5cab03b2e1d90ba9c66c510f1bb5fdc864f3a377d0f553f6b"}, + {file = "greenlet-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:d3c59a06c2c28a81a026ff11fbf012081ea34fb9b7052f2ed0366e14896f0a1d"}, + {file = "greenlet-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:5415b9494ff6240b09af06b91a375731febe0090218e2898d2b85f9b92abcda0"}, + {file = "greenlet-3.1.0-cp38-cp38-win32.whl", hash = "sha256:1544b8dd090b494c55e60c4ff46e238be44fdc472d2589e943c241e0169bcea2"}, + {file = "greenlet-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:7f346d24d74c00b6730440f5eb8ec3fe5774ca8d1c9574e8e57c8671bb51b910"}, + {file = "greenlet-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:db1b3ccb93488328c74e97ff888604a8b95ae4f35f4f56677ca57a4fc3a4220b"}, + {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44cd313629ded43bb3b98737bba2f3e2c2c8679b55ea29ed73daea6b755fe8e7"}, + {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fad7a051e07f64e297e6e8399b4d6a3bdcad3d7297409e9a06ef8cbccff4f501"}, + {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3967dcc1cd2ea61b08b0b276659242cbce5caca39e7cbc02408222fb9e6ff39"}, + {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d45b75b0f3fd8d99f62eb7908cfa6d727b7ed190737dec7fe46d993da550b81a"}, + {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2d004db911ed7b6218ec5c5bfe4cf70ae8aa2223dffbb5b3c69e342bb253cb28"}, + {file = "greenlet-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b9505a0c8579899057cbefd4ec34d865ab99852baf1ff33a9481eb3924e2da0b"}, + {file = "greenlet-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fd6e94593f6f9714dbad1aaba734b5ec04593374fa6638df61592055868f8b8"}, + {file = "greenlet-3.1.0-cp39-cp39-win32.whl", hash = "sha256:d0dd943282231480aad5f50f89bdf26690c995e8ff555f26d8a5b9887b559bcc"}, + {file = "greenlet-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:ac0adfdb3a21dc2a24ed728b61e72440d297d0fd3a577389df566651fcd08f97"}, + {file = "greenlet-3.1.0.tar.gz", hash = "sha256:b395121e9bbe8d02a750886f108d540abe66075e61e22f7353d9acb0b81be0f0"}, ] [package.extras] @@ -688,13 +695,13 @@ test = ["objgraph", "psutil"] [[package]] name = "gunicorn" -version = "22.0.0" +version = "23.0.0" description = "WSGI HTTP Server for UNIX" optional = false python-versions = ">=3.7" files = [ - {file = "gunicorn-22.0.0-py3-none-any.whl", hash = "sha256:350679f91b24062c86e386e198a15438d53a7a8207235a78ba1b53df4c4378d9"}, - {file = "gunicorn-22.0.0.tar.gz", hash = "sha256:4a0b436239ff76fb33f11c07a16482c521a7e09c1ce3cc293c2330afe01bec63"}, + {file = "gunicorn-23.0.0-py3-none-any.whl", hash = "sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d"}, + {file = "gunicorn-23.0.0.tar.gz", hash = "sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec"}, ] [package.dependencies] @@ -741,13 +748,13 @@ trio = ["trio (>=0.22.0,<0.26.0)"] [[package]] name = "httpx" -version = "0.27.0" +version = "0.27.2" description = "The next generation HTTP client." optional = false python-versions = ">=3.8" files = [ - {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, - {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, + {file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"}, + {file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"}, ] [package.dependencies] @@ -762,16 +769,17 @@ brotli = ["brotli", "brotlicffi"] cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] +zstd = ["zstandard (>=0.18.0)"] [[package]] name = "identify" -version = "2.6.0" +version = "2.6.1" description = "File identification library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "identify-2.6.0-py2.py3-none-any.whl", hash = "sha256:e79ae4406387a9d300332b5fd366d8994f1525e8414984e1a59e058b2eda2dd0"}, - {file = "identify-2.6.0.tar.gz", hash = "sha256:cb171c685bdc31bcc4c1734698736a7d5b6c8bf2e0c15117f4d469c8640ae5cf"}, + {file = "identify-2.6.1-py2.py3-none-any.whl", hash = "sha256:53863bcac7caf8d2ed85bd20312ea5dcfc22226800f6d6881f232d861db5a8f0"}, + {file = "identify-2.6.1.tar.gz", hash = "sha256:91478c5fb7c3aac5ff7bf9b4344f803843dc586832d5f110d672b19aa1984c98"}, ] [package.extras] @@ -779,54 +787,39 @@ license = ["ukkonen"] [[package]] name = "idna" -version = "3.8" +version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" files = [ - {file = "idna-3.8-py3-none-any.whl", hash = "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac"}, - {file = "idna-3.8.tar.gz", hash = "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603"}, + {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, + {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, ] +[package.extras] +all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] + [[package]] name = "importlib-metadata" -version = "8.4.0" +version = "8.5.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-8.4.0-py3-none-any.whl", hash = "sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1"}, - {file = "importlib_metadata-8.4.0.tar.gz", hash = "sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5"}, + {file = "importlib_metadata-8.5.0-py3-none-any.whl", hash = "sha256:45e54197d28b7a7f1559e60b95e7c567032b602131fbd588f1497f47880aa68b"}, + {file = "importlib_metadata-8.5.0.tar.gz", hash = "sha256:71522656f0abace1d072b9e5481a48f07c138e00f079c38c8f883823f9c26bd7"}, ] [package.dependencies] -zipp = ">=0.5" - -[package.extras] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] - -[[package]] -name = "importlib-resources" -version = "6.4.4" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_resources-6.4.4-py3-none-any.whl", hash = "sha256:dda242603d1c9cd836c3368b1174ed74cb4049ecd209e7a1a0104620c18c5c11"}, - {file = "importlib_resources-6.4.4.tar.gz", hash = "sha256:20600c8b7361938dc0bb2d5ec0297802e575df486f5a544fa414da65e13721f7"}, -] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} +zipp = ">=3.20" [package.extras] check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] enabler = ["pytest-enabler (>=2.2)"] -test = ["jaraco.test (>=5.4)", "pytest (>=6,!=8.1.*)", "zipp (>=3.17)"] +perf = ["ipython"] +test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-perf (>=0.9.2)"] type = ["pytest-mypy"] [[package]] @@ -928,18 +921,17 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "keyring" -version = "25.3.0" +version = "25.4.0" description = "Store and access your passwords safely." optional = false python-versions = ">=3.8" files = [ - {file = "keyring-25.3.0-py3-none-any.whl", hash = "sha256:8d963da00ccdf06e356acd9bf3b743208878751032d8599c6cc89eb51310ffae"}, - {file = "keyring-25.3.0.tar.gz", hash = "sha256:8d85a1ea5d6db8515b59e1c5d1d1678b03cf7fc8b8dcfb1651e8c4a524eb42ef"}, + {file = "keyring-25.4.0-py3-none-any.whl", hash = "sha256:a2a630d5c9bef5d3f0968d15ef4e42b894a83e17494edcb67b154c36491c9920"}, + {file = "keyring-25.4.0.tar.gz", hash = "sha256:ae8263fd9264c94f91ad82d098f8a5bb1b7fa71ce0a72388dc4fc0be3f6a034e"}, ] [package.dependencies] importlib-metadata = {version = ">=4.11.4", markers = "python_version < \"3.12\""} -importlib-resources = {version = "*", markers = "python_version < \"3.9\""} "jaraco.classes" = "*" "jaraco.context" = "*" "jaraco.functools" = "*" @@ -948,9 +940,13 @@ pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} SecretStorage = {version = ">=3.2", markers = "sys_platform == \"linux\""} [package.extras] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] completion = ["shtab (>=1.1.0)"] +cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -test = ["pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["pyfakefs", "pytest (>=6,!=8.1.*)"] +type = ["pygobject-stubs", "pytest-mypy", "shtab", "types-pywin32"] [[package]] name = "lazy-loader" @@ -1096,13 +1092,13 @@ files = [ [[package]] name = "more-itertools" -version = "10.4.0" +version = "10.5.0" description = "More routines for operating on iterables, beyond itertools" optional = false python-versions = ">=3.8" files = [ - {file = "more-itertools-10.4.0.tar.gz", hash = "sha256:fe0e63c4ab068eac62410ab05cccca2dc71ec44ba8ef29916a0090df061cf923"}, - {file = "more_itertools-10.4.0-py3-none-any.whl", hash = "sha256:0f7d9f83a0a8dcfa8a2694a770590d98a67ea943e3d9f5298309a484758c4e27"}, + {file = "more-itertools-10.5.0.tar.gz", hash = "sha256:5482bfef7849c25dc3c6dd53a6173ae4795da2a41a80faea6700d9f5846c5da6"}, + {file = "more_itertools-10.5.0-py3-none-any.whl", hash = "sha256:037b0d3203ce90cca8ab1defbbdac29d5f993fc20131f3664dc8d6acfa872aef"}, ] [[package]] @@ -1143,154 +1139,64 @@ files = [ [[package]] name = "numpy" -version = "1.24.4" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "numpy-1.24.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0bfb52d2169d58c1cdb8cc1f16989101639b34c7d3ce60ed70b19c63eba0b64"}, - {file = "numpy-1.24.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ed094d4f0c177b1b8e7aa9cba7d6ceed51c0e569a5318ac0ca9a090680a6a1b1"}, - {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79fc682a374c4a8ed08b331bef9c5f582585d1048fa6d80bc6c35bc384eee9b4"}, - {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7ffe43c74893dbf38c2b0a1f5428760a1a9c98285553c89e12d70a96a7f3a4d6"}, - {file = "numpy-1.24.4-cp310-cp310-win32.whl", hash = "sha256:4c21decb6ea94057331e111a5bed9a79d335658c27ce2adb580fb4d54f2ad9bc"}, - {file = "numpy-1.24.4-cp310-cp310-win_amd64.whl", hash = "sha256:b4bea75e47d9586d31e892a7401f76e909712a0fd510f58f5337bea9572c571e"}, - {file = "numpy-1.24.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f136bab9c2cfd8da131132c2cf6cc27331dd6fae65f95f69dcd4ae3c3639c810"}, - {file = "numpy-1.24.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e2926dac25b313635e4d6cf4dc4e51c8c0ebfed60b801c799ffc4c32bf3d1254"}, - {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:222e40d0e2548690405b0b3c7b21d1169117391c2e82c378467ef9ab4c8f0da7"}, - {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7215847ce88a85ce39baf9e89070cb860c98fdddacbaa6c0da3ffb31b3350bd5"}, - {file = "numpy-1.24.4-cp311-cp311-win32.whl", hash = "sha256:4979217d7de511a8d57f4b4b5b2b965f707768440c17cb70fbf254c4b225238d"}, - {file = "numpy-1.24.4-cp311-cp311-win_amd64.whl", hash = "sha256:b7b1fc9864d7d39e28f41d089bfd6353cb5f27ecd9905348c24187a768c79694"}, - {file = "numpy-1.24.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1452241c290f3e2a312c137a9999cdbf63f78864d63c79039bda65ee86943f61"}, - {file = "numpy-1.24.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:04640dab83f7c6c85abf9cd729c5b65f1ebd0ccf9de90b270cd61935eef0197f"}, - {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5425b114831d1e77e4b5d812b69d11d962e104095a5b9c3b641a218abcc050e"}, - {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd80e219fd4c71fc3699fc1dadac5dcf4fd882bfc6f7ec53d30fa197b8ee22dc"}, - {file = "numpy-1.24.4-cp38-cp38-win32.whl", hash = "sha256:4602244f345453db537be5314d3983dbf5834a9701b7723ec28923e2889e0bb2"}, - {file = "numpy-1.24.4-cp38-cp38-win_amd64.whl", hash = "sha256:692f2e0f55794943c5bfff12b3f56f99af76f902fc47487bdfe97856de51a706"}, - {file = "numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2541312fbf09977f3b3ad449c4e5f4bb55d0dbf79226d7724211acc905049400"}, - {file = "numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9667575fb6d13c95f1b36aca12c5ee3356bf001b714fc354eb5465ce1609e62f"}, - {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3a86ed21e4f87050382c7bc96571755193c4c1392490744ac73d660e8f564a9"}, - {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d11efb4dbecbdf22508d55e48d9c8384db795e1b7b51ea735289ff96613ff74d"}, - {file = "numpy-1.24.4-cp39-cp39-win32.whl", hash = "sha256:6620c0acd41dbcb368610bb2f4d83145674040025e5536954782467100aa8835"}, - {file = "numpy-1.24.4-cp39-cp39-win_amd64.whl", hash = "sha256:befe2bf740fd8373cf56149a5c23a0f601e82869598d41f8e188a0e9869926f8"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:31f13e25b4e304632a4619d0e0777662c2ffea99fcae2029556b17d8ff958aef"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95f7ac6540e95bc440ad77f56e520da5bf877f87dca58bd095288dce8940532a"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e98f220aa76ca2a977fe435f5b04d7b3470c0a2e6312907b37ba6068f26787f2"}, - {file = "numpy-1.24.4.tar.gz", hash = "sha256:80f5e3a4e498641401868df4208b74581206afbee7cf7b8329daae82676d9463"}, -] - -[[package]] -name = "numpy" -version = "2.0.1" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.9" -files = [ - {file = "numpy-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0fbb536eac80e27a2793ffd787895242b7f18ef792563d742c2d673bfcb75134"}, - {file = "numpy-2.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:69ff563d43c69b1baba77af455dd0a839df8d25e8590e79c90fcbe1499ebde42"}, - {file = "numpy-2.0.1-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:1b902ce0e0a5bb7704556a217c4f63a7974f8f43e090aff03fcf262e0b135e02"}, - {file = "numpy-2.0.1-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:f1659887361a7151f89e79b276ed8dff3d75877df906328f14d8bb40bb4f5101"}, - {file = "numpy-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4658c398d65d1b25e1760de3157011a80375da861709abd7cef3bad65d6543f9"}, - {file = "numpy-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4127d4303b9ac9f94ca0441138acead39928938660ca58329fe156f84b9f3015"}, - {file = "numpy-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e5eeca8067ad04bc8a2a8731183d51d7cbaac66d86085d5f4766ee6bf19c7f87"}, - {file = "numpy-2.0.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:9adbd9bb520c866e1bfd7e10e1880a1f7749f1f6e5017686a5fbb9b72cf69f82"}, - {file = "numpy-2.0.1-cp310-cp310-win32.whl", hash = "sha256:7b9853803278db3bdcc6cd5beca37815b133e9e77ff3d4733c247414e78eb8d1"}, - {file = "numpy-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:81b0893a39bc5b865b8bf89e9ad7807e16717f19868e9d234bdaf9b1f1393868"}, - {file = "numpy-2.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:75b4e316c5902d8163ef9d423b1c3f2f6252226d1aa5cd8a0a03a7d01ffc6268"}, - {file = "numpy-2.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6e4eeb6eb2fced786e32e6d8df9e755ce5be920d17f7ce00bc38fcde8ccdbf9e"}, - {file = "numpy-2.0.1-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:a1e01dcaab205fbece13c1410253a9eea1b1c9b61d237b6fa59bcc46e8e89343"}, - {file = "numpy-2.0.1-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:a8fc2de81ad835d999113ddf87d1ea2b0f4704cbd947c948d2f5513deafe5a7b"}, - {file = "numpy-2.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5a3d94942c331dd4e0e1147f7a8699a4aa47dffc11bf8a1523c12af8b2e91bbe"}, - {file = "numpy-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15eb4eca47d36ec3f78cde0a3a2ee24cf05ca7396ef808dda2c0ddad7c2bde67"}, - {file = "numpy-2.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b83e16a5511d1b1f8a88cbabb1a6f6a499f82c062a4251892d9ad5d609863fb7"}, - {file = "numpy-2.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1f87fec1f9bc1efd23f4227becff04bd0e979e23ca50cc92ec88b38489db3b55"}, - {file = "numpy-2.0.1-cp311-cp311-win32.whl", hash = "sha256:36d3a9405fd7c511804dc56fc32974fa5533bdeb3cd1604d6b8ff1d292b819c4"}, - {file = "numpy-2.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:08458fbf403bff5e2b45f08eda195d4b0c9b35682311da5a5a0a0925b11b9bd8"}, - {file = "numpy-2.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6bf4e6f4a2a2e26655717a1983ef6324f2664d7011f6ef7482e8c0b3d51e82ac"}, - {file = "numpy-2.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7d6fddc5fe258d3328cd8e3d7d3e02234c5d70e01ebe377a6ab92adb14039cb4"}, - {file = "numpy-2.0.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:5daab361be6ddeb299a918a7c0864fa8618af66019138263247af405018b04e1"}, - {file = "numpy-2.0.1-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:ea2326a4dca88e4a274ba3a4405eb6c6467d3ffbd8c7d38632502eaae3820587"}, - {file = "numpy-2.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:529af13c5f4b7a932fb0e1911d3a75da204eff023ee5e0e79c1751564221a5c8"}, - {file = "numpy-2.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6790654cb13eab303d8402354fabd47472b24635700f631f041bd0b65e37298a"}, - {file = "numpy-2.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:cbab9fc9c391700e3e1287666dfd82d8666d10e69a6c4a09ab97574c0b7ee0a7"}, - {file = "numpy-2.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:99d0d92a5e3613c33a5f01db206a33f8fdf3d71f2912b0de1739894668b7a93b"}, - {file = "numpy-2.0.1-cp312-cp312-win32.whl", hash = "sha256:173a00b9995f73b79eb0191129f2455f1e34c203f559dd118636858cc452a1bf"}, - {file = "numpy-2.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:bb2124fdc6e62baae159ebcfa368708867eb56806804d005860b6007388df171"}, - {file = "numpy-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bfc085b28d62ff4009364e7ca34b80a9a080cbd97c2c0630bb5f7f770dae9414"}, - {file = "numpy-2.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8fae4ebbf95a179c1156fab0b142b74e4ba4204c87bde8d3d8b6f9c34c5825ef"}, - {file = "numpy-2.0.1-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:72dc22e9ec8f6eaa206deb1b1355eb2e253899d7347f5e2fae5f0af613741d06"}, - {file = "numpy-2.0.1-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:ec87f5f8aca726117a1c9b7083e7656a9d0d606eec7299cc067bb83d26f16e0c"}, - {file = "numpy-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f682ea61a88479d9498bf2091fdcd722b090724b08b31d63e022adc063bad59"}, - {file = "numpy-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8efc84f01c1cd7e34b3fb310183e72fcdf55293ee736d679b6d35b35d80bba26"}, - {file = "numpy-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3fdabe3e2a52bc4eff8dc7a5044342f8bd9f11ef0934fcd3289a788c0eb10018"}, - {file = "numpy-2.0.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:24a0e1befbfa14615b49ba9659d3d8818a0f4d8a1c5822af8696706fbda7310c"}, - {file = "numpy-2.0.1-cp39-cp39-win32.whl", hash = "sha256:f9cf5ea551aec449206954b075db819f52adc1638d46a6738253a712d553c7b4"}, - {file = "numpy-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:e9e81fa9017eaa416c056e5d9e71be93d05e2c3c2ab308d23307a8bc4443c368"}, - {file = "numpy-2.0.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:61728fba1e464f789b11deb78a57805c70b2ed02343560456190d0501ba37b0f"}, - {file = "numpy-2.0.1-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:12f5d865d60fb9734e60a60f1d5afa6d962d8d4467c120a1c0cda6eb2964437d"}, - {file = "numpy-2.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eacf3291e263d5a67d8c1a581a8ebbcfd6447204ef58828caf69a5e3e8c75990"}, - {file = "numpy-2.0.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2c3a346ae20cfd80b6cfd3e60dc179963ef2ea58da5ec074fd3d9e7a1e7ba97f"}, - {file = "numpy-2.0.1.tar.gz", hash = "sha256:485b87235796410c3519a699cfe1faab097e509e90ebb05dcd098db2ae87e7b3"}, -] - -[[package]] -name = "numpy" -version = "2.1.0" +version = "2.1.1" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.10" files = [ - {file = "numpy-2.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6326ab99b52fafdcdeccf602d6286191a79fe2fda0ae90573c5814cd2b0bc1b8"}, - {file = "numpy-2.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0937e54c09f7a9a68da6889362ddd2ff584c02d015ec92672c099b61555f8911"}, - {file = "numpy-2.1.0-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:30014b234f07b5fec20f4146f69e13cfb1e33ee9a18a1879a0142fbb00d47673"}, - {file = "numpy-2.1.0-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:899da829b362ade41e1e7eccad2cf274035e1cb36ba73034946fccd4afd8606b"}, - {file = "numpy-2.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:08801848a40aea24ce16c2ecde3b756f9ad756586fb2d13210939eb69b023f5b"}, - {file = "numpy-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:398049e237d1aae53d82a416dade04defed1a47f87d18d5bd615b6e7d7e41d1f"}, - {file = "numpy-2.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0abb3916a35d9090088a748636b2c06dc9a6542f99cd476979fb156a18192b84"}, - {file = "numpy-2.1.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:10e2350aea18d04832319aac0f887d5fcec1b36abd485d14f173e3e900b83e33"}, - {file = "numpy-2.1.0-cp310-cp310-win32.whl", hash = "sha256:f6b26e6c3b98adb648243670fddc8cab6ae17473f9dc58c51574af3e64d61211"}, - {file = "numpy-2.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:f505264735ee074250a9c78247ee8618292091d9d1fcc023290e9ac67e8f1afa"}, - {file = "numpy-2.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:76368c788ccb4f4782cf9c842b316140142b4cbf22ff8db82724e82fe1205dce"}, - {file = "numpy-2.1.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:f8e93a01a35be08d31ae33021e5268f157a2d60ebd643cfc15de6ab8e4722eb1"}, - {file = "numpy-2.1.0-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:9523f8b46485db6939bd069b28b642fec86c30909cea90ef550373787f79530e"}, - {file = "numpy-2.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:54139e0eb219f52f60656d163cbe67c31ede51d13236c950145473504fa208cb"}, - {file = "numpy-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5ebbf9fbdabed208d4ecd2e1dfd2c0741af2f876e7ae522c2537d404ca895c3"}, - {file = "numpy-2.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:378cb4f24c7d93066ee4103204f73ed046eb88f9ad5bb2275bb9fa0f6a02bd36"}, - {file = "numpy-2.1.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d8f699a709120b220dfe173f79c73cb2a2cab2c0b88dd59d7b49407d032b8ebd"}, - {file = "numpy-2.1.0-cp311-cp311-win32.whl", hash = "sha256:ffbd6faeb190aaf2b5e9024bac9622d2ee549b7ec89ef3a9373fa35313d44e0e"}, - {file = "numpy-2.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:0af3a5987f59d9c529c022c8c2a64805b339b7ef506509fba7d0556649b9714b"}, - {file = "numpy-2.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:fe76d75b345dc045acdbc006adcb197cc680754afd6c259de60d358d60c93736"}, - {file = "numpy-2.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f358ea9e47eb3c2d6eba121ab512dfff38a88db719c38d1e67349af210bc7529"}, - {file = "numpy-2.1.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:dd94ce596bda40a9618324547cfaaf6650b1a24f5390350142499aa4e34e53d1"}, - {file = "numpy-2.1.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:b47c551c6724960479cefd7353656498b86e7232429e3a41ab83be4da1b109e8"}, - {file = "numpy-2.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0756a179afa766ad7cb6f036de622e8a8f16ffdd55aa31f296c870b5679d745"}, - {file = "numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24003ba8ff22ea29a8c306e61d316ac74111cebf942afbf692df65509a05f111"}, - {file = "numpy-2.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:b34fa5e3b5d6dc7e0a4243fa0f81367027cb6f4a7215a17852979634b5544ee0"}, - {file = "numpy-2.1.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c4f982715e65036c34897eb598d64aef15150c447be2cfc6643ec7a11af06574"}, - {file = "numpy-2.1.0-cp312-cp312-win32.whl", hash = "sha256:c4cd94dfefbefec3f8b544f61286584292d740e6e9d4677769bc76b8f41deb02"}, - {file = "numpy-2.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0cdef204199278f5c461a0bed6ed2e052998276e6d8ab2963d5b5c39a0500bc"}, - {file = "numpy-2.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8ab81ccd753859ab89e67199b9da62c543850f819993761c1e94a75a814ed667"}, - {file = "numpy-2.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:442596f01913656d579309edcd179a2a2f9977d9a14ff41d042475280fc7f34e"}, - {file = "numpy-2.1.0-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:848c6b5cad9898e4b9ef251b6f934fa34630371f2e916261070a4eb9092ffd33"}, - {file = "numpy-2.1.0-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:54c6a63e9d81efe64bfb7bcb0ec64332a87d0b87575f6009c8ba67ea6374770b"}, - {file = "numpy-2.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:652e92fc409e278abdd61e9505649e3938f6d04ce7ef1953f2ec598a50e7c195"}, - {file = "numpy-2.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ab32eb9170bf8ffcbb14f11613f4a0b108d3ffee0832457c5d4808233ba8977"}, - {file = "numpy-2.1.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:8fb49a0ba4d8f41198ae2d52118b050fd34dace4b8f3fb0ee34e23eb4ae775b1"}, - {file = "numpy-2.1.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:44e44973262dc3ae79e9063a1284a73e09d01b894b534a769732ccd46c28cc62"}, - {file = "numpy-2.1.0-cp313-cp313-win32.whl", hash = "sha256:ab83adc099ec62e044b1fbb3a05499fa1e99f6d53a1dde102b2d85eff66ed324"}, - {file = "numpy-2.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:de844aaa4815b78f6023832590d77da0e3b6805c644c33ce94a1e449f16d6ab5"}, - {file = "numpy-2.1.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:343e3e152bf5a087511cd325e3b7ecfd5b92d369e80e74c12cd87826e263ec06"}, - {file = "numpy-2.1.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:f07fa2f15dabe91259828ce7d71b5ca9e2eb7c8c26baa822c825ce43552f4883"}, - {file = "numpy-2.1.0-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:5474dad8c86ee9ba9bb776f4b99ef2d41b3b8f4e0d199d4f7304728ed34d0300"}, - {file = "numpy-2.1.0-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1f817c71683fd1bb5cff1529a1d085a57f02ccd2ebc5cd2c566f9a01118e3b7d"}, - {file = "numpy-2.1.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a3336fbfa0d38d3deacd3fe7f3d07e13597f29c13abf4d15c3b6dc2291cbbdd"}, - {file = "numpy-2.1.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a894c51fd8c4e834f00ac742abad73fc485df1062f1b875661a3c1e1fb1c2f6"}, - {file = "numpy-2.1.0-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:9156ca1f79fc4acc226696e95bfcc2b486f165a6a59ebe22b2c1f82ab190384a"}, - {file = "numpy-2.1.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:624884b572dff8ca8f60fab591413f077471de64e376b17d291b19f56504b2bb"}, - {file = "numpy-2.1.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:15ef8b2177eeb7e37dd5ef4016f30b7659c57c2c0b57a779f1d537ff33a72c7b"}, - {file = "numpy-2.1.0-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:e5f0642cdf4636198a4990de7a71b693d824c56a757862230454629cf62e323d"}, - {file = "numpy-2.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f15976718c004466406342789f31b6673776360f3b1e3c575f25302d7e789575"}, - {file = "numpy-2.1.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:6c1de77ded79fef664d5098a66810d4d27ca0224e9051906e634b3f7ead134c2"}, - {file = "numpy-2.1.0.tar.gz", hash = "sha256:7dc90da0081f7e1da49ec4e398ede6a8e9cc4f5ebe5f9e06b443ed889ee9aaa2"}, + {file = "numpy-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c8a0e34993b510fc19b9a2ce7f31cb8e94ecf6e924a40c0c9dd4f62d0aac47d9"}, + {file = "numpy-2.1.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:7dd86dfaf7c900c0bbdcb8b16e2f6ddf1eb1fe39c6c8cca6e94844ed3152a8fd"}, + {file = "numpy-2.1.1-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:5889dd24f03ca5a5b1e8a90a33b5a0846d8977565e4ae003a63d22ecddf6782f"}, + {file = "numpy-2.1.1-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:59ca673ad11d4b84ceb385290ed0ebe60266e356641428c845b39cd9df6713ab"}, + {file = "numpy-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:13ce49a34c44b6de5241f0b38b07e44c1b2dcacd9e36c30f9c2fcb1bb5135db7"}, + {file = "numpy-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:913cc1d311060b1d409e609947fa1b9753701dac96e6581b58afc36b7ee35af6"}, + {file = "numpy-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:caf5d284ddea7462c32b8d4a6b8af030b6c9fd5332afb70e7414d7fdded4bfd0"}, + {file = "numpy-2.1.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:57eb525e7c2a8fdee02d731f647146ff54ea8c973364f3b850069ffb42799647"}, + {file = "numpy-2.1.1-cp310-cp310-win32.whl", hash = "sha256:9a8e06c7a980869ea67bbf551283bbed2856915f0a792dc32dd0f9dd2fb56728"}, + {file = "numpy-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:d10c39947a2d351d6d466b4ae83dad4c37cd6c3cdd6d5d0fa797da56f710a6ae"}, + {file = "numpy-2.1.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0d07841fd284718feffe7dd17a63a2e6c78679b2d386d3e82f44f0108c905550"}, + {file = "numpy-2.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b5613cfeb1adfe791e8e681128f5f49f22f3fcaa942255a6124d58ca59d9528f"}, + {file = "numpy-2.1.1-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:0b8cc2715a84b7c3b161f9ebbd942740aaed913584cae9cdc7f8ad5ad41943d0"}, + {file = "numpy-2.1.1-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:b49742cdb85f1f81e4dc1b39dcf328244f4d8d1ded95dea725b316bd2cf18c95"}, + {file = "numpy-2.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8d5f8a8e3bc87334f025194c6193e408903d21ebaeb10952264943a985066ca"}, + {file = "numpy-2.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d51fc141ddbe3f919e91a096ec739f49d686df8af254b2053ba21a910ae518bf"}, + {file = "numpy-2.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:98ce7fb5b8063cfdd86596b9c762bf2b5e35a2cdd7e967494ab78a1fa7f8b86e"}, + {file = "numpy-2.1.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:24c2ad697bd8593887b019817ddd9974a7f429c14a5469d7fad413f28340a6d2"}, + {file = "numpy-2.1.1-cp311-cp311-win32.whl", hash = "sha256:397bc5ce62d3fb73f304bec332171535c187e0643e176a6e9421a6e3eacef06d"}, + {file = "numpy-2.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:ae8ce252404cdd4de56dcfce8b11eac3c594a9c16c231d081fb705cf23bd4d9e"}, + {file = "numpy-2.1.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:7c803b7934a7f59563db459292e6aa078bb38b7ab1446ca38dd138646a38203e"}, + {file = "numpy-2.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6435c48250c12f001920f0751fe50c0348f5f240852cfddc5e2f97e007544cbe"}, + {file = "numpy-2.1.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:3269c9eb8745e8d975980b3a7411a98976824e1fdef11f0aacf76147f662b15f"}, + {file = "numpy-2.1.1-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:fac6e277a41163d27dfab5f4ec1f7a83fac94e170665a4a50191b545721c6521"}, + {file = "numpy-2.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fcd8f556cdc8cfe35e70efb92463082b7f43dd7e547eb071ffc36abc0ca4699b"}, + {file = "numpy-2.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b9cd92c8f8e7b313b80e93cedc12c0112088541dcedd9197b5dee3738c1201"}, + {file = "numpy-2.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:afd9c680df4de71cd58582b51e88a61feed4abcc7530bcd3d48483f20fc76f2a"}, + {file = "numpy-2.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8661c94e3aad18e1ea17a11f60f843a4933ccaf1a25a7c6a9182af70610b2313"}, + {file = "numpy-2.1.1-cp312-cp312-win32.whl", hash = "sha256:950802d17a33c07cba7fd7c3dcfa7d64705509206be1606f196d179e539111ed"}, + {file = "numpy-2.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:3fc5eabfc720db95d68e6646e88f8b399bfedd235994016351b1d9e062c4b270"}, + {file = "numpy-2.1.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:046356b19d7ad1890c751b99acad5e82dc4a02232013bd9a9a712fddf8eb60f5"}, + {file = "numpy-2.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:6e5a9cb2be39350ae6c8f79410744e80154df658d5bea06e06e0ac5bb75480d5"}, + {file = "numpy-2.1.1-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:d4c57b68c8ef5e1ebf47238e99bf27657511ec3f071c465f6b1bccbef12d4136"}, + {file = "numpy-2.1.1-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:8ae0fd135e0b157365ac7cc31fff27f07a5572bdfc38f9c2d43b2aff416cc8b0"}, + {file = "numpy-2.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:981707f6b31b59c0c24bcda52e5605f9701cb46da4b86c2e8023656ad3e833cb"}, + {file = "numpy-2.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ca4b53e1e0b279142113b8c5eb7d7a877e967c306edc34f3b58e9be12fda8df"}, + {file = "numpy-2.1.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:e097507396c0be4e547ff15b13dc3866f45f3680f789c1a1301b07dadd3fbc78"}, + {file = "numpy-2.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7506387e191fe8cdb267f912469a3cccc538ab108471291636a96a54e599556"}, + {file = "numpy-2.1.1-cp313-cp313-win32.whl", hash = "sha256:251105b7c42abe40e3a689881e1793370cc9724ad50d64b30b358bbb3a97553b"}, + {file = "numpy-2.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:f212d4f46b67ff604d11fff7cc62d36b3e8714edf68e44e9760e19be38c03eb0"}, + {file = "numpy-2.1.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:920b0911bb2e4414c50e55bd658baeb78281a47feeb064ab40c2b66ecba85553"}, + {file = "numpy-2.1.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:bab7c09454460a487e631ffc0c42057e3d8f2a9ddccd1e60c7bb8ed774992480"}, + {file = "numpy-2.1.1-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:cea427d1350f3fd0d2818ce7350095c1a2ee33e30961d2f0fef48576ddbbe90f"}, + {file = "numpy-2.1.1-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:e30356d530528a42eeba51420ae8bf6c6c09559051887196599d96ee5f536468"}, + {file = "numpy-2.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8dfa9e94fc127c40979c3eacbae1e61fda4fe71d84869cc129e2721973231ef"}, + {file = "numpy-2.1.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:910b47a6d0635ec1bd53b88f86120a52bf56dcc27b51f18c7b4a2e2224c29f0f"}, + {file = "numpy-2.1.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:13cc11c00000848702322af4de0147ced365c81d66053a67c2e962a485b3717c"}, + {file = "numpy-2.1.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:53e27293b3a2b661c03f79aa51c3987492bd4641ef933e366e0f9f6c9bf257ec"}, + {file = "numpy-2.1.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7be6a07520b88214ea85d8ac8b7d6d8a1839b0b5cb87412ac9f49fa934eb15d5"}, + {file = "numpy-2.1.1-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:52ac2e48f5ad847cd43c4755520a2317f3380213493b9d8a4c5e37f3b87df504"}, + {file = "numpy-2.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50a95ca3560a6058d6ea91d4629a83a897ee27c00630aed9d933dff191f170cd"}, + {file = "numpy-2.1.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:99f4a9ee60eed1385a86e82288971a51e71df052ed0b2900ed30bc840c0f2e39"}, + {file = "numpy-2.1.1.tar.gz", hash = "sha256:d0cf7d55b1051387807405b3898efafa862997b4cba8aa5dbe657be794afeafd"}, ] [[package]] @@ -1318,50 +1224,6 @@ files = [ {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] -[[package]] -name = "pandas" -version = "1.5.3" -description = "Powerful data structures for data analysis, time series, and statistics" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, - {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, - {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, - {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, - {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, - {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, - {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, - {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, -] - -[package.dependencies] -numpy = {version = ">=1.20.3", markers = "python_version < \"3.10\""} -python-dateutil = ">=2.8.1" -pytz = ">=2020.1" - -[package.extras] -test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] - [[package]] name = "pandas" version = "2.2.2" @@ -1402,8 +1264,8 @@ files = [ [package.dependencies] numpy = [ - {version = ">=1.23.2", markers = "python_version == \"3.11\""}, {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, + {version = ">=1.23.2", markers = "python_version == \"3.11\""}, {version = ">=1.22.4", markers = "python_version < \"3.11\""}, ] python-dateutil = ">=2.8.2" @@ -1577,29 +1439,29 @@ testing = ["pytest", "pytest-cov", "wheel"] [[package]] name = "platformdirs" -version = "4.2.2" +version = "4.3.6" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ - {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, - {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, + {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, + {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, ] [package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] -type = ["mypy (>=1.8)"] +docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"] +type = ["mypy (>=1.11.2)"] [[package]] name = "plotly" -version = "5.23.0" +version = "5.24.1" description = "An open-source, interactive data visualization library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "plotly-5.23.0-py3-none-any.whl", hash = "sha256:76cbe78f75eddc10c56f5a4ee3e7ccaade7c0a57465546f02098c0caed6c2d1a"}, - {file = "plotly-5.23.0.tar.gz", hash = "sha256:89e57d003a116303a34de6700862391367dd564222ab71f8531df70279fc0193"}, + {file = "plotly-5.24.1-py3-none-any.whl", hash = "sha256:f67073a1e637eb0dc3e46324d9d51e2fe76e9727c892dde64ddf1e1b51f29089"}, + {file = "plotly-5.24.1.tar.gz", hash = "sha256:dbc8ac8339d248a4bcc36e08a5659bacfe1b079390b8953533f4eb22169b4bae"}, ] [package.dependencies] @@ -1623,13 +1485,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.5.0" +version = "3.8.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, - {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, + {file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"}, + {file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"}, ] [package.dependencies] @@ -1692,122 +1554,123 @@ files = [ [[package]] name = "pydantic" -version = "2.8.2" +version = "2.9.2" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.8.2-py3-none-any.whl", hash = "sha256:73ee9fddd406dc318b885c7a2eab8a6472b68b8fb5ba8150949fc3db939f23c8"}, - {file = "pydantic-2.8.2.tar.gz", hash = "sha256:6f62c13d067b0755ad1c21a34bdd06c0c12625a22b0fc09c6b149816604f7c2a"}, + {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"}, + {file = "pydantic-2.9.2.tar.gz", hash = "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f"}, ] [package.dependencies] -annotated-types = ">=0.4.0" -pydantic-core = "2.20.1" +annotated-types = ">=0.6.0" +pydantic-core = "2.23.4" typing-extensions = [ - {version = ">=4.6.1", markers = "python_version < \"3.13\""}, {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, + {version = ">=4.6.1", markers = "python_version < \"3.13\""}, ] [package.extras] email = ["email-validator (>=2.0.0)"] +timezone = ["tzdata"] [[package]] name = "pydantic-core" -version = "2.20.1" +version = "2.23.4" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.20.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:3acae97ffd19bf091c72df4d726d552c473f3576409b2a7ca36b2f535ffff4a3"}, - {file = "pydantic_core-2.20.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:41f4c96227a67a013e7de5ff8f20fb496ce573893b7f4f2707d065907bffdbd6"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f239eb799a2081495ea659d8d4a43a8f42cd1fe9ff2e7e436295c38a10c286a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53e431da3fc53360db73eedf6f7124d1076e1b4ee4276b36fb25514544ceb4a3"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1f62b2413c3a0e846c3b838b2ecd6c7a19ec6793b2a522745b0869e37ab5bc1"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5d41e6daee2813ecceea8eda38062d69e280b39df793f5a942fa515b8ed67953"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d482efec8b7dc6bfaedc0f166b2ce349df0011f5d2f1f25537ced4cfc34fd98"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e93e1a4b4b33daed65d781a57a522ff153dcf748dee70b40c7258c5861e1768a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e7c4ea22b6739b162c9ecaaa41d718dfad48a244909fe7ef4b54c0b530effc5a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4f2790949cf385d985a31984907fecb3896999329103df4e4983a4a41e13e840"}, - {file = "pydantic_core-2.20.1-cp310-none-win32.whl", hash = "sha256:5e999ba8dd90e93d57410c5e67ebb67ffcaadcea0ad973240fdfd3a135506250"}, - {file = "pydantic_core-2.20.1-cp310-none-win_amd64.whl", hash = "sha256:512ecfbefef6dac7bc5eaaf46177b2de58cdf7acac8793fe033b24ece0b9566c"}, - {file = "pydantic_core-2.20.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d2a8fa9d6d6f891f3deec72f5cc668e6f66b188ab14bb1ab52422fe8e644f312"}, - {file = "pydantic_core-2.20.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:175873691124f3d0da55aeea1d90660a6ea7a3cfea137c38afa0a5ffabe37b88"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37eee5b638f0e0dcd18d21f59b679686bbd18917b87db0193ae36f9c23c355fc"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25e9185e2d06c16ee438ed39bf62935ec436474a6ac4f9358524220f1b236e43"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:150906b40ff188a3260cbee25380e7494ee85048584998c1e66df0c7a11c17a6"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ad4aeb3e9a97286573c03df758fc7627aecdd02f1da04516a86dc159bf70121"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3f3ed29cd9f978c604708511a1f9c2fdcb6c38b9aae36a51905b8811ee5cbf1"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b0dae11d8f5ded51699c74d9548dcc5938e0804cc8298ec0aa0da95c21fff57b"}, - {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:faa6b09ee09433b87992fb5a2859efd1c264ddc37280d2dd5db502126d0e7f27"}, - {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9dc1b507c12eb0481d071f3c1808f0529ad41dc415d0ca11f7ebfc666e66a18b"}, - {file = "pydantic_core-2.20.1-cp311-none-win32.whl", hash = "sha256:fa2fddcb7107e0d1808086ca306dcade7df60a13a6c347a7acf1ec139aa6789a"}, - {file = "pydantic_core-2.20.1-cp311-none-win_amd64.whl", hash = "sha256:40a783fb7ee353c50bd3853e626f15677ea527ae556429453685ae32280c19c2"}, - {file = "pydantic_core-2.20.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:595ba5be69b35777474fa07f80fc260ea71255656191adb22a8c53aba4479231"}, - {file = "pydantic_core-2.20.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a4f55095ad087474999ee28d3398bae183a66be4823f753cd7d67dd0153427c9"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9aa05d09ecf4c75157197f27cdc9cfaeb7c5f15021c6373932bf3e124af029f"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e97fdf088d4b31ff4ba35db26d9cc472ac7ef4a2ff2badeabf8d727b3377fc52"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc633a9fe1eb87e250b5c57d389cf28998e4292336926b0b6cdaee353f89a237"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d573faf8eb7e6b1cbbcb4f5b247c60ca8be39fe2c674495df0eb4318303137fe"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26dc97754b57d2fd00ac2b24dfa341abffc380b823211994c4efac7f13b9e90e"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:33499e85e739a4b60c9dac710c20a08dc73cb3240c9a0e22325e671b27b70d24"}, - {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bebb4d6715c814597f85297c332297c6ce81e29436125ca59d1159b07f423eb1"}, - {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:516d9227919612425c8ef1c9b869bbbee249bc91912c8aaffb66116c0b447ebd"}, - {file = "pydantic_core-2.20.1-cp312-none-win32.whl", hash = "sha256:469f29f9093c9d834432034d33f5fe45699e664f12a13bf38c04967ce233d688"}, - {file = "pydantic_core-2.20.1-cp312-none-win_amd64.whl", hash = "sha256:035ede2e16da7281041f0e626459bcae33ed998cca6a0a007a5ebb73414ac72d"}, - {file = "pydantic_core-2.20.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0827505a5c87e8aa285dc31e9ec7f4a17c81a813d45f70b1d9164e03a813a686"}, - {file = "pydantic_core-2.20.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19c0fa39fa154e7e0b7f82f88ef85faa2a4c23cc65aae2f5aea625e3c13c735a"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa223cd1e36b642092c326d694d8bf59b71ddddc94cdb752bbbb1c5c91d833b"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c336a6d235522a62fef872c6295a42ecb0c4e1d0f1a3e500fe949415761b8a19"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7eb6a0587eded33aeefea9f916899d42b1799b7b14b8f8ff2753c0ac1741edac"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:70c8daf4faca8da5a6d655f9af86faf6ec2e1768f4b8b9d0226c02f3d6209703"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e9fa4c9bf273ca41f940bceb86922a7667cd5bf90e95dbb157cbb8441008482c"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:11b71d67b4725e7e2a9f6e9c0ac1239bbc0c48cce3dc59f98635efc57d6dac83"}, - {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:270755f15174fb983890c49881e93f8f1b80f0b5e3a3cc1394a255706cabd203"}, - {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c81131869240e3e568916ef4c307f8b99583efaa60a8112ef27a366eefba8ef0"}, - {file = "pydantic_core-2.20.1-cp313-none-win32.whl", hash = "sha256:b91ced227c41aa29c672814f50dbb05ec93536abf8f43cd14ec9521ea09afe4e"}, - {file = "pydantic_core-2.20.1-cp313-none-win_amd64.whl", hash = "sha256:65db0f2eefcaad1a3950f498aabb4875c8890438bc80b19362cf633b87a8ab20"}, - {file = "pydantic_core-2.20.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:4745f4ac52cc6686390c40eaa01d48b18997cb130833154801a442323cc78f91"}, - {file = "pydantic_core-2.20.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a8ad4c766d3f33ba8fd692f9aa297c9058970530a32c728a2c4bfd2616d3358b"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41e81317dd6a0127cabce83c0c9c3fbecceae981c8391e6f1dec88a77c8a569a"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:04024d270cf63f586ad41fff13fde4311c4fc13ea74676962c876d9577bcc78f"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eaad4ff2de1c3823fddf82f41121bdf453d922e9a238642b1dedb33c4e4f98ad"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26ab812fa0c845df815e506be30337e2df27e88399b985d0bb4e3ecfe72df31c"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c5ebac750d9d5f2706654c638c041635c385596caf68f81342011ddfa1e5598"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2aafc5a503855ea5885559eae883978c9b6d8c8993d67766ee73d82e841300dd"}, - {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4868f6bd7c9d98904b748a2653031fc9c2f85b6237009d475b1008bfaeb0a5aa"}, - {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa2f457b4af386254372dfa78a2eda2563680d982422641a85f271c859df1987"}, - {file = "pydantic_core-2.20.1-cp38-none-win32.whl", hash = "sha256:225b67a1f6d602de0ce7f6c1c3ae89a4aa25d3de9be857999e9124f15dab486a"}, - {file = "pydantic_core-2.20.1-cp38-none-win_amd64.whl", hash = "sha256:6b507132dcfc0dea440cce23ee2182c0ce7aba7054576efc65634f080dbe9434"}, - {file = "pydantic_core-2.20.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:b03f7941783b4c4a26051846dea594628b38f6940a2fdc0df00b221aed39314c"}, - {file = "pydantic_core-2.20.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1eedfeb6089ed3fad42e81a67755846ad4dcc14d73698c120a82e4ccf0f1f9f6"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:635fee4e041ab9c479e31edda27fcf966ea9614fff1317e280d99eb3e5ab6fe2"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:77bf3ac639c1ff567ae3b47f8d4cc3dc20f9966a2a6dd2311dcc055d3d04fb8a"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ed1b0132f24beeec5a78b67d9388656d03e6a7c837394f99257e2d55b461611"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c6514f963b023aeee506678a1cf821fe31159b925c4b76fe2afa94cc70b3222b"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10d4204d8ca33146e761c79f83cc861df20e7ae9f6487ca290a97702daf56006"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d036c7187b9422ae5b262badb87a20a49eb6c5238b2004e96d4da1231badef1"}, - {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9ebfef07dbe1d93efb94b4700f2d278494e9162565a54f124c404a5656d7ff09"}, - {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6b9d9bb600328a1ce523ab4f454859e9d439150abb0906c5a1983c146580ebab"}, - {file = "pydantic_core-2.20.1-cp39-none-win32.whl", hash = "sha256:784c1214cb6dd1e3b15dd8b91b9a53852aed16671cc3fbe4786f4f1db07089e2"}, - {file = "pydantic_core-2.20.1-cp39-none-win_amd64.whl", hash = "sha256:d2fe69c5434391727efa54b47a1e7986bb0186e72a41b203df8f5b0a19a4f669"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a45f84b09ac9c3d35dfcf6a27fd0634d30d183205230a0ebe8373a0e8cfa0906"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d02a72df14dfdbaf228424573a07af10637bd490f0901cee872c4f434a735b94"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d2b27e6af28f07e2f195552b37d7d66b150adbaa39a6d327766ffd695799780f"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:084659fac3c83fd674596612aeff6041a18402f1e1bc19ca39e417d554468482"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:242b8feb3c493ab78be289c034a1f659e8826e2233786e36f2893a950a719bb6"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:38cf1c40a921d05c5edc61a785c0ddb4bed67827069f535d794ce6bcded919fc"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e0bbdd76ce9aa5d4209d65f2b27fc6e5ef1312ae6c5333c26db3f5ade53a1e99"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:254ec27fdb5b1ee60684f91683be95e5133c994cc54e86a0b0963afa25c8f8a6"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:407653af5617f0757261ae249d3fba09504d7a71ab36ac057c938572d1bc9331"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:c693e916709c2465b02ca0ad7b387c4f8423d1db7b4649c551f27a529181c5ad"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b5ff4911aea936a47d9376fd3ab17e970cc543d1b68921886e7f64bd28308d1"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:177f55a886d74f1808763976ac4efd29b7ed15c69f4d838bbd74d9d09cf6fa86"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:964faa8a861d2664f0c7ab0c181af0bea66098b1919439815ca8803ef136fc4e"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:4dd484681c15e6b9a977c785a345d3e378d72678fd5f1f3c0509608da24f2ac0"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f6d6cff3538391e8486a431569b77921adfcdef14eb18fbf19b7c0a5294d4e6a"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a6d511cc297ff0883bc3708b465ff82d7560193169a8b93260f74ecb0a5e08a7"}, - {file = "pydantic_core-2.20.1.tar.gz", hash = "sha256:26ca695eeee5f9f1aeeb211ffc12f10bcb6f71e2989988fda61dabd65db878d4"}, + {file = "pydantic_core-2.23.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:b10bd51f823d891193d4717448fab065733958bdb6a6b351967bd349d48d5c9b"}, + {file = "pydantic_core-2.23.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4fc714bdbfb534f94034efaa6eadd74e5b93c8fa6315565a222f7b6f42ca1166"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63e46b3169866bd62849936de036f901a9356e36376079b05efa83caeaa02ceb"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed1a53de42fbe34853ba90513cea21673481cd81ed1be739f7f2efb931b24916"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cfdd16ab5e59fc31b5e906d1a3f666571abc367598e3e02c83403acabc092e07"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:255a8ef062cbf6674450e668482456abac99a5583bbafb73f9ad469540a3a232"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a7cd62e831afe623fbb7aabbb4fe583212115b3ef38a9f6b71869ba644624a2"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f09e2ff1f17c2b51f2bc76d1cc33da96298f0a036a137f5440ab3ec5360b624f"}, + {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e38e63e6f3d1cec5a27e0afe90a085af8b6806ee208b33030e65b6516353f1a3"}, + {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0dbd8dbed2085ed23b5c04afa29d8fd2771674223135dc9bc937f3c09284d071"}, + {file = "pydantic_core-2.23.4-cp310-none-win32.whl", hash = "sha256:6531b7ca5f951d663c339002e91aaebda765ec7d61b7d1e3991051906ddde119"}, + {file = "pydantic_core-2.23.4-cp310-none-win_amd64.whl", hash = "sha256:7c9129eb40958b3d4500fa2467e6a83356b3b61bfff1b414c7361d9220f9ae8f"}, + {file = "pydantic_core-2.23.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:77733e3892bb0a7fa797826361ce8a9184d25c8dffaec60b7ffe928153680ba8"}, + {file = "pydantic_core-2.23.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b84d168f6c48fabd1f2027a3d1bdfe62f92cade1fb273a5d68e621da0e44e6d"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:df49e7a0861a8c36d089c1ed57d308623d60416dab2647a4a17fe050ba85de0e"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ff02b6d461a6de369f07ec15e465a88895f3223eb75073ffea56b84d9331f607"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:996a38a83508c54c78a5f41456b0103c30508fed9abcad0a59b876d7398f25fd"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d97683ddee4723ae8c95d1eddac7c192e8c552da0c73a925a89fa8649bf13eea"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:216f9b2d7713eb98cb83c80b9c794de1f6b7e3145eef40400c62e86cee5f4e1e"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6f783e0ec4803c787bcea93e13e9932edab72068f68ecffdf86a99fd5918878b"}, + {file = "pydantic_core-2.23.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:d0776dea117cf5272382634bd2a5c1b6eb16767c223c6a5317cd3e2a757c61a0"}, + {file = "pydantic_core-2.23.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d5f7a395a8cf1621939692dba2a6b6a830efa6b3cee787d82c7de1ad2930de64"}, + {file = "pydantic_core-2.23.4-cp311-none-win32.whl", hash = "sha256:74b9127ffea03643e998e0c5ad9bd3811d3dac8c676e47db17b0ee7c3c3bf35f"}, + {file = "pydantic_core-2.23.4-cp311-none-win_amd64.whl", hash = "sha256:98d134c954828488b153d88ba1f34e14259284f256180ce659e8d83e9c05eaa3"}, + {file = "pydantic_core-2.23.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f3e0da4ebaef65158d4dfd7d3678aad692f7666877df0002b8a522cdf088f231"}, + {file = "pydantic_core-2.23.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f69a8e0b033b747bb3e36a44e7732f0c99f7edd5cea723d45bc0d6e95377ffee"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:723314c1d51722ab28bfcd5240d858512ffd3116449c557a1336cbe3919beb87"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bb2802e667b7051a1bebbfe93684841cc9351004e2badbd6411bf357ab8d5ac8"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d18ca8148bebe1b0a382a27a8ee60350091a6ddaf475fa05ef50dc35b5df6327"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33e3d65a85a2a4a0dc3b092b938a4062b1a05f3a9abde65ea93b233bca0e03f2"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:128585782e5bfa515c590ccee4b727fb76925dd04a98864182b22e89a4e6ed36"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:68665f4c17edcceecc112dfed5dbe6f92261fb9d6054b47d01bf6371a6196126"}, + {file = "pydantic_core-2.23.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:20152074317d9bed6b7a95ade3b7d6054845d70584216160860425f4fbd5ee9e"}, + {file = "pydantic_core-2.23.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:9261d3ce84fa1d38ed649c3638feefeae23d32ba9182963e465d58d62203bd24"}, + {file = "pydantic_core-2.23.4-cp312-none-win32.whl", hash = "sha256:4ba762ed58e8d68657fc1281e9bb72e1c3e79cc5d464be146e260c541ec12d84"}, + {file = "pydantic_core-2.23.4-cp312-none-win_amd64.whl", hash = "sha256:97df63000f4fea395b2824da80e169731088656d1818a11b95f3b173747b6cd9"}, + {file = "pydantic_core-2.23.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:7530e201d10d7d14abce4fb54cfe5b94a0aefc87da539d0346a484ead376c3cc"}, + {file = "pydantic_core-2.23.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:df933278128ea1cd77772673c73954e53a1c95a4fdf41eef97c2b779271bd0bd"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cb3da3fd1b6a5d0279a01877713dbda118a2a4fc6f0d821a57da2e464793f05"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:42c6dcb030aefb668a2b7009c85b27f90e51e6a3b4d5c9bc4c57631292015b0d"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:696dd8d674d6ce621ab9d45b205df149399e4bb9aa34102c970b721554828510"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2971bb5ffe72cc0f555c13e19b23c85b654dd2a8f7ab493c262071377bfce9f6"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8394d940e5d400d04cad4f75c0598665cbb81aecefaca82ca85bd28264af7f9b"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0dff76e0602ca7d4cdaacc1ac4c005e0ce0dcfe095d5b5259163a80d3a10d327"}, + {file = "pydantic_core-2.23.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7d32706badfe136888bdea71c0def994644e09fff0bfe47441deaed8e96fdbc6"}, + {file = "pydantic_core-2.23.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ed541d70698978a20eb63d8c5d72f2cc6d7079d9d90f6b50bad07826f1320f5f"}, + {file = "pydantic_core-2.23.4-cp313-none-win32.whl", hash = "sha256:3d5639516376dce1940ea36edf408c554475369f5da2abd45d44621cb616f769"}, + {file = "pydantic_core-2.23.4-cp313-none-win_amd64.whl", hash = "sha256:5a1504ad17ba4210df3a045132a7baeeba5a200e930f57512ee02909fc5c4cb5"}, + {file = "pydantic_core-2.23.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:d4488a93b071c04dc20f5cecc3631fc78b9789dd72483ba15d423b5b3689b555"}, + {file = "pydantic_core-2.23.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:81965a16b675b35e1d09dd14df53f190f9129c0202356ed44ab2728b1c905658"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ffa2ebd4c8530079140dd2d7f794a9d9a73cbb8e9d59ffe24c63436efa8f271"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:61817945f2fe7d166e75fbfb28004034b48e44878177fc54d81688e7b85a3665"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:29d2c342c4bc01b88402d60189f3df065fb0dda3654744d5a165a5288a657368"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5e11661ce0fd30a6790e8bcdf263b9ec5988e95e63cf901972107efc49218b13"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d18368b137c6295db49ce7218b1a9ba15c5bc254c96d7c9f9e924a9bc7825ad"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ec4e55f79b1c4ffb2eecd8a0cfba9955a2588497d96851f4c8f99aa4a1d39b12"}, + {file = "pydantic_core-2.23.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:374a5e5049eda9e0a44c696c7ade3ff355f06b1fe0bb945ea3cac2bc336478a2"}, + {file = "pydantic_core-2.23.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:5c364564d17da23db1106787675fc7af45f2f7b58b4173bfdd105564e132e6fb"}, + {file = "pydantic_core-2.23.4-cp38-none-win32.whl", hash = "sha256:d7a80d21d613eec45e3d41eb22f8f94ddc758a6c4720842dc74c0581f54993d6"}, + {file = "pydantic_core-2.23.4-cp38-none-win_amd64.whl", hash = "sha256:5f5ff8d839f4566a474a969508fe1c5e59c31c80d9e140566f9a37bba7b8d556"}, + {file = "pydantic_core-2.23.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a4fa4fc04dff799089689f4fd502ce7d59de529fc2f40a2c8836886c03e0175a"}, + {file = "pydantic_core-2.23.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0a7df63886be5e270da67e0966cf4afbae86069501d35c8c1b3b6c168f42cb36"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dcedcd19a557e182628afa1d553c3895a9f825b936415d0dbd3cd0bbcfd29b4b"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f54b118ce5de9ac21c363d9b3caa6c800341e8c47a508787e5868c6b79c9323"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86d2f57d3e1379a9525c5ab067b27dbb8a0642fb5d454e17a9ac434f9ce523e3"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:de6d1d1b9e5101508cb37ab0d972357cac5235f5c6533d1071964c47139257df"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1278e0d324f6908e872730c9102b0112477a7f7cf88b308e4fc36ce1bdb6d58c"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9a6b5099eeec78827553827f4c6b8615978bb4b6a88e5d9b93eddf8bb6790f55"}, + {file = "pydantic_core-2.23.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:e55541f756f9b3ee346b840103f32779c695a19826a4c442b7954550a0972040"}, + {file = "pydantic_core-2.23.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a5c7ba8ffb6d6f8f2ab08743be203654bb1aaa8c9dcb09f82ddd34eadb695605"}, + {file = "pydantic_core-2.23.4-cp39-none-win32.whl", hash = "sha256:37b0fe330e4a58d3c58b24d91d1eb102aeec675a3db4c292ec3928ecd892a9a6"}, + {file = "pydantic_core-2.23.4-cp39-none-win_amd64.whl", hash = "sha256:1498bec4c05c9c787bde9125cfdcc63a41004ff167f495063191b863399b1a29"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:f455ee30a9d61d3e1a15abd5068827773d6e4dc513e795f380cdd59932c782d5"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1e90d2e3bd2c3863d48525d297cd143fe541be8bbf6f579504b9712cb6b643ec"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e203fdf807ac7e12ab59ca2bfcabb38c7cf0b33c41efeb00f8e5da1d86af480"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e08277a400de01bc72436a0ccd02bdf596631411f592ad985dcee21445bd0068"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f220b0eea5965dec25480b6333c788fb72ce5f9129e8759ef876a1d805d00801"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d06b0c8da4f16d1d1e352134427cb194a0a6e19ad5db9161bf32b2113409e728"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ba1a0996f6c2773bd83e63f18914c1de3c9dd26d55f4ac302a7efe93fb8e7433"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:9a5bce9d23aac8f0cf0836ecfc033896aa8443b501c58d0602dbfd5bd5b37753"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:78ddaaa81421a29574a682b3179d4cf9e6d405a09b99d93ddcf7e5239c742e21"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:883a91b5dd7d26492ff2f04f40fbb652de40fcc0afe07e8129e8ae779c2110eb"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:88ad334a15b32a791ea935af224b9de1bf99bcd62fabf745d5f3442199d86d59"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:233710f069d251feb12a56da21e14cca67994eab08362207785cf8c598e74577"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:19442362866a753485ba5e4be408964644dd6a09123d9416c54cd49171f50744"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:624e278a7d29b6445e4e813af92af37820fafb6dcc55c012c834f9e26f9aaaef"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f5ef8f42bec47f21d07668a043f077d507e5bf4e668d5c6dfe6aaba89de1a5b8"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:aea443fffa9fbe3af1a9ba721a87f926fe548d32cab71d188a6ede77d0ff244e"}, + {file = "pydantic_core-2.23.4.tar.gz", hash = "sha256:2584f7cf844ac4d970fba483a717dbe10c1c1c96a969bf65d61ffe94df1b2863"}, ] [package.dependencies] @@ -2012,13 +1875,13 @@ dev = ["atomicwrites (==1.4.1)", "attrs (==23.2.0)", "coverage (==7.4.1)", "hatc [[package]] name = "python-socketio" -version = "5.11.3" +version = "5.11.4" description = "Socket.IO server and client for Python" optional = false python-versions = ">=3.8" files = [ - {file = "python_socketio-5.11.3-py3-none-any.whl", hash = "sha256:2a923a831ff70664b7c502df093c423eb6aa93c1ce68b8319e840227a26d8b69"}, - {file = "python_socketio-5.11.3.tar.gz", hash = "sha256:194af8cdbb7b0768c2e807ba76c7abc288eb5bb85559b7cddee51a6bc7a65737"}, + {file = "python_socketio-5.11.4-py3-none-any.whl", hash = "sha256:42efaa3e3e0b166fc72a527488a13caaac2cefc76174252486503bd496284945"}, + {file = "python_socketio-5.11.4.tar.gz", hash = "sha256:8b0b8ff2964b2957c865835e936310190639c00310a47d77321a594d1665355e"}, ] [package.dependencies] @@ -2032,13 +1895,13 @@ docs = ["sphinx"] [[package]] name = "pytz" -version = "2024.1" +version = "2024.2" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" files = [ - {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, - {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, + {file = "pytz-2024.2-py2.py3-none-any.whl", hash = "sha256:31c7c1817eb7fae7ca4b8c7ee50c72f93aa2dd863de768e1ef4245d426aa0725"}, + {file = "pytz-2024.2.tar.gz", hash = "sha256:2aa355083c50a0f93fa581709deac0c9ad65cca8a9e9beac660adcbd493c798a"}, ] [[package]] @@ -2116,17 +1979,17 @@ files = [ [[package]] name = "readme-renderer" -version = "43.0" +version = "44.0" description = "readme_renderer is a library for rendering readme descriptions for Warehouse" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "readme_renderer-43.0-py3-none-any.whl", hash = "sha256:19db308d86ecd60e5affa3b2a98f017af384678c63c88e5d4556a380e674f3f9"}, - {file = "readme_renderer-43.0.tar.gz", hash = "sha256:1818dd28140813509eeed8d62687f7cd4f7bad90d4db586001c5dc09d4fde311"}, + {file = "readme_renderer-44.0-py3-none-any.whl", hash = "sha256:2fbca89b81a08526aadf1357a8c2ae889ec05fb03f5da67f9769c9a592166151"}, + {file = "readme_renderer-44.0.tar.gz", hash = "sha256:8712034eabbfa6805cacf1402b4eeb2a73028f72d1166d6f5cb7f9c047c5d1e1"}, ] [package.dependencies] -docutils = ">=0.13.1" +docutils = ">=0.21.2" nh3 = ">=0.2.14" Pygments = ">=2.5.1" @@ -2153,13 +2016,13 @@ ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)" [[package]] name = "reflex-chakra" -version = "0.6.0a1" +version = "0.6.0a7" description = "reflex using chakra components" optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "reflex_chakra-0.6.0a1-py3-none-any.whl", hash = "sha256:68c22e00591530c38acedb20ee9c192109a3591f3e58fb3a51c9e939b13c66ad"}, - {file = "reflex_chakra-0.6.0a1.tar.gz", hash = "sha256:9061790bb59134cf2200461de45f582987cef29032f82864165a3c5badb86cf5"}, + {file = "reflex_chakra-0.6.0a7-py3-none-any.whl", hash = "sha256:d693aee7323af13ce491165ffb4fe392344939e45516991671d5601727f749f4"}, + {file = "reflex_chakra-0.6.0a7.tar.gz", hash = "sha256:fe17282e439fdfdfd507e24857a615258ef9789f15049aa0e70239fbcb4d5fbf"}, ] [package.dependencies] @@ -2239,19 +2102,18 @@ idna2008 = ["idna"] [[package]] name = "rich" -version = "13.7.1" +version = "13.8.1" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.7.0" files = [ - {file = "rich-13.7.1-py3-none-any.whl", hash = "sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222"}, - {file = "rich-13.7.1.tar.gz", hash = "sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432"}, + {file = "rich-13.8.1-py3-none-any.whl", hash = "sha256:1760a3c0848469b97b558fc61c85233e3dafb69c7a071b4d60c38099d3cd4c06"}, + {file = "rich-13.8.1.tar.gz", hash = "sha256:8260cda28e3db6bf04d2d1ef4dbc03ba80a824c88b0e7668a0f23126a424844a"}, ] [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" -typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] @@ -2299,13 +2161,13 @@ jeepney = ">=0.6" [[package]] name = "selenium" -version = "4.23.1" +version = "4.24.0" description = "Official Python bindings for Selenium WebDriver" optional = false python-versions = ">=3.8" files = [ - {file = "selenium-4.23.1-py3-none-any.whl", hash = "sha256:3a8d9f23dc636bd3840dd56f00c2739e32ec0c1e34a821dd553e15babef24477"}, - {file = "selenium-4.23.1.tar.gz", hash = "sha256:128d099e66284437e7128d2279176ec7a06e6ec7426e167f5d34987166bd8f46"}, + {file = "selenium-4.24.0-py3-none-any.whl", hash = "sha256:42c23f60753d5415b261b236cecbd69bd4eb5271e1563915f546b443cb6b71c6"}, + {file = "selenium-4.24.0.tar.gz", hash = "sha256:88281e5b5b90fe231868905d5ea745b9ee5e30db280b33498cc73fb0fa06d571"}, ] [package.dependencies] @@ -2394,60 +2256,60 @@ files = [ [[package]] name = "sqlalchemy" -version = "2.0.32" +version = "2.0.35" description = "Database Abstraction Library" optional = false python-versions = ">=3.7" files = [ - {file = "SQLAlchemy-2.0.32-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0c9045ecc2e4db59bfc97b20516dfdf8e41d910ac6fb667ebd3a79ea54084619"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1467940318e4a860afd546ef61fefb98a14d935cd6817ed07a228c7f7c62f389"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5954463675cb15db8d4b521f3566a017c8789222b8316b1e6934c811018ee08b"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:167e7497035c303ae50651b351c28dc22a40bb98fbdb8468cdc971821b1ae533"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b27dfb676ac02529fb6e343b3a482303f16e6bc3a4d868b73935b8792edb52d0"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:bf2360a5e0f7bd75fa80431bf8ebcfb920c9f885e7956c7efde89031695cafb8"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-win32.whl", hash = "sha256:306fe44e754a91cd9d600a6b070c1f2fadbb4a1a257b8781ccf33c7067fd3e4d"}, - {file = "SQLAlchemy-2.0.32-cp310-cp310-win_amd64.whl", hash = "sha256:99db65e6f3ab42e06c318f15c98f59a436f1c78179e6a6f40f529c8cc7100b22"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:21b053be28a8a414f2ddd401f1be8361e41032d2ef5884b2f31d31cb723e559f"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b178e875a7a25b5938b53b006598ee7645172fccafe1c291a706e93f48499ff5"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:723a40ee2cc7ea653645bd4cf024326dea2076673fc9d3d33f20f6c81db83e1d"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:295ff8689544f7ee7e819529633d058bd458c1fd7f7e3eebd0f9268ebc56c2a0"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:49496b68cd190a147118af585173ee624114dfb2e0297558c460ad7495f9dfe2"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:acd9b73c5c15f0ec5ce18128b1fe9157ddd0044abc373e6ecd5ba376a7e5d961"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-win32.whl", hash = "sha256:9365a3da32dabd3e69e06b972b1ffb0c89668994c7e8e75ce21d3e5e69ddef28"}, - {file = "SQLAlchemy-2.0.32-cp311-cp311-win_amd64.whl", hash = "sha256:8bd63d051f4f313b102a2af1cbc8b80f061bf78f3d5bd0843ff70b5859e27924"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6bab3db192a0c35e3c9d1560eb8332463e29e5507dbd822e29a0a3c48c0a8d92"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:19d98f4f58b13900d8dec4ed09dd09ef292208ee44cc9c2fe01c1f0a2fe440e9"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cd33c61513cb1b7371fd40cf221256456d26a56284e7d19d1f0b9f1eb7dd7e8"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d6ba0497c1d066dd004e0f02a92426ca2df20fac08728d03f67f6960271feec"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2b6be53e4fde0065524f1a0a7929b10e9280987b320716c1509478b712a7688c"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:916a798f62f410c0b80b63683c8061f5ebe237b0f4ad778739304253353bc1cb"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-win32.whl", hash = "sha256:31983018b74908ebc6c996a16ad3690301a23befb643093fcfe85efd292e384d"}, - {file = "SQLAlchemy-2.0.32-cp312-cp312-win_amd64.whl", hash = "sha256:4363ed245a6231f2e2957cccdda3c776265a75851f4753c60f3004b90e69bfeb"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b8afd5b26570bf41c35c0121801479958b4446751a3971fb9a480c1afd85558e"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c750987fc876813f27b60d619b987b057eb4896b81117f73bb8d9918c14f1cad"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ada0102afff4890f651ed91120c1120065663506b760da4e7823913ebd3258be"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:78c03d0f8a5ab4f3034c0e8482cfcc415a3ec6193491cfa1c643ed707d476f16"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:3bd1cae7519283ff525e64645ebd7a3e0283f3c038f461ecc1c7b040a0c932a1"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-win32.whl", hash = "sha256:01438ebcdc566d58c93af0171c74ec28efe6a29184b773e378a385e6215389da"}, - {file = "SQLAlchemy-2.0.32-cp37-cp37m-win_amd64.whl", hash = "sha256:4979dc80fbbc9d2ef569e71e0896990bc94df2b9fdbd878290bd129b65ab579c"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c742be912f57586ac43af38b3848f7688863a403dfb220193a882ea60e1ec3a"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:62e23d0ac103bcf1c5555b6c88c114089587bc64d048fef5bbdb58dfd26f96da"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:251f0d1108aab8ea7b9aadbd07fb47fb8e3a5838dde34aa95a3349876b5a1f1d"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ef18a84e5116340e38eca3e7f9eeaaef62738891422e7c2a0b80feab165905f"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:3eb6a97a1d39976f360b10ff208c73afb6a4de86dd2a6212ddf65c4a6a2347d5"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:0c1c9b673d21477cec17ab10bc4decb1322843ba35b481585facd88203754fc5"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-win32.whl", hash = "sha256:c41a2b9ca80ee555decc605bd3c4520cc6fef9abde8fd66b1cf65126a6922d65"}, - {file = "SQLAlchemy-2.0.32-cp38-cp38-win_amd64.whl", hash = "sha256:8a37e4d265033c897892279e8adf505c8b6b4075f2b40d77afb31f7185cd6ecd"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:52fec964fba2ef46476312a03ec8c425956b05c20220a1a03703537824b5e8e1"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:328429aecaba2aee3d71e11f2477c14eec5990fb6d0e884107935f7fb6001632"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85a01b5599e790e76ac3fe3aa2f26e1feba56270023d6afd5550ed63c68552b3"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aaf04784797dcdf4c0aa952c8d234fa01974c4729db55c45732520ce12dd95b4"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:4488120becf9b71b3ac718f4138269a6be99a42fe023ec457896ba4f80749525"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:14e09e083a5796d513918a66f3d6aedbc131e39e80875afe81d98a03312889e6"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-win32.whl", hash = "sha256:0d322cc9c9b2154ba7e82f7bf25ecc7c36fbe2d82e2933b3642fc095a52cfc78"}, - {file = "SQLAlchemy-2.0.32-cp39-cp39-win_amd64.whl", hash = "sha256:7dd8583df2f98dea28b5cd53a1beac963f4f9d087888d75f22fcc93a07cf8d84"}, - {file = "SQLAlchemy-2.0.32-py3-none-any.whl", hash = "sha256:e567a8793a692451f706b363ccf3c45e056b67d90ead58c3bc9471af5d212202"}, - {file = "SQLAlchemy-2.0.32.tar.gz", hash = "sha256:c1b88cc8b02b6a5f0efb0345a03672d4c897dc7d92585176f88c67346f565ea8"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:67219632be22f14750f0d1c70e62f204ba69d28f62fd6432ba05ab295853de9b"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4668bd8faf7e5b71c0319407b608f278f279668f358857dbfd10ef1954ac9f90"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb8bea573863762bbf45d1e13f87c2d2fd32cee2dbd50d050f83f87429c9e1ea"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f552023710d4b93d8fb29a91fadf97de89c5926c6bd758897875435f2a939f33"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:016b2e665f778f13d3c438651dd4de244214b527a275e0acf1d44c05bc6026a9"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7befc148de64b6060937231cbff8d01ccf0bfd75aa26383ffdf8d82b12ec04ff"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-win32.whl", hash = "sha256:22b83aed390e3099584b839b93f80a0f4a95ee7f48270c97c90acd40ee646f0b"}, + {file = "SQLAlchemy-2.0.35-cp310-cp310-win_amd64.whl", hash = "sha256:a29762cd3d116585278ffb2e5b8cc311fb095ea278b96feef28d0b423154858e"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:e21f66748ab725ade40fa7af8ec8b5019c68ab00b929f6643e1b1af461eddb60"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8a6219108a15fc6d24de499d0d515c7235c617b2540d97116b663dade1a54d62"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:042622a5306c23b972192283f4e22372da3b8ddf5f7aac1cc5d9c9b222ab3ff6"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:627dee0c280eea91aed87b20a1f849e9ae2fe719d52cbf847c0e0ea34464b3f7"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4fdcd72a789c1c31ed242fd8c1bcd9ea186a98ee8e5408a50e610edfef980d71"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:89b64cd8898a3a6f642db4eb7b26d1b28a497d4022eccd7717ca066823e9fb01"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-win32.whl", hash = "sha256:6a93c5a0dfe8d34951e8a6f499a9479ffb9258123551fa007fc708ae2ac2bc5e"}, + {file = "SQLAlchemy-2.0.35-cp311-cp311-win_amd64.whl", hash = "sha256:c68fe3fcde03920c46697585620135b4ecfdfc1ed23e75cc2c2ae9f8502c10b8"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:eb60b026d8ad0c97917cb81d3662d0b39b8ff1335e3fabb24984c6acd0c900a2"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6921ee01caf375363be5e9ae70d08ce7ca9d7e0e8983183080211a062d299468"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8cdf1a0dbe5ced887a9b127da4ffd7354e9c1a3b9bb330dce84df6b70ccb3a8d"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:93a71c8601e823236ac0e5d087e4f397874a421017b3318fd92c0b14acf2b6db"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e04b622bb8a88f10e439084486f2f6349bf4d50605ac3e445869c7ea5cf0fa8c"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1b56961e2d31389aaadf4906d453859f35302b4eb818d34a26fab72596076bb8"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-win32.whl", hash = "sha256:0f9f3f9a3763b9c4deb8c5d09c4cc52ffe49f9876af41cc1b2ad0138878453cf"}, + {file = "SQLAlchemy-2.0.35-cp312-cp312-win_amd64.whl", hash = "sha256:25b0f63e7fcc2a6290cb5f7f5b4fc4047843504983a28856ce9b35d8f7de03cc"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:f021d334f2ca692523aaf7bbf7592ceff70c8594fad853416a81d66b35e3abf9"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05c3f58cf91683102f2f0265c0db3bd3892e9eedabe059720492dbaa4f922da1"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:032d979ce77a6c2432653322ba4cbeabf5a6837f704d16fa38b5a05d8e21fa00"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:2e795c2f7d7249b75bb5f479b432a51b59041580d20599d4e112b5f2046437a3"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:cc32b2990fc34380ec2f6195f33a76b6cdaa9eecf09f0c9404b74fc120aef36f"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-win32.whl", hash = "sha256:9509c4123491d0e63fb5e16199e09f8e262066e58903e84615c301dde8fa2e87"}, + {file = "SQLAlchemy-2.0.35-cp37-cp37m-win_amd64.whl", hash = "sha256:3655af10ebcc0f1e4e06c5900bb33e080d6a1fa4228f502121f28a3b1753cde5"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4c31943b61ed8fdd63dfd12ccc919f2bf95eefca133767db6fbbd15da62078ec"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a62dd5d7cc8626a3634208df458c5fe4f21200d96a74d122c83bc2015b333bc1"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0630774b0977804fba4b6bbea6852ab56c14965a2b0c7fc7282c5f7d90a1ae72"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d625eddf7efeba2abfd9c014a22c0f6b3796e0ffb48f5d5ab106568ef01ff5a"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ada603db10bb865bbe591939de854faf2c60f43c9b763e90f653224138f910d9"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:c41411e192f8d3ea39ea70e0fae48762cd11a2244e03751a98bd3c0ca9a4e936"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-win32.whl", hash = "sha256:d299797d75cd747e7797b1b41817111406b8b10a4f88b6e8fe5b5e59598b43b0"}, + {file = "SQLAlchemy-2.0.35-cp38-cp38-win_amd64.whl", hash = "sha256:0375a141e1c0878103eb3d719eb6d5aa444b490c96f3fedab8471c7f6ffe70ee"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ccae5de2a0140d8be6838c331604f91d6fafd0735dbdcee1ac78fc8fbaba76b4"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2a275a806f73e849e1c309ac11108ea1a14cd7058577aba962cd7190e27c9e3c"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:732e026240cdd1c1b2e3ac515c7a23820430ed94292ce33806a95869c46bd139"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:890da8cd1941fa3dab28c5bac3b9da8502e7e366f895b3b8e500896f12f94d11"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:c0d8326269dbf944b9201911b0d9f3dc524d64779a07518199a58384c3d37a44"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b76d63495b0508ab9fc23f8152bac63205d2a704cd009a2b0722f4c8e0cba8e0"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-win32.whl", hash = "sha256:69683e02e8a9de37f17985905a5eca18ad651bf592314b4d3d799029797d0eb3"}, + {file = "SQLAlchemy-2.0.35-cp39-cp39-win_amd64.whl", hash = "sha256:aee110e4ef3c528f3abbc3c2018c121e708938adeeff9006428dd7c8555e9b3f"}, + {file = "SQLAlchemy-2.0.35-py3-none-any.whl", hash = "sha256:2ab3f0336c0387662ce6221ad30ab3a5e6499aab01b9790879b6578fd9b8faa1"}, + {file = "sqlalchemy-2.0.35.tar.gz", hash = "sha256:e11d7ea4d24f0a262bccf9a7cd6284c976c5369dac21db237cff59586045ab9f"}, ] [package.dependencies] @@ -2481,13 +2343,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "sqlmodel" -version = "0.0.21" +version = "0.0.22" description = "SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness." optional = false python-versions = ">=3.7" files = [ - {file = "sqlmodel-0.0.21-py3-none-any.whl", hash = "sha256:eca104afe8a643f0764076b29f02e51d19d6b35c458f4c119942960362a4b52a"}, - {file = "sqlmodel-0.0.21.tar.gz", hash = "sha256:b2034c23d930f66d2091b17a4280a9c23a7ea540a71e7fcf9c746d262f06f74a"}, + {file = "sqlmodel-0.0.22-py3-none-any.whl", hash = "sha256:a1ed13e28a1f4057cbf4ff6cdb4fc09e85702621d3259ba17b3c230bfb2f941b"}, + {file = "sqlmodel-0.0.22.tar.gz", hash = "sha256:7d37c882a30c43464d143e35e9ecaf945d88035e20117bf5ec2834a23cbe505e"}, ] [package.dependencies] @@ -2496,18 +2358,17 @@ SQLAlchemy = ">=2.0.14,<2.1.0" [[package]] name = "starlette" -version = "0.37.2" +version = "0.38.5" description = "The little ASGI library that shines." optional = false python-versions = ">=3.8" files = [ - {file = "starlette-0.37.2-py3-none-any.whl", hash = "sha256:6fe59f29268538e5d0d182f2791a479a0c64638e6935d1c6989e63fb2699c6ee"}, - {file = "starlette-0.37.2.tar.gz", hash = "sha256:9af890290133b79fc3db55474ade20f6220a364a0402e0b556e7cd5e1e093823"}, + {file = "starlette-0.38.5-py3-none-any.whl", hash = "sha256:632f420a9d13e3ee2a6f18f437b0a9f1faecb0bc42e1942aa2ea0e379a4c4206"}, + {file = "starlette-0.38.5.tar.gz", hash = "sha256:04a92830a9b6eb1442c766199d62260c3d4dc9c4f9188360626b1e0273cb7077"}, ] [package.dependencies] anyio = ">=3.4.0,<5" -typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} [package.extras] full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.7)", "pyyaml"] @@ -2657,13 +2518,13 @@ urllib3 = ">=1.26.0" [[package]] name = "typer" -version = "0.12.4" +version = "0.12.5" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." optional = false python-versions = ">=3.7" files = [ - {file = "typer-0.12.4-py3-none-any.whl", hash = "sha256:819aa03699f438397e876aa12b0d63766864ecba1b579092cc9fe35d886e34b6"}, - {file = "typer-0.12.4.tar.gz", hash = "sha256:c9c1613ed6a166162705b3347b8d10b661ccc5d95692654d0fb628118f2c34e6"}, + {file = "typer-0.12.5-py3-none-any.whl", hash = "sha256:62fe4e471711b147e3365034133904df3e235698399bc4de2b36c8579298d52b"}, + {file = "typer-0.12.5.tar.gz", hash = "sha256:f592f089bedcc8ec1b974125d64851029c3b1af145f04aca64d69410f0c9b722"}, ] [package.dependencies] @@ -2696,13 +2557,13 @@ files = [ [[package]] name = "urllib3" -version = "2.2.2" +version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, - {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, + {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, + {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, ] [package.dependencies] @@ -2735,13 +2596,13 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", [[package]] name = "virtualenv" -version = "20.26.3" +version = "20.26.5" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"}, - {file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"}, + {file = "virtualenv-20.26.5-py3-none-any.whl", hash = "sha256:4f3ac17b81fba3ce3bd6f4ead2749a72da5929c01774948e243db9ba41df4ff6"}, + {file = "virtualenv-20.26.5.tar.gz", hash = "sha256:ce489cac131aa58f4b25e321d6d186171f78e6cb13fafbf32a840cee67733ff4"}, ] [package.dependencies] @@ -2753,152 +2614,6 @@ platformdirs = ">=3.9.1,<5" docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] -[[package]] -name = "watchdog" -version = "4.0.2" -description = "Filesystem events monitoring" -optional = false -python-versions = ">=3.8" -files = [ - {file = "watchdog-4.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ede7f010f2239b97cc79e6cb3c249e72962404ae3865860855d5cbe708b0fd22"}, - {file = "watchdog-4.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a2cffa171445b0efa0726c561eca9a27d00a1f2b83846dbd5a4f639c4f8ca8e1"}, - {file = "watchdog-4.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c50f148b31b03fbadd6d0b5980e38b558046b127dc483e5e4505fcef250f9503"}, - {file = "watchdog-4.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:7c7d4bf585ad501c5f6c980e7be9c4f15604c7cc150e942d82083b31a7548930"}, - {file = "watchdog-4.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:914285126ad0b6eb2258bbbcb7b288d9dfd655ae88fa28945be05a7b475a800b"}, - {file = "watchdog-4.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:984306dc4720da5498b16fc037b36ac443816125a3705dfde4fd90652d8028ef"}, - {file = "watchdog-4.0.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:1cdcfd8142f604630deef34722d695fb455d04ab7cfe9963055df1fc69e6727a"}, - {file = "watchdog-4.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d7ab624ff2f663f98cd03c8b7eedc09375a911794dfea6bf2a359fcc266bff29"}, - {file = "watchdog-4.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:132937547a716027bd5714383dfc40dc66c26769f1ce8a72a859d6a48f371f3a"}, - {file = "watchdog-4.0.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:cd67c7df93eb58f360c43802acc945fa8da70c675b6fa37a241e17ca698ca49b"}, - {file = "watchdog-4.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:bcfd02377be80ef3b6bc4ce481ef3959640458d6feaae0bd43dd90a43da90a7d"}, - {file = "watchdog-4.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:980b71510f59c884d684b3663d46e7a14b457c9611c481e5cef08f4dd022eed7"}, - {file = "watchdog-4.0.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:aa160781cafff2719b663c8a506156e9289d111d80f3387cf3af49cedee1f040"}, - {file = "watchdog-4.0.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f6ee8dedd255087bc7fe82adf046f0b75479b989185fb0bdf9a98b612170eac7"}, - {file = "watchdog-4.0.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0b4359067d30d5b864e09c8597b112fe0a0a59321a0f331498b013fb097406b4"}, - {file = "watchdog-4.0.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:770eef5372f146997638d737c9a3c597a3b41037cfbc5c41538fc27c09c3a3f9"}, - {file = "watchdog-4.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:eeea812f38536a0aa859972d50c76e37f4456474b02bd93674d1947cf1e39578"}, - {file = "watchdog-4.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b2c45f6e1e57ebb4687690c05bc3a2c1fb6ab260550c4290b8abb1335e0fd08b"}, - {file = "watchdog-4.0.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:10b6683df70d340ac3279eff0b2766813f00f35a1d37515d2c99959ada8f05fa"}, - {file = "watchdog-4.0.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:f7c739888c20f99824f7aa9d31ac8a97353e22d0c0e54703a547a218f6637eb3"}, - {file = "watchdog-4.0.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:c100d09ac72a8a08ddbf0629ddfa0b8ee41740f9051429baa8e31bb903ad7508"}, - {file = "watchdog-4.0.2-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:f5315a8c8dd6dd9425b974515081fc0aadca1d1d61e078d2246509fd756141ee"}, - {file = "watchdog-4.0.2-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:2d468028a77b42cc685ed694a7a550a8d1771bb05193ba7b24006b8241a571a1"}, - {file = "watchdog-4.0.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:f15edcae3830ff20e55d1f4e743e92970c847bcddc8b7509bcd172aa04de506e"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:936acba76d636f70db8f3c66e76aa6cb5136a936fc2a5088b9ce1c7a3508fc83"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_armv7l.whl", hash = "sha256:e252f8ca942a870f38cf785aef420285431311652d871409a64e2a0a52a2174c"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_i686.whl", hash = "sha256:0e83619a2d5d436a7e58a1aea957a3c1ccbf9782c43c0b4fed80580e5e4acd1a"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_ppc64.whl", hash = "sha256:88456d65f207b39f1981bf772e473799fcdc10801062c36fd5ad9f9d1d463a73"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:32be97f3b75693a93c683787a87a0dc8db98bb84701539954eef991fb35f5fbc"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_s390x.whl", hash = "sha256:c82253cfc9be68e3e49282831afad2c1f6593af80c0daf1287f6a92657986757"}, - {file = "watchdog-4.0.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:c0b14488bd336c5b1845cee83d3e631a1f8b4e9c5091ec539406e4a324f882d8"}, - {file = "watchdog-4.0.2-py3-none-win32.whl", hash = "sha256:0d8a7e523ef03757a5aa29f591437d64d0d894635f8a50f370fe37f913ce4e19"}, - {file = "watchdog-4.0.2-py3-none-win_amd64.whl", hash = "sha256:c344453ef3bf875a535b0488e3ad28e341adbd5a9ffb0f7d62cefacc8824ef2b"}, - {file = "watchdog-4.0.2-py3-none-win_ia64.whl", hash = "sha256:baececaa8edff42cd16558a639a9b0ddf425f93d892e8392a56bf904f5eff22c"}, - {file = "watchdog-4.0.2.tar.gz", hash = "sha256:b4dfbb6c49221be4535623ea4474a4d6ee0a9cef4a80b20c28db4d858b64e270"}, -] - -[package.extras] -watchmedo = ["PyYAML (>=3.10)"] - -[[package]] -name = "watchfiles" -version = "0.23.0" -description = "Simple, modern and high performance file watching and code reload in python." -optional = false -python-versions = ">=3.8" -files = [ - {file = "watchfiles-0.23.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:bee8ce357a05c20db04f46c22be2d1a2c6a8ed365b325d08af94358e0688eeb4"}, - {file = "watchfiles-0.23.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4ccd3011cc7ee2f789af9ebe04745436371d36afe610028921cab9f24bb2987b"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb02d41c33be667e6135e6686f1bb76104c88a312a18faa0ef0262b5bf7f1a0f"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7cf12ac34c444362f3261fb3ff548f0037ddd4c5bb85f66c4be30d2936beb3c5"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a0b2c25040a3c0ce0e66c7779cc045fdfbbb8d59e5aabfe033000b42fe44b53e"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ecf2be4b9eece4f3da8ba5f244b9e51932ebc441c0867bd6af46a3d97eb068d6"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:40cb8fa00028908211eb9f8d47744dca21a4be6766672e1ff3280bee320436f1"}, - {file = "watchfiles-0.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f48c917ffd36ff9a5212614c2d0d585fa8b064ca7e66206fb5c095015bc8207"}, - {file = "watchfiles-0.23.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9d183e3888ada88185ab17064079c0db8c17e32023f5c278d7bf8014713b1b5b"}, - {file = "watchfiles-0.23.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:9837edf328b2805346f91209b7e660f65fb0e9ca18b7459d075d58db082bf981"}, - {file = "watchfiles-0.23.0-cp310-none-win32.whl", hash = "sha256:296e0b29ab0276ca59d82d2da22cbbdb39a23eed94cca69aed274595fb3dfe42"}, - {file = "watchfiles-0.23.0-cp310-none-win_amd64.whl", hash = "sha256:4ea756e425ab2dfc8ef2a0cb87af8aa7ef7dfc6fc46c6f89bcf382121d4fff75"}, - {file = "watchfiles-0.23.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:e397b64f7aaf26915bf2ad0f1190f75c855d11eb111cc00f12f97430153c2eab"}, - {file = "watchfiles-0.23.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b4ac73b02ca1824ec0a7351588241fd3953748d3774694aa7ddb5e8e46aef3e3"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:130a896d53b48a1cecccfa903f37a1d87dbb74295305f865a3e816452f6e49e4"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c5e7803a65eb2d563c73230e9d693c6539e3c975ccfe62526cadde69f3fda0cf"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d1aa4cc85202956d1a65c88d18c7b687b8319dbe6b1aec8969784ef7a10e7d1a"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:87f889f6e58849ddb7c5d2cb19e2e074917ed1c6e3ceca50405775166492cca8"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:37fd826dac84c6441615aa3f04077adcc5cac7194a021c9f0d69af20fb9fa788"}, - {file = "watchfiles-0.23.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ee7db6e36e7a2c15923072e41ea24d9a0cf39658cb0637ecc9307b09d28827e1"}, - {file = "watchfiles-0.23.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:2368c5371c17fdcb5a2ea71c5c9d49f9b128821bfee69503cc38eae00feb3220"}, - {file = "watchfiles-0.23.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:857af85d445b9ba9178db95658c219dbd77b71b8264e66836a6eba4fbf49c320"}, - {file = "watchfiles-0.23.0-cp311-none-win32.whl", hash = "sha256:1d636c8aeb28cdd04a4aa89030c4b48f8b2954d8483e5f989774fa441c0ed57b"}, - {file = "watchfiles-0.23.0-cp311-none-win_amd64.whl", hash = "sha256:46f1d8069a95885ca529645cdbb05aea5837d799965676e1b2b1f95a4206313e"}, - {file = "watchfiles-0.23.0-cp311-none-win_arm64.whl", hash = "sha256:e495ed2a7943503766c5d1ff05ae9212dc2ce1c0e30a80d4f0d84889298fa304"}, - {file = "watchfiles-0.23.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:1db691bad0243aed27c8354b12d60e8e266b75216ae99d33e927ff5238d270b5"}, - {file = "watchfiles-0.23.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:62d2b18cb1edaba311fbbfe83fb5e53a858ba37cacb01e69bc20553bb70911b8"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e087e8fdf1270d000913c12e6eca44edd02aad3559b3e6b8ef00f0ce76e0636f"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dd41d5c72417b87c00b1b635738f3c283e737d75c5fa5c3e1c60cd03eac3af77"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e5f3ca0ff47940ce0a389457b35d6df601c317c1e1a9615981c474452f98de1"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6991e3a78f642368b8b1b669327eb6751439f9f7eaaa625fae67dd6070ecfa0b"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7f7252f52a09f8fa5435dc82b6af79483118ce6bd51eb74e6269f05ee22a7b9f"}, - {file = "watchfiles-0.23.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e01bcb8d767c58865207a6c2f2792ad763a0fe1119fb0a430f444f5b02a5ea0"}, - {file = "watchfiles-0.23.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:8e56fbcdd27fce061854ddec99e015dd779cae186eb36b14471fc9ae713b118c"}, - {file = "watchfiles-0.23.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bd3e2d64500a6cad28bcd710ee6269fbeb2e5320525acd0cfab5f269ade68581"}, - {file = "watchfiles-0.23.0-cp312-none-win32.whl", hash = "sha256:eb99c954291b2fad0eff98b490aa641e128fbc4a03b11c8a0086de8b7077fb75"}, - {file = "watchfiles-0.23.0-cp312-none-win_amd64.whl", hash = "sha256:dccc858372a56080332ea89b78cfb18efb945da858fabeb67f5a44fa0bcb4ebb"}, - {file = "watchfiles-0.23.0-cp312-none-win_arm64.whl", hash = "sha256:6c21a5467f35c61eafb4e394303720893066897fca937bade5b4f5877d350ff8"}, - {file = "watchfiles-0.23.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:ba31c32f6b4dceeb2be04f717811565159617e28d61a60bb616b6442027fd4b9"}, - {file = "watchfiles-0.23.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:85042ab91814fca99cec4678fc063fb46df4cbb57b4835a1cc2cb7a51e10250e"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:24655e8c1c9c114005c3868a3d432c8aa595a786b8493500071e6a52f3d09217"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6b1a950ab299a4a78fd6369a97b8763732bfb154fdb433356ec55a5bce9515c1"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b8d3c5cd327dd6ce0edfc94374fb5883d254fe78a5e9d9dfc237a1897dc73cd1"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ff785af8bacdf0be863ec0c428e3288b817e82f3d0c1d652cd9c6d509020dd0"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:02b7ba9d4557149410747353e7325010d48edcfe9d609a85cb450f17fd50dc3d"}, - {file = "watchfiles-0.23.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48a1b05c0afb2cd2f48c1ed2ae5487b116e34b93b13074ed3c22ad5c743109f0"}, - {file = "watchfiles-0.23.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:109a61763e7318d9f821b878589e71229f97366fa6a5c7720687d367f3ab9eef"}, - {file = "watchfiles-0.23.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:9f8e6bb5ac007d4a4027b25f09827ed78cbbd5b9700fd6c54429278dacce05d1"}, - {file = "watchfiles-0.23.0-cp313-none-win32.whl", hash = "sha256:f46c6f0aec8d02a52d97a583782d9af38c19a29900747eb048af358a9c1d8e5b"}, - {file = "watchfiles-0.23.0-cp313-none-win_amd64.whl", hash = "sha256:f449afbb971df5c6faeb0a27bca0427d7b600dd8f4a068492faec18023f0dcff"}, - {file = "watchfiles-0.23.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:2dddc2487d33e92f8b6222b5fb74ae2cfde5e8e6c44e0248d24ec23befdc5366"}, - {file = "watchfiles-0.23.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e75695cc952e825fa3e0684a7f4a302f9128721f13eedd8dbd3af2ba450932b8"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2537ef60596511df79b91613a5bb499b63f46f01a11a81b0a2b0dedf645d0a9c"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:20b423b58f5fdde704a226b598a2d78165fe29eb5621358fe57ea63f16f165c4"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b98732ec893975455708d6fc9a6daab527fc8bbe65be354a3861f8c450a632a4"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee1f5fcbf5bc33acc0be9dd31130bcba35d6d2302e4eceafafd7d9018c7755ab"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8f195338a5a7b50a058522b39517c50238358d9ad8284fd92943643144c0c03"}, - {file = "watchfiles-0.23.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:524fcb8d59b0dbee2c9b32207084b67b2420f6431ed02c18bd191e6c575f5c48"}, - {file = "watchfiles-0.23.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:0eff099a4df36afaa0eea7a913aa64dcf2cbd4e7a4f319a73012210af4d23810"}, - {file = "watchfiles-0.23.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:a8323daae27ea290ba3350c70c836c0d2b0fb47897fa3b0ca6a5375b952b90d3"}, - {file = "watchfiles-0.23.0-cp38-none-win32.whl", hash = "sha256:aafea64a3ae698695975251f4254df2225e2624185a69534e7fe70581066bc1b"}, - {file = "watchfiles-0.23.0-cp38-none-win_amd64.whl", hash = "sha256:c846884b2e690ba62a51048a097acb6b5cd263d8bd91062cd6137e2880578472"}, - {file = "watchfiles-0.23.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a753993635eccf1ecb185dedcc69d220dab41804272f45e4aef0a67e790c3eb3"}, - {file = "watchfiles-0.23.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6bb91fa4d0b392f0f7e27c40981e46dda9eb0fbc84162c7fb478fe115944f491"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1f67312efa3902a8e8496bfa9824d3bec096ff83c4669ea555c6bdd213aa516"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7ca6b71dcc50d320c88fb2d88ecd63924934a8abc1673683a242a7ca7d39e781"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2aec5c29915caf08771d2507da3ac08e8de24a50f746eb1ed295584ba1820330"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1733b9bc2c8098c6bdb0ff7a3d7cb211753fecb7bd99bdd6df995621ee1a574b"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:02ff5d7bd066c6a7673b17c8879cd8ee903078d184802a7ee851449c43521bdd"}, - {file = "watchfiles-0.23.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18e2de19801b0eaa4c5292a223effb7cfb43904cb742c5317a0ac686ed604765"}, - {file = "watchfiles-0.23.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:8ada449e22198c31fb013ae7e9add887e8d2bd2335401abd3cbc55f8c5083647"}, - {file = "watchfiles-0.23.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3af1b05361e1cc497bf1be654a664750ae61f5739e4bb094a2be86ec8c6db9b6"}, - {file = "watchfiles-0.23.0-cp39-none-win32.whl", hash = "sha256:486bda18be5d25ab5d932699ceed918f68eb91f45d018b0343e3502e52866e5e"}, - {file = "watchfiles-0.23.0-cp39-none-win_amd64.whl", hash = "sha256:d2d42254b189a346249424fb9bb39182a19289a2409051ee432fb2926bad966a"}, - {file = "watchfiles-0.23.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:6a9265cf87a5b70147bfb2fec14770ed5b11a5bb83353f0eee1c25a81af5abfe"}, - {file = "watchfiles-0.23.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:9f02a259fcbbb5fcfe7a0805b1097ead5ba7a043e318eef1db59f93067f0b49b"}, - {file = "watchfiles-0.23.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ebaebb53b34690da0936c256c1cdb0914f24fb0e03da76d185806df9328abed"}, - {file = "watchfiles-0.23.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd257f98cff9c6cb39eee1a83c7c3183970d8a8d23e8cf4f47d9a21329285cee"}, - {file = "watchfiles-0.23.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:aba037c1310dd108411d27b3d5815998ef0e83573e47d4219f45753c710f969f"}, - {file = "watchfiles-0.23.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:a96ac14e184aa86dc43b8a22bb53854760a58b2966c2b41580de938e9bf26ed0"}, - {file = "watchfiles-0.23.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:11698bb2ea5e991d10f1f4f83a39a02f91e44e4bd05f01b5c1ec04c9342bf63c"}, - {file = "watchfiles-0.23.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:efadd40fca3a04063d40c4448c9303ce24dd6151dc162cfae4a2a060232ebdcb"}, - {file = "watchfiles-0.23.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:556347b0abb4224c5ec688fc58214162e92a500323f50182f994f3ad33385dcb"}, - {file = "watchfiles-0.23.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:1cf7f486169986c4b9d34087f08ce56a35126600b6fef3028f19ca16d5889071"}, - {file = "watchfiles-0.23.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f18de0f82c62c4197bea5ecf4389288ac755896aac734bd2cc44004c56e4ac47"}, - {file = "watchfiles-0.23.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:532e1f2c491274d1333a814e4c5c2e8b92345d41b12dc806cf07aaff786beb66"}, - {file = "watchfiles-0.23.0.tar.gz", hash = "sha256:9338ade39ff24f8086bb005d16c29f8e9f19e55b18dcb04dfa26fcbc09da497b"}, -] - -[package.dependencies] -anyio = ">=3.0.0" - [[package]] name = "websocket-client" version = "1.8.0" @@ -2917,97 +2632,97 @@ test = ["websockets"] [[package]] name = "websockets" -version = "13.0" +version = "13.0.1" description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" optional = false python-versions = ">=3.8" files = [ - {file = "websockets-13.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ad4fa707ff9e2ffee019e946257b5300a45137a58f41fbd9a4db8e684ab61528"}, - {file = "websockets-13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6fd757f313c13c34dae9f126d3ba4cf97175859c719e57c6a614b781c86b617e"}, - {file = "websockets-13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cbac2eb7ce0fac755fb983c9247c4a60c4019bcde4c0e4d167aeb17520cc7ef1"}, - {file = "websockets-13.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4b83cf7354cbbc058e97b3e545dceb75b8d9cf17fd5a19db419c319ddbaaf7a"}, - {file = "websockets-13.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9202c0010c78fad1041e1c5285232b6508d3633f92825687549540a70e9e5901"}, - {file = "websockets-13.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3e6566e79c8c7cbea75ec450f6e1828945fc5c9a4769ceb1c7b6e22470539712"}, - {file = "websockets-13.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:e7fcad070dcd9ad37a09d89a4cbc2a5e3e45080b88977c0da87b3090f9f55ead"}, - {file = "websockets-13.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:0a8f7d65358a25172db00c69bcc7df834155ee24229f560d035758fd6613111a"}, - {file = "websockets-13.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:63b702fb31e3f058f946ccdfa551f4d57a06f7729c369e8815eb18643099db37"}, - {file = "websockets-13.0-cp310-cp310-win32.whl", hash = "sha256:3a20cf14ba7b482c4a1924b5e061729afb89c890ca9ed44ac4127c6c5986e424"}, - {file = "websockets-13.0-cp310-cp310-win_amd64.whl", hash = "sha256:587245f0704d0bb675f919898d7473e8827a6d578e5a122a21756ca44b811ec8"}, - {file = "websockets-13.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:06df8306c241c235075d2ae77367038e701e53bc8c1bb4f6644f4f53aa6dedd0"}, - {file = "websockets-13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:85a1f92a02f0b8c1bf02699731a70a8a74402bb3f82bee36e7768b19a8ed9709"}, - {file = "websockets-13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9ed02c604349068d46d87ef4c2012c112c791f2bec08671903a6bb2bd9c06784"}, - {file = "websockets-13.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b89849171b590107f6724a7b0790736daead40926ddf47eadf998b4ff51d6414"}, - {file = "websockets-13.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:939a16849d71203628157a5e4a495da63967c744e1e32018e9b9e2689aca64d4"}, - {file = "websockets-13.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad818cdac37c0ad4c58e51cb4964eae4f18b43c4a83cb37170b0d90c31bd80cf"}, - {file = "websockets-13.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cbfe82a07596a044de78bb7a62519e71690c5812c26c5f1d4b877e64e4f46309"}, - {file = "websockets-13.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e07e76c49f39c5b45cbd7362b94f001ae209a3ea4905ae9a09cfd53b3c76373d"}, - {file = "websockets-13.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:372f46a0096cfda23c88f7e42349a33f8375e10912f712e6b496d3a9a557290f"}, - {file = "websockets-13.0-cp311-cp311-win32.whl", hash = "sha256:376a43a4fd96725f13450d3d2e98f4f36c3525c562ab53d9a98dd2950dca9a8a"}, - {file = "websockets-13.0-cp311-cp311-win_amd64.whl", hash = "sha256:2be1382a4daa61e2f3e2be3b3c86932a8db9d1f85297feb6e9df22f391f94452"}, - {file = "websockets-13.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:b5407c34776b9b77bd89a5f95eb0a34aaf91889e3f911c63f13035220eb50107"}, - {file = "websockets-13.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:4782ec789f059f888c1e8fdf94383d0e64b531cffebbf26dd55afd53ab487ca4"}, - {file = "websockets-13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c8feb8e19ef65c9994e652c5b0324abd657bedd0abeb946fb4f5163012c1e730"}, - {file = "websockets-13.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3f3d2e20c442b58dbac593cb1e02bc02d149a86056cc4126d977ad902472e3b"}, - {file = "websockets-13.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e39d393e0ab5b8bd01717cc26f2922026050188947ff54fe6a49dc489f7750b7"}, - {file = "websockets-13.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f661a4205741bdc88ac9c2b2ec003c72cee97e4acd156eb733662ff004ba429"}, - {file = "websockets-13.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:384129ad0490e06bab2b98c1da9b488acb35bb11e2464c728376c6f55f0d45f3"}, - {file = "websockets-13.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:df5c0eff91f61b8205a6c9f7b255ff390cdb77b61c7b41f79ca10afcbb22b6cb"}, - {file = "websockets-13.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:02cc9bb1a887dac0e08bf657c5d00aa3fac0d03215d35a599130c2034ae6663a"}, - {file = "websockets-13.0-cp312-cp312-win32.whl", hash = "sha256:d9726d2c9bd6aed8cb994d89b3910ca0079406edce3670886ec828a73e7bdd53"}, - {file = "websockets-13.0-cp312-cp312-win_amd64.whl", hash = "sha256:fa0839f35322f7b038d8adcf679e2698c3a483688cc92e3bd15ee4fb06669e9a"}, - {file = "websockets-13.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:da7e501e59857e8e3e9d10586139dc196b80445a591451ca9998aafba1af5278"}, - {file = "websockets-13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a00e1e587c655749afb5b135d8d3edcfe84ec6db864201e40a882e64168610b3"}, - {file = "websockets-13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a7fbf2a8fe7556a8f4e68cb3e736884af7bf93653e79f6219f17ebb75e97d8f0"}, - {file = "websockets-13.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ea9c9c7443a97ea4d84d3e4d42d0e8c4235834edae652993abcd2aff94affd7"}, - {file = "websockets-13.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:35c2221b539b360203f3f9ad168e527bf16d903e385068ae842c186efb13d0ea"}, - {file = "websockets-13.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:358d37c5c431dd050ffb06b4b075505aae3f4f795d7fff9794e5ed96ce99b998"}, - {file = "websockets-13.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:038e7a0f1bfafc7bf52915ab3506b7a03d1e06381e9f60440c856e8918138151"}, - {file = "websockets-13.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:fd038bc9e2c134847f1e0ce3191797fad110756e690c2fdd9702ed34e7a43abb"}, - {file = "websockets-13.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:93b8c2008f372379fb6e5d2b3f7c9ec32f7b80316543fd3a5ace6610c5cde1b0"}, - {file = "websockets-13.0-cp313-cp313-win32.whl", hash = "sha256:851fd0afb3bc0b73f7c5b5858975d42769a5fdde5314f4ef2c106aec63100687"}, - {file = "websockets-13.0-cp313-cp313-win_amd64.whl", hash = "sha256:7d14901fdcf212804970c30ab9ee8f3f0212e620c7ea93079d6534863444fb4e"}, - {file = "websockets-13.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ae7a519a56a714f64c3445cabde9fc2fc927e7eae44f413eae187cddd9e54178"}, - {file = "websockets-13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5575031472ca87302aeb2ce2c2349f4c6ea978c86a9d1289bc5d16058ad4c10a"}, - {file = "websockets-13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9895df6cd0bfe79d09bcd1dbdc03862846f26fbd93797153de954306620c1d00"}, - {file = "websockets-13.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a4de299c947a54fca9ce1c5fd4a08eb92ffce91961becb13bd9195f7c6e71b47"}, - {file = "websockets-13.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:05c25f7b849702950b6fd0e233989bb73a0d2bc83faa3b7233313ca395205f6d"}, - {file = "websockets-13.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ede95125a30602b1691a4b1da88946bf27dae283cf30f22cd2cb8ca4b2e0d119"}, - {file = "websockets-13.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:addf0a16e4983280efed272d8cb3b2e05f0051755372461e7d966b80a6554e16"}, - {file = "websockets-13.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:06b3186e97bf9a33921fa60734d5ed90f2a9b407cce8d23c7333a0984049ef61"}, - {file = "websockets-13.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:eae368cac85adc4c7dc3b0d5f84ffcca609d658db6447387300478e44db70796"}, - {file = "websockets-13.0-cp38-cp38-win32.whl", hash = "sha256:337837ac788d955728b1ab01876d72b73da59819a3388e1c5e8e05c3999f1afa"}, - {file = "websockets-13.0-cp38-cp38-win_amd64.whl", hash = "sha256:f66e00e42f25ca7e91076366303e11c82572ca87cc5aae51e6e9c094f315ab41"}, - {file = "websockets-13.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:94c1c02721139fe9940b38d28fb15b4b782981d800d5f40f9966264fbf23dcc8"}, - {file = "websockets-13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bd4ba86513430513e2aa25a441bb538f6f83734dc368a2c5d18afdd39097aa33"}, - {file = "websockets-13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a1ab8f0e0cadc5be5f3f9fa11a663957fecbf483d434762c8dfb8aa44948944a"}, - {file = "websockets-13.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3670def5d3dfd5af6f6e2b3b243ea8f1f72d8da1ef927322f0703f85c90d9603"}, - {file = "websockets-13.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6058b6be92743358885ad6dcdecb378fde4a4c74d4dd16a089d07580c75a0e80"}, - {file = "websockets-13.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:516062a0a8ef5ecbfa4acbaec14b199fc070577834f9fe3d40800a99f92523ca"}, - {file = "websockets-13.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:da7e918d82e7bdfc6f66d31febe1b2e28a1ca3387315f918de26f5e367f61572"}, - {file = "websockets-13.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:9cc7f35dcb49a4e32db82a849fcc0714c4d4acc9d2273aded2d61f87d7f660b7"}, - {file = "websockets-13.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:f5737c53eb2c8ed8f64b50d3dafd3c1dae739f78aa495a288421ac1b3de82717"}, - {file = "websockets-13.0-cp39-cp39-win32.whl", hash = "sha256:265e1f0d3f788ce8ef99dca591a1aec5263b26083ca0934467ad9a1d1181067c"}, - {file = "websockets-13.0-cp39-cp39-win_amd64.whl", hash = "sha256:4d70c89e3d3b347a7c4d3c33f8d323f0584c9ceb69b82c2ef8a174ca84ea3d4a"}, - {file = "websockets-13.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:602cbd010d8c21c8475f1798b705bb18567eb189c533ab5ef568bc3033fdf417"}, - {file = "websockets-13.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:bf8eb5dca4f484a60f5327b044e842e0d7f7cdbf02ea6dc4a4f811259f1f1f0b"}, - {file = "websockets-13.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89d795c1802d99a643bf689b277e8604c14b5af1bc0a31dade2cd7a678087212"}, - {file = "websockets-13.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:788bc841d250beccff67a20a5a53a15657a60111ef9c0c0a97fbdd614fae0fe2"}, - {file = "websockets-13.0-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7334752052532c156d28b8eaf3558137e115c7871ea82adff69b6d94a7bee273"}, - {file = "websockets-13.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:e7a1963302947332c3039e3f66209ec73b1626f8a0191649e0713c391e9f5b0d"}, - {file = "websockets-13.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2e1cf4e1eb84b4fd74a47688e8b0940c89a04ad9f6937afa43d468e71128cd68"}, - {file = "websockets-13.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:c026ee729c4ce55708a14b839ba35086dfae265fc12813b62d34ce33f4980c1c"}, - {file = "websockets-13.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f5f9d23fbbf96eefde836d9692670bfc89e2d159f456d499c5efcf6a6281c1af"}, - {file = "websockets-13.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ad684cb7efce227d756bae3e8484f2e56aa128398753b54245efdfbd1108f2c"}, - {file = "websockets-13.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e1e10b3fbed7be4a59831d3a939900e50fcd34d93716e433d4193a4d0d1d335d"}, - {file = "websockets-13.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:d42a818e634f789350cd8fb413a3f5eec1cf0400a53d02062534c41519f5125c"}, - {file = "websockets-13.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:e5ba5e9b332267d0f2c33ede390061850f1ac3ee6cd1bdcf4c5ea33ead971966"}, - {file = "websockets-13.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:f9af457ed593e35f467140d8b61d425495b127744a9d65d45a366f8678449a23"}, - {file = "websockets-13.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bcea3eb58c09c3a31cc83b45c06d5907f02ddaf10920aaa6443975310f699b95"}, - {file = "websockets-13.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c210d1460dc8d326ffdef9703c2f83269b7539a1690ad11ae04162bc1878d33d"}, - {file = "websockets-13.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b32f38bc81170fd56d0482d505b556e52bf9078b36819a8ba52624bd6667e39e"}, - {file = "websockets-13.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:81a11a1ddd5320429db47c04d35119c3e674d215173d87aaeb06ae80f6e9031f"}, - {file = "websockets-13.0-py3-none-any.whl", hash = "sha256:dbbac01e80aee253d44c4f098ab3cc17c822518519e869b284cfbb8cd16cc9de"}, - {file = "websockets-13.0.tar.gz", hash = "sha256:b7bf950234a482b7461afdb2ec99eee3548ec4d53f418c7990bb79c620476602"}, + {file = "websockets-13.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1841c9082a3ba4a05ea824cf6d99570a6a2d8849ef0db16e9c826acb28089e8f"}, + {file = "websockets-13.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c5870b4a11b77e4caa3937142b650fbbc0914a3e07a0cf3131f35c0587489c1c"}, + {file = "websockets-13.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f1d3d1f2eb79fe7b0fb02e599b2bf76a7619c79300fc55f0b5e2d382881d4f7f"}, + {file = "websockets-13.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15c7d62ee071fa94a2fc52c2b472fed4af258d43f9030479d9c4a2de885fd543"}, + {file = "websockets-13.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6724b554b70d6195ba19650fef5759ef11346f946c07dbbe390e039bcaa7cc3d"}, + {file = "websockets-13.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56a952fa2ae57a42ba7951e6b2605e08a24801a4931b5644dfc68939e041bc7f"}, + {file = "websockets-13.0.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:17118647c0ea14796364299e942c330d72acc4b248e07e639d34b75067b3cdd8"}, + {file = "websockets-13.0.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:64a11aae1de4c178fa653b07d90f2fb1a2ed31919a5ea2361a38760192e1858b"}, + {file = "websockets-13.0.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0617fd0b1d14309c7eab6ba5deae8a7179959861846cbc5cb528a7531c249448"}, + {file = "websockets-13.0.1-cp310-cp310-win32.whl", hash = "sha256:11f9976ecbc530248cf162e359a92f37b7b282de88d1d194f2167b5e7ad80ce3"}, + {file = "websockets-13.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:c3c493d0e5141ec055a7d6809a28ac2b88d5b878bb22df8c621ebe79a61123d0"}, + {file = "websockets-13.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:699ba9dd6a926f82a277063603fc8d586b89f4cb128efc353b749b641fcddda7"}, + {file = "websockets-13.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf2fae6d85e5dc384bf846f8243ddaa9197f3a1a70044f59399af001fd1f51d4"}, + {file = "websockets-13.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:52aed6ef21a0f1a2a5e310fb5c42d7555e9c5855476bbd7173c3aa3d8a0302f2"}, + {file = "websockets-13.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8eb2b9a318542153674c6e377eb8cb9ca0fc011c04475110d3477862f15d29f0"}, + {file = "websockets-13.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5df891c86fe68b2c38da55b7aea7095beca105933c697d719f3f45f4220a5e0e"}, + {file = "websockets-13.0.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fac2d146ff30d9dd2fcf917e5d147db037a5c573f0446c564f16f1f94cf87462"}, + {file = "websockets-13.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:b8ac5b46fd798bbbf2ac6620e0437c36a202b08e1f827832c4bf050da081b501"}, + {file = "websockets-13.0.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:46af561eba6f9b0848b2c9d2427086cabadf14e0abdd9fde9d72d447df268418"}, + {file = "websockets-13.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b5a06d7f60bc2fc378a333978470dfc4e1415ee52f5f0fce4f7853eb10c1e9df"}, + {file = "websockets-13.0.1-cp311-cp311-win32.whl", hash = "sha256:556e70e4f69be1082e6ef26dcb70efcd08d1850f5d6c5f4f2bcb4e397e68f01f"}, + {file = "websockets-13.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:67494e95d6565bf395476e9d040037ff69c8b3fa356a886b21d8422ad86ae075"}, + {file = "websockets-13.0.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f9c9e258e3d5efe199ec23903f5da0eeaad58cf6fccb3547b74fd4750e5ac47a"}, + {file = "websockets-13.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6b41a1b3b561f1cba8321fb32987552a024a8f67f0d05f06fcf29f0090a1b956"}, + {file = "websockets-13.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f73e676a46b0fe9426612ce8caeca54c9073191a77c3e9d5c94697aef99296af"}, + {file = "websockets-13.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f613289f4a94142f914aafad6c6c87903de78eae1e140fa769a7385fb232fdf"}, + {file = "websockets-13.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0f52504023b1480d458adf496dc1c9e9811df4ba4752f0bc1f89ae92f4f07d0c"}, + {file = "websockets-13.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:139add0f98206cb74109faf3611b7783ceafc928529c62b389917a037d4cfdf4"}, + {file = "websockets-13.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:47236c13be337ef36546004ce8c5580f4b1150d9538b27bf8a5ad8edf23ccfab"}, + {file = "websockets-13.0.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:c44ca9ade59b2e376612df34e837013e2b273e6c92d7ed6636d0556b6f4db93d"}, + {file = "websockets-13.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9bbc525f4be3e51b89b2a700f5746c2a6907d2e2ef4513a8daafc98198b92237"}, + {file = "websockets-13.0.1-cp312-cp312-win32.whl", hash = "sha256:3624fd8664f2577cf8de996db3250662e259bfbc870dd8ebdcf5d7c6ac0b5185"}, + {file = "websockets-13.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0513c727fb8adffa6d9bf4a4463b2bade0186cbd8c3604ae5540fae18a90cb99"}, + {file = "websockets-13.0.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:1ee4cc030a4bdab482a37462dbf3ffb7e09334d01dd37d1063be1136a0d825fa"}, + {file = "websockets-13.0.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:dbb0b697cc0655719522406c059eae233abaa3243821cfdfab1215d02ac10231"}, + {file = "websockets-13.0.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:acbebec8cb3d4df6e2488fbf34702cbc37fc39ac7abf9449392cefb3305562e9"}, + {file = "websockets-13.0.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63848cdb6fcc0bf09d4a155464c46c64ffdb5807ede4fb251da2c2692559ce75"}, + {file = "websockets-13.0.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:872afa52a9f4c414d6955c365b6588bc4401272c629ff8321a55f44e3f62b553"}, + {file = "websockets-13.0.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:05e70fec7c54aad4d71eae8e8cab50525e899791fc389ec6f77b95312e4e9920"}, + {file = "websockets-13.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e82db3756ccb66266504f5a3de05ac6b32f287faacff72462612120074103329"}, + {file = "websockets-13.0.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:4e85f46ce287f5c52438bb3703d86162263afccf034a5ef13dbe4318e98d86e7"}, + {file = "websockets-13.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f3fea72e4e6edb983908f0db373ae0732b275628901d909c382aae3b592589f2"}, + {file = "websockets-13.0.1-cp313-cp313-win32.whl", hash = "sha256:254ecf35572fca01a9f789a1d0f543898e222f7b69ecd7d5381d8d8047627bdb"}, + {file = "websockets-13.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:ca48914cdd9f2ccd94deab5bcb5ac98025a5ddce98881e5cce762854a5de330b"}, + {file = "websockets-13.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b74593e9acf18ea5469c3edaa6b27fa7ecf97b30e9dabd5a94c4c940637ab96e"}, + {file = "websockets-13.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:132511bfd42e77d152c919147078460c88a795af16b50e42a0bd14f0ad71ddd2"}, + {file = "websockets-13.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:165bedf13556f985a2aa064309baa01462aa79bf6112fbd068ae38993a0e1f1b"}, + {file = "websockets-13.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e801ca2f448850685417d723ec70298feff3ce4ff687c6f20922c7474b4746ae"}, + {file = "websockets-13.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:30d3a1f041360f029765d8704eae606781e673e8918e6b2c792e0775de51352f"}, + {file = "websockets-13.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67648f5e50231b5a7f6d83b32f9c525e319f0ddc841be0de64f24928cd75a603"}, + {file = "websockets-13.0.1-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:4f0426d51c8f0926a4879390f53c7f5a855e42d68df95fff6032c82c888b5f36"}, + {file = "websockets-13.0.1-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:ef48e4137e8799998a343706531e656fdec6797b80efd029117edacb74b0a10a"}, + {file = "websockets-13.0.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:249aab278810bee585cd0d4de2f08cfd67eed4fc75bde623be163798ed4db2eb"}, + {file = "websockets-13.0.1-cp38-cp38-win32.whl", hash = "sha256:06c0a667e466fcb56a0886d924b5f29a7f0886199102f0a0e1c60a02a3751cb4"}, + {file = "websockets-13.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1f3cf6d6ec1142412d4535adabc6bd72a63f5f148c43fe559f06298bc21953c9"}, + {file = "websockets-13.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:1fa082ea38d5de51dd409434edc27c0dcbd5fed2b09b9be982deb6f0508d25bc"}, + {file = "websockets-13.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4a365bcb7be554e6e1f9f3ed64016e67e2fa03d7b027a33e436aecf194febb63"}, + {file = "websockets-13.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:10a0dc7242215d794fb1918f69c6bb235f1f627aaf19e77f05336d147fce7c37"}, + {file = "websockets-13.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:59197afd478545b1f73367620407b0083303569c5f2d043afe5363676f2697c9"}, + {file = "websockets-13.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7d20516990d8ad557b5abeb48127b8b779b0b7e6771a265fa3e91767596d7d97"}, + {file = "websockets-13.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1a2e272d067030048e1fe41aa1ec8cfbbaabce733b3d634304fa2b19e5c897f"}, + {file = "websockets-13.0.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ad327ac80ba7ee61da85383ca8822ff808ab5ada0e4a030d66703cc025b021c4"}, + {file = "websockets-13.0.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:518f90e6dd089d34eaade01101fd8a990921c3ba18ebbe9b0165b46ebff947f0"}, + {file = "websockets-13.0.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:68264802399aed6fe9652e89761031acc734fc4c653137a5911c2bfa995d6d6d"}, + {file = "websockets-13.0.1-cp39-cp39-win32.whl", hash = "sha256:a5dc0c42ded1557cc7c3f0240b24129aefbad88af4f09346164349391dea8e58"}, + {file = "websockets-13.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:b448a0690ef43db5ef31b3a0d9aea79043882b4632cfc3eaab20105edecf6097"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:faef9ec6354fe4f9a2c0bbb52fb1ff852effc897e2a4501e25eb3a47cb0a4f89"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:03d3f9ba172e0a53e37fa4e636b86cc60c3ab2cfee4935e66ed1d7acaa4625ad"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d450f5a7a35662a9b91a64aefa852f0c0308ee256122f5218a42f1d13577d71e"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f55b36d17ac50aa8a171b771e15fbe1561217510c8768af3d546f56c7576cdc"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14b9c006cac63772b31abbcd3e3abb6228233eec966bf062e89e7fa7ae0b7333"}, + {file = "websockets-13.0.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:b79915a1179a91f6c5f04ece1e592e2e8a6bd245a0e45d12fd56b2b59e559a32"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:f40de079779acbcdbb6ed4c65af9f018f8b77c5ec4e17a4b737c05c2db554491"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:80e4ba642fc87fa532bac07e5ed7e19d56940b6af6a8c61d4429be48718a380f"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2a02b0161c43cc9e0232711eff846569fad6ec836a7acab16b3cf97b2344c060"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6aa74a45d4cdc028561a7d6ab3272c8b3018e23723100b12e58be9dfa5a24491"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:00fd961943b6c10ee6f0b1130753e50ac5dcd906130dcd77b0003c3ab797d026"}, + {file = "websockets-13.0.1-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:d93572720d781331fb10d3da9ca1067817d84ad1e7c31466e9f5e59965618096"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:71e6e5a3a3728886caee9ab8752e8113670936a193284be9d6ad2176a137f376"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:c4a6343e3b0714e80da0b0893543bf9a5b5fa71b846ae640e56e9abc6fbc4c83"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a678532018e435396e37422a95e3ab87f75028ac79570ad11f5bf23cd2a7d8c"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6716c087e4aa0b9260c4e579bb82e068f84faddb9bfba9906cb87726fa2e870"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e33505534f3f673270dd67f81e73550b11de5b538c56fe04435d63c02c3f26b5"}, + {file = "websockets-13.0.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:acab3539a027a85d568c2573291e864333ec9d912675107d6efceb7e2be5d980"}, + {file = "websockets-13.0.1-py3-none-any.whl", hash = "sha256:b80f0c51681c517604152eb6a572f5a9378f877763231fddb883ba2f968e8817"}, + {file = "websockets-13.0.1.tar.gz", hash = "sha256:4d6ece65099411cfd9a48d13701d7438d9c34f479046b34c50ff60bb8834e43e"}, ] [[package]] @@ -3119,20 +2834,24 @@ h11 = ">=0.9.0,<1" [[package]] name = "zipp" -version = "3.20.0" +version = "3.20.2" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.8" files = [ - {file = "zipp-3.20.0-py3-none-any.whl", hash = "sha256:58da6168be89f0be59beb194da1250516fdaa062ccebd30127ac65d30045e10d"}, - {file = "zipp-3.20.0.tar.gz", hash = "sha256:0145e43d89664cfe1a2e533adc75adafed82fe2da404b4bbb6b026c0157bdb31"}, + {file = "zipp-3.20.2-py3-none-any.whl", hash = "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350"}, + {file = "zipp-3.20.2.tar.gz", hash = "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29"}, ] [package.extras] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] +type = ["pytest-mypy"] [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "4b609c46858e2a6766b9c9b759833a1366dbe7bb64b3332f339a9c9f713a870f" +python-versions = "^3.10" +content-hash = "1c8904971be7061c2b33400d2b5f461e526703586e5b7f9eb08c2fbfda1a23ab" diff --git a/pyproject.toml b/pyproject.toml index 92a096f7b..203ccc917 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,10 +26,10 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.10" dill = ">=0.3.8,<0.4" -fastapi = ">=0.96.0,<0.111.0" -gunicorn = ">=20.1.0,<23.0" +fastapi = ">=0.96.0,!=0.111.0,!=0.111.1" +gunicorn = ">=20.1.0,<24.0" jinja2 = ">=3.1.2,<4.0" psutil = ">=5.9.4,<7.0" pydantic = ">=1.10.2,<3.0" @@ -40,8 +40,6 @@ rich = ">=13.0.0,<14.0" sqlmodel = ">=0.0.14,<0.1" typer = ">=0.4.2,<1.0" uvicorn = ">=0.20.0" -watchdog = ">=2.3.1,<5.0" -watchfiles = ">=0.19.0,<1.0" starlette-admin = ">=0.11.0,<1.0" alembic = ">=1.11.1,<2.0" platformdirs = ">=3.10.0,<5.0" @@ -61,7 +59,7 @@ httpx = ">=0.25.1,<1.0" twine = ">=4.0.0,<6.0" tomlkit = ">=0.12.4,<1.0" lazy_loader = ">=0.4" -reflex-chakra = ">=0.6.0a" +reflex-chakra = ">=0.6.0a6" [tool.poetry.group.dev.dependencies] pytest = ">=7.1.2,<8.0" @@ -72,16 +70,11 @@ toml = ">=0.10.2,<1.0" pytest-asyncio = ">=0.20.1,<0.22.0" # https://github.com/pytest-dev/pytest-asyncio/issues/706 pytest-cov = ">=4.0.0,<5.0" ruff = "^0.4.9" -pandas = [ - {version = ">=2.1.1,<3.0", python = ">=3.9,<3.13"}, - {version = ">=1.5.3,<2.0", python = ">=3.8,<3.9"}, -] -pillow = [ - {version = ">=10.0.0,<11.0", python = ">=3.8,<4.0"} -] +pandas = ">=2.1.1,<3.0" +pillow = ">=10.0.0,<11.0" plotly = ">=5.13.0,<6.0" asynctest = ">=0.13.0,<1.0" -pre-commit = {version = ">=3.2.1", python = ">=3.8,<4.0"} +pre-commit = ">=3.2.1" selenium = ">=4.11.0,<5.0" pytest-benchmark = ">=4.0.0,<5.0" @@ -95,7 +88,7 @@ build-backend = "poetry.core.masonry.api" [tool.pyright] [tool.ruff] -target-version = "py38" +target-version = "py310" lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541"] lint.pydocstyle.convention = "google" diff --git a/reflex/.templates/apps/demo/.gitignore b/reflex/.templates/apps/demo/.gitignore deleted file mode 100644 index eab0d4b05..000000000 --- a/reflex/.templates/apps/demo/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.db -*.py[cod] -.web -__pycache__/ \ No newline at end of file diff --git a/reflex/.templates/apps/demo/assets/favicon.ico b/reflex/.templates/apps/demo/assets/favicon.ico deleted file mode 100644 index 166ae995e..000000000 Binary files a/reflex/.templates/apps/demo/assets/favicon.ico and /dev/null differ diff --git a/reflex/.templates/apps/demo/assets/github.svg b/reflex/.templates/apps/demo/assets/github.svg deleted file mode 100644 index 61c9d791b..000000000 --- a/reflex/.templates/apps/demo/assets/github.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/icon.svg b/reflex/.templates/apps/demo/assets/icon.svg deleted file mode 100644 index b9cc89da9..000000000 --- a/reflex/.templates/apps/demo/assets/icon.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/logo.svg b/reflex/.templates/apps/demo/assets/logo.svg deleted file mode 100644 index 94fe1f511..000000000 --- a/reflex/.templates/apps/demo/assets/logo.svg +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/paneleft.svg b/reflex/.templates/apps/demo/assets/paneleft.svg deleted file mode 100644 index ac9c5040a..000000000 --- a/reflex/.templates/apps/demo/assets/paneleft.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/code/__init__.py b/reflex/.templates/apps/demo/code/__init__.py deleted file mode 100644 index e1d286346..000000000 --- a/reflex/.templates/apps/demo/code/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Base template for Reflex.""" diff --git a/reflex/.templates/apps/demo/code/demo.py b/reflex/.templates/apps/demo/code/demo.py deleted file mode 100644 index bdb1a447d..000000000 --- a/reflex/.templates/apps/demo/code/demo.py +++ /dev/null @@ -1,127 +0,0 @@ -"""Welcome to Reflex! This file outlines the steps to create a basic app.""" - -from typing import Callable - -import reflex as rx - -from .pages import chatapp_page, datatable_page, forms_page, graphing_page, home_page -from .sidebar import sidebar -from .state import State -from .styles import * - -meta = [ - { - "name": "viewport", - "content": "width=device-width, shrink-to-fit=no, initial-scale=1", - }, -] - - -def template(main_content: Callable[[], rx.Component]) -> rx.Component: - """The template for each page of the app. - - Args: - main_content (Callable[[], rx.Component]): The main content of the page. - - Returns: - rx.Component: The template for each page of the app. - """ - menu_button = rx.chakra.box( - rx.chakra.menu( - rx.chakra.menu_button( - rx.chakra.icon( - tag="hamburger", - size="4em", - color=text_color, - ), - ), - rx.chakra.menu_list( - rx.chakra.menu_item(rx.chakra.link("Home", href="/", width="100%")), - rx.chakra.menu_divider(), - rx.chakra.menu_item( - rx.chakra.link( - "About", href="https://github.com/reflex-dev", width="100%" - ) - ), - rx.chakra.menu_item( - rx.chakra.link( - "Contact", href="mailto:founders@reflex.dev", width="100%" - ) - ), - ), - ), - position="fixed", - right="1.5em", - top="1.5em", - z_index="500", - ) - - return rx.chakra.hstack( - sidebar(), - main_content(), - rx.chakra.spacer(), - menu_button, - align_items="flex-start", - transition="left 0.5s, width 0.5s", - position="relative", - left=rx.cond(State.sidebar_displayed, "0px", f"-{sidebar_width}"), - ) - - -@rx.page("/", meta=meta) -@template -def home() -> rx.Component: - """Home page. - - Returns: - rx.Component: The home page. - """ - return home_page() - - -@rx.page("/forms", meta=meta) -@template -def forms() -> rx.Component: - """Forms page. - - Returns: - rx.Component: The settings page. - """ - return forms_page() - - -@rx.page("/graphing", meta=meta) -@template -def graphing() -> rx.Component: - """Graphing page. - - Returns: - rx.Component: The graphing page. - """ - return graphing_page() - - -@rx.page("/datatable", meta=meta) -@template -def datatable() -> rx.Component: - """Data Table page. - - Returns: - rx.Component: The chatapp page. - """ - return datatable_page() - - -@rx.page("/chatapp", meta=meta) -@template -def chatapp() -> rx.Component: - """Chatapp page. - - Returns: - rx.Component: The chatapp page. - """ - return chatapp_page() - - -# Create the app. -app = rx.App(style=base_style) diff --git a/reflex/.templates/apps/demo/code/pages/__init__.py b/reflex/.templates/apps/demo/code/pages/__init__.py deleted file mode 100644 index ab6df6e3a..000000000 --- a/reflex/.templates/apps/demo/code/pages/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""The pages of the app.""" - -from .chatapp import chatapp_page -from .datatable import datatable_page -from .forms import forms_page -from .graphing import graphing_page -from .home import home_page diff --git a/reflex/.templates/apps/demo/code/pages/chatapp.py b/reflex/.templates/apps/demo/code/pages/chatapp.py deleted file mode 100644 index acd11a599..000000000 --- a/reflex/.templates/apps/demo/code/pages/chatapp.py +++ /dev/null @@ -1,31 +0,0 @@ -"""The main Chat app.""" - -import reflex as rx - -from ..styles import * -from ..webui import styles -from ..webui.components import chat, modal, navbar, sidebar - - -def chatapp_page() -> rx.Component: - """The main app. - - Returns: - The UI for the main app. - """ - return rx.chakra.box( - rx.chakra.vstack( - navbar(), - chat.chat(), - chat.action_bar(), - sidebar(), - modal(), - bg=styles.bg_dark_color, - color=styles.text_light_color, - min_h="100vh", - align_items="stretch", - spacing="0", - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/datatable.py b/reflex/.templates/apps/demo/code/pages/datatable.py deleted file mode 100644 index 53351ecf3..000000000 --- a/reflex/.templates/apps/demo/code/pages/datatable.py +++ /dev/null @@ -1,360 +0,0 @@ -"""The settings page for the template.""" - -from typing import Any - -import reflex as rx -from reflex.components.datadisplay.dataeditor import DataEditorTheme - -from ..styles import * -from ..webui.state import State - - -class DataTableState(State): - """Datatable state.""" - - cols: list[Any] = [ - {"title": "Title", "type": "str"}, - { - "title": "Name", - "type": "str", - "group": "Data", - "width": 300, - }, - { - "title": "Birth", - "type": "str", - "group": "Data", - "width": 150, - }, - { - "title": "Human", - "type": "bool", - "group": "Data", - "width": 80, - }, - { - "title": "House", - "type": "str", - "group": "Data", - }, - { - "title": "Wand", - "type": "str", - "group": "Data", - "width": 250, - }, - { - "title": "Patronus", - "type": "str", - "group": "Data", - }, - { - "title": "Blood status", - "type": "str", - "group": "Data", - "width": 200, - }, - ] - - data = [ - [ - "1", - "Harry James Potter", - "31 July 1980", - True, - "Gryffindor", - "11' Holly phoenix feather", - "Stag", - "Half-blood", - ], - [ - "2", - "Ronald Bilius Weasley", - "1 March 1980", - True, - "Gryffindor", - "12' Ash unicorn tail hair", - "Jack Russell terrier", - "Pure-blood", - ], - [ - "3", - "Hermione Jean Granger", - "19 September, 1979", - True, - "Gryffindor", - "10¾' vine wood dragon heartstring", - "Otter", - "Muggle-born", - ], - [ - "4", - "Albus Percival Wulfric Brian Dumbledore", - "Late August 1881", - True, - "Gryffindor", - "15' Elder Thestral tail hair core", - "Phoenix", - "Half-blood", - ], - [ - "5", - "Rubeus Hagrid", - "6 December 1928", - False, - "Gryffindor", - "16' Oak unknown core", - "None", - "Part-Human (Half-giant)", - ], - [ - "6", - "Fred Weasley", - "1 April, 1978", - True, - "Gryffindor", - "Unknown", - "Unknown", - "Pure-blood", - ], - [ - "7", - "George Weasley", - "1 April, 1978", - True, - "Gryffindor", - "Unknown", - "Unknown", - "Pure-blood", - ], - ] - - -code_show = """rx.chakra.hstack( - rx.chakra.divider(orientation="vertical", height="100vh", border="solid black 1px"), - rx.chakra.vstack( - rx.chakra.box( - rx.data_editor( - columns=DataTableState.cols, - data=DataTableState.data, - draw_focus_ring=True, - row_height=50, - smooth_scroll_x=True, - smooth_scroll_y=True, - column_select="single", - # style - theme=DataEditorTheme(**darkTheme), - width="80vw", - height="80vh", - ), - ), - rx.chakra.spacer(), - height="100vh", - spacing="25", - ), -)""" - -state_show = """class DataTableState(State): - cols: list[Any] = [ - {"title": "Title", "type": "str"}, - { - "title": "Name", - "type": "str", - "group": "Data", - "width": 300, - }, - { - "title": "Birth", - "type": "str", - "group": "Data", - "width": 150, - }, - { - "title": "Human", - "type": "bool", - "group": "Data", - "width": 80, - }, - { - "title": "House", - "type": "str", - "group": "Data", - }, - { - "title": "Wand", - "type": "str", - "group": "Data", - "width": 250, - }, - { - "title": "Patronus", - "type": "str", - "group": "Data", - }, - { - "title": "Blood status", - "type": "str", - "group": "Data", - "width": 200, - }, - ]""" - -data_show = """[ - ["1", "Harry James Potter", "31 July 1980", True, "Gryffindor", "11' Holly phoenix feather", "Stag", "Half-blood"], - ["2", "Ronald Bilius Weasley", "1 March 1980", True,"Gryffindor", "12' Ash unicorn tail hair", "Jack Russell terrier", "Pure-blood"], - ["3", "Hermione Jean Granger", "19 September, 1979", True, "Gryffindor", "10¾' vine wood dragon heartstring", "Otter", "Muggle-born"], - ["4", "Albus Percival Wulfric Brian Dumbledore", "Late August 1881", True, "Gryffindor", "15' Elder Thestral tail hair core", "Phoenix", "Half-blood"], - ["5", "Rubeus Hagrid", "6 December 1928", False, "Gryffindor", "16' Oak unknown core", "None", "Part-Human (Half-giant)"], - ["6", "Fred Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"], - ["7", "George Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"], -]""" - - -darkTheme = { - "accent_color": "#8c96ff", - "accent_light": "rgba(202, 206, 255, 0.253)", - "text_dark": "#ffffff", - "text_medium": "#b8b8b8", - "text_light": "#a0a0a0", - "text_bubble": "#ffffff", - "bg_icon_header": "#b8b8b8", - "fg_icon_header": "#000000", - "text_header": "#a1a1a1", - "text_header_selected": "#000000", - "bg_cell": "#16161b", - "bg_cell_medium": "#202027", - "bg_header": "#212121", - "bg_header_has_focus": "#474747", - "bg_header_hovered": "#404040", - "bg_bubble": "#212121", - "bg_bubble_selected": "#000000", - "bg_search_result": "#423c24", - "border_color": "rgba(225,225,225,0.2)", - "drilldown_border": "rgba(225,225,225,0.4)", - "link_color": "#4F5DFF", - "header_font_style": "bold 14px", - "base_font_style": "13px", - "font_family": "Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif", -} - -darkTheme_show = """darkTheme={ - "accent_color": "#8c96ff", - "accent_light": "rgba(202, 206, 255, 0.253)", - "text_dark": "#ffffff", - "text_medium": "#b8b8b8", - "text_light": "#a0a0a0", - "text_bubble": "#ffffff", - "bg_icon_header": "#b8b8b8", - "fg_icon_header": "#000000", - "text_header": "#a1a1a1", - "text_header_selected": "#000000", - "bg_cell": "#16161b", - "bg_cell_medium": "#202027", - "bg_header": "#212121", - "bg_header_has_focus": "#474747", - "bg_header_hovered": "#404040", - "bg_bubble": "#212121", - "bg_bubble_selected": "#000000", - "bg_search_result": "#423c24", - "border_color": "rgba(225,225,225,0.2)", - "drilldown_border": "rgba(225,225,225,0.4)", - "link_color": "#4F5DFF", - "header_font_style": "bold 14px", - "base_font_style": "13px", - "font_family": "Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif", -}""" - - -def datatable_page() -> rx.Component: - """The UI for the settings page. - - Returns: - rx.Component: The UI for the settings page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Data Table Demo", - font_size="3em", - ), - rx.chakra.hstack( - rx.chakra.vstack( - rx.chakra.box( - rx.data_editor( - columns=DataTableState.cols, - data=DataTableState.data, - draw_focus_ring=True, - row_height=50, - smooth_scroll_x=True, - smooth_scroll_y=True, - column_select="single", - # style - theme=DataEditorTheme(**darkTheme), - width="80vw", - ), - ), - rx.chakra.spacer(), - spacing="25", - ), - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("Data", style=tab_style), - rx.chakra.tab("State", style=tab_style), - rx.chakra.tab("Styling", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - code_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - data_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - state_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - darkTheme_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/forms.py b/reflex/.templates/apps/demo/code/pages/forms.py deleted file mode 100644 index 6e3150067..000000000 --- a/reflex/.templates/apps/demo/code/pages/forms.py +++ /dev/null @@ -1,257 +0,0 @@ -"""The settings page for the template.""" - -import reflex as rx - -from ..states.form_state import FormState, UploadState -from ..styles import * - -forms_1_code = """rx.chakra.vstack( - rx.chakra.form( - rx.chakra.vstack( - rx.chakra.input( - placeholder="First Name", - id="first_name", - ), - rx.chakra.input( - placeholder="Last Name", id="last_name" - ), - rx.chakra.hstack( - rx.chakra.checkbox("Checked", id="check"), - rx.chakra.switch("Switched", id="switch"), - ), - rx.chakra.button("Submit", - type_="submit", - bg="#ecfdf5", - color="#047857", - border_radius="lg", - ), - ), - on_submit=FormState.handle_submit, - ), - rx.chakra.divider(), - rx.chakra.heading("Results"), - rx.chakra.text(FormState.form_data.to_string()), - width="100%", -)""" - -color = "rgb(107,99,246)" - -forms_1_state = """class FormState(rx.State): - - form_data: dict = {} - - def handle_submit(self, form_data: dict): - "Handle the form submit." - self.form_data = form_data""" - - -forms_2_code = """rx.chakra.vstack( - rx.upload( - rx.chakra.vstack( - rx.chakra.button( - "Select File", - color=color, - bg="white", - border=f"1px solid {color}", - ), - rx.chakra.text( - "Drag and drop files here or click to select files" - ), - ), - border=f"1px dotted {color}", - padding="5em", - ), - rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)), - rx.chakra.button( - "Upload", - on_click=lambda: UploadState.handle_upload( - rx.upload_files() - ), - ), - rx.chakra.button( - "Clear", - on_click=rx.clear_selected_files, - ), - rx.foreach( - UploadState.img, lambda img: rx.chakra.image(src=img, width="20%", height="auto",) - ), - padding="5em", - width="100%", -)""" - -forms_2_state = """class UploadState(State): - "The app state." - - # The images to show. - img: list[str] - - async def handle_upload( - self, files: list[rx.UploadFile] - ): - "Handle the upload of file(s). - - Args: - files: The uploaded files. - " - for file in files: - upload_data = await file.read() - outfile = rx.get_asset_path(file.filename) - # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) - - # Update the img var. - self.img.append(f"/{file.filename}")""" - - -def forms_page() -> rx.Component: - """The UI for the settings page. - - Returns: - rx.Component: The UI for the settings page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Forms Demo", - font_size="3em", - ), - rx.chakra.vstack( - rx.chakra.form( - rx.chakra.vstack( - rx.chakra.input( - placeholder="First Name", - id="first_name", - ), - rx.chakra.input(placeholder="Last Name", id="last_name"), - rx.chakra.hstack( - rx.chakra.checkbox("Checked", id="check"), - rx.chakra.switch("Switched", id="switch"), - ), - rx.chakra.button( - "Submit", - type_="submit", - bg="#ecfdf5", - color="#047857", - border_radius="lg", - ), - ), - on_submit=FormState.handle_submit, - ), - rx.chakra.divider(), - rx.chakra.heading("Results"), - rx.chakra.text(FormState.form_data.to_string()), - width="100%", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - forms_1_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - forms_1_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - rx.chakra.heading("Upload Example", font_size="3em"), - rx.chakra.text("Try uploading some images and see how they look."), - rx.chakra.vstack( - rx.upload( - rx.chakra.vstack( - rx.chakra.button( - "Select File", - color=color, - bg="white", - border=f"1px solid {color}", - ), - rx.chakra.text( - "Drag and drop files here or click to select files" - ), - ), - border=f"1px dotted {color}", - padding="5em", - ), - rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)), - rx.chakra.button( - "Upload", - on_click=lambda: UploadState.handle_upload(rx.upload_files()), - ), - rx.chakra.button( - "Clear", - on_click=rx.clear_selected_files, - ), - rx.foreach( - UploadState.img, - lambda img: rx.chakra.image( - src=img, - width="20%", - height="auto", - ), - ), - padding="5em", - width="100%", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - forms_2_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - forms_2_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/graphing.py b/reflex/.templates/apps/demo/code/pages/graphing.py deleted file mode 100644 index e56af96c1..000000000 --- a/reflex/.templates/apps/demo/code/pages/graphing.py +++ /dev/null @@ -1,253 +0,0 @@ -"""The dashboard page for the template.""" - -import reflex as rx - -from ..states.pie_state import PieChartState -from ..styles import * - -data_1 = [ - {"name": "Page A", "uv": 4000, "pv": 2400, "amt": 2400}, - {"name": "Page B", "uv": 3000, "pv": 1398, "amt": 2210}, - {"name": "Page C", "uv": 2000, "pv": 9800, "amt": 2290}, - {"name": "Page D", "uv": 2780, "pv": 3908, "amt": 2000}, - {"name": "Page E", "uv": 1890, "pv": 4800, "amt": 2181}, - {"name": "Page F", "uv": 2390, "pv": 3800, "amt": 2500}, - {"name": "Page G", "uv": 3490, "pv": 4300, "amt": 2100}, -] -data_1_show = """[ - {"name": "Page A", "uv": 4000, "pv": 2400, "amt": 2400}, - {"name": "Page B", "uv": 3000, "pv": 1398, "amt": 2210}, - {"name": "Page C", "uv": 2000, "pv": 9800, "amt": 2290}, - {"name": "Page D", "uv": 2780, "pv": 3908, "amt": 2000}, - {"name": "Page E", "uv": 1890, "pv": 4800, "amt": 2181}, - {"name": "Page F", "uv": 2390, "pv": 3800, "amt": 2500}, - {"name": "Page G", "uv": 3490, "pv": 4300, "amt": 2100}, -]""" - - -graph_1_code = """rx.recharts.composed_chart( - rx.recharts.area( - data_key="uv", stroke="#8884d8", fill="#8884d8" - ), - rx.recharts.bar( - data_key="amt", bar_size=20, fill="#413ea0" - ), - rx.recharts.line( - data_key="pv", type_="monotone", stroke="#ff7300" - ), - rx.recharts.x_axis(data_key="name"), - rx.recharts.y_axis(), - rx.recharts.cartesian_grid(stroke_dasharray="3 3"), - rx.recharts.graphing_tooltip(), - data=data, -)""" - - -graph_2_code = """rx.recharts.pie_chart( - rx.recharts.pie( - data=PieChartState.resources, - data_key="count", - name_key="type_", - cx="50%", - cy="50%", - start_angle=180, - end_angle=0, - fill="#8884d8", - label=True, - ), - rx.recharts.graphing_tooltip(), -), -rx.chakra.vstack( - rx.foreach( - PieChartState.resource_types, - lambda type_, i: rx.chakra.hstack( - rx.chakra.button( - "-", - on_click=PieChartState.decrement(type_), - ), - rx.chakra.text( - type_, - PieChartState.resources[i]["count"], - ), - rx.chakra.button( - "+", - on_click=PieChartState.increment(type_), - ), - ), - ), -)""" - -graph_2_state = """class PieChartState(rx.State): - resources: list[dict[str, Any]] = [ - dict(type_="🏆", count=1), - dict(type_="🪵", count=1), - dict(type_="🥑", count=1), - dict(type_="🧱", count=1), - ] - - @rx.cached_var - def resource_types(self) -> list[str]: - return [r["type_"] for r in self.resources] - - def increment(self, type_: str): - for resource in self.resources: - if resource["type_"] == type_: - resource["count"] += 1 - break - - def decrement(self, type_: str): - for resource in self.resources: - if ( - resource["type_"] == type_ - and resource["count"] > 0 - ): - resource["count"] -= 1 - break -""" - - -def graphing_page() -> rx.Component: - """The UI for the dashboard page. - - Returns: - rx.Component: The UI for the dashboard page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Graphing Demo", - font_size="3em", - ), - rx.chakra.heading( - "Composed Chart", - font_size="2em", - ), - rx.chakra.stack( - rx.recharts.composed_chart( - rx.recharts.area(data_key="uv", stroke="#8884d8", fill="#8884d8"), - rx.recharts.bar(data_key="amt", bar_size=20, fill="#413ea0"), - rx.recharts.line(data_key="pv", type_="monotone", stroke="#ff7300"), - rx.recharts.x_axis(data_key="name"), - rx.recharts.y_axis(), - rx.recharts.cartesian_grid(stroke_dasharray="3 3"), - rx.recharts.graphing_tooltip(), - data=data_1, - # height="15em", - ), - width="100%", - height="20em", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("Data", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - graph_1_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - data_1_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - rx.chakra.heading("Interactive Example", font_size="2em"), - rx.chakra.hstack( - rx.recharts.pie_chart( - rx.recharts.pie( - data=PieChartState.resources, - data_key="count", - name_key="type_", - cx="50%", - cy="50%", - start_angle=180, - end_angle=0, - fill="#8884d8", - label=True, - ), - rx.recharts.graphing_tooltip(), - ), - rx.chakra.vstack( - rx.foreach( - PieChartState.resource_types, - lambda type_, i: rx.chakra.hstack( - rx.chakra.button( - "-", - on_click=PieChartState.decrement(type_), - ), - rx.chakra.text( - type_, - PieChartState.resources[i]["count"], - ), - rx.chakra.button( - "+", - on_click=PieChartState.increment(type_), - ), - ), - ), - ), - width="100%", - height="15em", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - graph_2_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - graph_2_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - min_h="100vh", - ), - style=template_page_style, - min_h="100vh", - ) diff --git a/reflex/.templates/apps/demo/code/pages/home.py b/reflex/.templates/apps/demo/code/pages/home.py deleted file mode 100644 index 8d85e015b..000000000 --- a/reflex/.templates/apps/demo/code/pages/home.py +++ /dev/null @@ -1,56 +0,0 @@ -"""The home page of the app.""" - -import reflex as rx - -from ..styles import * - - -def home_page() -> rx.Component: - """The UI for the home page. - - Returns: - rx.Component: The UI for the home page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Welcome to Reflex! 👋", - font_size="3em", - ), - rx.chakra.text( - "Reflex is an open-source app framework built specifically to allow you to build web apps in pure python. 👈 Select a demo from the sidebar to see some examples of what Reflex can do!", - ), - rx.chakra.heading( - "Things to check out:", - font_size="2em", - ), - rx.chakra.unordered_list( - rx.chakra.list_item( - "Take a look at ", - rx.chakra.link( - "reflex.dev", - href="https://reflex.dev", - color="rgb(107,99,246)", - ), - ), - rx.chakra.list_item( - "Check out our ", - rx.chakra.link( - "docs", - href="https://reflex.dev/docs/getting-started/introduction/", - color="rgb(107,99,246)", - ), - ), - rx.chakra.list_item( - "Ask a question in our ", - rx.chakra.link( - "community", - href="https://discord.gg/T5WSbC2YtQ", - color="rgb(107,99,246)", - ), - ), - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/sidebar.py b/reflex/.templates/apps/demo/code/sidebar.py deleted file mode 100644 index 5f634402f..000000000 --- a/reflex/.templates/apps/demo/code/sidebar.py +++ /dev/null @@ -1,178 +0,0 @@ -"""Sidebar component for the app.""" - -import reflex as rx - -from .state import State -from .styles import * - - -def sidebar_header() -> rx.Component: - """Sidebar header. - - Returns: - rx.Component: The sidebar header component. - """ - return rx.chakra.hstack( - rx.chakra.image( - src="/icon.svg", - height="2em", - ), - rx.chakra.spacer(), - rx.chakra.link( - rx.chakra.center( - rx.chakra.image( - src="/github.svg", - height="3em", - padding="0.5em", - ), - box_shadow=box_shadow, - bg="transparent", - border_radius=border_radius, - _hover={ - "bg": accent_color, - }, - ), - href="https://github.com/reflex-dev/reflex", - ), - width="100%", - border_bottom=border, - padding="1em", - ) - - -def sidebar_footer() -> rx.Component: - """Sidebar footer. - - Returns: - rx.Component: The sidebar footer component. - """ - return rx.chakra.hstack( - rx.chakra.link( - rx.chakra.center( - rx.chakra.image( - src="/paneleft.svg", - height="2em", - padding="0.5em", - ), - bg="transparent", - border_radius=border_radius, - **hover_accent_bg, - ), - on_click=State.toggle_sidebar_displayed, - transform=rx.cond(~State.sidebar_displayed, "rotate(180deg)", ""), - transition="transform 0.5s, left 0.5s", - position="relative", - left=rx.cond(State.sidebar_displayed, "0px", "20.5em"), - **overlapping_button_style, - ), - rx.chakra.spacer(), - rx.chakra.link( - rx.chakra.text( - "Docs", - ), - href="https://reflex.dev/docs/getting-started/introduction/", - ), - rx.chakra.link( - rx.chakra.text( - "Blog", - ), - href="https://reflex.dev/blog/", - ), - width="100%", - border_top=border, - padding="1em", - ) - - -def sidebar_item(text: str, icon: str, url: str) -> rx.Component: - """Sidebar item. - - Args: - text (str): The text of the item. - icon (str): The icon of the item. - url (str): The URL of the item. - - Returns: - rx.Component: The sidebar item component. - """ - return rx.chakra.link( - rx.chakra.hstack( - rx.chakra.image( - src=icon, - height="2.5em", - padding="0.5em", - ), - rx.chakra.text( - text, - ), - bg=rx.cond( - State.origin_url == f"/{text.lower()}/", - accent_color, - "transparent", - ), - color=rx.cond( - State.origin_url == f"/{text.lower()}/", - accent_text_color, - text_color, - ), - border_radius=border_radius, - box_shadow=box_shadow, - width="100%", - padding_x="1em", - ), - href=url, - width="100%", - ) - - -def sidebar() -> rx.Component: - """Sidebar. - - Returns: - rx.Component: The sidebar component. - """ - return rx.chakra.box( - rx.chakra.vstack( - sidebar_header(), - rx.chakra.vstack( - sidebar_item( - "Welcome", - "/github.svg", - "/", - ), - sidebar_item( - "Graphing Demo", - "/github.svg", - "/graphing", - ), - sidebar_item( - "Data Table Demo", - "/github.svg", - "/datatable", - ), - sidebar_item( - "Forms Demo", - "/github.svg", - "/forms", - ), - sidebar_item( - "Chat App Demo", - "/github.svg", - "/chatapp", - ), - width="100%", - overflow_y="auto", - align_items="flex-start", - padding="1em", - ), - rx.chakra.spacer(), - sidebar_footer(), - height="100dvh", - ), - display=["none", "none", "block"], - min_width=sidebar_width, - height="100%", - position="sticky", - top="0px", - border_right=border, - ) diff --git a/reflex/.templates/apps/demo/code/state.py b/reflex/.templates/apps/demo/code/state.py deleted file mode 100644 index a5c6f57bd..000000000 --- a/reflex/.templates/apps/demo/code/state.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Base state for the app.""" - -import reflex as rx - - -class State(rx.State): - """State for the app.""" - - sidebar_displayed: bool = True - - @rx.var - def origin_url(self) -> str: - """Get the url of the current page. - - Returns: - str: The url of the current page. - """ - return self.router_data.get("asPath", "") - - def toggle_sidebar_displayed(self) -> None: - """Toggle the sidebar displayed.""" - self.sidebar_displayed = not self.sidebar_displayed diff --git a/reflex/.templates/apps/demo/code/states/form_state.py b/reflex/.templates/apps/demo/code/states/form_state.py deleted file mode 100644 index 2b30e859e..000000000 --- a/reflex/.templates/apps/demo/code/states/form_state.py +++ /dev/null @@ -1,40 +0,0 @@ -import reflex as rx - -from ..state import State - - -class FormState(State): - """Form state.""" - - form_data: dict = {} - - def handle_submit(self, form_data: dict): - """Handle the form submit. - - Args: - form_data: The form data. - """ - self.form_data = form_data - - -class UploadState(State): - """The app state.""" - - # The images to show. - img: list[str] - - async def handle_upload(self, files: list[rx.UploadFile]): - """Handle the upload of file(s). - - Args: - files: The uploaded files. - """ - for file in files: - upload_data = await file.read() - outfile = rx.get_asset_path(file.filename) - # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) - - # Update the img var. - self.img.append(f"/{file.filename}") diff --git a/reflex/.templates/apps/demo/code/states/pie_state.py b/reflex/.templates/apps/demo/code/states/pie_state.py deleted file mode 100644 index 1c380c3af..000000000 --- a/reflex/.templates/apps/demo/code/states/pie_state.py +++ /dev/null @@ -1,47 +0,0 @@ -from typing import Any - -import reflex as rx - -from ..state import State - - -class PieChartState(State): - """Pie Chart State.""" - - resources: list[dict[str, Any]] = [ - dict(type_="🏆", count=1), - dict(type_="🪵", count=1), - dict(type_="🥑", count=1), - dict(type_="🧱", count=1), - ] - - @rx.cached_var - def resource_types(self) -> list[str]: - """Get the resource types. - - Returns: - The resource types. - """ - return [r["type_"] for r in self.resources] - - def increment(self, type_: str): - """Increment the count of a resource type. - - Args: - type_: The type of resource to increment. - """ - for resource in self.resources: - if resource["type_"] == type_: - resource["count"] += 1 - break - - def decrement(self, type_: str): - """Decrement the count of a resource type. - - Args: - type_: The type of resource to decrement. - """ - for resource in self.resources: - if resource["type_"] == type_ and resource["count"] > 0: - resource["count"] -= 1 - break diff --git a/reflex/.templates/apps/demo/code/styles.py b/reflex/.templates/apps/demo/code/styles.py deleted file mode 100644 index 5ca236ece..000000000 --- a/reflex/.templates/apps/demo/code/styles.py +++ /dev/null @@ -1,68 +0,0 @@ -"""Styles for the app.""" - -import reflex as rx - -from .state import State - -border_radius = "0.375rem" -box_shadow = "0px 0px 0px 1px rgba(84, 82, 95, 0.14)" -border = "1px solid #F4F3F6" -text_color = "black" -accent_text_color = "#1A1060" -accent_color = "#F5EFFE" -hover_accent_color = {"_hover": {"color": accent_color}} -hover_accent_bg = {"_hover": {"bg": accent_color}} -content_width_vw = "90vw" -sidebar_width = "20em" - -template_page_style = { - "padding_top": "5em", - "padding_x": "2em", -} - -template_content_style = { - "width": rx.cond( - State.sidebar_displayed, - f"calc({content_width_vw} - {sidebar_width})", - content_width_vw, - ), - "min-width": sidebar_width, - "align_items": "flex-start", - "box_shadow": box_shadow, - "border_radius": border_radius, - "padding": "1em", - "margin_bottom": "2em", -} - -link_style = { - "color": text_color, - "text_decoration": "none", - **hover_accent_color, -} - -overlapping_button_style = { - "background_color": "white", - "border": border, - "border_radius": border_radius, -} - -base_style = { - rx.chakra.MenuButton: { - "width": "3em", - "height": "3em", - **overlapping_button_style, - }, - rx.chakra.MenuItem: hover_accent_bg, -} - -tab_style = { - "color": "#494369", - "font_weight": 600, - "_selected": { - "color": "#5646ED", - "bg": "#F5EFFE", - "padding_x": "0.5em", - "padding_y": "0.25em", - "border_radius": "8px", - }, -} diff --git a/reflex/.templates/apps/demo/code/webui/__init__.py b/reflex/.templates/apps/demo/code/webui/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/reflex/.templates/apps/demo/code/webui/components/__init__.py b/reflex/.templates/apps/demo/code/webui/components/__init__.py deleted file mode 100644 index e29eb0ab2..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .loading_icon import loading_icon -from .modal import modal -from .navbar import navbar -from .sidebar import sidebar diff --git a/reflex/.templates/apps/demo/code/webui/components/chat.py b/reflex/.templates/apps/demo/code/webui/components/chat.py deleted file mode 100644 index fd9b6ba98..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/chat.py +++ /dev/null @@ -1,118 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.components import loading_icon -from ...webui.state import QA, State - - -def message(qa: QA) -> rx.Component: - """A single question/answer message. - - Args: - qa: The question/answer pair. - - Returns: - A component displaying the question/answer pair. - """ - return rx.chakra.box( - rx.chakra.box( - rx.chakra.text( - qa.question, - bg=styles.border_color, - shadow=styles.shadow_light, - **styles.message_style, - ), - text_align="right", - margin_top="1em", - ), - rx.chakra.box( - rx.chakra.text( - qa.answer, - bg=styles.accent_color, - shadow=styles.shadow_light, - **styles.message_style, - ), - text_align="left", - padding_top="1em", - ), - width="100%", - ) - - -def chat() -> rx.Component: - """List all the messages in a single conversation. - - Returns: - A component displaying all the messages in a single conversation. - """ - return rx.chakra.vstack( - rx.chakra.box(rx.foreach(State.chats[State.current_chat], message)), - py="8", - flex="1", - width="100%", - max_w="3xl", - padding_x="4", - align_self="center", - overflow="hidden", - padding_bottom="5em", - **styles.base_style[rx.chakra.Vstack], - ) - - -def action_bar() -> rx.Component: - """The action bar to send a new message. - - Returns: - The action bar to send a new message. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.form( - rx.chakra.form_control( - rx.chakra.hstack( - rx.chakra.input( - placeholder="Type something...", - value=State.question, - on_change=State.set_question, - _placeholder={"color": "#fffa"}, - _hover={"border_color": styles.accent_color}, - style=styles.input_style, - ), - rx.chakra.button( - rx.cond( - State.processing, - loading_icon(height="1em"), - rx.chakra.text("Send"), - ), - type_="submit", - _hover={"bg": styles.accent_color}, - style=styles.input_style, - ), - **styles.base_style[rx.chakra.Hstack], - ), - is_disabled=State.processing, - ), - on_submit=State.process_question, - width="100%", - ), - rx.chakra.text( - "ReflexGPT may return factually incorrect or misleading responses. Use discretion.", - font_size="xs", - color="#fff6", - text_align="center", - ), - width="100%", - max_w="3xl", - mx="auto", - **styles.base_style[rx.chakra.Vstack], - ), - position="sticky", - bottom="0", - left="0", - py="4", - backdrop_filter="auto", - backdrop_blur="lg", - border_top=f"1px solid {styles.border_color}", - align_items="stretch", - width="100%", - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/loading_icon.py b/reflex/.templates/apps/demo/code/webui/components/loading_icon.py deleted file mode 100644 index 46cedb8ef..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/loading_icon.py +++ /dev/null @@ -1,19 +0,0 @@ -import reflex as rx - - -class LoadingIcon(rx.Component): - """A custom loading icon component.""" - - library = "react-loading-icons" - tag = "SpinningCircles" - stroke: rx.Var[str] - stroke_opacity: rx.Var[str] - fill: rx.Var[str] - fill_opacity: rx.Var[str] - stroke_width: rx.Var[str] - speed: rx.Var[str] - height: rx.Var[str] - on_change: rx.EventHandler[lambda status: [status]] - - -loading_icon = LoadingIcon.create diff --git a/reflex/.templates/apps/demo/code/webui/components/modal.py b/reflex/.templates/apps/demo/code/webui/components/modal.py deleted file mode 100644 index c76b8dffd..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/modal.py +++ /dev/null @@ -1,56 +0,0 @@ -import reflex as rx - -from ...webui.state import State - - -def modal() -> rx.Component: - """A modal to create a new chat. - - Returns: - The modal component. - """ - return rx.chakra.modal( - rx.chakra.modal_overlay( - rx.chakra.modal_content( - rx.chakra.modal_header( - rx.chakra.hstack( - rx.chakra.text("Create new chat"), - rx.chakra.icon( - tag="close", - font_size="sm", - on_click=State.toggle_modal, - color="#fff8", - _hover={"color": "#fff"}, - cursor="pointer", - ), - align_items="center", - justify_content="space-between", - ) - ), - rx.chakra.modal_body( - rx.chakra.input( - placeholder="Type something...", - on_blur=State.set_new_chat_name, - bg="#222", - border_color="#fff3", - _placeholder={"color": "#fffa"}, - ), - ), - rx.chakra.modal_footer( - rx.chakra.button( - "Create", - bg="#5535d4", - box_shadow="md", - px="4", - py="2", - h="auto", - _hover={"bg": "#4c2db3"}, - on_click=State.create_chat, - ), - ), - bg="#222", - color="#fff", - ), - ), - is_open=State.modal_open, - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/navbar.py b/reflex/.templates/apps/demo/code/webui/components/navbar.py deleted file mode 100644 index e836f29ec..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/navbar.py +++ /dev/null @@ -1,70 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.state import State - - -def navbar(): - return rx.chakra.box( - rx.chakra.hstack( - rx.chakra.hstack( - rx.chakra.icon( - tag="hamburger", - mr=4, - on_click=State.toggle_drawer, - cursor="pointer", - ), - rx.chakra.link( - rx.chakra.box( - rx.chakra.image(src="favicon.ico", width=30, height="auto"), - p="1", - border_radius="6", - bg="#F0F0F0", - mr="2", - ), - href="/", - ), - rx.chakra.breadcrumb( - rx.chakra.breadcrumb_item( - rx.chakra.heading("ReflexGPT", size="sm"), - ), - rx.chakra.breadcrumb_item( - rx.chakra.text( - State.current_chat, size="sm", font_weight="normal" - ), - ), - ), - ), - rx.chakra.hstack( - rx.chakra.button( - "+ New chat", - bg=styles.accent_color, - px="4", - py="2", - h="auto", - on_click=State.toggle_modal, - ), - rx.chakra.menu( - rx.chakra.menu_button( - rx.chakra.avatar(name="User", size="md"), - rx.chakra.box(), - ), - rx.chakra.menu_list( - rx.chakra.menu_item("Help"), - rx.chakra.menu_divider(), - rx.chakra.menu_item("Settings"), - ), - ), - spacing="8", - ), - justify="space-between", - ), - bg=styles.bg_dark_color, - backdrop_filter="auto", - backdrop_blur="lg", - p="4", - border_bottom=f"1px solid {styles.border_color}", - position="sticky", - top="0", - z_index="100", - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/sidebar.py b/reflex/.templates/apps/demo/code/webui/components/sidebar.py deleted file mode 100644 index b4ffdd41f..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/sidebar.py +++ /dev/null @@ -1,66 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.state import State - - -def sidebar_chat(chat: str) -> rx.Component: - """A sidebar chat item. - - Args: - chat: The chat item. - - Returns: - The sidebar chat item. - """ - return rx.chakra.hstack( - rx.chakra.box( - chat, - on_click=lambda: State.set_chat(chat), - style=styles.sidebar_style, - color=styles.icon_color, - flex="1", - ), - rx.chakra.box( - rx.chakra.icon( - tag="delete", - style=styles.icon_style, - on_click=State.delete_chat, - ), - style=styles.sidebar_style, - ), - color=styles.text_light_color, - cursor="pointer", - ) - - -def sidebar() -> rx.Component: - """The sidebar component. - - Returns: - The sidebar component. - """ - return rx.chakra.drawer( - rx.chakra.drawer_overlay( - rx.chakra.drawer_content( - rx.chakra.drawer_header( - rx.chakra.hstack( - rx.chakra.text("Chats"), - rx.chakra.icon( - tag="close", - on_click=State.toggle_drawer, - style=styles.icon_style, - ), - ) - ), - rx.chakra.drawer_body( - rx.chakra.vstack( - rx.foreach(State.chat_titles, lambda chat: sidebar_chat(chat)), - align_items="stretch", - ) - ), - ), - ), - placement="left", - is_open=State.drawer_open, - ) diff --git a/reflex/.templates/apps/demo/code/webui/state.py b/reflex/.templates/apps/demo/code/webui/state.py deleted file mode 100644 index 51739222d..000000000 --- a/reflex/.templates/apps/demo/code/webui/state.py +++ /dev/null @@ -1,146 +0,0 @@ -import asyncio - -import reflex as rx - -from ..state import State - -# openai.api_key = os.environ["OPENAI_API_KEY"] -# openai.api_base = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1") - - -class QA(rx.Base): - """A question and answer pair.""" - - question: str - answer: str - - -DEFAULT_CHATS = { - "Intros": [], -} - - -class State(State): - """The app state.""" - - # A dict from the chat name to the list of questions and answers. - chats: dict[str, list[QA]] = DEFAULT_CHATS - - # The current chat name. - current_chat = "Intros" - - # The current question. - question: str - - # Whether we are processing the question. - processing: bool = False - - # The name of the new chat. - new_chat_name: str = "" - - # Whether the drawer is open. - drawer_open: bool = False - - # Whether the modal is open. - modal_open: bool = False - - def create_chat(self): - """Create a new chat.""" - # Add the new chat to the list of chats. - self.current_chat = self.new_chat_name - self.chats[self.new_chat_name] = [] - - # Toggle the modal. - self.modal_open = False - - def toggle_modal(self): - """Toggle the new chat modal.""" - self.modal_open = not self.modal_open - - def toggle_drawer(self): - """Toggle the drawer.""" - self.drawer_open = not self.drawer_open - - def delete_chat(self): - """Delete the current chat.""" - del self.chats[self.current_chat] - if len(self.chats) == 0: - self.chats = DEFAULT_CHATS - # set self.current_chat to the first chat. - self.current_chat = next(iter(self.chats)) - self.toggle_drawer() - - def set_chat(self, chat_name: str): - """Set the name of the current chat. - - Args: - chat_name: The name of the chat. - """ - self.current_chat = chat_name - self.toggle_drawer() - - @rx.var - def chat_titles(self) -> list[str]: - """Get the list of chat titles. - - Returns: - The list of chat names. - """ - return [*self.chats] - - async def process_question(self, form_data: dict[str, str]): - """Get the response from the API. - - Args: - form_data: A dict with the current question. - - Yields: - The current question and the response. - """ - # Check if the question is empty - if self.question == "": - return - - # Add the question to the list of questions. - qa = QA(question=self.question, answer="") - self.chats[self.current_chat].append(qa) - - # Clear the input and start the processing. - self.processing = True - self.question = "" - yield - - # # Build the messages. - # messages = [ - # {"role": "system", "content": "You are a friendly chatbot named Reflex."} - # ] - # for qa in self.chats[self.current_chat]: - # messages.append({"role": "user", "content": qa.question}) - # messages.append({"role": "assistant", "content": qa.answer}) - - # # Remove the last mock answer. - # messages = messages[:-1] - - # Start a new session to answer the question. - # session = openai.ChatCompletion.create( - # model=os.getenv("OPENAI_MODEL", "gpt-3.5-turbo"), - # messages=messages, - # stream=True, - # ) - - # Stream the results, yielding after every word. - # for item in session: - answer = "I don't know! This Chatbot still needs to add in AI API keys!" - for i in range(len(answer)): - # Pause to show the streaming effect. - await asyncio.sleep(0.1) - # Add one letter at a time to the output. - - # if hasattr(item.choices[0].delta, "content"): - # answer_text = item.choices[0].delta.content - self.chats[self.current_chat][-1].answer += answer[i] - self.chats = self.chats - yield - - # Toggle the processing flag. - self.processing = False diff --git a/reflex/.templates/apps/demo/code/webui/styles.py b/reflex/.templates/apps/demo/code/webui/styles.py deleted file mode 100644 index 62212ac1a..000000000 --- a/reflex/.templates/apps/demo/code/webui/styles.py +++ /dev/null @@ -1,88 +0,0 @@ -import reflex as rx - -bg_dark_color = "#111" -bg_medium_color = "#222" - -border_color = "#fff3" - -accennt_light = "#6649D8" -accent_color = "#5535d4" -accent_dark = "#4c2db3" - -icon_color = "#fff8" - -text_light_color = "#fff" -shadow_light = "rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;" -shadow = "rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;" - -message_style = dict(display="inline-block", p="4", border_radius="xl", max_w="30em") - -input_style = dict( - bg=bg_medium_color, - border_color=border_color, - border_width="1px", - p="4", -) - -icon_style = dict( - font_size="md", - color=icon_color, - _hover=dict(color=text_light_color), - cursor="pointer", - w="8", -) - -sidebar_style = dict( - border="double 1px transparent;", - border_radius="10px;", - background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accent_dark});", - background_origin="border-box;", - background_clip="padding-box, border-box;", - p="2", - _hover=dict( - background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accennt_light});", - ), -) - -base_style = { - rx.chakra.Avatar: { - "shadow": shadow, - "color": text_light_color, - # "bg": border_color, - }, - rx.chakra.Button: { - "shadow": shadow, - "color": text_light_color, - "_hover": { - "bg": accent_dark, - }, - }, - rx.chakra.Menu: { - "bg": bg_dark_color, - "border": f"red", - }, - rx.chakra.MenuList: { - "bg": bg_dark_color, - "border": f"1.5px solid {bg_medium_color}", - }, - rx.chakra.MenuDivider: { - "border": f"1px solid {bg_medium_color}", - }, - rx.chakra.MenuItem: { - "bg": bg_dark_color, - "color": text_light_color, - }, - rx.chakra.DrawerContent: { - "bg": bg_dark_color, - "color": text_light_color, - "opacity": "0.9", - }, - rx.chakra.Hstack: { - "align_items": "center", - "justify_content": "space-between", - }, - rx.chakra.Vstack: { - "align_items": "stretch", - "justify_content": "space-between", - }, -} diff --git a/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 b/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 index e70a835a5..abfd998fd 100644 --- a/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +++ b/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 @@ -8,11 +8,11 @@ version = "0.0.1" description = "Reflex custom component {{ module_name }}" readme = "README.md" license = { text = "Apache-2.0" } -requires-python = ">=3.8" +requires-python = ">=3.10" authors = [{ name = "", email = "YOUREMAIL@domain.com" }] keywords = ["reflex","reflex-custom-components"] -dependencies = ["reflex>=0.4.2"] +dependencies = ["reflex>={{ reflex_version }}"] classifiers = ["Development Status :: 4 - Beta"] diff --git a/reflex/.templates/jinja/web/pages/_app.js.jinja2 b/reflex/.templates/jinja/web/pages/_app.js.jinja2 index d4322b171..97c31925d 100644 --- a/reflex/.templates/jinja/web/pages/_app.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/_app.js.jinja2 @@ -7,6 +7,10 @@ import '/styles/styles.css' {% block declaration %} import { EventLoopProvider, StateProvider, defaultColorMode } from "/utils/context.js"; import { ThemeProvider } from 'next-themes' +import * as React from "react"; +import * as utils_context from "/utils/context.js"; +import * as utils_state from "/utils/state.js"; +import * as radix from "@radix-ui/themes"; {% for custom_code in custom_codes %} {{custom_code}} @@ -26,8 +30,18 @@ function AppWrap({children}) { } export default function MyApp({ Component, pageProps }) { + React.useEffect(() => { + // Make contexts and state objects available globally for dynamic eval'd components + let windowImports = { + "react": React, + "@radix-ui/themes": radix, + "/utils/context": utils_context, + "/utils/state": utils_state, + }; + window["__reflex"] = windowImports; + }, []); return ( - + diff --git a/reflex/.templates/jinja/web/pages/utils.js.jinja2 b/reflex/.templates/jinja/web/pages/utils.js.jinja2 index 8e9808fbb..908482d24 100644 --- a/reflex/.templates/jinja/web/pages/utils.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/utils.js.jinja2 @@ -64,11 +64,11 @@ {# Args: #} {# component: component dictionary #} {% macro render_iterable_tag(component) %} -{ {%- if component.iterable_type == 'dict' -%}Object.entries({{- component.iterable_state }}){%- else -%}{{- component.iterable_state }}{%- endif -%}.map(({{ component.arg_name }}, {{ component.arg_index }}) => ( +<>{ {%- if component.iterable_type == 'dict' -%}Object.entries({{- component.iterable_state }}){%- else -%}{{- component.iterable_state }}{%- endif -%}.map(({{ component.arg_name }}, {{ component.arg_index }}) => ( {% for child in component.children %} {{ render(child) }} {% endfor %} -))} +))} {%- endmacro %} @@ -85,10 +85,10 @@ {% macro render_match_tag(component) %} { (() => { - switch (JSON.stringify({{ component.cond._var_name_unwrapped }})) { + switch (JSON.stringify({{ component.cond._js_expr }})) { {% for case in component.match_cases %} {% for condition in case[:-1] %} - case JSON.stringify({{ condition._var_name_unwrapped }}): + case JSON.stringify({{ condition._js_expr }}): {% endfor %} return {{ case[-1] }}; break; diff --git a/reflex/.templates/jinja/web/utils/theme.js.jinja2 b/reflex/.templates/jinja/web/utils/theme.js.jinja2 index a647a35b3..819abd232 100644 --- a/reflex/.templates/jinja/web/utils/theme.js.jinja2 +++ b/reflex/.templates/jinja/web/utils/theme.js.jinja2 @@ -1 +1 @@ -export default {{ theme|json_dumps }} \ No newline at end of file +export default {{ theme }} \ No newline at end of file diff --git a/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js b/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js deleted file mode 100644 index ad41d5134..000000000 --- a/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +++ /dev/null @@ -1,36 +0,0 @@ -import { useColorMode as chakraUseColorMode } from "@chakra-ui/react"; -import { useTheme } from "next-themes"; -import { useEffect, useState } from "react"; -import { ColorModeContext, defaultColorMode } from "/utils/context.js"; - -export default function ChakraColorModeProvider({ children }) { - const { theme, resolvedTheme, setTheme } = useTheme(); - const { colorMode, toggleColorMode } = chakraUseColorMode(); - const [resolvedColorMode, setResolvedColorMode] = useState(colorMode); - - useEffect(() => { - if (colorMode != resolvedTheme) { - toggleColorMode(); - } - setResolvedColorMode(resolvedTheme); - }, [theme, resolvedTheme]); - - const rawColorMode = colorMode; - const setColorMode = (mode) => { - const allowedModes = ["light", "dark", "system"]; - if (!allowedModes.includes(mode)) { - console.error( - `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".` - ); - mode = defaultColorMode; - } - setTheme(mode); - }; - return ( - - {children} - - ); -} diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 26b2d0d0c..66b50b1b4 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -15,6 +15,7 @@ import { } from "utils/context.js"; import debounce from "/utils/helpers/debounce"; import throttle from "/utils/helpers/throttle"; +import * as Babel from "@babel/standalone"; // Endpoint URLs. const EVENTURL = env.EVENT; @@ -117,8 +118,8 @@ export const isStateful = () => { if (event_queue.length === 0) { return false; } - return event_queue.some(event => event.name.startsWith("reflex___state")); -} + return event_queue.some((event) => event.name.startsWith("reflex___state")); +}; /** * Apply a delta to the state. @@ -129,6 +130,22 @@ export const applyDelta = (state, delta) => { return { ...state, ...delta }; }; +/** + * Evaluate a dynamic component. + * @param component The component to evaluate. + * @returns The evaluated component. + */ +export const evalReactComponent = async (component) => { + if (!window.React && window.__reflex) { + window.React = window.__reflex.react; + } + const output = Babel.transform(component, { presets: ["react"] }).code; + const encodedJs = encodeURIComponent(output); + const dataUri = "data:text/javascript;charset=utf-8," + encodedJs; + const module = await eval(`import(dataUri)`); + return module.default; +}; + /** * Only Queue and process events when websocket connection exists. * @param event The event to queue. @@ -141,7 +158,7 @@ export const queueEventIfSocketExists = async (events, socket) => { return; } await queueEvents(events, socket); -} +}; /** * Handle frontend event or send the event to the backend via Websocket. @@ -208,7 +225,10 @@ export const applyEvent = async (event, socket) => { const a = document.createElement("a"); a.hidden = true; // Special case when linking to uploaded files - a.href = event.payload.url.replace("${getBackendURL(env.UPLOAD)}", getBackendURL(env.UPLOAD)) + a.href = event.payload.url.replace( + "${getBackendURL(env.UPLOAD)}", + getBackendURL(env.UPLOAD) + ); a.download = event.payload.filename; a.click(); a.remove(); @@ -249,7 +269,7 @@ export const applyEvent = async (event, socket) => { } catch (e) { console.log("_call_script", e); if (window && window?.onerror) { - window.onerror(e.message, null, null, null, e) + window.onerror(e.message, null, null, null, e); } } return false; @@ -290,10 +310,9 @@ export const applyEvent = async (event, socket) => { export const applyRestEvent = async (event, socket) => { let eventSent = false; if (event.handler === "uploadFiles") { - if (event.payload.files === undefined || event.payload.files.length === 0) { // Submit the event over the websocket to trigger the event handler. - return await applyEvent(Event(event.name), socket) + return await applyEvent(Event(event.name), socket); } // Start upload, but do not wait for it, which would block other events. @@ -397,7 +416,7 @@ export const connect = async ( console.log("Disconnect backend before bfcache on navigation"); socket.current.disconnect(); } - } + }; // Once the socket is open, hydrate the page. socket.current.on("connect", () => { @@ -416,7 +435,7 @@ export const connect = async ( }); // On each received message, queue the updates and events. - socket.current.on("event", (message) => { + socket.current.on("event", async (message) => { const update = JSON5.parse(message); for (const substate in update.delta) { dispatch[substate](update.delta[substate]); @@ -574,7 +593,11 @@ export const hydrateClientStorage = (client_storage) => { } } } - if (client_storage.cookies || client_storage.local_storage || client_storage.session_storage) { + if ( + client_storage.cookies || + client_storage.local_storage || + client_storage.session_storage + ) { return client_storage_values; } return {}; @@ -614,15 +637,17 @@ const applyClientStorageDelta = (client_storage, delta) => { ) { const options = client_storage.local_storage[state_key]; localStorage.setItem(options.name || state_key, delta[substate][key]); - } else if( + } else if ( client_storage.session_storage && state_key in client_storage.session_storage && typeof window !== "undefined" ) { const session_options = client_storage.session_storage[state_key]; - sessionStorage.setItem(session_options.name || state_key, delta[substate][key]); + sessionStorage.setItem( + session_options.name || state_key, + delta[substate][key] + ); } - } } }; @@ -651,7 +676,7 @@ export const useEventLoop = ( if (!(args instanceof Array)) { args = [args]; } - const _e = args.filter((o) => o?.preventDefault !== undefined)[0] + const _e = args.filter((o) => o?.preventDefault !== undefined)[0]; if (event_actions?.preventDefault && _e?.preventDefault) { _e.preventDefault(); @@ -671,7 +696,7 @@ export const useEventLoop = ( debounce( combined_name, () => queueEvents(events, socket), - event_actions.debounce, + event_actions.debounce ); } else { queueEvents(events, socket); @@ -696,30 +721,32 @@ export const useEventLoop = ( } }, [router.isReady]); - // Handle frontend errors and send them to the backend via websocket. - useEffect(() => { - - if (typeof window === 'undefined') { - return; - } - - window.onerror = function (msg, url, lineNo, columnNo, error) { - addEvents([Event(`${exception_state_name}.handle_frontend_exception`, { - stack: error.stack, - })]) - return false; - } + // Handle frontend errors and send them to the backend via websocket. + useEffect(() => { + if (typeof window === "undefined") { + return; + } - //NOTE: Only works in Chrome v49+ - //https://github.com/mknichel/javascript-errors?tab=readme-ov-file#promise-rejection-events - window.onunhandledrejection = function (event) { - addEvents([Event(`${exception_state_name}.handle_frontend_exception`, { - stack: event.reason.stack, - })]) - return false; - } - - },[]) + window.onerror = function (msg, url, lineNo, columnNo, error) { + addEvents([ + Event(`${exception_state_name}.handle_frontend_exception`, { + stack: error.stack, + }), + ]); + return false; + }; + + //NOTE: Only works in Chrome v49+ + //https://github.com/mknichel/javascript-errors?tab=readme-ov-file#promise-rejection-events + window.onunhandledrejection = function (event) { + addEvents([ + Event(`${exception_state_name}.handle_frontend_exception`, { + stack: event.reason.stack, + }), + ]); + return false; + }; + }, []); // Main event loop. useEffect(() => { @@ -782,11 +809,11 @@ export const useEventLoop = ( // Route after the initial page hydration. useEffect(() => { const change_start = () => { - const main_state_dispatch = dispatch["reflex___state____state"] + const main_state_dispatch = dispatch["reflex___state____state"]; if (main_state_dispatch !== undefined) { - main_state_dispatch({ is_hydrated: false }) + main_state_dispatch({ is_hydrated: false }); } - } + }; const change_complete = () => addEvents(onLoadInternalEvent()); router.events.on("routeChangeStart", change_start); router.events.on("routeChangeComplete", change_complete); diff --git a/reflex/__init__.py b/reflex/__init__.py index abfec245c..63de1f386 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -140,6 +140,7 @@ RADIX_THEMES_COMPONENTS_MAPPING: dict = { "components.radix.themes.components.radio_group": ["radio", "radio_group"], "components.radix.themes.components.dropdown_menu": ["menu", "dropdown_menu"], "components.radix.themes.components.separator": ["divider", "separator"], + "components.radix.themes.components.progress": ["progress"], } RADIX_THEMES_LAYOUT_MAPPING: dict = { @@ -205,7 +206,13 @@ RADIX_PRIMITIVES_MAPPING: dict = { "components.radix.primitives.form": [ "form", ], - "components.radix.primitives.progress": ["progress"], + "components.radix.primitives.progress": [ + "progress", + ], +} + +RADIX_PRIMITIVES_SHORTCUT_MAPPING: dict = { + k: v for k, v in RADIX_PRIMITIVES_MAPPING.items() if "progress" not in k } COMPONENTS_CORE_MAPPING: dict = { @@ -248,7 +255,7 @@ RADIX_MAPPING: dict = { **RADIX_THEMES_COMPONENTS_MAPPING, **RADIX_THEMES_TYPOGRAPHY_MAPPING, **RADIX_THEMES_LAYOUT_MAPPING, - **RADIX_PRIMITIVES_MAPPING, + **RADIX_PRIMITIVES_SHORTCUT_MAPPING, } _MAPPING: dict = { @@ -338,7 +345,6 @@ _SUBMODULES: set[str] = { "testing", "utils", "vars", - "ivars", "config", "compiler", } diff --git a/reflex/__init__.pyi b/reflex/__init__.pyi index c7aefd412..ef5bcfd8f 100644 --- a/reflex/__init__.pyi +++ b/reflex/__init__.pyi @@ -12,7 +12,6 @@ from . import compiler as compiler from . import components as components from . import config as config from . import event as event -from . import ivars as ivars from . import model as model from . import style as style from . import testing as testing @@ -71,7 +70,6 @@ from .components.plotly import plotly as plotly from .components.radix.primitives.accordion import accordion as accordion from .components.radix.primitives.drawer import drawer as drawer from .components.radix.primitives.form import form as form -from .components.radix.primitives.progress import progress as progress from .components.radix.themes.base import theme as theme from .components.radix.themes.base import theme_panel as theme_panel from .components.radix.themes.color_mode import color_mode as color_mode @@ -106,6 +104,7 @@ from .components.radix.themes.components.hover_card import hover_card as hover_c from .components.radix.themes.components.icon_button import icon_button as icon_button from .components.radix.themes.components.inset import inset as inset from .components.radix.themes.components.popover import popover as popover +from .components.radix.themes.components.progress import progress as progress from .components.radix.themes.components.radio_cards import radio_cards as radio_cards from .components.radix.themes.components.radio_group import radio as radio from .components.radix.themes.components.radio_group import radio_group as radio_group @@ -132,6 +131,7 @@ from .components.radix.themes.layout.container import container as container from .components.radix.themes.layout.flex import flex as flex from .components.radix.themes.layout.grid import grid as grid from .components.radix.themes.layout.list import list_item as list_item +from .components.radix.themes.layout.list import list_ns as list # noqa from .components.radix.themes.layout.list import ordered_list as ordered_list from .components.radix.themes.layout.list import unordered_list as unordered_list from .components.radix.themes.layout.section import section as section @@ -197,6 +197,7 @@ RADIX_THEMES_COMPONENTS_MAPPING: dict RADIX_THEMES_LAYOUT_MAPPING: dict RADIX_THEMES_TYPOGRAPHY_MAPPING: dict RADIX_PRIMITIVES_MAPPING: dict +RADIX_PRIMITIVES_SHORTCUT_MAPPING: dict COMPONENTS_CORE_MAPPING: dict COMPONENTS_BASE_MAPPING: dict RADIX_MAPPING: dict diff --git a/reflex/app.py b/reflex/app.py index b530a2ff7..84b7552c1 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -10,6 +10,7 @@ import dataclasses import functools import inspect import io +import json import multiprocessing import os import platform @@ -34,7 +35,7 @@ from typing import ( from fastapi import FastAPI, HTTPException, Request, UploadFile from fastapi.middleware import cors -from fastapi.responses import StreamingResponse +from fastapi.responses import JSONResponse, StreamingResponse from fastapi.staticfiles import StaticFiles from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn from socketio import ASGIApp, AsyncNamespace, AsyncServer @@ -69,7 +70,7 @@ from reflex.components.core.upload import Upload, get_upload_dir from reflex.components.radix import themes from reflex.config import get_config from reflex.event import Event, EventHandler, EventSpec, window_alert -from reflex.model import Model +from reflex.model import Model, get_db_status from reflex.page import ( DECORATED_PAGES, ) @@ -291,13 +292,12 @@ class App(MiddlewareMixin, LifespanMixin, Base): "`connect_error_component` is deprecated, use `overlay_component` instead" ) super().__init__(**kwargs) - base_state_subclasses = BaseState.__subclasses__() # Special case to allow test cases have multiple subclasses of rx.BaseState. - if not is_testing_env() and len(base_state_subclasses) > 1: - # Only one Base State class is allowed. + if not is_testing_env() and BaseState.__subclasses__() != [State]: + # Only rx.State is allowed as Base State subclass. raise ValueError( - "rx.BaseState cannot be subclassed multiple times. use rx.State instead" + "rx.BaseState cannot be subclassed directly. Use rx.State instead" ) if "breakpoints" in self.style: @@ -399,6 +399,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): """Add default api endpoints (ping).""" # To test the server. self.api.get(str(constants.Endpoint.PING))(ping) + self.api.get(str(constants.Endpoint.HEALTH))(health) def _add_optional_endpoints(self): """Add optional api endpoints (_upload).""" @@ -607,7 +608,10 @@ class App(MiddlewareMixin, LifespanMixin, Base): for route in self.pages: replaced_route = replace_brackets_with_keywords(route) for rw, r, nr in zip( - replaced_route.split("/"), route.split("/"), new_route.split("/") + replaced_route.split("/"), + route.split("/"), + new_route.split("/"), + strict=False, ): if rw in segments and r != nr: # If the slugs in the segments of both routes are not the same, then the route is invalid @@ -825,7 +829,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): for dep in deps: if dep not in state.vars and dep not in state.backend_vars: raise exceptions.VarDependencyError( - f"ComputedVar {var._var_name} on state {state.__name__} has an invalid dependency {dep}" + f"ComputedVar {var._js_expr} on state {state.__name__} has an invalid dependency {dep}" ) for substate in state.class_subclasses: @@ -1192,6 +1196,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): FRONTEND_ARG_SPEC, BACKEND_ARG_SPEC, ], + strict=False, ): if hasattr(handler_fn, "__name__"): _fn_name = handler_fn.__name__ @@ -1343,6 +1348,38 @@ async def ping() -> str: return "pong" +async def health() -> JSONResponse: + """Health check endpoint to assess the status of the database and Redis services. + + Returns: + JSONResponse: A JSON object with the health status: + - "status" (bool): Overall health, True if all checks pass. + - "db" (bool or str): Database status - True, False, or "NA". + - "redis" (bool or str): Redis status - True, False, or "NA". + """ + health_status = {"status": True} + status_code = 200 + + db_status, redis_status = await asyncio.gather( + get_db_status(), prerequisites.get_redis_status() + ) + + health_status["db"] = db_status + + if redis_status is None: + health_status["redis"] = False + else: + health_status["redis"] = redis_status + + if not health_status["db"] or ( + not health_status["redis"] and redis_status is not None + ): + health_status["status"] = False + status_code = 503 + + return JSONResponse(content=health_status, status_code=status_code) + + def upload(app: App): """Upload a file. @@ -1523,8 +1560,9 @@ class EventNamespace(AsyncNamespace): sid: The Socket.IO session id. data: The event data. """ + fields = json.loads(data) # Get the event. - event = Event.parse_raw(data) + event = Event(**{k: v for k, v in fields.items() if k != "handler"}) self.token_to_sid[event.token] = sid self.sid_to_token[sid] = event.token diff --git a/reflex/base.py b/reflex/base.py index 5a2a6d2a9..c334ddf56 100644 --- a/reflex/base.py +++ b/reflex/base.py @@ -47,6 +47,9 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None # shadowed state vars when reloading app via utils.prerequisites.get_app(reload=True) pydantic_main.validate_field_name = validate_field_name # type: ignore +if TYPE_CHECKING: + from reflex.vars import Var + class Base(BaseModel): # pyright: ignore [reportUnboundVariable] """The base class subclassed by all Reflex classes. @@ -92,7 +95,7 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] return self @classmethod - def get_fields(cls) -> dict[str, Any]: + def get_fields(cls) -> dict[str, ModelField]: """Get the fields of the object. Returns: @@ -101,7 +104,7 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] return cls.__fields__ @classmethod - def add_field(cls, var: Any, default_value: Any): + def add_field(cls, var: Var, default_value: Any): """Add a pydantic field after class definition. Used by State.add_var() to correctly handle the new variable. @@ -110,7 +113,7 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] var: The variable to add a pydantic field for. default_value: The default value of the field """ - var_name = var._var_name.split(".")[-1] + var_name = var._var_field_name new_field = ModelField.infer( name=var_name, value=default_value, @@ -133,13 +136,4 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] # Seems like this function signature was wrong all along? # If the user wants a field that we know of, get it and pass it off to _get_value key = getattr(self, key) - return self._get_value( - key, - to_dict=True, - by_alias=False, - include=None, - exclude=None, - exclude_unset=False, - exclude_defaults=False, - exclude_none=False, - ) + return key diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index fb1c6ebc9..5aeb37d2a 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -18,13 +18,12 @@ from reflex.components.component import ( StatefulComponent, ) from reflex.config import get_config -from reflex.ivars.base import LiteralVar from reflex.state import BaseState from reflex.style import SYSTEM_COLOR_MODE from reflex.utils.exec import is_prod_mode from reflex.utils.imports import ImportVar from reflex.utils.prerequisites import get_web_dir -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var def _compile_document_root(root: Component) -> str: @@ -59,7 +58,7 @@ def _compile_app(app_root: Component) -> str: ) -def _compile_theme(theme: dict) -> str: +def _compile_theme(theme: str) -> str: """Compile the theme. Args: @@ -379,7 +378,7 @@ def compile_theme(style: ComponentStyle) -> tuple[str, str]: theme = utils.create_theme(style) # Compile the theme. - code = _compile_theme(theme) + code = _compile_theme(str(LiteralVar.create(theme))) return output_path, code diff --git a/reflex/compiler/utils.py b/reflex/compiler/utils.py index 1b69539ac..3b643718f 100644 --- a/reflex/compiler/utils.py +++ b/reflex/compiler/utils.py @@ -8,6 +8,7 @@ from typing import Any, Callable, Dict, Optional, Type, Union from urllib.parse import urlparse from reflex.utils.prerequisites import get_web_dir +from reflex.vars.base import Var try: from pydantic.v1.fields import ModelField @@ -32,7 +33,6 @@ from reflex.state import BaseState, Cookie, LocalStorage, SessionStorage from reflex.style import Style from reflex.utils import console, format, imports, path_ops from reflex.utils.imports import ImportVar, ParsedImportDict -from reflex.vars import Var # To re-export this function. merge_imports = imports.merge_imports @@ -152,7 +152,9 @@ def compile_state(state: Type[BaseState]) -> dict: console.warn( f"Failed to compile initial state with computed vars, excluding them: {e}" ) - initial_state = state(_reflex_internal_init=True).dict(include_computed=False) + initial_state = state(_reflex_internal_init=True).dict( + initial=True, include_computed=False + ) return format.format_state(initial_state) @@ -266,7 +268,7 @@ def compile_custom_component( } # Concatenate the props. - props = [prop._var_name for prop in component.get_prop_vars()] + props = [prop._js_expr for prop in component.get_prop_vars()] # Compile the component. return ( diff --git a/reflex/components/base/app_wrap.py b/reflex/components/base/app_wrap.py index 7d6a085b4..c7cfe6505 100644 --- a/reflex/components/base/app_wrap.py +++ b/reflex/components/base/app_wrap.py @@ -2,7 +2,7 @@ from reflex.components.base.fragment import Fragment from reflex.components.component import Component -from reflex.ivars.base import ImmutableVar +from reflex.vars.base import Var class AppWrap(Fragment): @@ -15,4 +15,4 @@ class AppWrap(Fragment): Returns: A new AppWrap component containing {children}. """ - return super().create(ImmutableVar.create("children")) + return super().create(Var(_js_expr="children")) diff --git a/reflex/components/base/app_wrap.pyi b/reflex/components/base/app_wrap.pyi index 576f8cd69..29e1e54b1 100644 --- a/reflex/components/base/app_wrap.pyi +++ b/reflex/components/base/app_wrap.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.base.fragment import Fragment from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class AppWrap(Fragment): @overload diff --git a/reflex/components/base/bare.py b/reflex/components/base/bare.py index dca9a9287..970cdfc84 100644 --- a/reflex/components/base/bare.py +++ b/reflex/components/base/bare.py @@ -7,8 +7,7 @@ from typing import Any, Iterator from reflex.components.component import Component from reflex.components.tags import Tag from reflex.components.tags.tagless import Tagless -from reflex.ivars.base import ImmutableVar -from reflex.vars import Var +from reflex.vars.base import Var class Bare(Component): @@ -26,16 +25,14 @@ class Bare(Component): Returns: The component. """ - if isinstance(contents, ImmutableVar): + if isinstance(contents, Var): return cls(contents=contents) - if isinstance(contents, Var) and contents._get_all_var_data(): - contents = contents.to(str) else: contents = str(contents) if contents is not None else "" return cls(contents=contents) # type: ignore def _render(self) -> Tag: - if isinstance(self.contents, ImmutableVar): + if isinstance(self.contents, Var): return Tagless(contents=f"{{{str(self.contents)}}}") return Tagless(contents=str(self.contents)) diff --git a/reflex/components/base/body.pyi b/reflex/components/base/body.pyi index 57ff1b7b7..d638a5f3e 100644 --- a/reflex/components/base/body.pyi +++ b/reflex/components/base/body.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Body(Component): @overload diff --git a/reflex/components/base/document.pyi b/reflex/components/base/document.pyi index 77065d845..d9641a0d1 100644 --- a/reflex/components/base/document.pyi +++ b/reflex/components/base/document.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class NextDocumentLib(Component): @overload diff --git a/reflex/components/base/error_boundary.py b/reflex/components/base/error_boundary.py index 058976498..66a9c43c8 100644 --- a/reflex/components/base/error_boundary.py +++ b/reflex/components/base/error_boundary.py @@ -9,10 +9,9 @@ from reflex.components.component import Component from reflex.components.el import div, p from reflex.constants import Hooks, Imports from reflex.event import EventChain, EventHandler -from reflex.ivars.base import ImmutableVar -from reflex.ivars.function import FunctionVar from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.vars.base import Var +from reflex.vars.function import FunctionVar class ErrorBoundary(Component): @@ -22,12 +21,12 @@ class ErrorBoundary(Component): tag = "ErrorBoundary" # Fired when the boundary catches an error. - on_error: EventHandler[lambda error, info: [error, info]] = ImmutableVar( # type: ignore + on_error: EventHandler[lambda error, info: [error, info]] = Var( # type: ignore "logFrontendError" ).to(FunctionVar, EventChain) # Rendered instead of the children when an error is caught. - Fallback_component: Var[Component] = ImmutableVar.create_safe("Fallback")._replace( + Fallback_component: Var[Component] = Var(_js_expr="Fallback")._replace( _var_type=Component ) @@ -58,7 +57,7 @@ class ErrorBoundary(Component): fallback_container = div( p("Ooops...Unknown Reflex error has occured:"), p( - ImmutableVar.create("error.message"), + Var(_js_expr="error.message"), color="red", ), p("Please contact the support."), diff --git a/reflex/components/base/error_boundary.pyi b/reflex/components/base/error_boundary.pyi index 4777b09e9..3497f3141 100644 --- a/reflex/components/base/error_boundary.pyi +++ b/reflex/components/base/error_boundary.pyi @@ -9,7 +9,7 @@ from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.vars.base import Var class ErrorBoundary(Component): def add_imports(self) -> dict[str, list[ImportVar]]: ... @@ -20,7 +20,7 @@ class ErrorBoundary(Component): def create( # type: ignore cls, *children, - Fallback_component: Optional[Union[Var[Component], Component]] = None, + Fallback_component: Optional[Union[Component, Var[Component]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/base/fragment.pyi b/reflex/components/base/fragment.pyi index fae72cc9c..7c7f397db 100644 --- a/reflex/components/base/fragment.pyi +++ b/reflex/components/base/fragment.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Fragment(Component): @overload diff --git a/reflex/components/base/head.pyi b/reflex/components/base/head.pyi index 041457137..64554a57f 100644 --- a/reflex/components/base/head.pyi +++ b/reflex/components/base/head.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component, MemoizationLeaf from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class NextHeadLib(Component): @overload diff --git a/reflex/components/base/link.py b/reflex/components/base/link.py index 1c11ab262..3ea34f212 100644 --- a/reflex/components/base/link.py +++ b/reflex/components/base/link.py @@ -1,7 +1,7 @@ """Display the title of the current page.""" from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var class RawLink(Component): diff --git a/reflex/components/base/link.pyi b/reflex/components/base/link.pyi index 80388a327..6493b012c 100644 --- a/reflex/components/base/link.pyi +++ b/reflex/components/base/link.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class RawLink(Component): @overload diff --git a/reflex/components/base/meta.pyi b/reflex/components/base/meta.pyi index 372d202f9..08b8be65e 100644 --- a/reflex/components/base/meta.pyi +++ b/reflex/components/base/meta.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Title(Component): def render(self) -> dict: ... diff --git a/reflex/components/base/script.py b/reflex/components/base/script.py index 7b0596966..0eba03f49 100644 --- a/reflex/components/base/script.py +++ b/reflex/components/base/script.py @@ -9,8 +9,7 @@ from typing import Literal from reflex.components.component import Component from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var class Script(Component): diff --git a/reflex/components/base/script.pyi b/reflex/components/base/script.pyi index 311485b66..2de7b2fcc 100644 --- a/reflex/components/base/script.pyi +++ b/reflex/components/base/script.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Script(Component): @overload @@ -19,8 +19,8 @@ class Script(Component): src: Optional[Union[Var[str], str]] = None, strategy: Optional[ Union[ - Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]], Literal["afterInteractive", "beforeInteractive", "lazyOnload"], + Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/component.py b/reflex/components/component.py index 0a9da1adc..e6bdfef06 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -25,6 +25,7 @@ import reflex.state from reflex.base import Base from reflex.compiler.templates import STATEFUL_COMPONENT from reflex.components.core.breakpoints import Breakpoints +from reflex.components.dynamic import load_dynamic_serializer from reflex.components.tags import Tag from reflex.constants import ( Dirs, @@ -43,12 +44,17 @@ from reflex.event import ( call_event_handler, get_handler_args, ) -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style, format_as_emotion -from reflex.utils import console, format, imports, types -from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports -from reflex.utils.serializers import serializer -from reflex.vars import BaseVar, ImmutableVarData, Var, VarData +from reflex.utils import format, imports, types +from reflex.utils.imports import ( + ImmutableParsedImportDict, + ImportDict, + ImportVar, + ParsedImportDict, + parse_imports, +) +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var class BaseComponent(Base, ABC): @@ -189,7 +195,7 @@ class Component(BaseComponent, ABC): class_name: Any = None # Special component props. - special_props: Set[Var] = set() + special_props: List[Var] = [] # Whether the component should take the focus once the page is loaded autofocus: bool = False @@ -441,9 +447,9 @@ class Component(BaseComponent, ABC): not passed_types and not types._issubclass(passed_type, expected_type, value) ): - value_name = value._var_name if isinstance(value, Var) else value + value_name = value._js_expr if isinstance(value, Var) else value raise TypeError( - f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_types or passed_type}." + f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_type}." ) # Check if the key is an event trigger. if key in component_specific_triggers: @@ -491,7 +497,11 @@ class Component(BaseComponent, ABC): self, args_spec: Any, value: Union[ - Var, EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], Callable + Var, + EventHandler, + EventSpec, + List[Union[EventHandler, EventSpec]], + Callable, ], ) -> Union[EventChain, Var]: """Create an event chain from a variety of input types. @@ -527,15 +537,7 @@ class Component(BaseComponent, ABC): for v in value: if isinstance(v, (EventHandler, EventSpec)): # Call the event handler to get the event. - try: - event = call_event_handler(v, args_spec) - except ValueError as err: - raise ValueError( - f" {err} defined in the `{type(self).__name__}` component" - ) from err - - # Add the event to the chain. - events.append(event) + events.append(call_event_handler(v, args_spec)) elif isinstance(v, Callable): # Call the lambda to get the event chain. result = call_event_fn(v, args_spec) @@ -613,8 +615,8 @@ class Component(BaseComponent, ABC): if types._issubclass(field.type_, EventHandler): args_spec = None annotation = field.annotation - if hasattr(annotation, "__metadata__"): - args_spec = annotation.__metadata__[0] + if (metadata := getattr(annotation, "__metadata__", None)) is not None: + args_spec = metadata[0] default_triggers[field.name] = args_spec or (lambda: []) return default_triggers @@ -636,27 +638,6 @@ class Component(BaseComponent, ABC): return _compile_component(self) - def _apply_theme(self, theme: Optional[Component]): - """Apply the theme to this component. - - Deprecated. Use add_style instead. - - Args: - theme: The theme to apply. - """ - pass - - def apply_theme(self, theme: Optional[Component]): - """Apply a theme to the component and its children. - - Args: - theme: The theme to apply. - """ - self._apply_theme(theme) - for child in self.children: - if isinstance(child, Component): - child.apply_theme(theme) - def _exclude_props(self) -> list[str]: """Props to exclude when adding the component props to the Tag. @@ -676,7 +657,7 @@ class Component(BaseComponent, ABC): """ # Create the base tag. tag = Tag( - name=self.tag if not self.alias else self.alias, + name=(self.tag if not self.alias else self.alias) or "", special_props=self.special_props, ) @@ -690,7 +671,7 @@ class Component(BaseComponent, ABC): # Add ref to element if `id` is not None. ref = self.get_ref() if ref is not None: - props["ref"] = ImmutableVar.create(ref) + props["ref"] = Var(_js_expr=ref) else: props = props.copy() @@ -764,22 +745,6 @@ class Component(BaseComponent, ABC): from reflex.components.base.fragment import Fragment from reflex.utils.exceptions import ComponentTypeError - # Translate deprecated props to new names. - new_prop_names = [ - prop for prop in cls.get_props() if prop in ["type", "min", "max"] - ] - for prop in new_prop_names: - under_prop = f"{prop}_" - if under_prop in props: - console.deprecate( - f"Underscore suffix for prop `{under_prop}`", - reason=f"for consistency. Use `{prop}` instead.", - deprecation_version="0.4.0", - removal_version="0.6.0", - dedupe=False, - ) - props[prop] = props.pop(under_prop) - # Filter out None props props = {key: value for key, value in props.items() if value is not None} @@ -896,17 +861,6 @@ class Component(BaseComponent, ABC): new_style.update(component_style) style_vars.append(component_style._var_data) - # 3. User-defined style from `Component.style`. - # Apply theme for retro-compatibility with deprecated _apply_theme API - if type(self)._apply_theme != Component._apply_theme: - console.deprecate( - f"{self.__class__.__name__}._apply_theme", - reason="use add_style instead", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - self._apply_theme(theme) - # 4. style dict and css props passed to the component instance. new_style.update(self.style) style_vars.append(self.style._var_data) @@ -1092,10 +1046,10 @@ class Component(BaseComponent, ABC): # Style keeps track of its own VarData instance, so embed in a temp Var that is yielded. if isinstance(self.style, dict) and self.style or isinstance(self.style, Var): vars.append( - ImmutableVar( - _var_name="style", + Var( + _js_expr="style", _var_type=str, - _var_data=ImmutableVarData.merge(self.style._var_data), + _var_data=VarData.merge(self.style._var_data), ) ) @@ -1359,9 +1313,15 @@ class Component(BaseComponent, ABC): # Collect imports from Vars used directly by this component. var_datas = [var._get_all_var_data() for var in self._get_vars()] - var_imports = [ - var_data.imports for var_data in var_datas if var_data is not None - ] + var_imports: List[ImmutableParsedImportDict] = list( + map( + lambda var_data: var_data.imports, + filter( + None, + var_datas, + ), + ) + ) added_import_dicts: list[ParsedImportDict] = [] for clz in self._iter_parent_classes_with_method("add_imports"): @@ -1408,9 +1368,9 @@ class Component(BaseComponent, ABC): on_mount = self.event_triggers.get(EventTriggers.ON_MOUNT, None) on_unmount = self.event_triggers.get(EventTriggers.ON_UNMOUNT, None) if on_mount is not None: - on_mount = format.format_event_chain(on_mount) + on_mount = str(LiteralVar.create(on_mount)) + "()" if on_unmount is not None: - on_unmount = format.format_event_chain(on_unmount) + on_unmount = str(LiteralVar.create(on_unmount)) + "()" if on_mount is not None or on_unmount is not None: return f""" useEffect(() => {{ @@ -1428,7 +1388,7 @@ class Component(BaseComponent, ABC): """ ref = self.get_ref() if ref is not None: - return f"const {ref} = useRef(null); {str(ImmutableVar.create_safe(ref).as_ref())} = {ref};" + return f"const {ref} = useRef(null); {str(Var(_js_expr=ref).as_ref())} = {ref};" def _get_vars_hooks(self) -> dict[str, None]: """Get the hooks required by vars referenced in this component. @@ -1569,7 +1529,7 @@ class Component(BaseComponent, ABC): The ref name. """ # do not create a ref if the id is dynamic or unspecified - if self.id is None or isinstance(self.id, (BaseVar, ImmutableVar)): + if self.id is None or isinstance(self.id, Var): return None return format.format_ref(self.id) @@ -1808,15 +1768,15 @@ class CustomComponent(Component): """ return super()._render(props=self.props) - def get_prop_vars(self) -> List[ImmutableVar]: + def get_prop_vars(self) -> List[Var]: """Get the prop vars. Returns: The prop vars. """ return [ - ImmutableVar( - _var_name=name, + Var( + _js_expr=name, _var_type=( prop._var_type if types._isinstance(prop, Var) else type(prop) ), @@ -1922,19 +1882,6 @@ class NoSSRComponent(Component): return "".join((library_import, mod_import, opts_fragment)) -@serializer -def serialize_component(comp: Component): - """Serialize a component. - - Args: - comp: The component to serialize. - - Returns: - The serialized component. - """ - return str(comp) - - class StatefulComponent(BaseComponent): """A component that depends on state and is rendered outside of the page component. @@ -2186,9 +2133,7 @@ class StatefulComponent(BaseComponent): # Get the actual EventSpec and render it. event = component.event_triggers[event_trigger] - rendered_chain = format.format_prop(event) - if isinstance(rendered_chain, str): - rendered_chain = rendered_chain.strip("{}") + rendered_chain = str(LiteralVar.create(event)) # Hash the rendered EventChain to get a deterministic function name. chain_hash = md5(str(rendered_chain).encode("utf-8")).hexdigest() @@ -2197,9 +2142,10 @@ class StatefulComponent(BaseComponent): # Calculate Var dependencies accessed by the handler for useCallback dep array. var_deps = ["addEvents", "Event"] for arg in event_args: - if arg._get_all_var_data() is None: + var_data = arg._get_all_var_data() + if var_data is None: continue - for hook in arg._get_all_var_data().hooks: + for hook in var_data.hooks: var_deps.extend(cls._get_hook_deps(hook)) memo_var_data = VarData.merge( *[var._get_all_var_data() for var in event_args], @@ -2210,7 +2156,7 @@ class StatefulComponent(BaseComponent): # Store the memoized function name and hook code for this event trigger. trigger_memo[event_trigger] = ( - ImmutableVar.create_safe(memo_name)._replace( + Var(_js_expr=memo_name)._replace( _var_type=EventChain, merge_var_data=memo_var_data ), f"const {memo_name} = useCallback({rendered_chain}, [{', '.join(var_deps)}])", @@ -2283,7 +2229,7 @@ class StatefulComponent(BaseComponent): Returns: The tag to render. """ - return dict(Tag(name=self.tag)) + return dict(Tag(name=self.tag or "")) def __str__(self) -> str: """Represent the component in React. @@ -2348,3 +2294,6 @@ class MemoizationLeaf(Component): update={"disposition": MemoizationDisposition.ALWAYS} ) return comp + + +load_dynamic_serializer() diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py index 4c4f587ee..29897cffa 100644 --- a/reflex/components/core/banner.py +++ b/reflex/components/core/banner.py @@ -18,57 +18,53 @@ from reflex.components.radix.themes.typography.text import Text from reflex.components.sonner.toast import Toaster, ToastProps from reflex.constants import Dirs, Hooks, Imports from reflex.constants.compiler import CompileVars -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.ivars.function import FunctionStringVar -from reflex.ivars.number import BooleanVar -from reflex.ivars.sequence import LiteralArrayVar from reflex.utils.imports import ImportVar -from reflex.vars import ImmutableVarData, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionStringVar +from reflex.vars.number import BooleanVar +from reflex.vars.sequence import LiteralArrayVar connect_error_var_data: VarData = VarData( # type: ignore imports=Imports.EVENTS, hooks={Hooks.EVENTS: None}, ) -connect_errors: Var = ImmutableVar.create_safe( - value=CompileVars.CONNECT_ERROR, +connect_errors = Var( + _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data +) + +connection_error = Var( + _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')", _var_data=connect_error_var_data, ) -connection_error: Var = ImmutableVar.create_safe( - value="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')", - _var_data=connect_error_var_data, +connection_errors_count = Var( + _js_expr="connectErrors.length", _var_data=connect_error_var_data ) -connection_errors_count: Var = ImmutableVar.create_safe( - value="connectErrors.length", - _var_data=connect_error_var_data, -) - -has_connection_errors: Var = ImmutableVar.create_safe( - value="(connectErrors.length > 0)", - _var_data=connect_error_var_data, +has_connection_errors = Var( + _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data ).to(BooleanVar) -has_too_many_connection_errors: Var = ImmutableVar.create_safe( - value="(connectErrors.length >= 2)", - _var_data=connect_error_var_data, +has_too_many_connection_errors = Var( + _js_expr="(connectErrors.length >= 2)", _var_data=connect_error_var_data ).to(BooleanVar) -class WebsocketTargetURL(ImmutableVar): +class WebsocketTargetURL(Var): """A component that renders the websocket target URL.""" @classmethod - def create(cls) -> ImmutableVar: + def create(cls) -> Var: """Create a websocket target URL component. Returns: The websocket target URL component. """ - return ImmutableVar( - _var_name="getBackendURL(env.EVENT).href", - _var_data=ImmutableVarData( + return Var( + _js_expr="getBackendURL(env.EVENT).href", + _var_data=VarData( imports={ "/env.json": [ImportVar(tag="env", is_default=True)], f"/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")], @@ -125,8 +121,8 @@ class ConnectionToaster(Toaster): ), ).call( # TODO: This breaks the assumption that Vars are JS expressions - ImmutableVar.create_safe( - f""" + Var( + _js_expr=f""" () => {{ if ({str(has_too_many_connection_errors)}) {{ if (!userDismissed) {{ @@ -238,7 +234,7 @@ class WifiOffPulse(Icon): Returns: The icon component with default props applied. """ - pulse_var = ImmutableVar.create("pulse") + pulse_var = Var(_js_expr="pulse") return super().create( "wifi_off", color=props.pop("color", "crimson"), diff --git a/reflex/components/core/banner.pyi b/reflex/components/core/banner.pyi index 6327afe0b..01c526fac 100644 --- a/reflex/components/core/banner.pyi +++ b/reflex/components/core/banner.pyi @@ -9,22 +9,35 @@ from reflex.components.component import Component from reflex.components.el.elements.typography import Div from reflex.components.lucide.icon import Icon from reflex.components.sonner.toast import Toaster, ToastProps +from reflex.constants.compiler import CompileVars from reflex.event import EventHandler, EventSpec -from reflex.ivars.base import ImmutableVar from reflex.style import Style from reflex.utils.imports import ImportVar -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import Var +from reflex.vars.number import BooleanVar connect_error_var_data: VarData -connect_errors: Var -connection_error: Var -connection_errors_count: Var -has_connection_errors: Var -has_too_many_connection_errors: Var +connect_errors = Var( + _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data +) +connection_error = Var( + _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')", + _var_data=connect_error_var_data, +) +connection_errors_count = Var( + _js_expr="connectErrors.length", _var_data=connect_error_var_data +) +has_connection_errors = Var( + _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data +).to(BooleanVar) +has_too_many_connection_errors = Var( + _js_expr="(connectErrors.length >= 2)", _var_data=connect_error_var_data +).to(BooleanVar) -class WebsocketTargetURL(ImmutableVar): +class WebsocketTargetURL(Var): @classmethod - def create(cls) -> ImmutableVar: ... # type: ignore + def create(cls) -> Var: ... # type: ignore def default_connection_error() -> list[str | Var | Component]: ... @@ -41,24 +54,24 @@ class ConnectionToaster(Toaster): visible_toasts: Optional[Union[Var[int], int]] = None, position: Optional[ Union[ + Literal[ + "bottom-center", + "bottom-left", + "bottom-right", + "top-center", + "top-left", + "top-right", + ], Var[ Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", "bottom-center", + "bottom-left", "bottom-right", + "top-center", + "top-left", + "top-right", ] ], - Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", - "bottom-center", - "bottom-right", - ], ] ] = None, close_button: Optional[Union[Var[bool], bool]] = None, @@ -66,9 +79,9 @@ class ConnectionToaster(Toaster): dir: Optional[Union[Var[str], str]] = None, hotkey: Optional[Union[Var[str], str]] = None, invert: Optional[Union[Var[bool], bool]] = None, - toast_options: Optional[Union[Var[ToastProps], ToastProps]] = None, + toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None, gap: Optional[Union[Var[int], int]] = None, - loading_icon: Optional[Union[Var[Icon], Icon]] = None, + loading_icon: Optional[Union[Icon, Var[Icon]]] = None, pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -338,30 +351,30 @@ class ConnectionPulser(Div): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/core/breakpoints.py b/reflex/components/core/breakpoints.py index 4b2372a70..decd2727e 100644 --- a/reflex/components/core/breakpoints.py +++ b/reflex/components/core/breakpoints.py @@ -82,7 +82,9 @@ class Breakpoints(Dict[K, V]): return Breakpoints( { k: v - for k, v in zip(["initial", *breakpoint_names], thresholds) + for k, v in zip( + ["initial", *breakpoint_names], thresholds, strict=False + ) if v is not None } ) diff --git a/reflex/components/core/client_side_routing.py b/reflex/components/core/client_side_routing.py index 618467f39..efa622f81 100644 --- a/reflex/components/core/client_side_routing.py +++ b/reflex/components/core/client_side_routing.py @@ -13,9 +13,9 @@ from __future__ import annotations from reflex import constants from reflex.components.component import Component from reflex.components.core.cond import cond -from reflex.vars import Var +from reflex.vars.base import Var -route_not_found: Var = Var.create_safe(constants.ROUTE_NOT_FOUND, _var_is_string=False) +route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND) class ClientSideRouting(Component): diff --git a/reflex/components/core/client_side_routing.pyi b/reflex/components/core/client_side_routing.pyi index 605293ee8..9f73467b3 100644 --- a/reflex/components/core/client_side_routing.pyi +++ b/reflex/components/core/client_side_routing.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var route_not_found: Var diff --git a/reflex/components/core/clipboard.py b/reflex/components/core/clipboard.py index 9b0edcc29..1d7ce7c14 100644 --- a/reflex/components/core/clipboard.py +++ b/reflex/components/core/clipboard.py @@ -9,7 +9,8 @@ from reflex.components.tags.tag import Tag from reflex.event import EventChain, EventHandler from reflex.utils.format import format_prop, wrap from reflex.utils.imports import ImportVar -from reflex.vars import Var, get_unique_variable_name +from reflex.vars import get_unique_variable_name +from reflex.vars.base import Var class Clipboard(Fragment): @@ -85,8 +86,8 @@ class Clipboard(Fragment): return [ "usePasteHandler(%s, %s, %s)" % ( - self.targets._var_name_unwrapped, - self.on_paste_event_actions._var_name_unwrapped, + str(self.targets), + str(self.on_paste_event_actions), on_paste, ) ] diff --git a/reflex/components/core/clipboard.pyi b/reflex/components/core/clipboard.pyi index aaeac985c..cf02709fc 100644 --- a/reflex/components/core/clipboard.pyi +++ b/reflex/components/core/clipboard.pyi @@ -9,7 +9,7 @@ from reflex.components.base.fragment import Fragment from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.vars.base import Var class Clipboard(Fragment): @overload @@ -17,9 +17,9 @@ class Clipboard(Fragment): def create( # type: ignore cls, *children, - targets: Optional[Union[Var[List[str]], List[str]]] = None, + targets: Optional[Union[List[str], Var[List[str]]]] = None, on_paste_event_actions: Optional[ - Union[Var[Dict[str, Union[bool, int]]], Dict[str, Union[bool, int]]] + Union[Dict[str, Union[bool, int]], Var[Dict[str, Union[bool, int]]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/core/cond.py b/reflex/components/core/cond.py index 80dd35f0f..d1f53be23 100644 --- a/reflex/components/core/cond.py +++ b/reflex/components/core/cond.py @@ -8,11 +8,11 @@ from reflex.components.base.fragment import Fragment from reflex.components.component import BaseComponent, Component, MemoizationLeaf from reflex.components.tags import CondTag, Tag from reflex.constants import Dirs -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.ivars.number import TernaryOperator from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.number import ternary_operation _IS_TRUE_IMPORT: ImportDict = { f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")], @@ -94,7 +94,7 @@ class Cond(MemoizationLeaf): ).set( props=tag.format_props(), ), - cond_state=f"isTrue({self.cond._var_full_name})", + cond_state=f"isTrue({str(self.cond)})", ) def add_imports(self) -> ImportDict: @@ -103,10 +103,11 @@ class Cond(MemoizationLeaf): Returns: The import dict for the component. """ - cond_imports: dict[str, str | ImportVar | list[str | ImportVar]] = getattr( - VarData.merge(self.cond._get_all_var_data()), "imports", {} - ) - return {**cond_imports, **_IS_TRUE_IMPORT} + var_data = VarData.merge(self.cond._get_all_var_data()) + + imports = var_data.old_school_imports() if var_data else {} + + return {**imports, **_IS_TRUE_IMPORT} @overload @@ -118,10 +119,10 @@ def cond(condition: Any, c1: Component) -> Component: ... @overload -def cond(condition: Any, c1: Any, c2: Any) -> ImmutableVar: ... +def cond(condition: Any, c1: Any, c2: Any) -> Var: ... -def cond(condition: Any, c1: Any, c2: Any = None) -> Component | ImmutableVar: +def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var: """Create a conditional component or Prop. Args: @@ -135,8 +136,6 @@ def cond(condition: Any, c1: Any, c2: Any = None) -> Component | ImmutableVar: Raises: ValueError: If the arguments are invalid. """ - if isinstance(condition, Var) and not isinstance(condition, ImmutableVar): - condition._var_is_local = True # Convert the condition to a Var. cond_var = LiteralVar.create(condition) assert cond_var is not None, "The condition must be set." @@ -163,11 +162,12 @@ def cond(condition: Any, c1: Any, c2: Any = None) -> Component | ImmutableVar: c2 = create_var(c2) # Create the conditional var. - return TernaryOperator.create( - condition=cond_var.to(bool), # type: ignore - if_true=c1, - if_false=c2, - _var_data=VarData(imports=_IS_TRUE_IMPORT), + return ternary_operation( + cond_var.bool()._replace( # type: ignore + merge_var_data=VarData(imports=_IS_TRUE_IMPORT), + ), # type: ignore + c1, + c2, ) diff --git a/reflex/components/core/debounce.py b/reflex/components/core/debounce.py index 4dc7c14a1..a8f20f08a 100644 --- a/reflex/components/core/debounce.py +++ b/reflex/components/core/debounce.py @@ -7,7 +7,8 @@ from typing import Any, Type, Union from reflex.components.component import Component from reflex.constants import EventTriggers from reflex.event import EventHandler -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -106,23 +107,20 @@ class DebounceInput(Component): props[field] = getattr(child, field) child_ref = child.get_ref() if props.get("input_ref") is None and child_ref: - props["input_ref"] = Var.create_safe( - child_ref, _var_is_local=False, _var_is_string=False - ) + props["input_ref"] = Var(_js_expr=child_ref, _var_type=str) props["id"] = child.id # Set the child element to wrap, including any imports/hooks from the child. props.setdefault( "element", - Var.create_safe( - "{%s}" % (child.alias or child.tag), - _var_is_local=False, - _var_is_string=False, + Var( + _js_expr=str(child.alias or child.tag), + _var_type=Type[Component], _var_data=VarData( imports=child._get_imports(), hooks=child._get_hooks_internal(), ), - ).to(Type[Component]), + ), ) component = super().create(**props) diff --git a/reflex/components/core/debounce.pyi b/reflex/components/core/debounce.pyi index 486fcc284..dc2b505f5 100644 --- a/reflex/components/core/debounce.pyi +++ b/reflex/components/core/debounce.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Type, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -22,9 +22,9 @@ class DebounceInput(Component): debounce_timeout: Optional[Union[Var[int], int]] = None, force_notify_by_enter: Optional[Union[Var[bool], bool]] = None, force_notify_on_blur: Optional[Union[Var[bool], bool]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, input_ref: Optional[Union[Var[str], str]] = None, - element: Optional[Union[Var[Type[Component]], Type[Component]]] = None, + element: Optional[Union[Type[Component], Var[Type[Component]]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/core/foreach.py b/reflex/components/core/foreach.py index 327680a2b..a3f97d594 100644 --- a/reflex/components/core/foreach.py +++ b/reflex/components/core/foreach.py @@ -9,10 +9,8 @@ from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.tags import IterTag from reflex.constants import MemoizationMode -from reflex.ivars.base import ImmutableVar from reflex.state import ComponentState -from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var class ForeachVarError(TypeError): @@ -39,14 +37,12 @@ class Foreach(Component): cls, iterable: Var[Iterable] | Iterable, render_fn: Callable, - **props, ) -> Foreach: """Create a foreach component. Args: iterable: The iterable to create components from. render_fn: A function from the render args to the component. - **props: The attributes to pass to each child component (deprecated). Returns: The foreach component. @@ -55,17 +51,10 @@ class Foreach(Component): ForeachVarError: If the iterable is of type Any. TypeError: If the render function is a ComponentState. """ - if props: - console.deprecate( - feature_name="Passing props to rx.foreach", - reason="it does not have the intended effect and may be confusing", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - iterable = ImmutableVar.create_safe(iterable) + iterable = LiteralVar.create(iterable) if iterable._var_type == Any: raise ForeachVarError( - f"Could not foreach over var `{iterable._var_full_name}` of type Any. " + f"Could not foreach over var `{str(iterable)}` of type Any. " "(If you are trying to foreach over a state var, add a type annotation to the var). " "See https://reflex.dev/docs/library/dynamic-rendering/foreach/" ) @@ -137,7 +126,7 @@ class Foreach(Component): return dict( tag, - iterable_state=tag.iterable._var_full_name, + iterable_state=str(tag.iterable), arg_name=tag.arg_var_name, arg_index=tag.get_index_var_arg(), iterable_type=tag.iterable._var_type.mro()[0].__name__, diff --git a/reflex/components/core/html.py b/reflex/components/core/html.py index 812bf64be..cfe46e591 100644 --- a/reflex/components/core/html.py +++ b/reflex/components/core/html.py @@ -3,7 +3,7 @@ from typing import Dict from reflex.components.el.elements.typography import Div -from reflex.vars import Var +from reflex.vars.base import Var class Html(Div): diff --git a/reflex/components/core/html.pyi b/reflex/components/core/html.pyi index c3d2ed06f..969508a6a 100644 --- a/reflex/components/core/html.pyi +++ b/reflex/components/core/html.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.el.elements.typography import Div from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Html(Div): @overload @@ -17,32 +17,32 @@ class Html(Div): cls, *children, dangerouslySetInnerHTML: Optional[ - Union[Var[Dict[str, str]], Dict[str, str]] + Union[Dict[str, str], Var[Dict[str, str]]] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py index 3ddef38c6..8b9382c89 100644 --- a/reflex/components/core/match.py +++ b/reflex/components/core/match.py @@ -6,12 +6,12 @@ from typing import Any, Dict, List, Optional, Tuple, Union from reflex.components.base import Fragment from reflex.components.component import BaseComponent, Component, MemoizationLeaf from reflex.components.tags import MatchTag, Tag -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style from reflex.utils import format, types from reflex.utils.exceptions import MatchTypeError from reflex.utils.imports import ImportDict -from reflex.vars import ImmutableVarData, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var class Match(MemoizationLeaf): @@ -187,7 +187,7 @@ class Match(MemoizationLeaf): if not types._issubclass(type(case[-1]), return_type): raise MatchTypeError( f"Match cases should have the same return types. Case {index} with return " - f"value `{case[-1]._var_name if isinstance(case[-1], Var) else textwrap.shorten(str(case[-1]), width=250)}`" + f"value `{case[-1]._js_expr if isinstance(case[-1], Var) else textwrap.shorten(str(case[-1]), width=250)}`" f" of type {type(case[-1])!r} is not {return_type}" ) @@ -232,14 +232,14 @@ class Match(MemoizationLeaf): ) or not types._isinstance(default, Var): raise ValueError("Return types of match cases should be Vars.") - return ImmutableVar( - _var_name=format.format_match( - cond=match_cond_var._var_name_unwrapped, - match_cases=match_cases, # type: ignore + return Var( + _js_expr=format.format_match( + cond=str(match_cond_var), + match_cases=match_cases, default=default, # type: ignore ), _var_type=default._var_type, # type: ignore - _var_data=ImmutableVarData.merge( + _var_data=VarData.merge( match_cond_var._get_all_var_data(), *[el._get_all_var_data() for case in match_cases for el in case], default._get_all_var_data(), # type: ignore @@ -267,7 +267,8 @@ class Match(MemoizationLeaf): Returns: The import dict. """ - return getattr(VarData.merge(self.cond._get_all_var_data()), "imports", {}) + var_data = VarData.merge(self.cond._get_all_var_data()) + return var_data.old_school_imports() if var_data else {} match = Match.create diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index df9146c4d..62a46d823 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -19,10 +19,10 @@ from reflex.event import ( call_script, parse_args_spec, ) -from reflex.ivars.base import ImmutableCallableVar, ImmutableVar -from reflex.ivars.sequence import LiteralStringVar from reflex.utils.imports import ImportVar -from reflex.vars import ImmutableVarData, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import CallableVar, LiteralVar, Var +from reflex.vars.sequence import LiteralStringVar DEFAULT_UPLOAD_ID: str = "default" @@ -37,8 +37,8 @@ upload_files_context_var_data: VarData = VarData( ) -@ImmutableCallableVar -def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: +@CallableVar +def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: """Get the file upload drop trigger. This var is passed to the dropzone component to update the file list when a @@ -58,17 +58,17 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: }}) """ - return ImmutableVar( - _var_name=var_name, + return Var( + _js_expr=var_name, _var_type=EventChain, - _var_data=ImmutableVarData.merge( + _var_data=VarData.merge( upload_files_context_var_data, id_var._get_all_var_data() ), ) -@ImmutableCallableVar -def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: +@CallableVar +def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: """Get the list of selected files. Args: @@ -78,10 +78,10 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: A var referencing the list of selected file paths. """ id_var = LiteralStringVar.create(id_) - return ImmutableVar( - _var_name=f"(filesById[{str(id_var)}] ? filesById[{str(id_var)}].map((f) => (f.path || f.name)) : [])", + return Var( + _js_expr=f"(filesById[{str(id_var)}] ? filesById[{str(id_var)}].map((f) => (f.path || f.name)) : [])", _var_type=List[str], - _var_data=ImmutableVarData.merge( + _var_data=VarData.merge( upload_files_context_var_data, id_var._get_all_var_data() ), ).guess_type() @@ -113,7 +113,7 @@ def cancel_upload(upload_id: str) -> EventSpec: An event spec that cancels the upload when triggered. """ return call_script( - f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]?.abort()" + f"upload_controllers[{str(LiteralVar.create(upload_id))}]?.abort()" ) @@ -132,16 +132,15 @@ def get_upload_dir() -> Path: return uploaded_files_dir -uploaded_files_url_prefix: Var = Var.create_safe( - "${getBackendURL(env.UPLOAD)}", - _var_is_string=False, +uploaded_files_url_prefix = Var( + _js_expr="getBackendURL(env.UPLOAD)", _var_data=VarData( imports={ f"/{Dirs.STATE_PATH}": "getBackendURL", "/env.json": ImportVar(tag="env", is_default=True), } ), -) +).to(str) def get_upload_url(file_path: str) -> Var[str]: @@ -155,9 +154,7 @@ def get_upload_url(file_path: str) -> Var[str]: """ Upload.is_used = True - return Var.create_safe( - f"{uploaded_files_url_prefix}/{file_path}", _var_is_string=True - ) + return uploaded_files_url_prefix + "/" + file_path def _on_drop_spec(files: Var): @@ -250,9 +247,7 @@ class Upload(MemoizationLeaf): } # The file input to use. upload = Input.create(type="file") - upload.special_props = { - ImmutableVar(_var_name="...getInputProps()", _var_type=None) - } + upload.special_props = [Var(_js_expr="{...getInputProps()}", _var_type=None)] # The dropzone to use. zone = Box.create( @@ -260,9 +255,7 @@ class Upload(MemoizationLeaf): *children, **{k: v for k, v in props.items() if k not in supported_props}, ) - zone.special_props = { - ImmutableVar(_var_name="...getRootProps()", _var_type=None) - } + zone.special_props = [Var(_js_expr="{...getRootProps()}", _var_type=None)] # Create the component. upload_props["id"] = props.get("id", DEFAULT_UPLOAD_ID) @@ -299,7 +292,7 @@ class Upload(MemoizationLeaf): Returns: The updated arg_value tuple when arg is "files", otherwise the original arg_value. """ - if arg_value[0]._var_name == "files": + if arg_value[0]._js_expr == "files": placeholder = parse_args_spec(_on_drop_spec)[0] return (arg_value[0], placeholder) return arg_value diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi index ff5085514..22f229098 100644 --- a/reflex/components/core/upload.pyi +++ b/reflex/components/core/upload.pyi @@ -7,28 +7,38 @@ from pathlib import Path from typing import Any, Callable, ClassVar, Dict, List, Optional, Union, overload from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf +from reflex.constants import Dirs from reflex.event import ( CallableEventSpec, EventHandler, EventSpec, ) -from reflex.ivars.base import ImmutableCallableVar, ImmutableVar from reflex.style import Style -from reflex.vars import Var, VarData +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import CallableVar, Var DEFAULT_UPLOAD_ID: str upload_files_context_var_data: VarData -@ImmutableCallableVar -def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: ... -@ImmutableCallableVar -def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: ... +@CallableVar +def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ... +@CallableVar +def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ... @CallableEventSpec def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ... def cancel_upload(upload_id: str) -> EventSpec: ... def get_upload_dir() -> Path: ... -uploaded_files_url_prefix: Var +uploaded_files_url_prefix = Var( + _js_expr="getBackendURL(env.UPLOAD)", + _var_data=VarData( + imports={ + f"/{Dirs.STATE_PATH}": "getBackendURL", + "/env.json": ImportVar(tag="env", is_default=True), + } + ), +).to(str) def get_upload_url(file_path: str) -> Var[str]: ... @@ -106,7 +116,7 @@ class Upload(MemoizationLeaf): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, @@ -191,7 +201,7 @@ class StyledUpload(Upload): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, @@ -276,7 +286,7 @@ class UploadNamespace(ComponentNamespace): @staticmethod def __call__( *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py index 779d4c5d3..0b26e0c04 100644 --- a/reflex/components/datadisplay/code.py +++ b/reflex/components/datadisplay/code.py @@ -2,22 +2,22 @@ from __future__ import annotations -from typing import Dict, Literal, Optional, Union +import enum +from typing import Any, Dict, Literal, Optional, Union from typing_extensions import get_args -from reflex.components.component import Component +from reflex.components.component import Component, ComponentNamespace from reflex.components.core.cond import color_mode_cond from reflex.components.lucide.icon import Icon from reflex.components.radix.themes.components.button import Button from reflex.components.radix.themes.layout.box import Box from reflex.constants.colors import Color from reflex.event import set_clipboard -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style -from reflex.utils import format +from reflex.utils import console, format from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var, VarData LiteralCodeBlockTheme = Literal[ "a11y-dark", @@ -375,7 +375,7 @@ class CodeBlock(Component): alias = "SyntaxHighlighter" # The theme to use ("light" or "dark"). - theme: Var[LiteralCodeBlockTheme] = "one-light" # type: ignore + theme: Var[Any] = "one-light" # type: ignore # The language to use. language: Var[LiteralCodeLanguage] = "python" # type: ignore @@ -406,31 +406,6 @@ class CodeBlock(Component): """ imports_: ImportDict = {} - themeString = str(self.theme) - - selected_themes = [] - - for possibleTheme in get_args(LiteralCodeBlockTheme): - if format.to_camel_case(possibleTheme) in themeString: - selected_themes.append(possibleTheme) - if possibleTheme in themeString: - selected_themes.append(possibleTheme) - - selected_themes = sorted(set(map(self.convert_theme_name, selected_themes))) - - imports_.update( - { - f"react-syntax-highlighter/dist/cjs/styles/prism/{theme}": [ - ImportVar( - tag=format.to_camel_case(theme), - is_default=True, - install=False, - ) - ] - for theme in selected_themes - } - ) - if ( self.language is not None and (language_without_quotes := str(self.language).replace('"', "")) @@ -481,14 +456,20 @@ class CodeBlock(Component): if "theme" not in props: # Default color scheme responds to global color mode. props["theme"] = color_mode_cond( - light=ImmutableVar.create_safe("oneLight"), - dark=ImmutableVar.create_safe("oneDark"), + light=Theme.one_light, + dark=Theme.one_dark, ) # react-syntax-highlighter doesnt have an explicit "light" or "dark" theme so we use one-light and one-dark # themes respectively to ensure code compatibility. if "theme" in props and not isinstance(props["theme"], Var): - props["theme"] = cls.convert_theme_name(props["theme"]) + props["theme"] = getattr(Theme, format.to_snake_case(props["theme"])) # type: ignore + console.deprecate( + feature_name="theme prop as string", + reason="Use code_block.themes instead.", + deprecation_version="0.6.0", + removal_version="0.7.0", + ) if can_copy: code = children[0] @@ -534,9 +515,7 @@ class CodeBlock(Component): def _render(self): out = super()._render() - theme = self.theme._replace( - _var_name=replace_quotes_with_camel_case(str(self.theme)) - ) + theme = self.theme out.add_props(style=theme).remove_props("theme", "code").add_props( children=self.code @@ -559,4 +538,83 @@ class CodeBlock(Component): return theme -code_block = CodeBlock.create +def construct_theme_var(theme: str) -> Var: + """Construct a theme var. + + Args: + theme: The theme to construct. + + Returns: + The constructed theme var. + """ + return Var( + theme, + _var_data=VarData( + imports={ + f"react-syntax-highlighter/dist/cjs/styles/prism/{format.to_kebab_case(theme)}": [ + ImportVar(tag=theme, is_default=True, install=False) + ] + } + ), + ) + + +class Theme(enum.Enum): + """Themes for the CodeBlock component.""" + + a11y_dark = construct_theme_var("a11yDark") + atom_dark = construct_theme_var("atomDark") + cb = construct_theme_var("cb") + coldark_cold = construct_theme_var("coldarkCold") + coldark_dark = construct_theme_var("coldarkDark") + coy = construct_theme_var("coy") + coy_without_shadows = construct_theme_var("coyWithoutShadows") + darcula = construct_theme_var("darcula") + dark = construct_theme_var("oneDark") + dracula = construct_theme_var("dracula") + duotone_dark = construct_theme_var("duotoneDark") + duotone_earth = construct_theme_var("duotoneEarth") + duotone_forest = construct_theme_var("duotoneForest") + duotone_light = construct_theme_var("duotoneLight") + duotone_sea = construct_theme_var("duotoneSea") + duotone_space = construct_theme_var("duotoneSpace") + funky = construct_theme_var("funky") + ghcolors = construct_theme_var("ghcolors") + gruvbox_dark = construct_theme_var("gruvboxDark") + gruvbox_light = construct_theme_var("gruvboxLight") + holi_theme = construct_theme_var("holiTheme") + hopscotch = construct_theme_var("hopscotch") + light = construct_theme_var("oneLight") + lucario = construct_theme_var("lucario") + material_dark = construct_theme_var("materialDark") + material_light = construct_theme_var("materialLight") + material_oceanic = construct_theme_var("materialOceanic") + night_owl = construct_theme_var("nightOwl") + nord = construct_theme_var("nord") + okaidia = construct_theme_var("okaidia") + one_dark = construct_theme_var("oneDark") + one_light = construct_theme_var("oneLight") + pojoaque = construct_theme_var("pojoaque") + prism = construct_theme_var("prism") + shades_of_purple = construct_theme_var("shadesOfPurple") + solarized_dark_atom = construct_theme_var("solarizedDarkAtom") + solarizedlight = construct_theme_var("solarizedlight") + synthwave84 = construct_theme_var("synthwave84") + tomorrow = construct_theme_var("tomorrow") + twilight = construct_theme_var("twilight") + vs = construct_theme_var("vs") + vs_dark = construct_theme_var("vsDark") + vsc_dark_plus = construct_theme_var("vscDarkPlus") + xonokai = construct_theme_var("xonokai") + z_touch = construct_theme_var("zTouch") + + +class CodeblockNamespace(ComponentNamespace): + """Namespace for the CodeBlock component.""" + + themes = Theme + + __call__ = CodeBlock.create + + +code_block = CodeblockNamespace() diff --git a/reflex/components/datadisplay/code.pyi b/reflex/components/datadisplay/code.pyi index 015cc0708..7a074d1f9 100644 --- a/reflex/components/datadisplay/code.pyi +++ b/reflex/components/datadisplay/code.pyi @@ -3,14 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +import enum from typing import Any, Callable, Dict, Literal, Optional, Union, overload -from reflex.components.component import Component +from reflex.components.component import Component, ComponentNamespace from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var LiteralCodeBlockTheme = Literal[ "a11y-dark", @@ -352,108 +353,290 @@ class CodeBlock(Component): *children, can_copy: Optional[bool] = False, copy_button: Optional[Union[Component, bool]] = None, - theme: Optional[ - Union[ - Var[ - Literal[ - "a11y-dark", - "atom-dark", - "cb", - "coldark-cold", - "coldark-dark", - "coy", - "coy-without-shadows", - "darcula", - "dark", - "dracula", - "duotone-dark", - "duotone-earth", - "duotone-forest", - "duotone-light", - "duotone-sea", - "duotone-space", - "funky", - "ghcolors", - "gruvbox-dark", - "gruvbox-light", - "holi-theme", - "hopscotch", - "light", - "lucario", - "material-dark", - "material-light", - "material-oceanic", - "night-owl", - "nord", - "okaidia", - "one-dark", - "one-light", - "pojoaque", - "prism", - "shades-of-purple", - "solarized-dark-atom", - "solarizedlight", - "synthwave84", - "tomorrow", - "twilight", - "vs", - "vs-dark", - "vsc-dark-plus", - "xonokai", - "z-touch", - ] - ], - Literal[ - "a11y-dark", - "atom-dark", - "cb", - "coldark-cold", - "coldark-dark", - "coy", - "coy-without-shadows", - "darcula", - "dark", - "dracula", - "duotone-dark", - "duotone-earth", - "duotone-forest", - "duotone-light", - "duotone-sea", - "duotone-space", - "funky", - "ghcolors", - "gruvbox-dark", - "gruvbox-light", - "holi-theme", - "hopscotch", - "light", - "lucario", - "material-dark", - "material-light", - "material-oceanic", - "night-owl", - "nord", - "okaidia", - "one-dark", - "one-light", - "pojoaque", - "prism", - "shades-of-purple", - "solarized-dark-atom", - "solarizedlight", - "synthwave84", - "tomorrow", - "twilight", - "vs", - "vs-dark", - "vsc-dark-plus", - "xonokai", - "z-touch", - ], - ] - ] = None, + theme: Optional[Union[Any, Var[Any]]] = None, language: Optional[ Union[ + Literal[ + "abap", + "abnf", + "actionscript", + "ada", + "agda", + "al", + "antlr4", + "apacheconf", + "apex", + "apl", + "applescript", + "aql", + "arduino", + "arff", + "asciidoc", + "asm6502", + "asmatmel", + "aspnet", + "autohotkey", + "autoit", + "avisynth", + "avro-idl", + "bash", + "basic", + "batch", + "bbcode", + "bicep", + "birb", + "bison", + "bnf", + "brainfuck", + "brightscript", + "bro", + "bsl", + "c", + "cfscript", + "chaiscript", + "cil", + "clike", + "clojure", + "cmake", + "cobol", + "coffeescript", + "concurnas", + "coq", + "core", + "cpp", + "crystal", + "csharp", + "cshtml", + "csp", + "css", + "css-extras", + "csv", + "cypher", + "d", + "dart", + "dataweave", + "dax", + "dhall", + "diff", + "django", + "dns-zone-file", + "docker", + "dot", + "ebnf", + "editorconfig", + "eiffel", + "ejs", + "elixir", + "elm", + "erb", + "erlang", + "etlua", + "excel-formula", + "factor", + "false", + "firestore-security-rules", + "flow", + "fortran", + "fsharp", + "ftl", + "gap", + "gcode", + "gdscript", + "gedcom", + "gherkin", + "git", + "glsl", + "gml", + "gn", + "go", + "go-module", + "graphql", + "groovy", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hlsl", + "hoon", + "hpkp", + "hsts", + "http", + "ichigojam", + "icon", + "icu-message-format", + "idris", + "iecst", + "ignore", + "index", + "inform7", + "ini", + "io", + "j", + "java", + "javadoc", + "javadoclike", + "javascript", + "javastacktrace", + "jexl", + "jolie", + "jq", + "js-extras", + "js-templates", + "jsdoc", + "json", + "json5", + "jsonp", + "jsstacktrace", + "jsx", + "julia", + "keepalived", + "keyman", + "kotlin", + "kumir", + "kusto", + "latex", + "latte", + "less", + "lilypond", + "liquid", + "lisp", + "livescript", + "llvm", + "log", + "lolcode", + "lua", + "magma", + "makefile", + "markdown", + "markup", + "markup-templating", + "matlab", + "maxscript", + "mel", + "mermaid", + "mizar", + "mongodb", + "monkey", + "moonscript", + "n1ql", + "n4js", + "nand2tetris-hdl", + "naniscript", + "nasm", + "neon", + "nevod", + "nginx", + "nim", + "nix", + "nsis", + "objectivec", + "ocaml", + "opencl", + "openqasm", + "oz", + "parigp", + "parser", + "pascal", + "pascaligo", + "pcaxis", + "peoplecode", + "perl", + "php", + "php-extras", + "phpdoc", + "plsql", + "powerquery", + "powershell", + "processing", + "prolog", + "promql", + "properties", + "protobuf", + "psl", + "pug", + "puppet", + "pure", + "purebasic", + "purescript", + "python", + "q", + "qml", + "qore", + "qsharp", + "r", + "racket", + "reason", + "regex", + "rego", + "renpy", + "rest", + "rip", + "roboconf", + "robotframework", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shell-session", + "smali", + "smalltalk", + "smarty", + "sml", + "solidity", + "solution-file", + "soy", + "sparql", + "splunk-spl", + "sqf", + "sql", + "squirrel", + "stan", + "stylus", + "swift", + "systemd", + "t4-cs", + "t4-templating", + "t4-vb", + "tap", + "tcl", + "textile", + "toml", + "tremor", + "tsx", + "tt2", + "turtle", + "twig", + "typescript", + "typoscript", + "unrealscript", + "uorazor", + "uri", + "v", + "vala", + "vbnet", + "velocity", + "verilog", + "vhdl", + "vim", + "visual-basic", + "warpscript", + "wasm", + "web-idl", + "wiki", + "wolfram", + "wren", + "xeora", + "xml-doc", + "xojo", + "xquery", + "yaml", + "yang", + "zig", + ], Var[ Literal[ "abap", @@ -737,6 +920,148 @@ class CodeBlock(Component): "zig", ] ], + ] + ] = None, + code: Optional[Union[Var[str], str]] = None, + show_line_numbers: Optional[Union[Var[bool], bool]] = None, + starting_line_number: Optional[Union[Var[int], int]] = None, + wrap_long_lines: Optional[Union[Var[bool], bool]] = None, + custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None, + code_tag_props: Optional[Union[Dict[str, str], Var[Dict[str, str]]]] = None, + style: Optional[Style] = None, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None, + on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None, + on_context_menu: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_double_click: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None, + on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None, + on_mouse_down: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_enter: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_leave: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_move: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_out: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_over: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_mouse_up: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None, + on_unmount: Optional[ + Union[EventHandler, EventSpec, list, Callable, Var] + ] = None, + **props, + ) -> "CodeBlock": + """Create a text component. + + Args: + *children: The children of the component. + can_copy: Whether a copy button should appears. + copy_button: A custom copy button to override the default one. + theme: The theme to use ("light" or "dark"). + language: The language to use. + code: The code to display. + show_line_numbers: If this is enabled line numbers will be shown next to the code block. + starting_line_number: The starting line number to use. + wrap_long_lines: Whether to wrap long lines. + custom_style: A custom style for the code block. + code_tag_props: Props passed down to the code tag. + style: The style of the component. + key: A unique key for the component. + id: The id for the component. + class_name: The class name for the component. + autofocus: Whether the component should take the focus once the page is loaded + custom_attrs: custom attribute + **props: The props to pass to the component. + + Returns: + The text component. + """ + ... + + def add_style(self): ... + @staticmethod + def convert_theme_name(theme) -> str: ... + +def construct_theme_var(theme: str) -> Var: ... + +class Theme(enum.Enum): + a11y_dark = construct_theme_var("a11yDark") + atom_dark = construct_theme_var("atomDark") + cb = construct_theme_var("cb") + coldark_cold = construct_theme_var("coldarkCold") + coldark_dark = construct_theme_var("coldarkDark") + coy = construct_theme_var("coy") + coy_without_shadows = construct_theme_var("coyWithoutShadows") + darcula = construct_theme_var("darcula") + dark = construct_theme_var("oneDark") + dracula = construct_theme_var("dracula") + duotone_dark = construct_theme_var("duotoneDark") + duotone_earth = construct_theme_var("duotoneEarth") + duotone_forest = construct_theme_var("duotoneForest") + duotone_light = construct_theme_var("duotoneLight") + duotone_sea = construct_theme_var("duotoneSea") + duotone_space = construct_theme_var("duotoneSpace") + funky = construct_theme_var("funky") + ghcolors = construct_theme_var("ghcolors") + gruvbox_dark = construct_theme_var("gruvboxDark") + gruvbox_light = construct_theme_var("gruvboxLight") + holi_theme = construct_theme_var("holiTheme") + hopscotch = construct_theme_var("hopscotch") + light = construct_theme_var("oneLight") + lucario = construct_theme_var("lucario") + material_dark = construct_theme_var("materialDark") + material_light = construct_theme_var("materialLight") + material_oceanic = construct_theme_var("materialOceanic") + night_owl = construct_theme_var("nightOwl") + nord = construct_theme_var("nord") + okaidia = construct_theme_var("okaidia") + one_dark = construct_theme_var("oneDark") + one_light = construct_theme_var("oneLight") + pojoaque = construct_theme_var("pojoaque") + prism = construct_theme_var("prism") + shades_of_purple = construct_theme_var("shadesOfPurple") + solarized_dark_atom = construct_theme_var("solarizedDarkAtom") + solarizedlight = construct_theme_var("solarizedlight") + synthwave84 = construct_theme_var("synthwave84") + tomorrow = construct_theme_var("tomorrow") + twilight = construct_theme_var("twilight") + vs = construct_theme_var("vs") + vs_dark = construct_theme_var("vsDark") + vsc_dark_plus = construct_theme_var("vscDarkPlus") + xonokai = construct_theme_var("xonokai") + z_touch = construct_theme_var("zTouch") + +class CodeblockNamespace(ComponentNamespace): + themes = Theme + + @staticmethod + def __call__( + *children, + can_copy: Optional[bool] = False, + copy_button: Optional[Union[Component, bool]] = None, + theme: Optional[Union[Any, Var[Any]]] = None, + language: Optional[ + Union[ Literal[ "abap", "abnf", @@ -1018,6 +1343,289 @@ class CodeBlock(Component): "yang", "zig", ], + Var[ + Literal[ + "abap", + "abnf", + "actionscript", + "ada", + "agda", + "al", + "antlr4", + "apacheconf", + "apex", + "apl", + "applescript", + "aql", + "arduino", + "arff", + "asciidoc", + "asm6502", + "asmatmel", + "aspnet", + "autohotkey", + "autoit", + "avisynth", + "avro-idl", + "bash", + "basic", + "batch", + "bbcode", + "bicep", + "birb", + "bison", + "bnf", + "brainfuck", + "brightscript", + "bro", + "bsl", + "c", + "cfscript", + "chaiscript", + "cil", + "clike", + "clojure", + "cmake", + "cobol", + "coffeescript", + "concurnas", + "coq", + "core", + "cpp", + "crystal", + "csharp", + "cshtml", + "csp", + "css", + "css-extras", + "csv", + "cypher", + "d", + "dart", + "dataweave", + "dax", + "dhall", + "diff", + "django", + "dns-zone-file", + "docker", + "dot", + "ebnf", + "editorconfig", + "eiffel", + "ejs", + "elixir", + "elm", + "erb", + "erlang", + "etlua", + "excel-formula", + "factor", + "false", + "firestore-security-rules", + "flow", + "fortran", + "fsharp", + "ftl", + "gap", + "gcode", + "gdscript", + "gedcom", + "gherkin", + "git", + "glsl", + "gml", + "gn", + "go", + "go-module", + "graphql", + "groovy", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hlsl", + "hoon", + "hpkp", + "hsts", + "http", + "ichigojam", + "icon", + "icu-message-format", + "idris", + "iecst", + "ignore", + "index", + "inform7", + "ini", + "io", + "j", + "java", + "javadoc", + "javadoclike", + "javascript", + "javastacktrace", + "jexl", + "jolie", + "jq", + "js-extras", + "js-templates", + "jsdoc", + "json", + "json5", + "jsonp", + "jsstacktrace", + "jsx", + "julia", + "keepalived", + "keyman", + "kotlin", + "kumir", + "kusto", + "latex", + "latte", + "less", + "lilypond", + "liquid", + "lisp", + "livescript", + "llvm", + "log", + "lolcode", + "lua", + "magma", + "makefile", + "markdown", + "markup", + "markup-templating", + "matlab", + "maxscript", + "mel", + "mermaid", + "mizar", + "mongodb", + "monkey", + "moonscript", + "n1ql", + "n4js", + "nand2tetris-hdl", + "naniscript", + "nasm", + "neon", + "nevod", + "nginx", + "nim", + "nix", + "nsis", + "objectivec", + "ocaml", + "opencl", + "openqasm", + "oz", + "parigp", + "parser", + "pascal", + "pascaligo", + "pcaxis", + "peoplecode", + "perl", + "php", + "php-extras", + "phpdoc", + "plsql", + "powerquery", + "powershell", + "processing", + "prolog", + "promql", + "properties", + "protobuf", + "psl", + "pug", + "puppet", + "pure", + "purebasic", + "purescript", + "python", + "q", + "qml", + "qore", + "qsharp", + "r", + "racket", + "reason", + "regex", + "rego", + "renpy", + "rest", + "rip", + "roboconf", + "robotframework", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shell-session", + "smali", + "smalltalk", + "smarty", + "sml", + "solidity", + "solution-file", + "soy", + "sparql", + "splunk-spl", + "sqf", + "sql", + "squirrel", + "stan", + "stylus", + "swift", + "systemd", + "t4-cs", + "t4-templating", + "t4-vb", + "tap", + "tcl", + "textile", + "toml", + "tremor", + "tsx", + "tt2", + "turtle", + "twig", + "typescript", + "typoscript", + "unrealscript", + "uorazor", + "uri", + "v", + "vala", + "vbnet", + "velocity", + "verilog", + "vhdl", + "vim", + "visual-basic", + "warpscript", + "wasm", + "web-idl", + "wiki", + "wolfram", + "wren", + "xeora", + "xml-doc", + "xojo", + "xquery", + "yaml", + "yang", + "zig", + ] + ], ] ] = None, code: Optional[Union[Var[str], str]] = None, @@ -1025,7 +1633,7 @@ class CodeBlock(Component): starting_line_number: Optional[Union[Var[int], int]] = None, wrap_long_lines: Optional[Union[Var[bool], bool]] = None, custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None, - code_tag_props: Optional[Union[Var[Dict[str, str]], Dict[str, str]]] = None, + code_tag_props: Optional[Union[Dict[str, str], Var[Dict[str, str]]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1096,8 +1704,4 @@ class CodeBlock(Component): """ ... - def add_style(self): ... - @staticmethod - def convert_theme_name(theme) -> str: ... - -code_block = CodeBlock.create +code_block = CodeblockNamespace() diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index f3296e0b7..9d1ecc775 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -9,11 +9,12 @@ from reflex.base import Base from reflex.components.component import Component, NoSSRComponent from reflex.components.literals import LiteralRowMarker from reflex.event import EventHandler -from reflex.ivars.base import ImmutableVar from reflex.utils import console, format, types from reflex.utils.imports import ImportDict, ImportVar from reflex.utils.serializers import serializer -from reflex.vars import Var, get_unique_variable_name +from reflex.vars import get_unique_variable_name +from reflex.vars.base import Var +from reflex.vars.sequence import ArrayVar # TODO: Fix the serialization issue for custom types. @@ -294,12 +295,12 @@ class DataEditor(NoSSRComponent): # Define the name of the getData callback associated with this component and assign to get_cell_content. data_callback = f"getData_{editor_id}" - self.get_cell_content = ImmutableVar.create(data_callback) # type: ignore + self.get_cell_content = Var(_js_expr=data_callback) # type: ignore code = [f"function {data_callback}([col, row])" "{"] - columns_path = f"{self.columns._var_full_name}" - data_path = f"{self.data._var_full_name}" + columns_path = str(self.columns) + data_path = str(self.data) code.extend( [ @@ -332,6 +333,10 @@ class DataEditor(NoSSRComponent): # If rows is not provided, determine from data. if rows is None: + if isinstance(data, Var) and not isinstance(data, ArrayVar): + raise ValueError( + "DataEditor data must be an ArrayVar if rows is not provided." + ) props["rows"] = data.length() if isinstance(data, Var) else len(data) if not isinstance(columns, Var) and len(columns): @@ -402,9 +407,9 @@ def serialize_dataeditortheme(theme: DataEditorTheme): Returns: The serialized theme. """ - return format.json_dumps( - {format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None} - ) + return { + format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None + } data_editor = DataEditor.create diff --git a/reflex/components/datadisplay/dataeditor.pyi b/reflex/components/datadisplay/dataeditor.pyi index b40890b73..edfd0521a 100644 --- a/reflex/components/datadisplay/dataeditor.pyi +++ b/reflex/components/datadisplay/dataeditor.pyi @@ -12,7 +12,7 @@ from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict from reflex.utils.serializers import serializer -from reflex.vars import Var +from reflex.vars.base import Var class GridColumnIcons(Enum): Array = "array" @@ -88,9 +88,9 @@ class DataEditor(NoSSRComponent): *children, rows: Optional[Union[Var[int], int]] = None, columns: Optional[ - Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]] + Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] ] = None, - data: Optional[Union[Var[List[List[Any]]], List[List[Any]]]] = None, + data: Optional[Union[List[List[Any]], Var[List[List[Any]]]]] = None, get_cell_content: Optional[Union[Var[str], str]] = None, get_cell_for_selection: Optional[Union[Var[bool], bool]] = None, on_paste: Optional[Union[Var[bool], bool]] = None, @@ -106,8 +106,8 @@ class DataEditor(NoSSRComponent): row_height: Optional[Union[Var[int], int]] = None, row_markers: Optional[ Union[ - Var[Literal["none", "number", "checkbox", "both", "clickable-number"]], - Literal["none", "number", "checkbox", "both", "clickable-number"], + Literal["both", "checkbox", "clickable-number", "none", "number"], + Var[Literal["both", "checkbox", "clickable-number", "none", "number"]], ] ] = None, row_marker_start_index: Optional[Union[Var[int], int]] = None, @@ -117,8 +117,8 @@ class DataEditor(NoSSRComponent): vertical_border: Optional[Union[Var[bool], bool]] = None, column_select: Optional[ Union[ - Var[Literal["none", "single", "multi"]], - Literal["none", "single", "multi"], + Literal["multi", "none", "single"], + Var[Literal["multi", "none", "single"]], ] ] = None, prevent_diagonal_scrolling: Optional[Union[Var[bool], bool]] = None, @@ -127,7 +127,7 @@ class DataEditor(NoSSRComponent): scroll_offset_x: Optional[Union[Var[int], int]] = None, scroll_offset_y: Optional[Union[Var[int], int]] = None, theme: Optional[ - Union[Var[Union[DataEditorTheme, Dict]], DataEditorTheme, Dict] + Union[DataEditorTheme, Dict, Var[Union[DataEditorTheme, Dict]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/dynamic.py b/reflex/components/dynamic.py new file mode 100644 index 000000000..6ae78161f --- /dev/null +++ b/reflex/components/dynamic.py @@ -0,0 +1,143 @@ +"""Components that are dynamically generated on the backend.""" + +from reflex import constants +from reflex.utils import imports +from reflex.utils.serializers import serializer +from reflex.vars import Var, get_unique_variable_name +from reflex.vars.base import VarData, transform + + +def get_cdn_url(lib: str) -> str: + """Get the CDN URL for a library. + + Args: + lib: The library to get the CDN URL for. + + Returns: + The CDN URL for the library. + """ + return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm" + + +def load_dynamic_serializer(): + """Load the serializer for dynamic components.""" + # Causes a circular import, so we import here. + from reflex.components.component import Component + + @serializer + def make_component(component: Component) -> str: + """Generate the code for a dynamic component. + + Args: + component: The component to generate code for. + + Returns: + The generated code + """ + # Causes a circular import, so we import here. + from reflex.compiler import templates, utils + + rendered_components = {} + # Include dynamic imports in the shared component. + if dynamic_imports := component._get_all_dynamic_imports(): + rendered_components.update( + {dynamic_import: None for dynamic_import in dynamic_imports} + ) + + # Include custom code in the shared component. + rendered_components.update( + {code: None for code in component._get_all_custom_code()}, + ) + + rendered_components[ + templates.STATEFUL_COMPONENT.render( + tag_name="MySSRComponent", + memo_trigger_hooks=[], + component=component, + ) + ] = None + + imports = {} + for lib, names in component._get_all_imports().items(): + if ( + not lib.startswith((".", "/")) + and not lib.startswith("http") + and lib != "react" + ): + imports[get_cdn_url(lib)] = names + else: + imports[lib] = names + + module_code_lines = templates.STATEFUL_COMPONENTS.render( + imports=utils.compile_imports(imports), + memoized_code="\n".join(rendered_components), + ).splitlines()[1:] + + # Rewrite imports from `/` to destructure from window + for ix, line in enumerate(module_code_lines[:]): + if line.startswith("import "): + if 'from "/' in line: + module_code_lines[ix] = ( + line.replace("import ", "const ", 1).replace( + " from ", " = window['__reflex'][", 1 + ) + + "]" + ) + elif 'from "react"' in line: + module_code_lines[ix] = line.replace( + "import ", "const ", 1 + ).replace(' from "react"', " = window.__reflex.react", 1) + if line.startswith("export function"): + module_code_lines[ix] = line.replace( + "export function", "export default function", 1 + ) + + module_code_lines.insert(0, "const React = window.__reflex.react;") + + return "//__reflex_evaluate\n" + "\n".join(module_code_lines) + + @transform + def evaluate_component(js_string: Var[str]) -> Var[Component]: + """Evaluate a component. + + Args: + js_string: The JavaScript string to evaluate. + + Returns: + The evaluated JavaScript string. + """ + unique_var_name = get_unique_variable_name() + + return js_string._replace( + _js_expr=unique_var_name, + _var_type=Component, + merge_var_data=VarData.merge( + VarData( + imports={ + f"/{constants.Dirs.STATE_PATH}": [ + imports.ImportVar(tag="evalReactComponent"), + ], + "react": [ + imports.ImportVar(tag="useState"), + imports.ImportVar(tag="useEffect"), + ], + }, + hooks={ + f"const [{unique_var_name}, set_{unique_var_name}] = useState(null);": None, + "useEffect(() => {" + "let isMounted = true;" + f"evalReactComponent({str(js_string)})" + ".then((component) => {" + "if (isMounted) {" + f"set_{unique_var_name}(component);" + "}" + "});" + "return () => {" + "isMounted = false;" + "};" + "}" + f", [{str(js_string)}]);": None, + }, + ), + ), + ) diff --git a/reflex/components/el/__init__.py b/reflex/components/el/__init__.py index 9fe1d89cd..750e65dba 100644 --- a/reflex/components/el/__init__.py +++ b/reflex/components/el/__init__.py @@ -10,7 +10,6 @@ _SUBMODULES: set[str] = {"elements"} _SUBMOD_ATTRS: dict[str, list[str]] = { f"elements.{k}": v for k, v in elements._MAPPING.items() } -_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS __getattr__, __dir__, __all__ = lazy_loader.attach( __name__, diff --git a/reflex/components/el/__init__.pyi b/reflex/components/el/__init__.pyi index d312db84e..adf657b7e 100644 --- a/reflex/components/el/__init__.pyi +++ b/reflex/components/el/__init__.pyi @@ -3,7 +3,6 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from . import elements from .elements.forms import Button as Button from .elements.forms import Fieldset as Fieldset from .elements.forms import Form as Form @@ -88,36 +87,28 @@ from .elements.inline import u as u from .elements.inline import wbr as wbr from .elements.media import Area as Area from .elements.media import Audio as Audio -from .elements.media import Defs as Defs from .elements.media import Embed as Embed from .elements.media import Iframe as Iframe from .elements.media import Img as Img -from .elements.media import LinearGradient as LinearGradient from .elements.media import Map as Map from .elements.media import Object as Object -from .elements.media import Path as Path from .elements.media import Picture as Picture from .elements.media import Portal as Portal from .elements.media import Source as Source -from .elements.media import Stop as Stop from .elements.media import Svg as Svg from .elements.media import Track as Track from .elements.media import Video as Video from .elements.media import area as area from .elements.media import audio as audio -from .elements.media import defs as defs # type: ignore from .elements.media import embed as embed from .elements.media import iframe as iframe from .elements.media import image as image from .elements.media import img as img -from .elements.media import lineargradient as lineargradient # type: ignore from .elements.media import map as map from .elements.media import object as object -from .elements.media import path as path # type: ignore from .elements.media import picture as picture from .elements.media import portal as portal from .elements.media import source as source -from .elements.media import stop as stop # type: ignore from .elements.media import svg as svg from .elements.media import track as track from .elements.media import video as video @@ -231,5 +222,3 @@ from .elements.typography import ol as ol from .elements.typography import p as p from .elements.typography import pre as pre from .elements.typography import ul as ul - -_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS diff --git a/reflex/components/el/element.pyi b/reflex/components/el/element.pyi index f18d9008c..4ea86f273 100644 --- a/reflex/components/el/element.pyi +++ b/reflex/components/el/element.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Element(Component): @overload diff --git a/reflex/components/el/elements/__init__.py b/reflex/components/el/elements/__init__.py index 024ae8c3d..17fdb77ca 100644 --- a/reflex/components/el/elements/__init__.py +++ b/reflex/components/el/elements/__init__.py @@ -65,11 +65,6 @@ _MAPPING = { "portal", "source", "svg", - "defs", - "lineargradient", - "LinearGradient", - "stop", - "path", ], "metadata": [ "base", @@ -130,13 +125,12 @@ _MAPPING = { } -EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"] +EXCLUDE = ["del_", "Del", "image"] for _, v in _MAPPING.items(): v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE]) _SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING -_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"] __getattr__, __dir__, __all__ = lazy_loader.attach( __name__, submod_attrs=_SUBMOD_ATTRS, diff --git a/reflex/components/el/elements/__init__.pyi b/reflex/components/el/elements/__init__.pyi index 4f218f361..b35e70dd2 100644 --- a/reflex/components/el/elements/__init__.pyi +++ b/reflex/components/el/elements/__init__.pyi @@ -87,36 +87,28 @@ from .inline import u as u from .inline import wbr as wbr from .media import Area as Area from .media import Audio as Audio -from .media import Defs as Defs from .media import Embed as Embed from .media import Iframe as Iframe from .media import Img as Img -from .media import LinearGradient as LinearGradient from .media import Map as Map from .media import Object as Object -from .media import Path as Path from .media import Picture as Picture from .media import Portal as Portal from .media import Source as Source -from .media import Stop as Stop from .media import Svg as Svg from .media import Track as Track from .media import Video as Video from .media import area as area from .media import audio as audio -from .media import defs as defs # type: ignore from .media import embed as embed from .media import iframe as iframe from .media import image as image from .media import img as img -from .media import lineargradient as lineargradient # type: ignore from .media import map as map from .media import object as object -from .media import path as path # type: ignore from .media import picture as picture from .media import portal as portal from .media import source as source -from .media import stop as stop # type: ignore from .media import svg as svg from .media import track as track from .media import video as video @@ -292,11 +284,6 @@ _MAPPING = { "portal", "source", "svg", - "defs", - "lineargradient", - "LinearGradient", - "stop", - "path", ], "metadata": ["base", "head", "link", "meta", "title", "style"], "other": ["details", "dialog", "summary", "slot", "template", "math", "html"], @@ -348,7 +335,6 @@ _MAPPING = { "Del", ], } -EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"] +EXCLUDE = ["del_", "Del", "image"] for _, v in _MAPPING.items(): v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE]) -_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"] diff --git a/reflex/components/el/elements/base.py b/reflex/components/el/elements/base.py index 5eb8aa70c..a9748ae25 100644 --- a/reflex/components/el/elements/base.py +++ b/reflex/components/el/elements/base.py @@ -3,7 +3,7 @@ from typing import Union from reflex.components.el.element import Element -from reflex.vars import Var as Var +from reflex.vars.base import Var class BaseHTML(Element): diff --git a/reflex/components/el/elements/base.pyi b/reflex/components/el/elements/base.pyi index d802cc2ee..d3f0622da 100644 --- a/reflex/components/el/elements/base.pyi +++ b/reflex/components/el/elements/base.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.el.element import Element from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class BaseHTML(Element): @overload @@ -16,30 +16,30 @@ class BaseHTML(Element): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/forms.py b/reflex/components/el/elements/forms.py index dfbdc4c1f..29fea357b 100644 --- a/reflex/components/el/elements/forms.py +++ b/reflex/components/el/elements/forms.py @@ -11,22 +11,21 @@ from reflex.components.el.element import Element from reflex.components.tags.tag import Tag from reflex.constants import Dirs, EventTriggers from reflex.event import EventChain, EventHandler -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.utils.format import format_event_chain from reflex.utils.imports import ImportDict -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var from .base import BaseHTML -FORM_DATA = ImmutableVar.create("form_data") +FORM_DATA = Var(_js_expr="form_data") HANDLE_SUBMIT_JS_JINJA2 = Environment().from_string( """ const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => { const $form = ev.target ev.preventDefault() - const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}} + const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}}; - {{ on_submit_event_chain }} + ({{ on_submit_event_chain }}()); if ({{ reset_on_submit }}) { $form.reset() @@ -186,8 +185,8 @@ class Form(BaseHTML): handle_submit_unique_name=self.handle_submit_unique_name, form_data=FORM_DATA, field_ref_mapping=str(LiteralVar.create(self._get_form_refs())), - on_submit_event_chain=format_event_chain( - self.event_triggers[EventTriggers.ON_SUBMIT] + on_submit_event_chain=str( + LiteralVar.create(self.event_triggers[EventTriggers.ON_SUBMIT]) ), reset_on_submit=self.reset_on_submit, ) @@ -198,8 +197,8 @@ class Form(BaseHTML): if EventTriggers.ON_SUBMIT in self.event_triggers: render_tag.add_props( **{ - EventTriggers.ON_SUBMIT: ImmutableVar( - _var_name=f"handleSubmit_{self.handle_submit_unique_name}", + EventTriggers.ON_SUBMIT: Var( + _js_expr=f"handleSubmit_{self.handle_submit_unique_name}", _var_type=EventChain, ) } @@ -213,15 +212,15 @@ class Form(BaseHTML): # when ref start with refs_ it's an array of refs, so we need different method # to collect data if ref.startswith("refs_"): - ref_var = ImmutableVar.create_safe(ref[:-3]).as_ref() - form_refs[ref[len("refs_") : -3]] = ImmutableVar.create_safe( - f"getRefValues({str(ref_var)})", + ref_var = Var(_js_expr=ref[:-3]).as_ref() + form_refs[ref[len("refs_") : -3]] = Var( + _js_expr=f"getRefValues({str(ref_var)})", _var_data=VarData.merge(ref_var._get_all_var_data()), ) else: - ref_var = ImmutableVar.create_safe(ref).as_ref() - form_refs[ref[4:]] = ImmutableVar.create_safe( - f"getRefValue({str(ref_var)})", + ref_var = Var(_js_expr=ref).as_ref() + form_refs[ref[4:]] = Var( + _js_expr=f"getRefValue({str(ref_var)})", _var_data=VarData.merge(ref_var._get_all_var_data()), ) # print(repr(form_refs)) @@ -501,7 +500,7 @@ AUTO_HEIGHT_JS = """ const autoHeightOnInput = (e, is_enabled) => { if (is_enabled) { const el = e.target; - el.style.overflowY = "hidden"; + el.style.overflowY = "scroll"; el.style.height = "auto"; el.style.height = (e.target.scrollHeight) + "px"; if (el.form && !el.form.data_resize_on_reset) { @@ -625,19 +624,15 @@ class Textarea(BaseHTML): "Cannot combine `enter_key_submit` with `on_key_down`.", ) tag.add_props( - on_key_down=Var.create_safe( - f"(e) => enterKeySubmitOnKeyDown(e, {self.enter_key_submit._var_name_unwrapped})", - _var_is_local=False, - _var_is_string=False, + on_key_down=Var( + _js_expr=f"(e) => enterKeySubmitOnKeyDown(e, {str(self.enter_key_submit)})", _var_data=VarData.merge(self.enter_key_submit._get_all_var_data()), ) ) if self.auto_height is not None: tag.add_props( - on_input=Var.create_safe( - f"(e) => autoHeightOnInput(e, {self.auto_height._var_name_unwrapped})", - _var_is_local=False, - _var_is_string=False, + on_input=Var( + _js_expr=f"(e) => autoHeightOnInput(e, {str(self.auto_height)})", _var_data=VarData.merge(self.auto_height._get_all_var_data()), ) ) diff --git a/reflex/components/el/elements/forms.pyi b/reflex/components/el/elements/forms.pyi index 7b20571eb..5677eb741 100644 --- a/reflex/components/el/elements/forms.pyi +++ b/reflex/components/el/elements/forms.pyi @@ -9,16 +9,15 @@ from jinja2 import Environment from reflex.components.el.element import Element from reflex.event import EventHandler, EventSpec -from reflex.ivars.base import ImmutableVar from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML -FORM_DATA = ImmutableVar.create("form_data") +FORM_DATA = Var(_js_expr="form_data") HANDLE_SUBMIT_JS_JINJA2 = Environment().from_string( - "\n const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {\n const $form = ev.target\n ev.preventDefault()\n const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}}\n\n {{ on_submit_event_chain }}\n\n if ({{ reset_on_submit }}) {\n $form.reset()\n }\n })\n " + "\n const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {\n const $form = ev.target\n ev.preventDefault()\n const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}};\n\n ({{ on_submit_event_chain }}());\n\n if ({{ reset_on_submit }}) {\n $form.reset()\n }\n })\n " ) class Button(BaseHTML): @@ -27,45 +26,45 @@ class Button(BaseHTML): def create( # type: ignore cls, *children, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -159,30 +158,30 @@ class Datalist(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -265,9 +264,9 @@ class Fieldset(Element): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -337,45 +336,45 @@ class Form(BaseHTML): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -473,69 +472,69 @@ class Input(BaseHTML): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - capture: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - checked: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, default_checked: Optional[Union[Var[bool], bool]] = None, default_value: Optional[Union[Var[str], str]] = None, - dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - list: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - pattern: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - step: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -656,32 +655,32 @@ class Label(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -766,30 +765,30 @@ class Legend(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -872,37 +871,37 @@ class Meter(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - high: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - low: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - optimum: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + high: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + low: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + optimum: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -992,32 +991,32 @@ class Optgroup(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1102,34 +1101,34 @@ class Option(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - selected: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + selected: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1216,33 +1215,33 @@ class Output(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1328,33 +1327,33 @@ class Progress(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1441,39 +1440,39 @@ class Select(BaseHTML): cls, *children, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1559,7 +1558,7 @@ class Select(BaseHTML): """ ... -AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "hidden";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n' +AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "scroll";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n' ENTER_KEY_SUBMIT_JS = "\nconst enterKeySubmitOnKeyDown = (e, is_enabled) => {\n if (is_enabled && e.which === 13 && !e.shiftKey) {\n e.preventDefault();\n if (!e.repeat) {\n if (e.target.form) {\n e.target.form.requestSubmit();\n }\n }\n }\n}\n" class Textarea(BaseHTML): @@ -1569,48 +1568,48 @@ class Textarea(BaseHTML): cls, *children, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_height: Optional[Union[Var[bool], bool]] = None, - cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_submit: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - rows: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - wrap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + rows: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + wrap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/inline.py b/reflex/components/el/elements/inline.py index 4364c1ead..d1bdf6b87 100644 --- a/reflex/components/el/elements/inline.py +++ b/reflex/components/el/elements/inline.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/inline.pyi b/reflex/components/el/elements/inline.pyi index dfddf5f10..e53e6da04 100644 --- a/reflex/components/el/elements/inline.pyi +++ b/reflex/components/el/elements/inline.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,41 +17,41 @@ class A(BaseHTML): def create( # type: ignore cls, *children, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -143,30 +143,30 @@ class Abbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -249,30 +249,30 @@ class B(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -355,30 +355,30 @@ class Bdi(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -461,30 +461,30 @@ class Bdo(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -567,30 +567,30 @@ class Br(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -673,30 +673,30 @@ class Cite(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -779,30 +779,30 @@ class Code(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -885,31 +885,31 @@ class Data(BaseHTML): def create( # type: ignore cls, *children, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -993,30 +993,30 @@ class Dfn(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1099,30 +1099,30 @@ class Em(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1205,30 +1205,30 @@ class I(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1311,30 +1311,30 @@ class Kbd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1417,30 +1417,30 @@ class Mark(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1523,31 +1523,31 @@ class Q(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1631,30 +1631,30 @@ class Rp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1737,30 +1737,30 @@ class Rt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1843,30 +1843,30 @@ class Ruby(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1949,30 +1949,30 @@ class S(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2055,30 +2055,30 @@ class Samp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2161,30 +2161,30 @@ class Small(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2267,30 +2267,30 @@ class Span(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2373,30 +2373,30 @@ class Strong(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2479,30 +2479,30 @@ class Sub(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2585,30 +2585,30 @@ class Sup(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2691,31 +2691,31 @@ class Time(BaseHTML): def create( # type: ignore cls, *children, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2799,30 +2799,30 @@ class U(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2905,30 +2905,30 @@ class Wbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py index b2bdc9e6f..705233532 100644 --- a/reflex/components/el/elements/media.py +++ b/reflex/components/el/elements/media.py @@ -4,8 +4,7 @@ from typing import Any, Union from reflex import Component, ComponentNamespace from reflex.constants.colors import Color -from reflex.utils import console -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -445,23 +444,3 @@ picture = Picture.create portal = Portal.create source = Source.create svg = SVG() - - -def __getattr__(name: str): - if name in ("defs", "lineargradient", "stop", "path"): - console.deprecate( - f"`rx.el.{name}`", - reason=f"use `rx.el.svg.{'linear_gradient' if name =='lineargradient' else name}`", - deprecation_version="0.5.8", - removal_version="0.6.0", - ) - return ( - LinearGradient.create - if name == "lineargradient" - else globals()[name.capitalize()].create - ) - - try: - return globals()[name] - except KeyError: - raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi index cf673ddf9..6d05fe69f 100644 --- a/reflex/components/el/elements/media.pyi +++ b/reflex/components/el/elements/media.pyi @@ -9,7 +9,7 @@ from reflex import ComponentNamespace from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -19,43 +19,43 @@ class Area(BaseHTML): def create( # type: ignore cls, *children, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - coords: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + coords: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -149,40 +149,40 @@ class Audio(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -273,48 +273,48 @@ class Img(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - decoding: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + decoding: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, intrinsicsize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - ismap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + ismap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Any], Any]] = None, - src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Any, Var[Any]]] = None, + src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -410,31 +410,31 @@ class Map(BaseHTML): def create( # type: ignore cls, *children, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -518,35 +518,35 @@ class Track(BaseHTML): def create( # type: ignore cls, *children, - default: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - kind: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + default: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + kind: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -634,44 +634,44 @@ class Video(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, plays_inline: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - poster: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + poster: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -764,32 +764,32 @@ class Embed(BaseHTML): def create( # type: ignore cls, *children, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -874,41 +874,41 @@ class Iframe(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - allow: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - csp: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + allow: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + csp: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - sandbox: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_doc: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + sandbox: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_doc: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1000,35 +1000,35 @@ class Object(BaseHTML): def create( # type: ignore cls, *children, - data: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + data: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1116,30 +1116,30 @@ class Picture(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1222,30 +1222,30 @@ class Portal(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1328,35 +1328,35 @@ class Source(BaseHTML): def create( # type: ignore cls, *children, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1444,33 +1444,33 @@ class Svg(BaseHTML): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, xmlns: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1556,34 +1556,34 @@ class Circle(BaseHTML): def create( # type: ignore cls, *children, - cx: Optional[Union[Var[Union[int, str]], str, int]] = None, - cy: Optional[Union[Var[Union[int, str]], str, int]] = None, - r: Optional[Union[Var[Union[int, str]], str, int]] = None, + cx: Optional[Union[Var[Union[int, str]], int, str]] = None, + cy: Optional[Union[Var[Union[int, str]], int, str]] = None, + r: Optional[Union[Var[Union[int, str]], int, str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1670,37 +1670,37 @@ class Rect(BaseHTML): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, - rx: Optional[Union[Var[Union[int, str]], str, int]] = None, - ry: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, + rx: Optional[Union[Var[Union[int, str]], int, str]] = None, + ry: Optional[Union[Var[Union[int, str]], int, str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1792,30 +1792,30 @@ class Polygon(BaseHTML): *children, points: Optional[Union[Var[str], str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1900,30 +1900,30 @@ class Defs(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2006,37 +2006,37 @@ class LinearGradient(BaseHTML): def create( # type: ignore cls, *children, - gradient_units: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - gradient_transform: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - spread_method: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - x1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - x2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - y1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - y2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + gradient_units: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + gradient_transform: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + spread_method: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + x1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + x2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + y1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + y2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2126,37 +2126,37 @@ class Stop(BaseHTML): def create( # type: ignore cls, *children, - offset: Optional[Union[Var[Union[float, int, str]], str, float, int]] = None, + offset: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, stop_color: Optional[ - Union[Var[Union[Color, bool, str]], str, Color, bool] + Union[Color, Var[Union[Color, bool, str]], bool, str] ] = None, stop_opacity: Optional[ - Union[Var[Union[bool, float, int, str]], str, float, int, bool] + Union[Var[Union[bool, float, int, str]], bool, float, int, str] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2242,31 +2242,31 @@ class Path(BaseHTML): def create( # type: ignore cls, *children, - d: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + d: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -2356,33 +2356,33 @@ class SVG(ComponentNamespace): @staticmethod def __call__( *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, xmlns: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/metadata.py b/reflex/components/el/elements/metadata.py index 9a4d18b73..983a8f3a0 100644 --- a/reflex/components/el/elements/metadata.py +++ b/reflex/components/el/elements/metadata.py @@ -1,9 +1,9 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" -from typing import Set, Union +from typing import List, Union from reflex.components.el.element import Element -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -89,9 +89,7 @@ class StyleEl(Element): # noqa: E742 media: Var[Union[str, int, bool]] - special_props: Set[Var] = { - Var.create_safe("suppressHydrationWarning", _var_is_string=False) - } + special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")] base = Base.create diff --git a/reflex/components/el/elements/metadata.pyi b/reflex/components/el/elements/metadata.pyi index cb7e1dca9..f59ed14fc 100644 --- a/reflex/components/el/elements/metadata.pyi +++ b/reflex/components/el/elements/metadata.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.el.element import Element from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -18,32 +18,32 @@ class Base(BaseHTML): def create( # type: ignore cls, *children, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -126,30 +126,30 @@ class Head(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -233,42 +233,42 @@ class Link(BaseHTML): cls, *children, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -360,34 +360,34 @@ class Meta(BaseHTML): def create( # type: ignore cls, *children, - char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - content: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - http_equiv: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + content: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + http_equiv: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -540,7 +540,7 @@ class StyleEl(Element): def create( # type: ignore cls, *children, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/other.py b/reflex/components/el/elements/other.py index 560ed5138..fa7c6cdec 100644 --- a/reflex/components/el/elements/other.py +++ b/reflex/components/el/elements/other.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/other.pyi b/reflex/components/el/elements/other.pyi index 89b50b085..9d4cdd7c9 100644 --- a/reflex/components/el/elements/other.pyi +++ b/reflex/components/el/elements/other.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,31 +17,31 @@ class Details(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -125,31 +125,31 @@ class Dialog(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -233,30 +233,30 @@ class Summary(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -339,30 +339,30 @@ class Slot(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -445,30 +445,30 @@ class Template(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -551,30 +551,30 @@ class Math(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -657,31 +657,31 @@ class Html(BaseHTML): def create( # type: ignore cls, *children, - manifest: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + manifest: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/scripts.py b/reflex/components/el/elements/scripts.py index 09a9fd17a..b53306e02 100644 --- a/reflex/components/el/elements/scripts.py +++ b/reflex/components/el/elements/scripts.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/scripts.pyi b/reflex/components/el/elements/scripts.pyi index 9923d8c6b..a6495720c 100644 --- a/reflex/components/el/elements/scripts.pyi +++ b/reflex/components/el/elements/scripts.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,30 +17,30 @@ class Canvas(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -123,30 +123,30 @@ class Noscript(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -229,43 +229,43 @@ class Script(BaseHTML): def create( # type: ignore cls, *children, - async_: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + async_: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - defer: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - language: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + defer: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + language: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/sectioning.py b/reflex/components/el/elements/sectioning.py index e1544bd15..6aea8c1e3 100644 --- a/reflex/components/el/elements/sectioning.py +++ b/reflex/components/el/elements/sectioning.py @@ -1,7 +1,5 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" -from reflex.vars import Var as Var - from .base import BaseHTML diff --git a/reflex/components/el/elements/sectioning.pyi b/reflex/components/el/elements/sectioning.pyi index 2d1cc457d..6b5905b13 100644 --- a/reflex/components/el/elements/sectioning.pyi +++ b/reflex/components/el/elements/sectioning.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,30 +17,30 @@ class Body(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -123,30 +123,30 @@ class Address(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -229,30 +229,30 @@ class Article(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -335,30 +335,30 @@ class Aside(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -441,30 +441,30 @@ class Footer(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -547,30 +547,30 @@ class Header(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -653,30 +653,30 @@ class H1(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -759,30 +759,30 @@ class H2(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -865,30 +865,30 @@ class H3(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -971,30 +971,30 @@ class H4(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1077,30 +1077,30 @@ class H5(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1183,30 +1183,30 @@ class H6(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1289,30 +1289,30 @@ class Main(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1395,30 +1395,30 @@ class Nav(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1501,30 +1501,30 @@ class Section(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/tables.py b/reflex/components/el/elements/tables.py index 007879358..8f6cfcba4 100644 --- a/reflex/components/el/elements/tables.py +++ b/reflex/components/el/elements/tables.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/tables.pyi b/reflex/components/el/elements/tables.pyi index 39ca144b8..49ab1b407 100644 --- a/reflex/components/el/elements/tables.pyi +++ b/reflex/components/el/elements/tables.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,31 +17,31 @@ class Caption(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -125,32 +125,32 @@ class Col(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -235,32 +235,32 @@ class Colgroup(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -345,32 +345,32 @@ class Table(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -455,31 +455,31 @@ class Tbody(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -563,34 +563,34 @@ class Td(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -677,31 +677,31 @@ class Tfoot(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -785,35 +785,35 @@ class Th(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -901,31 +901,31 @@ class Thead(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1009,31 +1009,31 @@ class Tr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/el/elements/typography.py b/reflex/components/el/elements/typography.py index dccad7a6d..7c55ecce7 100644 --- a/reflex/components/el/elements/typography.py +++ b/reflex/components/el/elements/typography.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/typography.pyi b/reflex/components/el/elements/typography.pyi index 926376441..2e8177090 100644 --- a/reflex/components/el/elements/typography.pyi +++ b/reflex/components/el/elements/typography.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,31 +17,31 @@ class Blockquote(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -125,30 +125,30 @@ class Dd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -231,30 +231,30 @@ class Div(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -337,30 +337,30 @@ class Dl(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -443,30 +443,30 @@ class Dt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -549,30 +549,30 @@ class Figcaption(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -655,31 +655,31 @@ class Hr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -763,30 +763,30 @@ class Li(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -869,31 +869,31 @@ class Menu(BaseHTML): def create( # type: ignore cls, *children, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -977,33 +977,33 @@ class Ol(BaseHTML): def create( # type: ignore cls, *children, - reversed: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + reversed: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + start: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1089,30 +1089,30 @@ class P(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1195,30 +1195,30 @@ class Pre(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1301,30 +1301,30 @@ class Ul(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1407,32 +1407,32 @@ class Ins(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1517,32 +1517,32 @@ class Del(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/gridjs/datatable.py b/reflex/components/gridjs/datatable.py index 47069843b..aaccda9d2 100644 --- a/reflex/components/gridjs/datatable.py +++ b/reflex/components/gridjs/datatable.py @@ -6,11 +6,10 @@ from typing import Any, Dict, List, Union from reflex.components.component import Component from reflex.components.tags import Tag -from reflex.ivars.base import ImmutableComputedVar from reflex.utils import types from reflex.utils.imports import ImportDict from reflex.utils.serializers import serialize -from reflex.vars import ComputedVar, Var +from reflex.vars.base import LiteralVar, Var, is_computed_var class Gridjs(Component): @@ -66,17 +65,14 @@ class DataTable(Gridjs): # The annotation should be provided if data is a computed var. We need this to know how to # render pandas dataframes. - if ( - isinstance(data, (ComputedVar, ImmutableComputedVar)) - and data._var_type == Any - ): + if is_computed_var(data) and data._var_type == Any: raise ValueError( "Annotation of the computed var assigned to the data field should be provided." ) if ( columns is not None - and isinstance(columns, (ComputedVar, ImmutableComputedVar)) + and is_computed_var(columns) and columns._var_type == Any ): raise ValueError( @@ -101,8 +97,6 @@ class DataTable(Gridjs): "column field should be specified when the data field is a list type" ) - print("props", props) - # Create the component. return super().create( *children, @@ -120,19 +114,19 @@ class DataTable(Gridjs): def _render(self) -> Tag: if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type): self.columns = self.data._replace( - _var_name=f"{self.data._var_name}.columns", + _js_expr=f"{self.data._js_expr}.columns", _var_type=List[Any], ) self.data = self.data._replace( - _var_name=f"{self.data._var_name}.data", + _js_expr=f"{self.data._js_expr}.data", _var_type=List[List[Any]], ) if types.is_dataframe(type(self.data)): # If given a pandas df break up the data and columns data = serialize(self.data) assert isinstance(data, dict), "Serialized dataframe should be a dict." - self.columns = Var.create_safe(data["columns"]) - self.data = Var.create_safe(data["data"]) + self.columns = LiteralVar.create(data["columns"]) + self.data = LiteralVar.create(data["data"]) # Render the table. return super()._render() diff --git a/reflex/components/gridjs/datatable.pyi b/reflex/components/gridjs/datatable.pyi index 8f0a427b1..ae7a8c0d3 100644 --- a/reflex/components/gridjs/datatable.pyi +++ b/reflex/components/gridjs/datatable.pyi @@ -9,7 +9,7 @@ from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var class Gridjs(Component): @overload @@ -84,11 +84,11 @@ class DataTable(Gridjs): cls, *children, data: Optional[Any] = None, - columns: Optional[Union[Var[List], List]] = None, + columns: Optional[Union[List, Var[List]]] = None, search: Optional[Union[Var[bool], bool]] = None, sort: Optional[Union[Var[bool], bool]] = None, resizable: Optional[Union[Var[bool], bool]] = None, - pagination: Optional[Union[Var[Union[Dict, bool]], bool, Dict]] = None, + pagination: Optional[Union[Dict, Var[Union[Dict, bool]], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/lucide/icon.py b/reflex/components/lucide/icon.py index e9cf9ab82..1ee68aaa3 100644 --- a/reflex/components/lucide/icon.py +++ b/reflex/components/lucide/icon.py @@ -1,8 +1,8 @@ """Lucide Icon component.""" from reflex.components.component import Component -from reflex.utils import console, format -from reflex.vars import Var +from reflex.utils import format +from reflex.vars.base import Var class LucideIconComponent(Component): @@ -36,19 +36,6 @@ class Icon(LucideIconComponent): Returns: The created component. """ - - def map_deprecated_icon_names_05(tag: str) -> str: - new_tag = RENAMED_ICONS_05.get(tag) - if new_tag is not None: - console.deprecate( - feature_name=f"icon {tag}", - reason=f"it was renamed upstream. Use {new_tag} instead.", - deprecation_version="0.4.6", - removal_version="0.6.0", - ) - return new_tag - return tag - if children: if len(children) == 1 and isinstance(children[0], str): props["tag"] = children[0] @@ -62,8 +49,7 @@ class Icon(LucideIconComponent): if ( not isinstance(props["tag"], str) - or map_deprecated_icon_names_05(format.to_snake_case(props["tag"])) - not in LUCIDE_ICON_LIST + or format.to_snake_case(props["tag"]) not in LUCIDE_ICON_LIST ): raise ValueError( f"Invalid icon tag: {props['tag']}. Please use one of the following: {', '.join(LUCIDE_ICON_LIST[0:25])}, ..." @@ -76,116 +62,6 @@ class Icon(LucideIconComponent): return super().create(*children, **props) -RENAMED_ICONS_05 = { - "activity_square": "square_activity", - "alert_circle": "circle_alert", - "alert_octagon": "octagon_alert", - "alert_triangle": "triangle_alert", - "arrow_down_circle": "circle_arrow_down", - "arrow_down_left_from_circle": "circle_arrow_out_down_left", - "arrow_down_left_from_square": "square_arrow_out_down_left", - "arrow_down_left_square": "square_arrow_down_left", - "arrow_down_right_from_circle": "circle_arrow_out_down_right", - "arrow_down_right_from_square": "square_arrow_out_down_right", - "arrow_down_right_square": "square_arrow_down_right", - "arrow_down_square": "square_arrow_down", - "arrow_left_circle": "circle_arrow_left", - "arrow_left_square": "square_arrow_left", - "arrow_right_circle": "circle_arrow_right", - "arrow_right_square": "square_arrow_right", - "arrow_up_circle": "circle_arrow_up", - "arrow_up_left_from_circle": "circle_arrow_out_up_left", - "arrow_up_left_from_square": "square_arrow_out_up_left", - "arrow_up_left_square": "square_arrow_up_left", - "arrow_up_right_from_circle": "circle_arrow_out_up_right", - "arrow_up_right_from_square": "square_arrow_out_up_right", - "arrow_up_right_square": "square_arrow_up_right", - "arrow_up_square": "square_arrow_up", - "asterisk_square": "square_asterisk", - "check_circle": "circle_check_big", - "check_circle_2": "circle_check", - "check_square": "square_check_big", - "check_square_2": "square_check", - "chevron_down_circle": "circle_chevron_down", - "chevron_down_square": "square_chevron_down", - "chevron_left_circle": "circle_chevron_left", - "chevron_left_square": "square_chevron_left", - "chevron_right_circle": "circle_chevron_right", - "chevron_right_square": "square_chevron_right", - "chevron_up_circle": "circle_chevron_up", - "chevron_up_square": "square_chevron_up", - "code_2": "code_xml", - "code_square": "square_code", - "contact_2": "contact_round", - "divide_circle": "circle_divide", - "divide_square": "square_divide", - "dot_square": "square_dot", - "download_cloud": "cloud_download", - "equal_square": "square_equal", - "form_input": "rectangle_ellipsis", - "function_square": "square_function", - "gantt_chart_square": "square_gantt_chart", - "gauge_circle": "circle_gauge", - "globe_2": "earth", - "help_circle": "circle_help", - "helping_hand": "hand_helping", - "ice_cream": "ice_cream_cone", - "ice_cream_2": "ice_cream_bowl", - "indent": "indent_increase", - "kanban_square": "square_kanban", - "kanban_square_dashed": "square_dashed_kanban", - "laptop_2": "laptop_minimal", - "library_square": "square_library", - "loader_2": "loader_circle", - "m_square": "square_m", - "menu_square": "square_menu", - "mic_2": "mic_vocal", - "minus_circle": "circle_minus", - "minus_square": "square_minus", - "more_horizontal": "ellipsis", - "more_vertical": "ellipsis_vertical", - "mouse_pointer_square": "square_mouse_pointer", - "mouse_pointer_square_dashed": "square_dashed_mouse_pointer", - "outdent": "indent_decrease", - "palm_tree": "tree_palm", - "parking_circle": "circle_parking", - "parking_circle_off": "circle_parking_off", - "parking_square": "square_parking", - "parking_square_off": "square_parking_off", - "pause_circle": "circle_pause", - "pause_octagon": "octagon_pause", - "percent_circle": "circle_percent", - "percent_diamond": "diamond_percent", - "percent_square": "square_percent", - "pi_square": "square_pi", - "pilcrow_square": "square_pilcrow", - "play_circle": "circle_play", - "play_square": "square_play", - "plus_circle": "circle_plus", - "plus_square": "square_plus", - "power_circle": "circle_power", - "power_square": "square_power", - "school_2": "university", - "scissors_square": "square_scissors", - "scissors_square_dashed_bottom": "square_bottom_dashed_scissors", - "sigma_square": "square_sigma", - "slash_circle": "circle_slash", - "sliders": "sliders_vertical", - "split_square_horizontal": "square_split_horizontal", - "split_square_vertical": "square_split_vertical", - "stop_circle": "circle_stop", - "subtitles": "captions", - "test_tube_2": "test_tube_diagonal", - "unlock": "lock_open", - "unlock_keyhole": "lock_keyhole_open", - "upload_cloud": "cloud_upload", - "wallet_2": "wallet_minimal", - "wand_2": "wand_sparkles", - "x_circle": "circle_x", - "x_octagon": "octagon_x", - "x_square": "square_x", -} - LUCIDE_ICON_LIST = [ "a_arrow_down", "a_arrow_up", diff --git a/reflex/components/lucide/icon.pyi b/reflex/components/lucide/icon.pyi index 8fafa2827..811576200 100644 --- a/reflex/components/lucide/icon.pyi +++ b/reflex/components/lucide/icon.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class LucideIconComponent(Component): @overload @@ -150,115 +150,6 @@ class Icon(LucideIconComponent): """ ... -RENAMED_ICONS_05 = { - "activity_square": "square_activity", - "alert_circle": "circle_alert", - "alert_octagon": "octagon_alert", - "alert_triangle": "triangle_alert", - "arrow_down_circle": "circle_arrow_down", - "arrow_down_left_from_circle": "circle_arrow_out_down_left", - "arrow_down_left_from_square": "square_arrow_out_down_left", - "arrow_down_left_square": "square_arrow_down_left", - "arrow_down_right_from_circle": "circle_arrow_out_down_right", - "arrow_down_right_from_square": "square_arrow_out_down_right", - "arrow_down_right_square": "square_arrow_down_right", - "arrow_down_square": "square_arrow_down", - "arrow_left_circle": "circle_arrow_left", - "arrow_left_square": "square_arrow_left", - "arrow_right_circle": "circle_arrow_right", - "arrow_right_square": "square_arrow_right", - "arrow_up_circle": "circle_arrow_up", - "arrow_up_left_from_circle": "circle_arrow_out_up_left", - "arrow_up_left_from_square": "square_arrow_out_up_left", - "arrow_up_left_square": "square_arrow_up_left", - "arrow_up_right_from_circle": "circle_arrow_out_up_right", - "arrow_up_right_from_square": "square_arrow_out_up_right", - "arrow_up_right_square": "square_arrow_up_right", - "arrow_up_square": "square_arrow_up", - "asterisk_square": "square_asterisk", - "check_circle": "circle_check_big", - "check_circle_2": "circle_check", - "check_square": "square_check_big", - "check_square_2": "square_check", - "chevron_down_circle": "circle_chevron_down", - "chevron_down_square": "square_chevron_down", - "chevron_left_circle": "circle_chevron_left", - "chevron_left_square": "square_chevron_left", - "chevron_right_circle": "circle_chevron_right", - "chevron_right_square": "square_chevron_right", - "chevron_up_circle": "circle_chevron_up", - "chevron_up_square": "square_chevron_up", - "code_2": "code_xml", - "code_square": "square_code", - "contact_2": "contact_round", - "divide_circle": "circle_divide", - "divide_square": "square_divide", - "dot_square": "square_dot", - "download_cloud": "cloud_download", - "equal_square": "square_equal", - "form_input": "rectangle_ellipsis", - "function_square": "square_function", - "gantt_chart_square": "square_gantt_chart", - "gauge_circle": "circle_gauge", - "globe_2": "earth", - "help_circle": "circle_help", - "helping_hand": "hand_helping", - "ice_cream": "ice_cream_cone", - "ice_cream_2": "ice_cream_bowl", - "indent": "indent_increase", - "kanban_square": "square_kanban", - "kanban_square_dashed": "square_dashed_kanban", - "laptop_2": "laptop_minimal", - "library_square": "square_library", - "loader_2": "loader_circle", - "m_square": "square_m", - "menu_square": "square_menu", - "mic_2": "mic_vocal", - "minus_circle": "circle_minus", - "minus_square": "square_minus", - "more_horizontal": "ellipsis", - "more_vertical": "ellipsis_vertical", - "mouse_pointer_square": "square_mouse_pointer", - "mouse_pointer_square_dashed": "square_dashed_mouse_pointer", - "outdent": "indent_decrease", - "palm_tree": "tree_palm", - "parking_circle": "circle_parking", - "parking_circle_off": "circle_parking_off", - "parking_square": "square_parking", - "parking_square_off": "square_parking_off", - "pause_circle": "circle_pause", - "pause_octagon": "octagon_pause", - "percent_circle": "circle_percent", - "percent_diamond": "diamond_percent", - "percent_square": "square_percent", - "pi_square": "square_pi", - "pilcrow_square": "square_pilcrow", - "play_circle": "circle_play", - "play_square": "square_play", - "plus_circle": "circle_plus", - "plus_square": "square_plus", - "power_circle": "circle_power", - "power_square": "square_power", - "school_2": "university", - "scissors_square": "square_scissors", - "scissors_square_dashed_bottom": "square_bottom_dashed_scissors", - "sigma_square": "square_sigma", - "slash_circle": "circle_slash", - "sliders": "sliders_vertical", - "split_square_horizontal": "square_split_horizontal", - "split_square_vertical": "square_split_vertical", - "stop_circle": "circle_stop", - "subtitles": "captions", - "test_tube_2": "test_tube_diagonal", - "unlock": "lock_open", - "unlock_keyhole": "lock_keyhole_open", - "upload_cloud": "cloud_upload", - "wallet_2": "wallet_minimal", - "wand_2": "wand_sparkles", - "x_circle": "circle_x", - "x_octagon": "octagon_x", - "x_square": "square_x", -} LUCIDE_ICON_LIST = [ "a_arrow_down", "a_arrow_up", diff --git a/reflex/components/markdown/markdown.py b/reflex/components/markdown/markdown.py index 272b576a2..1596f5ce2 100644 --- a/reflex/components/markdown/markdown.py +++ b/reflex/components/markdown/markdown.py @@ -17,25 +17,25 @@ from reflex.components.radix.themes.typography.heading import Heading from reflex.components.radix.themes.typography.link import Link from reflex.components.radix.themes.typography.text import Text from reflex.components.tags.tag import Tag -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.utils import types from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var # Special vars used in the component map. -_CHILDREN = ImmutableVar.create_safe("children") -_PROPS = ImmutableVar.create_safe("...props") -_MOCK_ARG = ImmutableVar.create_safe("") +_CHILDREN = Var(_js_expr="children", _var_type=str) +_PROPS = Var(_js_expr="...props") +_PROPS_IN_TAG = Var(_js_expr="{...props}") +_MOCK_ARG = Var(_js_expr="", _var_type=str) # Special remark plugins. -_REMARK_MATH = ImmutableVar.create_safe("remarkMath") -_REMARK_GFM = ImmutableVar.create_safe("remarkGfm") -_REMARK_UNWRAP_IMAGES = ImmutableVar.create_safe("remarkUnwrapImages") +_REMARK_MATH = Var(_js_expr="remarkMath") +_REMARK_GFM = Var(_js_expr="remarkGfm") +_REMARK_UNWRAP_IMAGES = Var(_js_expr="remarkUnwrapImages") _REMARK_PLUGINS = LiteralVar.create([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES]) # Special rehype plugins. -_REHYPE_KATEX = ImmutableVar.create_safe("rehypeKatex") -_REHYPE_RAW = ImmutableVar.create_safe("rehypeRaw") +_REHYPE_KATEX = Var(_js_expr="rehypeKatex") +_REHYPE_RAW = Var(_js_expr="rehypeRaw") _REHYPE_PLUGINS = LiteralVar.create([_REHYPE_KATEX, _REHYPE_RAW]) # These tags do NOT get props passed to them @@ -154,23 +154,23 @@ class Markdown(Component): { "": "katex/dist/katex.min.css", "remark-math@5.1.1": ImportVar( - tag=_REMARK_MATH._var_name, is_default=True + tag=_REMARK_MATH._js_expr, is_default=True ), "remark-gfm@3.0.1": ImportVar( - tag=_REMARK_GFM._var_name, is_default=True + tag=_REMARK_GFM._js_expr, is_default=True ), "remark-unwrap-images@4.0.0": ImportVar( - tag=_REMARK_UNWRAP_IMAGES._var_name, is_default=True + tag=_REMARK_UNWRAP_IMAGES._js_expr, is_default=True ), "rehype-katex@6.0.3": ImportVar( - tag=_REHYPE_KATEX._var_name, is_default=True + tag=_REHYPE_KATEX._js_expr, is_default=True ), "rehype-raw@6.1.1": ImportVar( - tag=_REHYPE_RAW._var_name, is_default=True + tag=_REHYPE_RAW._js_expr, is_default=True ), }, *[ - component(_MOCK_ARG)._get_imports() # type: ignore + component(_MOCK_ARG)._get_all_imports() # type: ignore for component in self.component_map.values() ], CodeBlock.create(theme="light")._get_imports(), # type: ignore, @@ -194,21 +194,17 @@ class Markdown(Component): if tag not in self.component_map: raise ValueError(f"No markdown component found for tag: {tag}.") - special_props = {_PROPS} + special_props = [_PROPS_IN_TAG] children = [_CHILDREN] # For certain tags, the props from the markdown renderer are not actually valid for the component. if tag in NO_PROPS_TAGS: - special_props = set() + special_props = [] # If the children are set as a prop, don't pass them as children. children_prop = props.pop("children", None) if children_prop is not None: - special_props.add( - Var.create_safe( - f"children={{{str(children_prop)}}}", _var_is_string=False - ) - ) + special_props.append(Var(_js_expr=f"children={{{str(children_prop)}}}")) children = [] # Get the component. component = self.component_map[tag](*children, **props).set( @@ -228,21 +224,22 @@ class Markdown(Component): """ return str(self.get_component(tag, **props)).replace("\n", "") - def format_component_map(self) -> dict[str, str]: + def format_component_map(self) -> dict[str, Var]: """Format the component map for rendering. Returns: The formatted component map. """ components = { - tag: f"{{({{node, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => ({self.format_component(tag)})}}" + tag: Var( + _js_expr=f"(({{node, {_CHILDREN._js_expr}, {_PROPS._js_expr}}}) => ({self.format_component(tag)}))" + ) for tag in self.component_map } # Separate out inline code and code blocks. - components[ - "code" - ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{ + components["code"] = Var( + _js_expr=f"""(({{node, inline, className, {_CHILDREN._js_expr}, {_PROPS._js_expr}}}) => {{ const match = (className || '').match(/language-(?.*)/); const language = match ? match[1] : ''; if (language) {{ @@ -258,9 +255,10 @@ class Markdown(Component): return inline ? ( {self.format_component("code")} ) : ( - {self.format_component("codeblock", language=ImmutableVar.create_safe("language"))} + {self.format_component("codeblock", language=Var(_js_expr="language", _var_type=str))} ); - }}}}""".replace("\n", " ") + }})""".replace("\n", " ") + ) return components @@ -285,7 +283,7 @@ class Markdown(Component): function {self._get_component_map_name()} () {{ {formatted_hooks} return ( - {str(ImmutableVar.create_safe(self.format_component_map()))} + {str(LiteralVar.create(self.format_component_map()))} ) }} """ @@ -297,9 +295,7 @@ class Markdown(Component): .add_props( remark_plugins=_REMARK_PLUGINS, rehype_plugins=_REHYPE_PLUGINS, - components=ImmutableVar.create_safe( - f"{self._get_component_map_name()}()" - ), + components=Var(_js_expr=f"{self._get_component_map_name()}()"), ) .remove_props("componentMap", "componentMapHash") ) diff --git a/reflex/components/markdown/markdown.pyi b/reflex/components/markdown/markdown.pyi index 299cb99ff..611770a55 100644 --- a/reflex/components/markdown/markdown.pyi +++ b/reflex/components/markdown/markdown.pyi @@ -8,20 +8,20 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var -_CHILDREN = ImmutableVar.create_safe("children") -_PROPS = ImmutableVar.create_safe("...props") -_MOCK_ARG = ImmutableVar.create_safe("") -_REMARK_MATH = ImmutableVar.create_safe("remarkMath") -_REMARK_GFM = ImmutableVar.create_safe("remarkGfm") -_REMARK_UNWRAP_IMAGES = ImmutableVar.create_safe("remarkUnwrapImages") +_CHILDREN = Var(_js_expr="children", _var_type=str) +_PROPS = Var(_js_expr="...props") +_PROPS_IN_TAG = Var(_js_expr="{...props}") +_MOCK_ARG = Var(_js_expr="", _var_type=str) +_REMARK_MATH = Var(_js_expr="remarkMath") +_REMARK_GFM = Var(_js_expr="remarkGfm") +_REMARK_UNWRAP_IMAGES = Var(_js_expr="remarkUnwrapImages") _REMARK_PLUGINS = LiteralVar.create([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES]) -_REHYPE_KATEX = ImmutableVar.create_safe("rehypeKatex") -_REHYPE_RAW = ImmutableVar.create_safe("rehypeRaw") +_REHYPE_KATEX = Var(_js_expr="rehypeKatex") +_REHYPE_RAW = Var(_js_expr="rehypeRaw") _REHYPE_PLUGINS = LiteralVar.create([_REHYPE_KATEX, _REHYPE_RAW]) NO_PROPS_TAGS = ("ul", "ol", "li") @@ -101,4 +101,4 @@ class Markdown(Component): def add_imports(self) -> ImportDict | list[ImportDict]: ... def get_component(self, tag: str, **props) -> Component: ... def format_component(self, tag: str, **props) -> str: ... - def format_component_map(self) -> dict[str, str]: ... + def format_component_map(self) -> dict[str, Var]: ... diff --git a/reflex/components/moment/moment.py b/reflex/components/moment/moment.py index 958ba6c57..da9949235 100644 --- a/reflex/components/moment/moment.py +++ b/reflex/components/moment/moment.py @@ -1,26 +1,27 @@ """Moment component for humanized date rendering.""" +import dataclasses from typing import List, Optional -from reflex.base import Base from reflex.components.component import Component, NoSSRComponent from reflex.event import EventHandler from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var -class MomentDelta(Base): +@dataclasses.dataclass(frozen=True) +class MomentDelta: """A delta used for add/subtract prop in Moment.""" - years: Optional[int] - quarters: Optional[int] - months: Optional[int] - weeks: Optional[int] - days: Optional[int] - hours: Optional[int] - minutess: Optional[int] - seconds: Optional[int] - milliseconds: Optional[int] + years: Optional[int] = dataclasses.field(default=None) + quarters: Optional[int] = dataclasses.field(default=None) + months: Optional[int] = dataclasses.field(default=None) + weeks: Optional[int] = dataclasses.field(default=None) + days: Optional[int] = dataclasses.field(default=None) + hours: Optional[int] = dataclasses.field(default=None) + minutess: Optional[int] = dataclasses.field(default=None) + seconds: Optional[int] = dataclasses.field(default=None) + milliseconds: Optional[int] = dataclasses.field(default=None) class Moment(NoSSRComponent): diff --git a/reflex/components/moment/moment.pyi b/reflex/components/moment/moment.pyi index 05c7ffc96..f0d747f77 100644 --- a/reflex/components/moment/moment.pyi +++ b/reflex/components/moment/moment.pyi @@ -3,16 +3,17 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +import dataclasses from typing import Any, Callable, Dict, Optional, Union, overload -from reflex.base import Base from reflex.components.component import NoSSRComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var -class MomentDelta(Base): +@dataclasses.dataclass(frozen=True) +class MomentDelta: years: Optional[int] quarters: Optional[int] months: Optional[int] @@ -34,8 +35,8 @@ class Moment(NoSSRComponent): format: Optional[Union[Var[str], str]] = None, trim: Optional[Union[Var[bool], bool]] = None, parse: Optional[Union[Var[str], str]] = None, - add: Optional[Union[Var[MomentDelta], MomentDelta]] = None, - subtract: Optional[Union[Var[MomentDelta], MomentDelta]] = None, + add: Optional[Union[MomentDelta, Var[MomentDelta]]] = None, + subtract: Optional[Union[MomentDelta, Var[MomentDelta]]] = None, from_now: Optional[Union[Var[bool], bool]] = None, from_now_during: Optional[Union[Var[int], int]] = None, to_now: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/next/base.pyi b/reflex/components/next/base.pyi index c8b9934d8..af8064aaf 100644 --- a/reflex/components/next/base.pyi +++ b/reflex/components/next/base.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class NextComponent(Component): ... diff --git a/reflex/components/next/image.py b/reflex/components/next/image.py index 817bf590a..9e2f71821 100644 --- a/reflex/components/next/image.py +++ b/reflex/components/next/image.py @@ -4,7 +4,7 @@ from typing import Any, Literal, Optional, Union from reflex.event import EventHandler from reflex.utils import types -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent diff --git a/reflex/components/next/image.pyi b/reflex/components/next/image.pyi index e6b902cb0..7786c8a4b 100644 --- a/reflex/components/next/image.pyi +++ b/reflex/components/next/image.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent @@ -19,16 +19,16 @@ class Image(NextComponent): *children, width: Optional[Union[int, str]] = None, height: Optional[Union[int, str]] = None, - src: Optional[Union[Var[Any], Any]] = None, + src: Optional[Union[Any, Var[Any]]] = None, alt: Optional[Union[Var[str], str]] = None, - loader: Optional[Union[Var[Any], Any]] = None, + loader: Optional[Union[Any, Var[Any]]] = None, fill: Optional[Union[Var[bool], bool]] = None, sizes: Optional[Union[Var[str], str]] = None, quality: Optional[Union[Var[int], int]] = None, priority: Optional[Union[Var[bool], bool]] = None, placeholder: Optional[Union[Var[str], str]] = None, loading: Optional[ - Union[Var[Literal["lazy", "eager"]], Literal["lazy", "eager"]] + Union[Literal["eager", "lazy"], Var[Literal["eager", "lazy"]]] ] = None, blurDataURL: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, diff --git a/reflex/components/next/link.py b/reflex/components/next/link.py index be32cd8e5..0f7c81296 100644 --- a/reflex/components/next/link.py +++ b/reflex/components/next/link.py @@ -1,7 +1,7 @@ """A link component.""" from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var class NextLink(Component): diff --git a/reflex/components/next/link.pyi b/reflex/components/next/link.pyi index c25ca8258..2a3207956 100644 --- a/reflex/components/next/link.pyi +++ b/reflex/components/next/link.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class NextLink(Component): @overload diff --git a/reflex/components/next/video.py b/reflex/components/next/video.py index ae6007671..435f4401f 100644 --- a/reflex/components/next/video.py +++ b/reflex/components/next/video.py @@ -3,7 +3,7 @@ from typing import Optional from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent diff --git a/reflex/components/next/video.pyi b/reflex/components/next/video.pyi index 13b39a4f8..842e27d22 100644 --- a/reflex/components/next/video.pyi +++ b/reflex/components/next/video.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent diff --git a/reflex/components/plotly/plotly.py b/reflex/components/plotly/plotly.py index a2393fdca..eb12bbc1c 100644 --- a/reflex/components/plotly/plotly.py +++ b/reflex/components/plotly/plotly.py @@ -9,7 +9,7 @@ from reflex.components.component import Component, NoSSRComponent from reflex.components.core.cond import color_mode_cond from reflex.event import EventHandler from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var try: from plotly.graph_objects import Figure, layout @@ -30,7 +30,7 @@ def _event_data_signature(e0: Var) -> List[Any]: Returns: The event key extracted from the event data (if defined). """ - return [Var.create_safe(f"{e0}?.event", _var_is_string=False)] + return [Var(_js_expr=f"{e0}?.event")] def _event_points_data_signature(e0: Var) -> List[Any]: @@ -43,11 +43,8 @@ def _event_points_data_signature(e0: Var) -> List[Any]: The event data and the extracted points. """ return [ - Var.create_safe(f"{e0}?.event", _var_is_string=False), - Var.create_safe( - f"extractPoints({e0}?.points)", - _var_is_string=False, - ), + Var(_js_expr=f"{e0}?.event"), + Var(_js_expr=f"extractPoints({e0}?.points)"), ] @@ -104,19 +101,19 @@ class Plotly(NoSSRComponent): is_default = True # The figure to display. This can be a plotly figure or a plotly data json. - data: Var[Figure] + data: Var[Figure] # type: ignore # The layout of the graph. layout: Var[Dict] # The template for visual appearance of the graph. - template: Var[Template] + template: Var[Template] # type: ignore # The config of the graph. config: Var[Dict] # If true, the graph will resize when the window is resized. - use_resize_handler: Var[bool] = Var.create_safe(True) + use_resize_handler: Var[bool] = LiteralVar.create(True) # Fired after the plot is redrawn. on_after_plot: EventHandler[_passthrough_signature] @@ -242,8 +239,8 @@ const extractPoints = (points) => { from plotly.io import templates responsive_template = color_mode_cond( - light=Var.create_safe(templates["plotly"]).to(dict), - dark=Var.create_safe(templates["plotly_dark"]).to(dict), + light=LiteralVar.create(templates["plotly"]), + dark=LiteralVar.create(templates["plotly_dark"]), ) if isinstance(responsive_template, Var): # Mark the conditional Var as a Template to avoid type mismatch @@ -263,30 +260,20 @@ const extractPoints = (points) => { # Why is this not a literal dict? Great question... it didn't work # reliably because of how _var_name_unwrapped strips the outer curly # brackets if any of the contained Vars depend on state. - layout_dict = Var.create_safe( - f"{{'layout': {self.layout.to(dict)._var_name_unwrapped}}}" - ).to(dict) + layout_dict = LiteralVar.create({"layout": self.layout}) merge_dicts.append(layout_dict) if self.template is not None: - template_dict = Var.create_safe( - {"layout": {"template": self.template.to(dict)}} - ) - template_dict._var_data = None # To avoid stripping outer curly brackets - merge_dicts.append(template_dict) + template_dict = LiteralVar.create({"layout": {"template": self.template}}) + merge_dicts.append(template_dict.without_data()) if merge_dicts: - tag.special_props.add( + tag.special_props.append( # Merge all dictionaries and spread the result over props. - Var.create_safe( - f"{{...mergician({figure._var_name_unwrapped}," - f"{','.join(md._var_name_unwrapped for md in merge_dicts)})}}", - _var_is_string=False, + Var( + _js_expr=f"{{...mergician({str(figure)}," + f"{','.join(str(md) for md in merge_dicts)})}}", ), ) else: # Spread the figure dict over props, nothing to merge. - tag.special_props.add( - Var.create_safe( - f"{{...{figure._var_name_unwrapped}}}", _var_is_string=False - ) - ) + tag.special_props.append(Var(_js_expr=f"{{...{str(figure)}}}")) return tag diff --git a/reflex/components/plotly/plotly.pyi b/reflex/components/plotly/plotly.pyi index c308e160f..c8be366c8 100644 --- a/reflex/components/plotly/plotly.pyi +++ b/reflex/components/plotly/plotly.pyi @@ -10,7 +10,7 @@ from reflex.components.component import NoSSRComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import Var try: from plotly.graph_objects import Figure, layout @@ -34,10 +34,10 @@ class Plotly(NoSSRComponent): def create( # type: ignore cls, *children, - data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore - layout: Optional[Union[Var[Dict], Dict]] = None, - template: Optional[Union[Var[Template], Template]] = None, # type: ignore - config: Optional[Union[Var[Dict], Dict]] = None, + data: Optional[Union[Figure, Var[Figure]]] = None, # type: ignore + layout: Optional[Union[Dict, Var[Dict]]] = None, + template: Optional[Union[Template, Var[Template]]] = None, # type: ignore + config: Optional[Union[Dict, Var[Dict]]] = None, use_resize_handler: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/props.py b/reflex/components/props.py index a66ba7f2f..92dbe8144 100644 --- a/reflex/components/props.py +++ b/reflex/components/props.py @@ -4,7 +4,7 @@ from __future__ import annotations from reflex.base import Base from reflex.utils import format -from reflex.utils.serializers import serialize +from reflex.vars.object import LiteralObjectVar class PropsBase(Base): @@ -20,12 +20,23 @@ class PropsBase(Base): Returns: The object as a Javascript Object literal. """ - return format.unwrap_vars( - self.__config__.json_dumps( - { - format.to_camel_case(key): value - for key, value in self.dict().items() - }, - default=serialize, - ) - ) + return LiteralObjectVar.create( + {format.to_camel_case(key): value for key, value in self.dict().items()} + ).json() + + def dict(self, *args, **kwargs): + """Convert the object to a dictionary. + + Keys will be converted to camelCase. + + Args: + *args: Arguments to pass to the parent class. + **kwargs: Keyword arguments to pass to the parent class. + + Returns: + The object as a dictionary. + """ + return { + format.to_camel_case(key): value + for key, value in super().dict(*args, **kwargs).items() + } diff --git a/reflex/components/radix/__init__.pyi b/reflex/components/radix/__init__.pyi index b61659320..f4e81666a 100644 --- a/reflex/components/radix/__init__.pyi +++ b/reflex/components/radix/__init__.pyi @@ -8,7 +8,6 @@ from . import themes as themes from .primitives.accordion import accordion as accordion from .primitives.drawer import drawer as drawer from .primitives.form import form as form -from .primitives.progress import progress as progress from .themes.base import theme as theme from .themes.base import theme_panel as theme_panel from .themes.color_mode import color_mode as color_mode @@ -31,6 +30,7 @@ from .themes.components.hover_card import hover_card as hover_card from .themes.components.icon_button import icon_button as icon_button from .themes.components.inset import inset as inset from .themes.components.popover import popover as popover +from .themes.components.progress import progress as progress from .themes.components.radio_cards import radio_cards as radio_cards from .themes.components.radio_group import radio as radio from .themes.components.radio_group import radio_group as radio_group @@ -55,6 +55,7 @@ from .themes.layout.container import container as container from .themes.layout.flex import flex as flex from .themes.layout.grid import grid as grid from .themes.layout.list import list_item as list_item +from .themes.layout.list import list_ns as list # noqa from .themes.layout.list import ordered_list as ordered_list from .themes.layout.list import unordered_list as unordered_list from .themes.layout.section import section as section diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index da32d747b..40cbfa2a7 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -11,9 +11,9 @@ from reflex.components.lucide.icon import Icon from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar from reflex.style import Style -from reflex.vars import Var, get_uuid_string_var +from reflex.vars import get_uuid_string_var +from reflex.vars.base import LiteralVar, Var LiteralAccordionType = Literal["single", "multiple"] LiteralAccordionDir = Literal["ltr", "rtl"] diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi index edf011183..5d86636ad 100644 --- a/reflex/components/radix/primitives/accordion.pyi +++ b/reflex/components/radix/primitives/accordion.pyi @@ -10,7 +10,7 @@ from reflex.components.lucide.icon import Icon from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralAccordionType = Literal["single", "multiple"] LiteralAccordionDir = Literal["ltr", "rtl"] @@ -28,70 +28,70 @@ class AccordionComponent(RadixPrimitiveComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -166,25 +166,25 @@ class AccordionRoot(AccordionComponent): cls, *children, type: Optional[ - Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]] + Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, - value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None, + value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, default_value: Optional[ - Union[Var[Union[List[str], str]], str, List[str]] + Union[List[str], Var[Union[List[str], str]], str] ] = None, collapsible: Optional[Union[Var[bool], bool]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, orientation: Optional[ Union[ - Var[Literal["vertical", "horizontal"]], - Literal["vertical", "horizontal"], + Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, duration: Optional[Union[Var[int], int]] = None, @@ -192,70 +192,70 @@ class AccordionRoot(AccordionComponent): show_dividers: Optional[Union[Var[bool], bool]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -348,70 +348,70 @@ class AccordionItem(AccordionComponent): disabled: Optional[Union[Var[bool], bool]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -492,70 +492,70 @@ class AccordionHeader(AccordionComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -632,70 +632,70 @@ class AccordionTrigger(AccordionComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -841,70 +841,70 @@ class AccordionContent(AccordionComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/primitives/base.py b/reflex/components/radix/primitives/base.py index 857e80b5a..479cd2912 100644 --- a/reflex/components/radix/primitives/base.py +++ b/reflex/components/radix/primitives/base.py @@ -5,7 +5,7 @@ from typing import List from reflex.components.component import Component from reflex.components.tags.tag import Tag from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var class RadixPrimitiveComponent(Component): diff --git a/reflex/components/radix/primitives/base.pyi b/reflex/components/radix/primitives/base.pyi index a94b2263c..3f1194424 100644 --- a/reflex/components/radix/primitives/base.pyi +++ b/reflex/components/radix/primitives/base.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class RadixPrimitiveComponent(Component): @overload diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py index 1c8a91837..b814e878f 100644 --- a/reflex/components/radix/primitives/drawer.py +++ b/reflex/components/radix/primitives/drawer.py @@ -11,7 +11,7 @@ from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import Theme from reflex.components.radix.themes.layout.flex import Flex from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): diff --git a/reflex/components/radix/primitives/drawer.pyi b/reflex/components/radix/primitives/drawer.pyi index c40bdf53d..269d86d47 100644 --- a/reflex/components/radix/primitives/drawer.pyi +++ b/reflex/components/radix/primitives/drawer.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): @overload @@ -96,8 +96,8 @@ class DrawerRoot(DrawerComponent): modal: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, @@ -678,8 +678,8 @@ class Drawer(ComponentNamespace): modal: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/primitives/form.py b/reflex/components/radix/primitives/form.py index 3b871d0af..63a4056e0 100644 --- a/reflex/components/radix/primitives/form.py +++ b/reflex/components/radix/primitives/form.py @@ -9,7 +9,7 @@ from reflex.components.core.debounce import DebounceInput from reflex.components.el.elements.forms import Form as HTMLForm from reflex.components.radix.themes.components.text_field import TextFieldRoot from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from .base import RadixPrimitiveComponentWithClassName diff --git a/reflex/components/radix/primitives/form.pyi b/reflex/components/radix/primitives/form.pyi index 758630c4a..75efc1a3f 100644 --- a/reflex/components/radix/primitives/form.pyi +++ b/reflex/components/radix/primitives/form.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.el.elements.forms import Form as HTMLForm from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .base import RadixPrimitiveComponentWithClassName @@ -89,45 +89,45 @@ class FormRoot(FormComponent, HTMLForm): cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -457,6 +457,18 @@ class FormMessage(FormComponent): name: Optional[Union[Var[str], str]] = None, match: Optional[ Union[ + Literal[ + "badInput", + "patternMismatch", + "rangeOverflow", + "rangeUnderflow", + "stepMismatch", + "tooLong", + "tooShort", + "typeMismatch", + "valid", + "valueMissing", + ], Var[ Literal[ "badInput", @@ -471,18 +483,6 @@ class FormMessage(FormComponent): "valueMissing", ] ], - Literal[ - "badInput", - "patternMismatch", - "rangeOverflow", - "rangeUnderflow", - "stepMismatch", - "tooLong", - "tooShort", - "typeMismatch", - "valid", - "valueMissing", - ], ] ] = None, force_match: Optional[Union[Var[bool], bool]] = None, @@ -696,45 +696,45 @@ class Form(FormRoot): cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -840,45 +840,45 @@ class FormNamespace(ComponentNamespace): def __call__( *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/primitives/progress.py b/reflex/components/radix/primitives/progress.py index 976daf505..72aee1038 100644 --- a/reflex/components/radix/primitives/progress.py +++ b/reflex/components/radix/primitives/progress.py @@ -9,7 +9,7 @@ from reflex.components.core.colors import color from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius -from reflex.vars import Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): diff --git a/reflex/components/radix/primitives/progress.pyi b/reflex/components/radix/primitives/progress.pyi index f1c817587..4e185a903 100644 --- a/reflex/components/radix/primitives/progress.pyi +++ b/reflex/components/radix/primitives/progress.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): @overload @@ -88,8 +88,8 @@ class ProgressRoot(ProgressComponent): *children, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -166,63 +166,63 @@ class ProgressIndicator(ProgressComponent): max: Optional[Union[Var[Optional[int]], int]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -299,63 +299,63 @@ class Progress(ProgressRoot): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -363,8 +363,8 @@ class Progress(ProgressRoot): max: Optional[Union[Var[Optional[int]], int]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -441,63 +441,63 @@ class ProgressNamespace(ComponentNamespace): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -505,8 +505,8 @@ class ProgressNamespace(ComponentNamespace): max: Optional[Union[Var[Optional[int]], int]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/primitives/slider.py b/reflex/components/radix/primitives/slider.py index b8abd23b5..dd3108f0e 100644 --- a/reflex/components/radix/primitives/slider.py +++ b/reflex/components/radix/primitives/slider.py @@ -7,7 +7,7 @@ from typing import Any, List, Literal from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] diff --git a/reflex/components/radix/primitives/slider.pyi b/reflex/components/radix/primitives/slider.pyi index 9ce737df4..782a83776 100644 --- a/reflex/components/radix/primitives/slider.pyi +++ b/reflex/components/radix/primitives/slider.pyi @@ -9,7 +9,7 @@ from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] @@ -89,17 +89,17 @@ class SliderRoot(SliderComponent): def create( # type: ignore cls, *children, - default_value: Optional[Union[Var[List[int]], List[int]]] = None, - value: Optional[Union[Var[List[int]], List[int]]] = None, + default_value: Optional[Union[List[int], Var[List[int]]]] = None, + value: Optional[Union[List[int], Var[List[int]]]] = None, name: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, inverted: Optional[Union[Var[bool], bool]] = None, min: Optional[Union[Var[int], int]] = None, max: Optional[Union[Var[int], int]] = None, diff --git a/reflex/components/radix/themes/base.py b/reflex/components/radix/themes/base.py index 5a7fb2d99..e41c5e7b0 100644 --- a/reflex/components/radix/themes/base.py +++ b/reflex/components/radix/themes/base.py @@ -7,9 +7,8 @@ from typing import Any, Dict, Literal from reflex.components import Component from reflex.components.tags import Tag from reflex.config import get_config -from reflex.ivars.base import ImmutableVar from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -236,8 +235,8 @@ class Theme(RadixThemesComponent): def _render(self, props: dict[str, Any] | None = None) -> Tag: tag = super()._render(props) tag.add_props( - css=ImmutableVar.create( - f"{{...theme.styles.global[':root'], ...theme.styles.global.body}}" + css=Var( + _js_expr=f"{{...theme.styles.global[':root'], ...theme.styles.global.body}}" ), ) return tag @@ -262,26 +261,6 @@ class ThemePanel(RadixThemesComponent): """ return {"react": "useEffect"} - def add_hooks(self) -> list[str]: - """Add a hook on the ThemePanel to clear chakra-ui-color-mode. - - Returns: - The hooks to render. - """ - # The panel freezes the tab if the user color preference differs from the - # theme "appearance", so clear it out when theme panel is used. - return [ - """ - useEffect(() => { - if (typeof window !== 'undefined') { - window.onbeforeunload = () => { - localStorage.removeItem('chakra-ui-color-mode'); - } - window.onbeforeunload(); - } - }, [])""" - ] - class RadixThemesColorModeProvider(Component): """Next-themes integration for radix themes components.""" diff --git a/reflex/components/radix/themes/base.pyi b/reflex/components/radix/themes/base.pyi index 5aea55d90..da3c922e9 100644 --- a/reflex/components/radix/themes/base.pyi +++ b/reflex/components/radix/themes/base.pyi @@ -9,7 +9,7 @@ from reflex.components import Component from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -57,44 +57,44 @@ class CommonMarginProps(Component): *children, m: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mx: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, my: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mt: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mr: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mb: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, ml: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, style: Optional[Style] = None, @@ -367,96 +367,96 @@ class Theme(RadixThemesComponent): def create( # type: ignore cls, *children, - color_mode: Optional[Literal["inherit", "light", "dark"]] = None, + color_mode: Optional[Literal["dark", "inherit", "light"]] = None, theme_panel: Optional[bool] = False, has_background: Optional[Union[Var[bool], bool]] = None, appearance: Optional[ Union[ - Var[Literal["inherit", "light", "dark"]], - Literal["inherit", "light", "dark"], + Literal["dark", "inherit", "light"], + Var[Literal["dark", "inherit", "light"]], ] ] = None, accent_color: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, gray_color: Optional[ Union[ - Var[Literal["gray", "mauve", "slate", "sage", "olive", "sand", "auto"]], - Literal["gray", "mauve", "slate", "sage", "olive", "sand", "auto"], + Literal["auto", "gray", "mauve", "olive", "sage", "sand", "slate"], + Var[Literal["auto", "gray", "mauve", "olive", "sage", "sand", "slate"]], ] ] = None, panel_background: Optional[ - Union[Var[Literal["solid", "translucent"]], Literal["solid", "translucent"]] + Union[Literal["solid", "translucent"], Var[Literal["solid", "translucent"]]] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, scaling: Optional[ Union[ - Var[Literal["90%", "95%", "100%", "105%", "110%"]], - Literal["90%", "95%", "100%", "105%", "110%"], + Literal["100%", "105%", "110%", "90%", "95%"], + Var[Literal["100%", "105%", "110%", "90%", "95%"]], ] ] = None, style: Optional[Style] = None, @@ -532,7 +532,6 @@ class Theme(RadixThemesComponent): class ThemePanel(RadixThemesComponent): def add_imports(self) -> dict[str, str]: ... - def add_hooks(self) -> list[str]: ... @overload @classmethod def create( # type: ignore diff --git a/reflex/components/radix/themes/color_mode.py b/reflex/components/radix/themes/color_mode.py index 511a2ea31..b1083ba94 100644 --- a/reflex/components/radix/themes/color_mode.py +++ b/reflex/components/radix/themes/color_mode.py @@ -17,14 +17,13 @@ rx.text( from __future__ import annotations -from typing import Literal, get_args +from typing import Dict, List, Literal, get_args from reflex.components.component import BaseComponent from reflex.components.core.cond import Cond, color_mode_cond, cond from reflex.components.lucide.icon import Icon from reflex.components.radix.themes.components.dropdown_menu import dropdown_menu from reflex.components.radix.themes.components.switch import Switch -from reflex.ivars.base import ImmutableVar from reflex.style import ( LIGHT_COLOR_MODE, color_mode, @@ -32,8 +31,8 @@ from reflex.style import ( set_color_mode, toggle_color_mode, ) -from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import Var +from reflex.vars.sequence import LiteralArrayVar from .components.icon_button import IconButton @@ -67,9 +66,9 @@ class ColorModeIcon(Cond): LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"] -position_values = get_args(LiteralPosition) +position_values: List[str] = list(get_args(LiteralPosition)) -position_map = { +position_map: Dict[str, List[str]] = { "position": position_values, "left": ["top-left", "bottom-left"], "right": ["top-right", "bottom-right"], @@ -79,8 +78,8 @@ position_map = { # needed to inverse contains for find -def _find(const, var): - return Var.create_safe(const, _var_is_string=False).contains(var) +def _find(const: List[str], var): + return LiteralArrayVar.create(const).contains(var) def _set_var_default(props, position, prop, default1, default2=""): @@ -100,7 +99,6 @@ class ColorModeIconButton(IconButton): @classmethod def create( cls, - *children, position: LiteralPosition | None = None, allow_system: bool = False, **props, @@ -108,7 +106,6 @@ class ColorModeIconButton(IconButton): """Create a icon button component that calls toggle_color_mode on click. Args: - *children: The children of the component. position: The position of the icon button. Follow document flow if None. allow_system: Allow picking the "system" value for the color mode. **props: The props to pass to the component. @@ -116,14 +113,6 @@ class ColorModeIconButton(IconButton): Returns: The button component. """ - if children: - console.deprecate( - feature_name="passing children to color_mode.button", - reason=", use color_mode_cond and toggle_color_mode instead to build a custom color_mode component", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - # position is used to set nice defaults for positioning the icon button if isinstance(position, Var): _set_var_default(props, position, "position", "fixed", position) @@ -195,7 +184,7 @@ class ColorModeSwitch(Switch): ) -class ColorModeNamespace(ImmutableVar): +class ColorModeNamespace(Var): """Namespace for color mode components.""" icon = staticmethod(ColorModeIcon.create) @@ -204,7 +193,7 @@ class ColorModeNamespace(ImmutableVar): color_mode = color_mode_var_and_namespace = ColorModeNamespace( - _var_name=color_mode._var_name, + _js_expr=color_mode._js_expr, _var_type=color_mode._var_type, _var_data=color_mode.get_default_value(), ) diff --git a/reflex/components/radix/themes/color_mode.pyi b/reflex/components/radix/themes/color_mode.pyi index 3ad5e46d3..d41019747 100644 --- a/reflex/components/radix/themes/color_mode.pyi +++ b/reflex/components/radix/themes/color_mode.pyi @@ -3,7 +3,16 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, get_args, overload +from typing import ( + Any, + Callable, + Dict, + List, + Literal, + Optional, + Union, + overload, +) from reflex.components.component import BaseComponent from reflex.components.core.breakpoints import Breakpoints @@ -11,12 +20,11 @@ from reflex.components.core.cond import Cond from reflex.components.lucide.icon import Icon from reflex.components.radix.themes.components.switch import Switch from reflex.event import EventHandler, EventSpec -from reflex.ivars.base import ImmutableVar from reflex.style import ( Style, color_mode, ) -from reflex.vars import Var +from reflex.vars.base import Var from .components.icon_button import IconButton @@ -29,7 +37,7 @@ class ColorModeIcon(Cond): def create( # type: ignore cls, *children, - cond: Optional[Union[Var[Any], Any]] = None, + cond: Optional[Union[Any, Var[Any]]] = None, comp1: Optional[BaseComponent] = None, comp2: Optional[BaseComponent] = None, style: Optional[Style] = None, @@ -87,14 +95,8 @@ class ColorModeIcon(Cond): ... LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"] -position_values = get_args(LiteralPosition) -position_map = { - "position": position_values, - "left": ["top-left", "bottom-left"], - "right": ["top-right", "bottom-right"], - "top": ["top-left", "top-right"], - "bottom": ["bottom-left", "bottom-right"], -} +position_values: List[str] +position_map: Dict[str, List[str]] class ColorModeIconButton(IconButton): @overload @@ -102,137 +104,133 @@ class ColorModeIconButton(IconButton): def create( # type: ignore cls, *children, - position: Optional[ - Literal["top-left", "top-right", "bottom-left", "bottom-right"] - ] = None, - allow_system: Optional[bool] = False, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -280,7 +278,6 @@ class ColorModeIconButton(IconButton): """Create a icon button component that calls toggle_color_mode on click. Args: - *children: The children of the component. position: The position of the icon button. Follow document flow if None. allow_system: Allow picking the "system" value for the color mode. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. @@ -345,87 +342,87 @@ class ColorModeSwitch(Switch): value: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, style: Optional[Style] = None, @@ -501,13 +498,13 @@ class ColorModeSwitch(Switch): """ ... -class ColorModeNamespace(ImmutableVar): +class ColorModeNamespace(Var): icon = staticmethod(ColorModeIcon.create) button = staticmethod(ColorModeIconButton.create) switch = staticmethod(ColorModeSwitch.create) color_mode = color_mode_var_and_namespace = ColorModeNamespace( - _var_name=color_mode._var_name, + _js_expr=color_mode._js_expr, _var_type=color_mode._var_type, _var_data=color_mode.get_default_value(), ) diff --git a/reflex/components/radix/themes/components/__init__.pyi b/reflex/components/radix/themes/components/__init__.pyi index 6f6df88fa..29f15e311 100644 --- a/reflex/components/radix/themes/components/__init__.pyi +++ b/reflex/components/radix/themes/components/__init__.pyi @@ -22,6 +22,7 @@ from .hover_card import hover_card as hover_card from .icon_button import icon_button as icon_button from .inset import inset as inset from .popover import popover as popover +from .progress import progress as progress from .radio_cards import radio_cards as radio_cards from .radio_group import radio as radio from .radio_group import radio_group as radio_group diff --git a/reflex/components/radix/themes/components/alert_dialog.py b/reflex/components/radix/themes/components/alert_dialog.py index e8dfb57b2..ca876b4c3 100644 --- a/reflex/components/radix/themes/components/alert_dialog.py +++ b/reflex/components/radix/themes/components/alert_dialog.py @@ -6,7 +6,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent diff --git a/reflex/components/radix/themes/components/alert_dialog.pyi b/reflex/components/radix/themes/components/alert_dialog.pyi index 4cb9e966c..019b3f89b 100644 --- a/reflex/components/radix/themes/components/alert_dialog.pyi +++ b/reflex/components/radix/themes/components/alert_dialog.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -158,41 +158,41 @@ class AlertDialogContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, force_mount: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/aspect_ratio.py b/reflex/components/radix/themes/components/aspect_ratio.py index b06b2d564..fc8052c85 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.py +++ b/reflex/components/radix/themes/components/aspect_ratio.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent diff --git a/reflex/components/radix/themes/components/aspect_ratio.pyi b/reflex/components/radix/themes/components/aspect_ratio.pyi index 612c67a29..024261d91 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.pyi +++ b/reflex/components/radix/themes/components/aspect_ratio.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent diff --git a/reflex/components/radix/themes/components/avatar.py b/reflex/components/radix/themes/components/avatar.py index 22482f0c9..4f3956e76 100644 --- a/reflex/components/radix/themes/components/avatar.py +++ b/reflex/components/radix/themes/components/avatar.py @@ -3,7 +3,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/avatar.pyi b/reflex/components/radix/themes/components/avatar.pyi index c0476d543..ee6ef6e31 100644 --- a/reflex/components/radix/themes/components/avatar.pyi +++ b/reflex/components/radix/themes/components/avatar.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,10 +21,12 @@ class Avatar(RadixThemesComponent): cls, *children, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -33,77 +35,75 @@ class Avatar(RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, src: Optional[Union[Var[str], str]] = None, diff --git a/reflex/components/radix/themes/components/badge.py b/reflex/components/radix/themes/components/badge.py index fd26b17ab..9391e53c3 100644 --- a/reflex/components/radix/themes/components/badge.py +++ b/reflex/components/radix/themes/components/badge.py @@ -4,7 +4,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/badge.pyi b/reflex/components/radix/themes/components/badge.pyi index 327fe2b90..d5c2f2697 100644 --- a/reflex/components/radix/themes/components/badge.pyi +++ b/reflex/components/radix/themes/components/badge.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,114 +21,114 @@ class Badge(elements.Span, RadixThemesComponent): *children, variant: Optional[ Union[ - Var[Literal["solid", "soft", "surface", "outline"]], - Literal["solid", "soft", "surface", "outline"], + Literal["outline", "soft", "solid", "surface"], + Var[Literal["outline", "soft", "solid", "surface"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/button.py b/reflex/components/radix/themes/components/button.py index 0c52e6ec6..cb44ee684 100644 --- a/reflex/components/radix/themes/components/button.py +++ b/reflex/components/radix/themes/components/button.py @@ -4,7 +4,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/button.pyi b/reflex/components/radix/themes/components/button.pyi index 95a80c84e..de9651dd9 100644 --- a/reflex/components/radix/themes/components/button.pyi +++ b/reflex/components/radix/themes/components/button.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixLoadingProp, @@ -27,130 +27,130 @@ class Button(elements.Button, RadixLoadingProp, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/callout.py b/reflex/components/radix/themes/components/callout.py index ea8be4623..926e0ad54 100644 --- a/reflex/components/radix/themes/components/callout.py +++ b/reflex/components/radix/themes/components/callout.py @@ -7,7 +7,7 @@ from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements from reflex.components.lucide.icon import Icon -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/callout.pyi b/reflex/components/radix/themes/components/callout.pyi index 04e1d1317..5caa825d6 100644 --- a/reflex/components/radix/themes/components/callout.pyi +++ b/reflex/components/radix/themes/components/callout.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,108 +25,108 @@ class CalloutRoot(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -217,30 +217,30 @@ class CalloutIcon(elements.Div, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -326,30 +326,30 @@ class CalloutText(elements.P, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -440,108 +440,108 @@ class Callout(CalloutRoot): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -638,108 +638,108 @@ class CalloutNamespace(ComponentNamespace): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/card.py b/reflex/components/radix/themes/components/card.py index 574336b1b..4983cdd41 100644 --- a/reflex/components/radix/themes/components/card.py +++ b/reflex/components/radix/themes/components/card.py @@ -4,7 +4,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/card.pyi b/reflex/components/radix/themes/components/card.pyi index 142cc7448..d2bc6f68c 100644 --- a/reflex/components/radix/themes/components/card.pyi +++ b/reflex/components/radix/themes/components/card.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,46 +22,46 @@ class Card(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5"]], + Literal["1", "2", "3", "4", "5"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4", "5"]], Literal["1", "2", "3", "4", "5"], ] ], - Literal["1", "2", "3", "4", "5"], - Breakpoints[str, Literal["1", "2", "3", "4", "5"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["surface", "classic", "ghost"]], - Literal["surface", "classic", "ghost"], + Literal["classic", "ghost", "surface"], + Var[Literal["classic", "ghost", "surface"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/checkbox.py b/reflex/components/radix/themes/components/checkbox.py index f191ce613..6ba1b04da 100644 --- a/reflex/components/radix/themes/components/checkbox.py +++ b/reflex/components/radix/themes/components/checkbox.py @@ -7,8 +7,7 @@ from reflex.components.core.breakpoints import Responsive from reflex.components.radix.themes.layout.flex import Flex from reflex.components.radix.themes.typography.text import Text from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/checkbox.pyi b/reflex/components/radix/themes/components/checkbox.pyi index 52441eef4..978c3e8c2 100644 --- a/reflex/components/radix/themes/components/checkbox.pyi +++ b/reflex/components/radix/themes/components/checkbox.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,80 +25,80 @@ class Checkbox(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -193,79 +193,79 @@ class HighLevelCheckbox(RadixThemesComponent): text: Optional[Union[Var[str], str]] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -357,79 +357,79 @@ class CheckboxNamespace(ComponentNamespace): text: Optional[Union[Var[str], str]] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, diff --git a/reflex/components/radix/themes/components/checkbox_cards.py b/reflex/components/radix/themes/components/checkbox_cards.py index d5042c355..5f5fc3ae3 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.py +++ b/reflex/components/radix/themes/components/checkbox_cards.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import Literal, Union from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/checkbox_cards.pyi b/reflex/components/radix/themes/components/checkbox_cards.pyi index d7be8a056..086630a3b 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.pyi +++ b/reflex/components/radix/themes/components/checkbox_cards.pyi @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,83 +21,88 @@ class CheckboxCardsRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, columns: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -112,15 +117,15 @@ class CheckboxCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, gap: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -135,11 +140,6 @@ class CheckboxCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/components/checkbox_group.py b/reflex/components/radix/themes/components/checkbox_group.py index 754f354b5..f6379e588 100644 --- a/reflex/components/radix/themes/components/checkbox_group.py +++ b/reflex/components/radix/themes/components/checkbox_group.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import List, Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/checkbox_group.pyi b/reflex/components/radix/themes/components/checkbox_group.pyi index 8a730b870..21f0ad23a 100644 --- a/reflex/components/radix/themes/components/checkbox_group.pyi +++ b/reflex/components/radix/themes/components/checkbox_group.pyi @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,85 +21,85 @@ class CheckboxGroupRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - default_value: Optional[Union[Var[List[str]], List[str]]] = None, + default_value: Optional[Union[List[str], Var[List[str]]]] = None, name: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/context_menu.py b/reflex/components/radix/themes/components/context_menu.py index 95a0f2e74..c82f8e714 100644 --- a/reflex/components/radix/themes/components/context_menu.py +++ b/reflex/components/radix/themes/components/context_menu.py @@ -5,7 +5,7 @@ from typing import List, Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/context_menu.pyi b/reflex/components/radix/themes/components/context_menu.pyi index e2f9d01e2..6295ccb49 100644 --- a/reflex/components/radix/themes/components/context_menu.pyi +++ b/reflex/components/radix/themes/components/context_menu.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -166,73 +166,73 @@ class ContextMenuContent(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -554,63 +554,63 @@ class ContextMenuItem(RadixThemesComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, diff --git a/reflex/components/radix/themes/components/data_list.py b/reflex/components/radix/themes/components/data_list.py index 8b95d24c6..05d4af074 100644 --- a/reflex/components/radix/themes/components/data_list.py +++ b/reflex/components/radix/themes/components/data_list.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/data_list.pyi b/reflex/components/radix/themes/components/data_list.pyi index 93d00c86b..dafc0fa0b 100644 --- a/reflex/components/radix/themes/components/data_list.pyi +++ b/reflex/components/radix/themes/components/data_list.pyi @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,37 +21,37 @@ class DataListRoot(RadixThemesComponent): *children, orientation: Optional[ Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], Var[ Union[ Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], ] ], - Literal["horizontal", "vertical"], - Breakpoints[str, Literal["horizontal", "vertical"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, style: Optional[Style] = None, @@ -128,19 +128,19 @@ class DataListItem(RadixThemesComponent): *children, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, style: Optional[Style] = None, @@ -214,73 +214,73 @@ class DataListLabel(RadixThemesComponent): cls, *children, width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, diff --git a/reflex/components/radix/themes/components/dialog.py b/reflex/components/radix/themes/components/dialog.py index e0d7fae12..951e8506d 100644 --- a/reflex/components/radix/themes/components/dialog.py +++ b/reflex/components/radix/themes/components/dialog.py @@ -6,7 +6,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/dialog.pyi b/reflex/components/radix/themes/components/dialog.pyi index 02b1a6c9f..827e50ea7 100644 --- a/reflex/components/radix/themes/components/dialog.pyi +++ b/reflex/components/radix/themes/components/dialog.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -225,40 +225,40 @@ class DialogContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/dropdown_menu.py b/reflex/components/radix/themes/components/dropdown_menu.py index b425ef609..5ed1f9f64 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.py +++ b/reflex/components/radix/themes/components/dropdown_menu.py @@ -5,7 +5,7 @@ from typing import Dict, List, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/dropdown_menu.pyi b/reflex/components/radix/themes/components/dropdown_menu.pyi index df7b23589..0995ef2e4 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.pyi +++ b/reflex/components/radix/themes/components/dropdown_menu.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -29,7 +29,7 @@ class DropdownMenuRoot(RadixThemesComponent): default_open: Optional[Union[Var[bool], bool]] = None, open: Optional[Union[Var[bool], bool]] = None, modal: Optional[Union[Var[bool], bool]] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -169,73 +169,73 @@ class DropdownMenuContent(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -245,30 +245,30 @@ class DropdownMenuContent(RadixThemesComponent): force_mount: Optional[Union[Var[bool], bool]] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -518,15 +518,15 @@ class DropdownMenuSubContent(RadixThemesComponent): avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -622,63 +622,63 @@ class DropdownMenuItem(RadixThemesComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, diff --git a/reflex/components/radix/themes/components/hover_card.py b/reflex/components/radix/themes/components/hover_card.py index a1c5c82d4..d67a0396a 100644 --- a/reflex/components/radix/themes/components/hover_card.py +++ b/reflex/components/radix/themes/components/hover_card.py @@ -6,7 +6,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/hover_card.pyi b/reflex/components/radix/themes/components/hover_card.pyi index ad56a8302..966d66276 100644 --- a/reflex/components/radix/themes/components/hover_card.pyi +++ b/reflex/components/radix/themes/components/hover_card.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -162,48 +162,48 @@ class HoverCardContent(elements.Div, RadixThemesComponent): *children, side: Optional[ Union[ + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + Literal["bottom", "left", "right", "top"], Var[ Union[ - Breakpoints[str, Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + Literal["bottom", "left", "right", "top"], ] ], - Literal["top", "right", "bottom", "left"], - Breakpoints[str, Literal["top", "right", "bottom", "left"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/icon_button.py b/reflex/components/radix/themes/components/icon_button.py index 76077057e..2a32afe3a 100644 --- a/reflex/components/radix/themes/components/icon_button.py +++ b/reflex/components/radix/themes/components/icon_button.py @@ -10,7 +10,7 @@ from reflex.components.core.match import Match from reflex.components.el import elements from reflex.components.lucide import Icon from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/icon_button.pyi b/reflex/components/radix/themes/components/icon_button.pyi index b5c75a9b6..fe858aeca 100644 --- a/reflex/components/radix/themes/components/icon_button.pyi +++ b/reflex/components/radix/themes/components/icon_button.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixLoadingProp, @@ -27,130 +27,130 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/inset.py b/reflex/components/radix/themes/components/inset.py index 96f1f61ce..347b9f6b0 100644 --- a/reflex/components/radix/themes/components/inset.py +++ b/reflex/components/radix/themes/components/inset.py @@ -4,7 +4,7 @@ from typing import Literal, Union from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/inset.pyi b/reflex/components/radix/themes/components/inset.pyi index 3671d2a5c..45e7d6434 100644 --- a/reflex/components/radix/themes/components/inset.pyi +++ b/reflex/components/radix/themes/components/inset.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,110 +23,110 @@ class Inset(elements.Div, RadixThemesComponent): *children, side: Optional[ Union[ + Breakpoints[str, Literal["bottom", "left", "right", "top", "x", "y"]], + Literal["bottom", "left", "right", "top", "x", "y"], Var[ Union[ Breakpoints[ - str, Literal["x", "y", "top", "bottom", "right", "left"] + str, Literal["bottom", "left", "right", "top", "x", "y"] ], - Literal["x", "y", "top", "bottom", "right", "left"], + Literal["bottom", "left", "right", "top", "x", "y"], ] ], - Literal["x", "y", "top", "bottom", "right", "left"], - Breakpoints[str, Literal["x", "y", "top", "bottom", "right", "left"]], ] ] = None, clip: Optional[ Union[ + Breakpoints[str, Literal["border-box", "padding-box"]], + Literal["border-box", "padding-box"], Var[ Union[ Breakpoints[str, Literal["border-box", "padding-box"]], Literal["border-box", "padding-box"], ] ], - Literal["border-box", "padding-box"], - Breakpoints[str, Literal["border-box", "padding-box"]], ] ] = None, p: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, px: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, py: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pt: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pr: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pb: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pl: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/popover.py b/reflex/components/radix/themes/components/popover.py index 7c51cb53b..0297b2d99 100644 --- a/reflex/components/radix/themes/components/popover.py +++ b/reflex/components/radix/themes/components/popover.py @@ -6,7 +6,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/popover.pyi b/reflex/components/radix/themes/components/popover.pyi index d8bd9d1d6..70349aea3 100644 --- a/reflex/components/radix/themes/components/popover.pyi +++ b/reflex/components/radix/themes/components/popover.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -158,55 +158,55 @@ class PopoverContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[int], int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/progress.py b/reflex/components/radix/themes/components/progress.py index a122130c8..e9fe168c6 100644 --- a/reflex/components/radix/themes/components/progress.py +++ b/reflex/components/radix/themes/components/progress.py @@ -4,7 +4,8 @@ from typing import Literal from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.style import Style +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -38,6 +39,21 @@ class Progress(RadixThemesComponent): # The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation. duration: Var[str] + # The color of the progress bar fill animation. + fill_color: Var[str] + + @staticmethod + def _color_selector(color: str) -> Style: + """Return a style object with the correct color and css selector. + + Args: + color: Color of the fill part. + + Returns: + Style: Style object with the correct css selector and color. + """ + return Style({".rt-ProgressIndicator": {"background_color": color}}) + @classmethod def create(cls, *children, **props) -> Component: """Create a Progress component. @@ -50,6 +66,12 @@ class Progress(RadixThemesComponent): The Progress Component. """ props.setdefault("width", "100%") + if "fill_color" in props: + color = props.get("fill_color", "") + style = props.get("style", {}) + style = style | cls._color_selector(color) + props["style"] = style + return super().create(*children, **props) diff --git a/reflex/components/radix/themes/components/progress.pyi b/reflex/components/radix/themes/components/progress.pyi index a647e94e6..f2e89526a 100644 --- a/reflex/components/radix/themes/components/progress.pyi +++ b/reflex/components/radix/themes/components/progress.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,91 +22,92 @@ class Progress(RadixThemesComponent): max: Optional[Union[Var[int], int]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, duration: Optional[Union[Var[str], str]] = None, + fill_color: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -162,6 +163,7 @@ class Progress(RadixThemesComponent): high_contrast: Whether to render the progress bar with higher contrast color against background radius: Override theme radius for progress bar: "none" | "small" | "medium" | "large" | "full" duration: The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation. + fill_color: The color of the progress bar fill animation. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/radix/themes/components/radio.py b/reflex/components/radix/themes/components/radio.py index 53cb35f32..fd24bb6b5 100644 --- a/reflex/components/radix/themes/components/radio.py +++ b/reflex/components/radix/themes/components/radio.py @@ -3,7 +3,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/radio.pyi b/reflex/components/radix/themes/components/radio.pyi index 5c1b303fa..a35ac33f3 100644 --- a/reflex/components/radix/themes/components/radio.pyi +++ b/reflex/components/radix/themes/components/radio.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -20,80 +20,80 @@ class Radio(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, diff --git a/reflex/components/radix/themes/components/radio_cards.py b/reflex/components/radix/themes/components/radio_cards.py index 88688521f..4c1a92aef 100644 --- a/reflex/components/radix/themes/components/radio_cards.py +++ b/reflex/components/radix/themes/components/radio_cards.py @@ -5,7 +5,7 @@ from typing import Literal, Union from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/radio_cards.pyi b/reflex/components/radix/themes/components/radio_cards.pyi index 2c0bf002b..f7cc97066 100644 --- a/reflex/components/radix/themes/components/radio_cards.pyi +++ b/reflex/components/radix/themes/components/radio_cards.pyi @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,83 +22,88 @@ class RadioCardsRoot(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, columns: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -113,15 +118,15 @@ class RadioCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, gap: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -136,11 +141,6 @@ class RadioCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -150,11 +150,11 @@ class RadioCardsRoot(RadixThemesComponent): required: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical", "undefined"]], - Literal["horizontal", "vertical", "undefined"], + Literal["horizontal", "undefined", "vertical"], + Var[Literal["horizontal", "undefined", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, loop: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/radio_group.py b/reflex/components/radix/themes/components/radio_group.py index 049e47b29..dcc74e040 100644 --- a/reflex/components/radix/themes/components/radio_group.py +++ b/reflex/components/radix/themes/components/radio_group.py @@ -10,9 +10,9 @@ from reflex.components.core.breakpoints import Responsive from reflex.components.radix.themes.layout.flex import Flex from reflex.components.radix.themes.typography.text import Text from reflex.event import EventHandler -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.ivars.sequence import StringVar -from reflex.vars import Var +from reflex.utils import types +from reflex.vars.base import LiteralVar, Var +from reflex.vars.sequence import StringVar from ..base import ( LiteralAccentColor, @@ -133,6 +133,9 @@ class HighLevelRadioGroup(RadixThemesComponent): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ direction = props.pop("direction", "column") spacing = props.pop("spacing", "2") @@ -141,6 +144,16 @@ class HighLevelRadioGroup(RadixThemesComponent): color_scheme = props.pop("color_scheme", None) default_value = props.pop("default_value", "") + if ( + not isinstance(items, (list, Var)) + or isinstance(items, Var) + and not types._issubclass(items._var_type, list) + ): + items_type = type(items) if not isinstance(items, Var) else items._var_type + raise TypeError( + f"The radio group component takes in a list, got {items_type} instead" + ) + default_value = LiteralVar.create(default_value) # convert only non-strings to json(JSON.stringify) so quotes are not rendered @@ -150,11 +163,11 @@ class HighLevelRadioGroup(RadixThemesComponent): ): default_value = LiteralVar.create(default_value) # type: ignore else: - default_value = ImmutableVar.create_safe(default_value).to_string() + default_value = LiteralVar.create(default_value).to_string() def radio_group_item(value: Var) -> Component: item_value = rx.cond( - value._type() == "string", + value.js_type() == "string", value, value.to_string(), ).to(StringVar) diff --git a/reflex/components/radix/themes/components/radio_group.pyi b/reflex/components/radix/themes/components/radio_group.pyi index 8fb19ae67..d255adcb1 100644 --- a/reflex/components/radix/themes/components/radio_group.pyi +++ b/reflex/components/radix/themes/components/radio_group.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,80 +23,80 @@ class RadioGroupRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -260,87 +260,87 @@ class HighLevelRadioGroup(RadixThemesComponent): def create( # type: ignore cls, *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[Literal["column", "column-reverse", "row", "row-reverse"]], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -419,6 +419,9 @@ class HighLevelRadioGroup(RadixThemesComponent): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ ... @@ -429,87 +432,87 @@ class RadioGroup(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[Literal["column", "column-reverse", "row", "row-reverse"]], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -588,6 +591,9 @@ class RadioGroup(ComponentNamespace): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ ... diff --git a/reflex/components/radix/themes/components/scroll_area.py b/reflex/components/radix/themes/components/scroll_area.py index 8920d81d6..bd58118dd 100644 --- a/reflex/components/radix/themes/components/scroll_area.py +++ b/reflex/components/radix/themes/components/scroll_area.py @@ -2,7 +2,7 @@ from typing import Literal -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/scroll_area.pyi b/reflex/components/radix/themes/components/scroll_area.pyi index 8b4e44df5..583e97888 100644 --- a/reflex/components/radix/themes/components/scroll_area.pyi +++ b/reflex/components/radix/themes/components/scroll_area.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -19,14 +19,14 @@ class ScrollArea(RadixThemesComponent): *children, scrollbars: Optional[ Union[ - Var[Literal["vertical", "horizontal", "both"]], - Literal["vertical", "horizontal", "both"], + Literal["both", "horizontal", "vertical"], + Var[Literal["both", "horizontal", "vertical"]], ] ] = None, type: Optional[ Union[ - Var[Literal["auto", "always", "scroll", "hover"]], - Literal["auto", "always", "scroll", "hover"], + Literal["always", "auto", "hover", "scroll"], + Var[Literal["always", "auto", "hover", "scroll"]], ] ] = None, scroll_hide_delay: Optional[Union[Var[int], int]] = None, diff --git a/reflex/components/radix/themes/components/segmented_control.py b/reflex/components/radix/themes/components/segmented_control.py index 40beb603a..21b50f03e 100644 --- a/reflex/components/radix/themes/components/segmented_control.py +++ b/reflex/components/radix/themes/components/segmented_control.py @@ -7,7 +7,7 @@ from typing import List, Literal, Union from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -23,6 +23,7 @@ class SegmentedControlRoot(RadixThemesComponent): # Variant of button: "classic" | "surface" variant: Var[Literal["classic", "surface"]] + # The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options. type: Var[Literal["single", "multiple"]] # Override theme color for button @@ -34,8 +35,10 @@ class SegmentedControlRoot(RadixThemesComponent): # The default value of the segmented control. default_value: Var[Union[str, List[str]]] + # The current value of the segmented control. value: Var[Union[str, List[str]]] + # Handles the `onChange` event for the SegmentedControl component. on_change: EventHandler[lambda e0: [e0]] _rename_props = {"onChange": "onValueChange"} diff --git a/reflex/components/radix/themes/components/segmented_control.pyi b/reflex/components/radix/themes/components/segmented_control.pyi index f284dab77..171fc490a 100644 --- a/reflex/components/radix/themes/components/segmented_control.pyi +++ b/reflex/components/radix/themes/components/segmented_control.pyi @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,93 +21,93 @@ class SegmentedControlRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, type: Optional[ - Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]] + Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, default_value: Optional[ - Union[Var[Union[List[str], str]], str, List[str]] + Union[List[str], Var[Union[List[str], str]], str] ] = None, - value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None, + value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -161,9 +161,11 @@ class SegmentedControlRoot(RadixThemesComponent): *children: Child components. size: The size of the segmented control: "1" | "2" | "3" variant: Variant of button: "classic" | "surface" + type: The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options. color_scheme: Override theme color for button radius: The radius of the segmented control: "none" | "small" | "medium" | "large" | "full" default_value: The default value of the segmented control. + value: The current value of the segmented control. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/radix/themes/components/select.py b/reflex/components/radix/themes/components/select.py index fc10d00de..9017ab5c7 100644 --- a/reflex/components/radix/themes/components/select.py +++ b/reflex/components/radix/themes/components/select.py @@ -5,7 +5,7 @@ from typing import List, Literal, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/select.pyi b/reflex/components/radix/themes/components/select.pyi index e2657b7ce..b6adac6e7 100644 --- a/reflex/components/radix/themes/components/select.pyi +++ b/reflex/components/radix/themes/components/select.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,13 +21,13 @@ class SelectRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -120,76 +120,76 @@ class SelectTrigger(RadixThemesComponent): *children, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft", "ghost"]], - Literal["classic", "surface", "soft", "ghost"], + Literal["classic", "ghost", "soft", "surface"], + Var[Literal["classic", "ghost", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, placeholder: Optional[Union[Var[str], str]] = None, @@ -267,88 +267,88 @@ class SelectContent(RadixThemesComponent): cls, *children, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[int], int]] = None, @@ -718,100 +718,100 @@ class HighLevelSelect(SelectRoot): def create( # type: ignore cls, *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft", "ghost"]], - Literal["classic", "surface", "soft", "ghost"], + Literal["classic", "ghost", "soft", "surface"], + Var[Literal["classic", "ghost", "soft", "surface"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, width: Optional[Union[Var[str], str]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -914,100 +914,100 @@ class Select(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft", "ghost"]], - Literal["classic", "surface", "soft", "ghost"], + Literal["classic", "ghost", "soft", "surface"], + Var[Literal["classic", "ghost", "soft", "surface"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, width: Optional[Union[Var[str], str]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, diff --git a/reflex/components/radix/themes/components/separator.py b/reflex/components/radix/themes/components/separator.py index 81f83194b..1689717d2 100644 --- a/reflex/components/radix/themes/components/separator.py +++ b/reflex/components/radix/themes/components/separator.py @@ -3,8 +3,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/separator.pyi b/reflex/components/radix/themes/components/separator.pyi index 15670f51a..cd5f4abce 100644 --- a/reflex/components/radix/themes/components/separator.pyi +++ b/reflex/components/radix/themes/components/separator.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,88 +22,88 @@ class Separator(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, orientation: Optional[ Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], Var[ Union[ Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], ] ], - Literal["horizontal", "vertical"], - Breakpoints[str, Literal["horizontal", "vertical"]], ] ] = None, decorative: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/themes/components/skeleton.py b/reflex/components/radix/themes/components/skeleton.py index 0738512aa..1fb6390a1 100644 --- a/reflex/components/radix/themes/components/skeleton.py +++ b/reflex/components/radix/themes/components/skeleton.py @@ -1,7 +1,7 @@ """Skeleton theme from Radix components.""" from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/skeleton.pyi b/reflex/components/radix/themes/components/skeleton.pyi index d6c6bbb03..46d2697bf 100644 --- a/reflex/components/radix/themes/components/skeleton.pyi +++ b/reflex/components/radix/themes/components/skeleton.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent @@ -19,22 +19,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): cls, *children, width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/components/slider.py b/reflex/components/radix/themes/components/slider.py index c03fffe7b..3cf2e172d 100644 --- a/reflex/components/radix/themes/components/slider.py +++ b/reflex/components/radix/themes/components/slider.py @@ -5,7 +5,7 @@ from typing import List, Literal, Optional, Union from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/slider.pyi b/reflex/components/radix/themes/components/slider.pyi index 362451bfe..0157aaab0 100644 --- a/reflex/components/radix/themes/components/slider.pyi +++ b/reflex/components/radix/themes/components/slider.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,99 +22,99 @@ class Slider(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, default_value: Optional[ Union[ - Var[Union[List[Union[float, int]], float, int]], List[Union[float, int]], + Var[Union[List[Union[float, int]], float, int]], float, int, ] ] = None, value: Optional[ - Union[Var[List[Union[float, int]]], List[Union[float, int]]] + Union[List[Union[float, int]], Var[List[Union[float, int]]]] ] = None, name: Optional[Union[Var[str], str]] = None, min: Optional[Union[Var[Union[float, int]], float, int]] = None, @@ -123,8 +123,8 @@ class Slider(RadixThemesComponent): disabled: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/components/spinner.py b/reflex/components/radix/themes/components/spinner.py index 22f5bba0b..cc29d6091 100644 --- a/reflex/components/radix/themes/components/spinner.py +++ b/reflex/components/radix/themes/components/spinner.py @@ -3,7 +3,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixLoadingProp, diff --git a/reflex/components/radix/themes/components/spinner.pyi b/reflex/components/radix/themes/components/spinner.pyi index 7fa62734a..b8f37d636 100644 --- a/reflex/components/radix/themes/components/spinner.pyi +++ b/reflex/components/radix/themes/components/spinner.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent @@ -22,13 +22,13 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, loading: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/themes/components/switch.py b/reflex/components/radix/themes/components/switch.py index f5109faf5..56951bc74 100644 --- a/reflex/components/radix/themes/components/switch.py +++ b/reflex/components/radix/themes/components/switch.py @@ -4,7 +4,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/switch.pyi b/reflex/components/radix/themes/components/switch.pyi index a0f85dbac..013501313 100644 --- a/reflex/components/radix/themes/components/switch.pyi +++ b/reflex/components/radix/themes/components/switch.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -29,87 +29,87 @@ class Switch(RadixThemesComponent): value: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/components/table.py b/reflex/components/radix/themes/components/table.py index 27b0e3563..e1f03d4e2 100644 --- a/reflex/components/radix/themes/components/table.py +++ b/reflex/components/radix/themes/components/table.py @@ -5,7 +5,7 @@ from typing import List, Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/table.pyi b/reflex/components/radix/themes/components/table.pyi index 9cac240f2..69f94176b 100644 --- a/reflex/components/radix/themes/components/table.pyi +++ b/reflex/components/radix/themes/components/table.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,44 +22,44 @@ class TableRoot(elements.Table, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["surface", "ghost"]], Literal["surface", "ghost"]] + Union[Literal["ghost", "surface"], Var[Literal["ghost", "surface"]]] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -149,31 +149,31 @@ class TableHeader(elements.Thead, RadixThemesComponent): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -262,34 +262,34 @@ class TableRow(elements.Tr, RadixThemesComponent): *children, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline"]], - Literal["start", "center", "end", "baseline"], + Literal["baseline", "center", "end", "start"], + Var[Literal["baseline", "center", "end", "start"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -378,39 +378,39 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -502,31 +502,31 @@ class TableBody(elements.Tbody, RadixThemesComponent): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -615,38 +615,38 @@ class TableCell(elements.Td, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -739,39 +739,39 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/tabs.py b/reflex/components/radix/themes/components/tabs.py index 08e09262b..5560d44b0 100644 --- a/reflex/components/radix/themes/components/tabs.py +++ b/reflex/components/radix/themes/components/tabs.py @@ -8,7 +8,7 @@ from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.core.colors import color from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/tabs.pyi b/reflex/components/radix/themes/components/tabs.pyi index 0fb33b16d..8e3c29406 100644 --- a/reflex/components/radix/themes/components/tabs.pyi +++ b/reflex/components/radix/themes/components/tabs.pyi @@ -9,7 +9,7 @@ from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -26,13 +26,13 @@ class TabsRoot(RadixThemesComponent): value: Optional[Union[Var[str], str]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, activation_mode: Optional[ - Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]] + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -112,9 +112,9 @@ class TabsList(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, loop: Optional[Union[Var[bool], bool]] = None, @@ -193,63 +193,63 @@ class TabsTrigger(RadixThemesComponent): disabled: Optional[Union[Var[bool], bool]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -405,13 +405,13 @@ class Tabs(ComponentNamespace): value: Optional[Union[Var[str], str]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, activation_mode: Optional[ - Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]] + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/text_area.py b/reflex/components/radix/themes/components/text_area.py index 5218f1d7b..8b3b531cb 100644 --- a/reflex/components/radix/themes/components/text_area.py +++ b/reflex/components/radix/themes/components/text_area.py @@ -7,7 +7,7 @@ from reflex.components.core.breakpoints import Responsive from reflex.components.core.debounce import DebounceInput from reflex.components.el import elements from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/text_area.pyi b/reflex/components/radix/themes/components/text_area.pyi index 9a8a47873..c39be4b1f 100644 --- a/reflex/components/radix/themes/components/text_area.pyi +++ b/reflex/components/radix/themes/components/text_area.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -24,108 +24,108 @@ class TextArea(RadixThemesComponent, elements.Textarea): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, resize: Optional[ Union[ + Breakpoints[str, Literal["both", "horizontal", "none", "vertical"]], + Literal["both", "horizontal", "none", "vertical"], Var[ Union[ Breakpoints[ - str, Literal["none", "vertical", "horizontal", "both"] + str, Literal["both", "horizontal", "none", "vertical"] ], - Literal["none", "vertical", "horizontal", "both"], + Literal["both", "horizontal", "none", "vertical"], ] ], - Literal["none", "vertical", "horizontal", "both"], - Breakpoints[str, Literal["none", "vertical", "horizontal", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, auto_focus: Optional[Union[Var[bool], bool]] = None, dirname: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, max_length: Optional[Union[Var[int], int]] = None, min_length: Optional[Union[Var[int], int]] = None, name: Optional[Union[Var[str], str]] = None, @@ -136,32 +136,32 @@ class TextArea(RadixThemesComponent, elements.Textarea): value: Optional[Union[Var[str], str]] = None, wrap: Optional[Union[Var[str], str]] = None, auto_height: Optional[Union[Var[bool], bool]] = None, - cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_submit: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py index aca422840..6c3372985 100644 --- a/reflex/components/radix/themes/components/text_field.py +++ b/reflex/components/radix/themes/components/text_field.py @@ -4,16 +4,12 @@ from __future__ import annotations from typing import Literal, Union -from reflex.components.base.fragment import Fragment from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.core.debounce import DebounceInput from reflex.components.el import elements from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.style import Style, format_as_emotion -from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -107,80 +103,6 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): return DebounceInput.create(component) return component - @classmethod - def create_root_deprecated(cls, *children, **props) -> Component: - """Create a Fragment component (wrapper for deprecated name). - - Copy the attributes that were previously defined on TextFieldRoot in 0.4.9 to - any child input elements (via custom_attrs). - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The component. - """ - console.deprecate( - feature_name="rx.input.root", - reason="use rx.input without the .root suffix", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - inputs = [ - child - for child in children - if isinstance(child, (TextFieldRoot, DebounceInput)) - ] - if not inputs: - # Old-style where no explicit child input was provided - return cls.create(*children, **props) - slots = [child for child in children if isinstance(child, TextFieldSlot)] - carry_props = { - prop: props.pop(prop) - for prop in ["size", "variant", "color_scheme", "radius"] - if prop in props - } - template = cls.create(**props) - for child in inputs: - child.children.extend(slots) - custom_attrs = child.custom_attrs - custom_attrs.update( - { - prop: value - for prop, value in carry_props.items() - if prop not in custom_attrs and getattr(child, prop) is None - } - ) - style = Style(template.style) - style.update(child.style) - child._get_style = lambda style=style: { - "css": LiteralVar.create(format_as_emotion(style)) - } - for trigger in template.event_triggers: - if trigger not in child.event_triggers: - child.event_triggers[trigger] = template.event_triggers[trigger] - return Fragment.create(*inputs) - - @classmethod - def create_input_deprecated(cls, *children, **props) -> Component: - """Create a TextFieldRoot component (wrapper for deprecated name). - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The component. - """ - console.deprecate( - feature_name="rx.input.input", - reason="use rx.input without the .input suffix", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - return cls.create(*children, **props) - class TextFieldSlot(RadixThemesComponent): """Contains icons or buttons associated with an Input.""" @@ -194,8 +116,6 @@ class TextFieldSlot(RadixThemesComponent): class TextField(ComponentNamespace): """TextField components namespace.""" - root = staticmethod(TextFieldRoot.create_root_deprecated) - input = staticmethod(TextFieldRoot.create_input_deprecated) slot = staticmethod(TextFieldSlot.create) __call__ = staticmethod(TextFieldRoot.create) diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi index 5d6df2f26..ff5b79344 100644 --- a/reflex/components/radix/themes/components/text_field.pyi +++ b/reflex/components/radix/themes/components/text_field.pyi @@ -5,12 +5,12 @@ # ------------------------------------------------------ from typing import Any, Callable, Dict, Literal, Optional, Union, overload -from reflex.components.component import Component, ComponentNamespace +from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,87 +25,87 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, @@ -118,31 +118,31 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -239,11 +239,6 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): """ ... - @classmethod - def create_root_deprecated(cls, *children, **props) -> Component: ... - @classmethod - def create_input_deprecated(cls, *children, **props) -> Component: ... - class TextFieldSlot(RadixThemesComponent): @overload @classmethod @@ -252,63 +247,63 @@ class TextFieldSlot(RadixThemesComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -377,8 +372,6 @@ class TextFieldSlot(RadixThemesComponent): ... class TextField(ComponentNamespace): - root = staticmethod(TextFieldRoot.create_root_deprecated) - input = staticmethod(TextFieldRoot.create_input_deprecated) slot = staticmethod(TextFieldSlot.create) @staticmethod @@ -386,87 +379,87 @@ class TextField(ComponentNamespace): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, @@ -479,31 +472,31 @@ class TextField(ComponentNamespace): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/tooltip.py b/reflex/components/radix/themes/components/tooltip.py index 9a1355be5..f39de68a8 100644 --- a/reflex/components/radix/themes/components/tooltip.py +++ b/reflex/components/radix/themes/components/tooltip.py @@ -5,7 +5,7 @@ from typing import Dict, Literal, Union from reflex.components.component import Component from reflex.event import EventHandler from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, diff --git a/reflex/components/radix/themes/components/tooltip.pyi b/reflex/components/radix/themes/components/tooltip.pyi index a2344958f..f886dc608 100644 --- a/reflex/components/radix/themes/components/tooltip.pyi +++ b/reflex/components/radix/themes/components/tooltip.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -26,30 +26,30 @@ class Tooltip(RadixThemesComponent): open: Optional[Union[Var[bool], bool]] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, delay_duration: Optional[Union[Var[Union[float, int]], float, int]] = None, diff --git a/reflex/components/radix/themes/layout/__init__.pyi b/reflex/components/radix/themes/layout/__init__.pyi index 1420299e0..6712a3068 100644 --- a/reflex/components/radix/themes/layout/__init__.pyi +++ b/reflex/components/radix/themes/layout/__init__.pyi @@ -9,6 +9,7 @@ from .container import container as container from .flex import flex as flex from .grid import grid as grid from .list import list_item as list_item +from .list import list_ns as list # noqa from .list import ordered_list as ordered_list from .list import unordered_list as unordered_list from .section import section as section diff --git a/reflex/components/radix/themes/layout/base.py b/reflex/components/radix/themes/layout/base.py index dd598538e..3ee78d209 100644 --- a/reflex/components/radix/themes/layout/base.py +++ b/reflex/components/radix/themes/layout/base.py @@ -5,7 +5,7 @@ from __future__ import annotations from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( CommonMarginProps, diff --git a/reflex/components/radix/themes/layout/base.pyi b/reflex/components/radix/themes/layout/base.pyi index 21fed38ef..4da48975b 100644 --- a/reflex/components/radix/themes/layout/base.pyi +++ b/reflex/components/radix/themes/layout/base.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import CommonMarginProps, RadixThemesComponent @@ -22,6 +22,10 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): *children, p: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -31,14 +35,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, px: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -48,14 +52,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, py: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -65,14 +69,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pt: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -82,14 +86,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pr: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -99,14 +103,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pb: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -116,14 +120,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pl: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -133,66 +137,62 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, flex_shrink: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], - Literal["0", "1"], Breakpoints[str, Literal["0", "1"]], + Literal["0", "1"], + Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], ] ] = None, flex_grow: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], - Literal["0", "1"], Breakpoints[str, Literal["0", "1"]], + Literal["0", "1"], + Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], ] ] = None, m: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mx: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, my: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mt: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mr: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, mb: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, ml: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/layout/box.pyi b/reflex/components/radix/themes/layout/box.pyi index 6bcd75cad..ba651b488 100644 --- a/reflex/components/radix/themes/layout/box.pyi +++ b/reflex/components/radix/themes/layout/box.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -18,30 +18,30 @@ class Box(elements.Div, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/center.pyi b/reflex/components/radix/themes/layout/center.pyi index 93f884898..e6a622c48 100644 --- a/reflex/components/radix/themes/layout/center.pyi +++ b/reflex/components/radix/themes/layout/center.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .flex import Flex @@ -22,64 +22,68 @@ class Center(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -89,36 +93,32 @@ class Center(Flex): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/container.py b/reflex/components/radix/themes/layout/container.py index 4ed18031d..b1d2fbed3 100644 --- a/reflex/components/radix/themes/layout/container.py +++ b/reflex/components/radix/themes/layout/container.py @@ -6,9 +6,8 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.ivars.base import LiteralVar from reflex.style import STACK_CHILDREN_FULL_WIDTH -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import RadixThemesComponent diff --git a/reflex/components/radix/themes/layout/container.pyi b/reflex/components/radix/themes/layout/container.pyi index 3c2013b8e..f4c92b085 100644 --- a/reflex/components/radix/themes/layout/container.pyi +++ b/reflex/components/radix/themes/layout/container.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,40 +25,40 @@ class Container(elements.Div, RadixThemesComponent): stack_children_full_width: Optional[bool] = False, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/flex.py b/reflex/components/radix/themes/layout/flex.py index 825c84f42..8be16973d 100644 --- a/reflex/components/radix/themes/layout/flex.py +++ b/reflex/components/radix/themes/layout/flex.py @@ -6,7 +6,7 @@ from typing import Dict, Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAlign, diff --git a/reflex/components/radix/themes/layout/flex.pyi b/reflex/components/radix/themes/layout/flex.pyi index a49f08262..be7d1ce55 100644 --- a/reflex/components/radix/themes/layout/flex.pyi +++ b/reflex/components/radix/themes/layout/flex.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,64 +25,68 @@ class Flex(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -92,36 +96,32 @@ class Flex(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/grid.py b/reflex/components/radix/themes/layout/grid.py index ab7fbdb3b..b9ac28d41 100644 --- a/reflex/components/radix/themes/layout/grid.py +++ b/reflex/components/radix/themes/layout/grid.py @@ -6,7 +6,7 @@ from typing import Dict, Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAlign, diff --git a/reflex/components/radix/themes/layout/grid.pyi b/reflex/components/radix/themes/layout/grid.pyi index c11d1dfcd..124928198 100644 --- a/reflex/components/radix/themes/layout/grid.pyi +++ b/reflex/components/radix/themes/layout/grid.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,61 +23,65 @@ class Grid(elements.Div, RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, columns: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, rows: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, flow: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-dense", "dense", "row", "row-dense"] + ], + Literal["column", "column-dense", "dense", "row", "row-dense"], Var[ Union[ Breakpoints[ str, Literal[ - "row", "column", "dense", "row-dense", "column-dense" + "column", "column-dense", "dense", "row", "row-dense" ], ], - Literal["row", "column", "dense", "row-dense", "column-dense"], + Literal["column", "column-dense", "dense", "row", "row-dense"], ] ], - Literal["row", "column", "dense", "row-dense", "column-dense"], - Breakpoints[ - str, Literal["row", "column", "dense", "row-dense", "column-dense"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -87,14 +91,14 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, spacing_x: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -104,14 +108,14 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, spacing_y: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -121,36 +125,32 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py index fb77b223d..699028380 100644 --- a/reflex/components/radix/themes/layout/list.py +++ b/reflex/components/radix/themes/layout/list.py @@ -9,7 +9,7 @@ from reflex.components.core.foreach import Foreach from reflex.components.el.elements.typography import Li, Ol, Ul from reflex.components.lucide.icon import Icon from reflex.components.radix.themes.typography.text import Text -from reflex.vars import Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal[ "none", diff --git a/reflex/components/radix/themes/layout/list.pyi b/reflex/components/radix/themes/layout/list.pyi index bf8da641c..a3ea33916 100644 --- a/reflex/components/radix/themes/layout/list.pyi +++ b/reflex/components/radix/themes/layout/list.pyi @@ -9,7 +9,7 @@ from reflex.components.component import Component, ComponentNamespace from reflex.components.el.elements.typography import Li, Ol, Ul from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal["none", "disc", "circle", "square"] LiteralListStyleTypeOrdered = Literal[ @@ -35,47 +35,47 @@ class BaseList(Component): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = None, list_style_type: Optional[ Union[ + Literal[ + "armenian", + "decimal", + "decimal-leading-zero", + "georgian", + "hiragana", + "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", + ], + Literal["circle", "disc", "none", "square"], Var[ Union[ Literal[ - "none", + "armenian", "decimal", "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", "georgian", - "lower-alpha", - "upper-alpha", "hiragana", "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", ], - Literal["none", "disc", "circle", "square"], + Literal["circle", "disc", "none", "square"], ] ], - Literal["none", "disc", "circle", "square"], - Literal[ - "none", - "decimal", - "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", - "georgian", - "lower-alpha", - "upper-alpha", - "hiragana", - "katakana", - ], ] ] = None, style: Optional[Style] = None, @@ -149,32 +149,32 @@ class UnorderedList(BaseList, Ul): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = None, list_style_type: Optional[LiteralListStyleTypeUnordered] = "disc", - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -260,35 +260,35 @@ class OrderedList(BaseList, Ol): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = None, list_style_type: Optional[LiteralListStyleTypeOrdered] = "decimal", - reversed: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + reversed: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + start: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -377,30 +377,30 @@ class ListItem(Li): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -486,47 +486,47 @@ class List(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = None, list_style_type: Optional[ Union[ + Literal[ + "armenian", + "decimal", + "decimal-leading-zero", + "georgian", + "hiragana", + "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", + ], + Literal["circle", "disc", "none", "square"], Var[ Union[ Literal[ - "none", + "armenian", "decimal", "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", "georgian", - "lower-alpha", - "upper-alpha", "hiragana", "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", ], - Literal["none", "disc", "circle", "square"], + Literal["circle", "disc", "none", "square"], ] ], - Literal["none", "disc", "circle", "square"], - Literal[ - "none", - "decimal", - "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", - "georgian", - "lower-alpha", - "upper-alpha", - "hiragana", - "katakana", - ], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/radix/themes/layout/section.py b/reflex/components/radix/themes/layout/section.py index a3e58be86..68a131751 100644 --- a/reflex/components/radix/themes/layout/section.py +++ b/reflex/components/radix/themes/layout/section.py @@ -6,8 +6,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import RadixThemesComponent diff --git a/reflex/components/radix/themes/layout/section.pyi b/reflex/components/radix/themes/layout/section.pyi index b4e1050d8..b949e5e05 100644 --- a/reflex/components/radix/themes/layout/section.pyi +++ b/reflex/components/radix/themes/layout/section.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,39 +23,39 @@ class Section(elements.Section, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/spacer.pyi b/reflex/components/radix/themes/layout/spacer.pyi index 652c1a0b0..5a3775ef6 100644 --- a/reflex/components/radix/themes/layout/spacer.pyi +++ b/reflex/components/radix/themes/layout/spacer.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .flex import Flex @@ -22,64 +22,68 @@ class Spacer(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -89,36 +93,32 @@ class Spacer(Flex): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/layout/stack.py b/reflex/components/radix/themes/layout/stack.py index 13f80dc1e..cb513cbfb 100644 --- a/reflex/components/radix/themes/layout/stack.py +++ b/reflex/components/radix/themes/layout/stack.py @@ -3,7 +3,7 @@ from __future__ import annotations from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAlign, LiteralSpacing from .flex import Flex, LiteralFlexDirection diff --git a/reflex/components/radix/themes/layout/stack.pyi b/reflex/components/radix/themes/layout/stack.pyi index 4ba630fc2..0547cbc8f 100644 --- a/reflex/components/radix/themes/layout/stack.pyi +++ b/reflex/components/radix/themes/layout/stack.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAlign, LiteralSpacing from .flex import Flex @@ -24,69 +24,69 @@ class Stack(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -179,59 +179,59 @@ class VStack(Stack): align: Optional[LiteralAlign] = "start", direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[Literal["column", "column-reverse", "row", "row-reverse"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -324,59 +324,59 @@ class HStack(Stack): align: Optional[LiteralAlign] = "start", direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[Literal["column", "column-reverse", "row", "row-reverse"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/typography/blockquote.py b/reflex/components/radix/themes/typography/blockquote.py index a4f3069b8..a60c05471 100644 --- a/reflex/components/radix/themes/typography/blockquote.py +++ b/reflex/components/radix/themes/typography/blockquote.py @@ -7,7 +7,7 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/typography/blockquote.pyi b/reflex/components/radix/themes/typography/blockquote.pyi index 3ab3c829b..3abf53fd6 100644 --- a/reflex/components/radix/themes/typography/blockquote.pyi +++ b/reflex/components/radix/themes/typography/blockquote.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,6 +21,8 @@ class Blockquote(elements.Blockquote, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -29,110 +31,108 @@ class Blockquote(elements.Blockquote, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/typography/code.py b/reflex/components/radix/themes/typography/code.py index 2c0212b8b..663f260da 100644 --- a/reflex/components/radix/themes/typography/code.py +++ b/reflex/components/radix/themes/typography/code.py @@ -7,7 +7,7 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/typography/code.pyi b/reflex/components/radix/themes/typography/code.pyi index f30a39f9a..1da91fc96 100644 --- a/reflex/components/radix/themes/typography/code.pyi +++ b/reflex/components/radix/themes/typography/code.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,12 +21,14 @@ class Code(elements.Code, RadixThemesComponent): *children, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -35,109 +37,107 @@ class Code(elements.Code, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/typography/heading.py b/reflex/components/radix/themes/typography/heading.py index 374fe8dcc..f5fec8bb1 100644 --- a/reflex/components/radix/themes/typography/heading.py +++ b/reflex/components/radix/themes/typography/heading.py @@ -7,7 +7,7 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/typography/heading.pyi b/reflex/components/radix/themes/typography/heading.pyi index d1fe26218..7b7c45fde 100644 --- a/reflex/components/radix/themes/typography/heading.pyi +++ b/reflex/components/radix/themes/typography/heading.pyi @@ -9,7 +9,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,6 +23,8 @@ class Heading(elements.H1, RadixThemesComponent): as_: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -31,133 +33,131 @@ class Heading(elements.H1, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/typography/link.py b/reflex/components/radix/themes/typography/link.py index 92fa47173..e51209dce 100644 --- a/reflex/components/radix/themes/typography/link.py +++ b/reflex/components/radix/themes/typography/link.py @@ -14,7 +14,7 @@ from reflex.components.core.cond import cond from reflex.components.el.elements.inline import A from reflex.components.next.link import NextLink from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/typography/link.pyi b/reflex/components/radix/themes/typography/link.pyi index 54cebee64..da715f73b 100644 --- a/reflex/components/radix/themes/typography/link.pyi +++ b/reflex/components/radix/themes/typography/link.pyi @@ -12,7 +12,7 @@ from reflex.components.next.link import NextLink from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -29,6 +29,8 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -37,139 +39,137 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, underline: Optional[ Union[ - Var[Literal["auto", "hover", "always", "none"]], - Literal["auto", "hover", "always", "none"], + Literal["always", "auto", "hover", "none"], + Var[Literal["always", "auto", "hover", "none"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, is_external: Optional[Union[Var[bool], bool]] = None, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/radix/themes/typography/text.py b/reflex/components/radix/themes/typography/text.py index fe4b17afc..24b09c753 100644 --- a/reflex/components/radix/themes/typography/text.py +++ b/reflex/components/radix/themes/typography/text.py @@ -10,7 +10,7 @@ from typing import Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/typography/text.pyi b/reflex/components/radix/themes/typography/text.pyi index 919ed17e0..85f7754cc 100644 --- a/reflex/components/radix/themes/typography/text.pyi +++ b/reflex/components/radix/themes/typography/text.pyi @@ -10,7 +10,7 @@ from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -44,52 +44,54 @@ class Text(elements.Span, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -98,133 +100,131 @@ class Text(elements.Span, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -320,53 +320,55 @@ class Span(Text): *children, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -375,133 +377,131 @@ class Span(Text): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -595,30 +595,30 @@ class Em(elements.Em, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -706,34 +706,34 @@ class Kbd(elements.Kbd, RadixThemesComponent): *children, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -820,31 +820,31 @@ class Quote(elements.Q, RadixThemesComponent): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -931,30 +931,30 @@ class Strong(elements.Strong, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1047,52 +1047,54 @@ class TextNamespace(ComponentNamespace): as_child: Optional[Union[Var[bool], bool]] = None, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -1101,133 +1103,131 @@ class TextNamespace(ComponentNamespace): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/react_player/audio.pyi b/reflex/components/react_player/audio.pyi index f84122403..af5714148 100644 --- a/reflex/components/react_player/audio.pyi +++ b/reflex/components/react_player/audio.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.react_player.react_player import ReactPlayer from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Audio(ReactPlayer): pass diff --git a/reflex/components/react_player/react_player.py b/reflex/components/react_player/react_player.py index 1c9b20cea..08c6df017 100644 --- a/reflex/components/react_player/react_player.py +++ b/reflex/components/react_player/react_player.py @@ -4,7 +4,7 @@ from __future__ import annotations from reflex.components.component import NoSSRComponent from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var class ReactPlayer(NoSSRComponent): diff --git a/reflex/components/react_player/react_player.pyi b/reflex/components/react_player/react_player.pyi index c9e8ba569..4f466ea2d 100644 --- a/reflex/components/react_player/react_player.pyi +++ b/reflex/components/react_player/react_player.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.component import NoSSRComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class ReactPlayer(NoSSRComponent): @overload diff --git a/reflex/components/react_player/video.pyi b/reflex/components/react_player/video.pyi index 7f7c1fda1..e60f03920 100644 --- a/reflex/components/react_player/video.pyi +++ b/reflex/components/react_player/video.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload from reflex.components.react_player.react_player import ReactPlayer from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Video(ReactPlayer): pass diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index 4c76e82ea..06ca80dc5 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -7,8 +7,7 @@ from typing import Any, Dict, List, Union from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, @@ -168,7 +167,7 @@ class ZAxis(Recharts): tag = "ZAxis" - alias = "RechartszAxis" + alias = "RechartsZAxis" # The key of data displayed in the axis. data_key: Var[Union[str, int]] diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi index 0ffbd6c53..e7b186f6f 100644 --- a/reflex/components/recharts/cartesian.pyi +++ b/reflex/components/recharts/cartesian.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .recharts import ( Recharts, @@ -20,12 +20,12 @@ class Axis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, hide: Optional[Union[Var[bool], bool]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, @@ -34,59 +34,59 @@ class Axis(Recharts): mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, text_anchor: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -178,17 +178,17 @@ class XAxis(Axis): cls, *children, orientation: Optional[ - Union[Var[Literal["top", "bottom"]], Literal["top", "bottom"]] + Union[Literal["bottom", "top"], Var[Literal["bottom", "top"]]] ] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, include_hidden: Optional[Union[Var[bool], bool]] = None, - domain: Optional[Union[Var[List], List]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + domain: Optional[Union[List, Var[List]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, hide: Optional[Union[Var[bool], bool]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, @@ -197,59 +197,59 @@ class XAxis(Axis): mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, text_anchor: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -345,16 +345,16 @@ class YAxis(Axis): cls, *children, orientation: Optional[ - Union[Var[Literal["left", "right"]], Literal["left", "right"]] + Union[Literal["left", "right"], Var[Literal["left", "right"]]] ] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - domain: Optional[Union[Var[List], List]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + domain: Optional[Union[List, Var[List]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, hide: Optional[Union[Var[bool], bool]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, @@ -363,59 +363,59 @@ class YAxis(Axis): mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, text_anchor: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -509,48 +509,48 @@ class ZAxis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - range: Optional[Union[Var[List[int]], List[int]]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + range: Optional[Union[List[int], Var[List[int]]]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, style: Optional[Style] = None, @@ -625,14 +625,14 @@ class Brush(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, x: Optional[Union[Var[int], int]] = None, y: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None, height: Optional[Union[Var[int], int]] = None, - data: Optional[Union[Var[List[Any]], List[Any]]] = None, + data: Optional[Union[List[Any], Var[List[Any]]]] = None, traveller_width: Optional[Union[Var[int], int]] = None, gap: Optional[Union[Var[int], int]] = None, start_index: Optional[Union[Var[int], int]] = None, @@ -683,42 +683,42 @@ class Cartesian(Recharts): *children, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -793,97 +793,97 @@ class Area(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, type_: Optional[ Union[ + Literal[ + "basis", + "basisClosed", + "basisOpen", + "bump", + "bumpX", + "bumpY", + "linear", + "linearClosed", + "monotone", + "monotoneX", + "monotoneY", + "natural", + "step", + "stepAfter", + "stepBefore", + ], Var[ Literal[ "basis", "basisClosed", "basisOpen", + "bump", "bumpX", "bumpY", - "bump", "linear", "linearClosed", - "natural", + "monotone", "monotoneX", "monotoneY", - "monotone", + "natural", "step", - "stepBefore", "stepAfter", + "stepBefore", ] ], - Literal[ - "basis", - "basisClosed", - "basisOpen", - "bumpX", - "bumpY", - "bump", - "linear", - "linearClosed", - "natural", - "monotoneX", - "monotoneY", - "monotone", - "step", - "stepBefore", - "stepAfter", - ], ] ] = None, dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, active_dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, label: Optional[Union[Var[bool], bool]] = None, - stack_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + stack_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -968,15 +968,15 @@ class Bar(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, background: Optional[Union[Var[bool], bool]] = None, label: Optional[Union[Var[bool], bool]] = None, stack_id: Optional[Union[Var[str], str]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, min_point_size: Optional[Union[Var[int], int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, max_bar_size: Optional[Union[Var[int], int]] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, @@ -984,48 +984,48 @@ class Bar(Cartesian): animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -1123,95 +1123,95 @@ class Line(Cartesian): *children, type_: Optional[ Union[ + Literal[ + "basis", + "basisClosed", + "basisOpen", + "bump", + "bumpX", + "bumpY", + "linear", + "linearClosed", + "monotone", + "monotoneX", + "monotoneY", + "natural", + "step", + "stepAfter", + "stepBefore", + ], Var[ Literal[ "basis", "basisClosed", "basisOpen", + "bump", "bumpX", "bumpY", - "bump", "linear", "linearClosed", - "natural", + "monotone", "monotoneX", "monotoneY", - "monotone", + "natural", "step", - "stepBefore", "stepAfter", + "stepBefore", ] ], - Literal[ - "basis", - "basisClosed", - "basisOpen", - "bumpX", - "bumpY", - "bump", - "linear", - "linearClosed", - "natural", - "monotoneX", - "monotoneY", - "monotone", - "step", - "stepBefore", - "stepAfter", - ], ] ] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, active_dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, label: Optional[Union[Var[bool], bool]] = None, hide: Optional[Union[Var[bool], bool]] = None, connect_nulls: Optional[Union[Var[bool], bool]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -1296,73 +1296,73 @@ class Scatter(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, z_axis_id: Optional[Union[Var[str], str]] = None, line: Optional[Union[Var[bool], bool]] = None, shape: Optional[ Union[ + Literal[ + "circle", "cross", "diamond", "square", "star", "triangle", "wye" + ], Var[ Literal[ - "square", "circle", "cross", "diamond", + "square", "star", "triangle", "wye", ] ], - Literal[ - "square", "circle", "cross", "diamond", "star", "triangle", "wye" - ], ] ] = None, line_type: Optional[ - Union[Var[Literal["joint", "fitting"]], Literal["joint", "fitting"]] + Union[Literal["fitting", "joint"], Var[Literal["fitting", "joint"]]] ] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_begin: Optional[Union[Var[int], int]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -1445,38 +1445,38 @@ class Funnel(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, name_key: Optional[Union[Var[str], str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -1485,11 +1485,11 @@ class Funnel(Recharts): animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -1572,11 +1572,11 @@ class ErrorBar(Recharts): cls, *children, direction: Optional[ - Union[Var[Literal["x", "y", "both"]], Literal["x", "y", "both"]] + Union[Literal["both", "x", "y"], Var[Literal["both", "x", "y"]]] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, width: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1649,15 +1649,15 @@ class Reference(Recharts): def create( # type: ignore cls, *children, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1730,20 +1730,20 @@ class ReferenceLine(Reference): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke_width: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke_width: Optional[Union[Var[Union[int, str]], int, str]] = None, segment: Optional[List[Any]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1821,20 +1821,20 @@ class ReferenceDot(Reference): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, r: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1912,19 +1912,19 @@ class ReferenceArea(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - x1: Optional[Union[Var[Union[int, str]], str, int]] = None, - x2: Optional[Union[Var[Union[int, str]], str, int]] = None, - y1: Optional[Union[Var[Union[int, str]], str, int]] = None, - y2: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + x1: Optional[Union[Var[Union[int, str]], int, str]] = None, + x2: Optional[Union[Var[Union[int, str]], int, str]] = None, + y1: Optional[Union[Var[Union[int, str]], int, str]] = None, + y2: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, is_front: Optional[Union[Var[bool], bool]] = None, @@ -2082,15 +2082,15 @@ class CartesianGrid(Grid): horizontal: Optional[Union[Var[bool], bool]] = None, vertical: Optional[Union[Var[bool], bool]] = None, vertical_points: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, horizontal_points: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, stroke_dasharray: Optional[Union[Var[str], str]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, x: Optional[Union[Var[int], int]] = None, y: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None, @@ -2175,8 +2175,8 @@ class CartesianAxis(Grid): *children, orientation: Optional[ Union[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, axis_line: Optional[Union[Var[bool], bool]] = None, @@ -2184,8 +2184,8 @@ class CartesianAxis(Grid): tick_size: Optional[Union[Var[int], int]] = None, interval: Optional[ Union[ - Var[Literal["preserveStart", "preserveEnd", "preserveStartEnd"]], - Literal["preserveStart", "preserveEnd", "preserveStartEnd"], + Literal["preserveEnd", "preserveStart", "preserveStartEnd"], + Var[Literal["preserveEnd", "preserveStart", "preserveStartEnd"]], ] ] = None, ticks: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py index 37b865b1d..6f79a70ae 100644 --- a/reflex/components/recharts/charts.py +++ b/reflex/components/recharts/charts.py @@ -9,8 +9,7 @@ from reflex.components.recharts.general import ResponsiveContainer from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, diff --git a/reflex/components/recharts/charts.pyi b/reflex/components/recharts/charts.pyi index 48bde7483..2d5036656 100644 --- a/reflex/components/recharts/charts.pyi +++ b/reflex/components/recharts/charts.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .recharts import ( RechartsCharts, @@ -20,8 +20,8 @@ class ChartBase(RechartsCharts): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -90,26 +90,26 @@ class CategoricalChartBase(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -186,31 +186,31 @@ class AreaChart(CategoricalChartBase): *children, base_value: Optional[ Union[ - Var[Union[Literal["dataMin", "dataMax", "auto"], int]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], int, - Literal["dataMin", "dataMax", "auto"], ] ] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -286,31 +286,31 @@ class BarChart(CategoricalChartBase): def create( # type: ignore cls, *children, - bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, - bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, + bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, + bar_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, max_bar_size: Optional[Union[Var[int], int]] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, reverse_stack_order: Optional[Union[Var[bool], bool]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -390,26 +390,26 @@ class LineChart(CategoricalChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -486,35 +486,35 @@ class ComposedChart(CategoricalChartBase): *children, base_value: Optional[ Union[ - Var[Union[Literal["dataMin", "dataMax", "auto"], int]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], int, - Literal["dataMin", "dataMax", "auto"], ] ] = None, - bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, - bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, + bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, + bar_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, reverse_stack_order: Optional[Union[Var[bool], bool]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -594,9 +594,9 @@ class PieChart(ChartBase): def create( # type: ignore cls, *children, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -667,16 +667,16 @@ class RadarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, start_angle: Optional[Union[Var[int], int]] = None, end_angle: Optional[Union[Var[int], int]] = None, inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -725,8 +725,8 @@ class RadialBarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, start_angle: Optional[Union[Var[int], int]] = None, @@ -736,8 +736,8 @@ class RadialBarChart(ChartBase): bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_gap: Optional[Union[Var[str], str]] = None, bar_size: Optional[Union[Var[int], int]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -818,9 +818,9 @@ class ScatterChart(ChartBase): def create( # type: ignore cls, *children, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -878,10 +878,10 @@ class FunnelChart(ChartBase): cls, *children, layout: Optional[Union[Var[str], str]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -953,18 +953,18 @@ class Treemap(RechartsCharts): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, aspect_ratio: Optional[Union[Var[int], int]] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_begin: Optional[Union[Var[int], int]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py index 4f81ea833..cc252de57 100644 --- a/reflex/components/recharts/general.py +++ b/reflex/components/recharts/general.py @@ -7,8 +7,7 @@ from typing import Any, Dict, List, Union from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi index be6a0d42f..0e21c8b85 100644 --- a/reflex/components/recharts/general.pyi +++ b/reflex/components/recharts/general.pyi @@ -9,7 +9,7 @@ from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .recharts import ( Recharts, @@ -103,56 +103,56 @@ class Legend(Recharts): height: Optional[Union[Var[int], int]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, align: Optional[ Union[ - Var[Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Literal["center", "left", "right"], + Var[Literal["center", "left", "right"]], ] ] = None, vertical_align: Optional[ Union[ - Var[Literal["top", "middle", "bottom"]], - Literal["top", "middle", "bottom"], + Literal["bottom", "middle", "top"], + Var[Literal["bottom", "middle", "top"]], ] ] = None, icon_size: Optional[Union[Var[int], int]] = None, icon_type: Optional[ Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], Var[ Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "plainline", + "rect", + "square", "star", "triangle", "wye", ] ], - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - ], ] ] = None, chart_width: Optional[Union[Var[int], int]] = None, chart_height: Optional[Union[Var[int], int]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -233,25 +233,25 @@ class GraphingTooltip(Recharts): offset: Optional[Union[Var[int], int]] = None, filter_null: Optional[Union[Var[bool], bool]] = None, cursor: Optional[ - Union[Var[Union[Dict[str, Any], bool]], Dict[str, Any], bool] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - item_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - wrapper_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - content_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - label_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + item_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + wrapper_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + content_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + label_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, allow_escape_view_box: Optional[ - Union[Var[Dict[str, bool]], Dict[str, bool]] + Union[Dict[str, bool], Var[Dict[str, bool]]] ] = None, active: Optional[Union[Var[bool], bool]] = None, - position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - coordinate: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + position: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + coordinate: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -336,52 +336,52 @@ class Label(Recharts): def create( # type: ignore cls, *children, - view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, value: Optional[Union[Var[str], str]] = None, offset: Optional[Union[Var[int], int]] = None, position: Optional[ Union[ - Var[ - Literal[ - "top", - "left", - "right", - "bottom", - "inside", - "outside", - "insideLeft", - "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", - "insideStart", - "insideEnd", - "end", - "center", - ] - ], Literal[ - "top", - "left", - "right", "bottom", + "center", + "end", "inside", - "outside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", "insideLeft", "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", "insideStart", - "insideEnd", - "end", - "center", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ], + Var[ + Literal[ + "bottom", + "center", + "end", + "inside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", + "insideLeft", + "insideRight", + "insideStart", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ] ], ] ] = None, @@ -455,56 +455,56 @@ class LabelList(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, position: Optional[ Union[ - Var[ - Literal[ - "top", - "left", - "right", - "bottom", - "inside", - "outside", - "insideLeft", - "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", - "insideStart", - "insideEnd", - "end", - "center", - ] - ], Literal[ - "top", - "left", - "right", "bottom", + "center", + "end", "inside", - "outside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", "insideLeft", "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", "insideStart", - "insideEnd", - "end", - "center", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ], + Var[ + Literal[ + "bottom", + "center", + "end", + "inside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", + "insideLeft", + "insideRight", + "insideStart", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ] ], ] ] = None, offset: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index 76347352b..adeb0eb91 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -7,8 +7,7 @@ from typing import Any, Dict, List, Union from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler -from reflex.ivars.base import LiteralVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi index 81fb74b27..9d793f3da 100644 --- a/reflex/components/recharts/polar.pyi +++ b/reflex/components/recharts/polar.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from .recharts import ( Recharts, @@ -21,8 +21,8 @@ class Pie(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -34,40 +34,40 @@ class Pie(Recharts): name_key: Optional[Union[Var[str], str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, label: Optional[Union[Var[bool], bool]] = None, label_line: Optional[Union[Var[bool], bool]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -131,10 +131,10 @@ class Radar(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - points: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, dot: Optional[Union[Var[bool], bool]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill: Optional[Union[Var[str], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, legend_type: Optional[Union[Var[str], str]] = None, @@ -143,8 +143,8 @@ class Radar(Recharts): animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -225,22 +225,22 @@ class RadialBar(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, min_angle: Optional[Union[Var[int], int]] = None, legend_type: Optional[Union[Var[str], str]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, background: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_begin: Optional[Union[Var[int], int]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -305,21 +305,21 @@ class PolarAngleAxis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, radius: Optional[Union[Var[Union[int, str]], int, str]] = None, axis_line: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, axis_line_type: Optional[Union[Var[str], str]] = None, tick_line: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, tick: Optional[Union[Var[Union[int, str]], int, str]] = None, - ticks: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, + ticks: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, orient: Optional[Union[Var[str], str]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -403,12 +403,12 @@ class PolarGrid(Recharts): cy: Optional[Union[Var[Union[int, str]], int, str]] = None, inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, - polar_angles: Optional[Union[Var[List[int]], List[int]]] = None, - polar_radius: Optional[Union[Var[List[int]], List[int]]] = None, + polar_angles: Optional[Union[List[int], Var[List[int]]]] = None, + polar_radius: Optional[Union[List[int], Var[List[int]]]] = None, grid_type: Optional[ - Union[Var[Literal["polygon", "circle"]], Literal["polygon", "circle"]] + Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]] ] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -486,7 +486,7 @@ class PolarRadiusAxis(Recharts): *children, angle: Optional[Union[Var[int], int]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -494,52 +494,52 @@ class PolarRadiusAxis(Recharts): reversed: Optional[Union[Var[bool], bool]] = None, orientation: Optional[Union[Var[str], str]] = None, axis_line: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, tick: Optional[Union[Var[Union[int, str]], int, str]] = None, tick_count: Optional[Union[Var[int], int]] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - domain: Optional[Union[Var[List[int]], List[int]]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + domain: Optional[Union[List[int], Var[List[int]]]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/components/recharts/recharts.pyi b/reflex/components/recharts/recharts.pyi index 695ecab48..1f1937dc6 100644 --- a/reflex/components/recharts/recharts.pyi +++ b/reflex/components/recharts/recharts.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Recharts(Component): def render(self) -> Dict: ... diff --git a/reflex/components/sonner/toast.py b/reflex/components/sonner/toast.py index 07e18b156..c797d7f84 100644 --- a/reflex/components/sonner/toast.py +++ b/reflex/components/sonner/toast.py @@ -14,12 +14,12 @@ from reflex.event import ( EventSpec, call_script, ) -from reflex.ivars.base import LiteralVar from reflex.style import Style, resolved_color_mode from reflex.utils import format from reflex.utils.imports import ImportVar from reflex.utils.serializers import serialize, serializer -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var LiteralPosition = Literal[ "top-left", @@ -30,7 +30,7 @@ LiteralPosition = Literal[ "bottom-right", ] -toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False) +toast_ref = Var(_js_expr="refs['__toast']") class ToastAction(Base): @@ -66,9 +66,8 @@ def _toast_callback_signature(toast: Var) -> list[Var]: A function call stripping non-serializable members of the toast object. """ return [ - Var.create_safe( - f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {toast}; return rest}})()", - _var_is_string=False, + Var( + _js_expr=f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {str(toast)}; return rest}})()" ) ] @@ -76,6 +75,9 @@ def _toast_callback_signature(toast: Var) -> list[Var]: class ToastProps(PropsBase): """Props for the toast component.""" + # Toast's title, renders above the description. + title: Optional[Union[str, Var]] + # Toast's description, renders underneath the title. description: Optional[Union[str, Var]] @@ -169,12 +171,12 @@ class ToastProps(PropsBase): d["cancel"] = self.cancel if isinstance(self.cancel, dict): d["cancel"] = ToastAction(**self.cancel) - if "on_dismiss" in d: - d["on_dismiss"] = format.format_queue_events( + if "onDismiss" in d: + d["onDismiss"] = format.format_queue_events( self.on_dismiss, _toast_callback_signature ) - if "on_auto_close" in d: - d["on_auto_close"] = format.format_queue_events( + if "onAutoClose" in d: + d["onAutoClose"] = format.format_queue_events( self.on_auto_close, _toast_callback_signature ) return d @@ -245,10 +247,8 @@ class Toaster(Component): Returns: The hooks for the toaster component. """ - hook = Var.create_safe( - f"{toast_ref} = toast", - _var_is_local=True, - _var_is_string=False, + hook = Var( + _js_expr=f"{toast_ref} = toast", _var_data=VarData( imports={ "/utils/state": [ImportVar(tag="refs")], @@ -286,11 +286,11 @@ class Toaster(Component): else: toast = f"{toast_command}(`{message}`)" - toast_action = Var.create_safe(toast, _var_is_string=False, _var_is_local=True) + toast_action = Var(_js_expr=toast) return call_script(toast_action) @staticmethod - def toast_info(message: str, **kwargs): + def toast_info(message: str = "", **kwargs): """Display an info toast message. Args: @@ -303,7 +303,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="info", **kwargs) @staticmethod - def toast_warning(message: str, **kwargs): + def toast_warning(message: str = "", **kwargs): """Display a warning toast message. Args: @@ -316,7 +316,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="warning", **kwargs) @staticmethod - def toast_error(message: str, **kwargs): + def toast_error(message: str = "", **kwargs): """Display an error toast message. Args: @@ -329,7 +329,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="error", **kwargs) @staticmethod - def toast_success(message: str, **kwargs): + def toast_success(message: str = "", **kwargs): """Display a success toast message. Args: @@ -354,17 +354,14 @@ class Toaster(Component): dismiss_var_data = None if isinstance(id, Var): - dismiss = f"{toast_ref}.dismiss({id._var_name_unwrapped})" + dismiss = f"{toast_ref}.dismiss({str(id)})" dismiss_var_data = id._get_all_var_data() elif isinstance(id, str): dismiss = f"{toast_ref}.dismiss('{id}')" else: dismiss = f"{toast_ref}.dismiss()" - dismiss_action = Var.create_safe( - dismiss, - _var_is_string=False, - _var_is_local=True, - _var_data=VarData.merge(dismiss_var_data), + dismiss_action = Var( + _js_expr=dismiss, _var_data=VarData.merge(dismiss_var_data) ) return call_script(dismiss_action) diff --git a/reflex/components/sonner/toast.pyi b/reflex/components/sonner/toast.pyi index 8826e9df7..67f826164 100644 --- a/reflex/components/sonner/toast.pyi +++ b/reflex/components/sonner/toast.pyi @@ -12,7 +12,7 @@ from reflex.components.props import PropsBase from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.serializers import serializer -from reflex.vars import Var +from reflex.vars.base import Var LiteralPosition = Literal[ "top-left", @@ -22,7 +22,7 @@ LiteralPosition = Literal[ "bottom-center", "bottom-right", ] -toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False) +toast_ref = Var(_js_expr="refs['__toast']") class ToastAction(Base): label: str @@ -32,6 +32,7 @@ class ToastAction(Base): def serialize_action(action: ToastAction) -> dict: ... class ToastProps(PropsBase): + title: Optional[Union[str, Var]] description: Optional[Union[str, Var]] close_button: Optional[bool] invert: Optional[bool] @@ -65,13 +66,13 @@ class Toaster(Component): message: str = "", level: str | None = None, **props ) -> EventSpec: ... @staticmethod - def toast_info(message: str, **kwargs): ... + def toast_info(message: str = "", **kwargs): ... @staticmethod - def toast_warning(message: str, **kwargs): ... + def toast_warning(message: str = "", **kwargs): ... @staticmethod - def toast_error(message: str, **kwargs): ... + def toast_error(message: str = "", **kwargs): ... @staticmethod - def toast_success(message: str, **kwargs): ... + def toast_success(message: str = "", **kwargs): ... @staticmethod def toast_dismiss(id: Var | str | None = None): ... @overload @@ -85,24 +86,24 @@ class Toaster(Component): visible_toasts: Optional[Union[Var[int], int]] = None, position: Optional[ Union[ + Literal[ + "bottom-center", + "bottom-left", + "bottom-right", + "top-center", + "top-left", + "top-right", + ], Var[ Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", "bottom-center", + "bottom-left", "bottom-right", + "top-center", + "top-left", + "top-right", ] ], - Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", - "bottom-center", - "bottom-right", - ], ] ] = None, close_button: Optional[Union[Var[bool], bool]] = None, @@ -110,9 +111,9 @@ class Toaster(Component): dir: Optional[Union[Var[str], str]] = None, hotkey: Optional[Union[Var[str], str]] = None, invert: Optional[Union[Var[bool], bool]] = None, - toast_options: Optional[Union[Var[ToastProps], ToastProps]] = None, + toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None, gap: Optional[Union[Var[int], int]] = None, - loading_icon: Optional[Union[Var[Icon], Icon]] = None, + loading_icon: Optional[Union[Icon, Var[Icon]]] = None, pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/suneditor/editor.py b/reflex/components/suneditor/editor.py index 6e28b396a..6f5b6e4b4 100644 --- a/reflex/components/suneditor/editor.py +++ b/reflex/components/suneditor/editor.py @@ -10,7 +10,7 @@ from reflex.components.component import Component, NoSSRComponent from reflex.event import EventHandler from reflex.utils.format import to_camel_case from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): diff --git a/reflex/components/suneditor/editor.pyi b/reflex/components/suneditor/editor.pyi index b1bc8a830..8fb92b51a 100644 --- a/reflex/components/suneditor/editor.pyi +++ b/reflex/components/suneditor/editor.pyi @@ -11,7 +11,7 @@ from reflex.components.component import NoSSRComponent from reflex.event import EventHandler, EventSpec from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): BASIC = [["font", "fontSize"], ["fontColor"], ["horizontalRule"], ["link", "image"]] @@ -53,51 +53,51 @@ class Editor(NoSSRComponent): *children, lang: Optional[ Union[ + Literal[ + "ckb", + "da", + "de", + "en", + "es", + "fr", + "he", + "it", + "ja", + "ko", + "lv", + "pl", + "pt_br", + "ro", + "ru", + "se", + "ua", + "zh_cn", + ], Var[ Union[ Literal[ - "en", + "ckb", "da", "de", + "en", "es", "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", "he", "it", + "ja", + "ko", + "lv", + "pl", + "pt_br", + "ro", + "ru", + "se", + "ua", + "zh_cn", ], dict, ] ], - Literal[ - "en", - "da", - "de", - "es", - "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", - "he", - "it", - ], dict, ] ] = None, @@ -107,7 +107,7 @@ class Editor(NoSSRComponent): height: Optional[Union[Var[str], str]] = None, placeholder: Optional[Union[Var[str], str]] = None, auto_focus: Optional[Union[Var[bool], bool]] = None, - set_options: Optional[Union[Var[Dict], Dict]] = None, + set_options: Optional[Union[Dict, Var[Dict]]] = None, set_all_plugins: Optional[Union[Var[bool], bool]] = None, set_contents: Optional[Union[Var[str], str]] = None, append_contents: Optional[Union[Var[str], str]] = None, diff --git a/reflex/components/tags/cond_tag.py b/reflex/components/tags/cond_tag.py index 3143890c4..b4d0fe469 100644 --- a/reflex/components/tags/cond_tag.py +++ b/reflex/components/tags/cond_tag.py @@ -1,19 +1,21 @@ """Tag to conditionally render components.""" +import dataclasses from typing import Any, Dict, Optional from reflex.components.tags.tag import Tag -from reflex.vars import Var +from reflex.vars.base import Var +@dataclasses.dataclass() class CondTag(Tag): """A conditional tag.""" # The condition to determine which component to render. - cond: Var[Any] + cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True)) # The code to render if the condition is true. - true_value: Dict + true_value: Dict = dataclasses.field(default_factory=dict) # The code to render if the condition is false. - false_value: Optional[Dict] + false_value: Optional[Dict] = None diff --git a/reflex/components/tags/iter_tag.py b/reflex/components/tags/iter_tag.py index 0828f8b10..e998fc41a 100644 --- a/reflex/components/tags/iter_tag.py +++ b/reflex/components/tags/iter_tag.py @@ -2,31 +2,43 @@ from __future__ import annotations +import dataclasses import inspect -from typing import TYPE_CHECKING, Any, Callable, List, Tuple, Type, Union, get_args +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Iterable, + Tuple, + Type, + Union, + get_args, +) from reflex.components.tags.tag import Tag -from reflex.ivars.base import ImmutableVar -from reflex.vars import Var +from reflex.vars import LiteralArrayVar, Var, get_unique_variable_name if TYPE_CHECKING: from reflex.components.component import Component +@dataclasses.dataclass() class IterTag(Tag): """An iterator tag.""" # The var to iterate over. - iterable: Var[List] + iterable: Var[Iterable] = dataclasses.field( + default_factory=lambda: LiteralArrayVar.create([]) + ) # The component render function for each item in the iterable. - render_fn: Callable + render_fn: Callable = dataclasses.field(default_factory=lambda: lambda x: x) # The name of the arg var. - arg_var_name: str + arg_var_name: str = dataclasses.field(default_factory=get_unique_variable_name) # The name of the index var. - index_var_name: str + index_var_name: str = dataclasses.field(default_factory=get_unique_variable_name) def get_iterable_var_type(self) -> Type: """Get the type of the iterable var. @@ -34,15 +46,16 @@ class IterTag(Tag): Returns: The type of the iterable var. """ + iterable = self.iterable try: - if self.iterable._var_type.mro()[0] == dict: + if iterable._var_type.mro()[0] == dict: # Arg is a tuple of (key, value). - return Tuple[get_args(self.iterable._var_type)] # type: ignore - elif self.iterable._var_type.mro()[0] == tuple: + return Tuple[get_args(iterable._var_type)] # type: ignore + elif iterable._var_type.mro()[0] == tuple: # Arg is a union of any possible values in the tuple. - return Union[get_args(self.iterable._var_type)] # type: ignore + return Union[get_args(iterable._var_type)] # type: ignore else: - return get_args(self.iterable._var_type)[0] + return get_args(iterable._var_type)[0] except Exception: return Any @@ -54,8 +67,8 @@ class IterTag(Tag): Returns: The index var. """ - return ImmutableVar( - _var_name=self.index_var_name, + return Var( + _js_expr=self.index_var_name, _var_type=int, ).guess_type() @@ -67,8 +80,8 @@ class IterTag(Tag): Returns: The arg var. """ - return ImmutableVar( - _var_name=self.arg_var_name, + return Var( + _js_expr=self.arg_var_name, _var_type=self.get_iterable_var_type(), ).guess_type() @@ -80,8 +93,8 @@ class IterTag(Tag): Returns: The index var. """ - return ImmutableVar( - _var_name=self.index_var_name, + return Var( + _js_expr=self.index_var_name, _var_type=int, ).guess_type() @@ -93,8 +106,8 @@ class IterTag(Tag): Returns: The arg var. """ - return ImmutableVar( - _var_name=self.arg_var_name, + return Var( + _js_expr=self.arg_var_name, _var_type=self.get_iterable_var_type(), ).guess_type() diff --git a/reflex/components/tags/match_tag.py b/reflex/components/tags/match_tag.py index c2f6649d5..01eedb296 100644 --- a/reflex/components/tags/match_tag.py +++ b/reflex/components/tags/match_tag.py @@ -1,19 +1,21 @@ """Tag to conditionally match cases.""" +import dataclasses from typing import Any, List from reflex.components.tags.tag import Tag -from reflex.vars import Var +from reflex.vars.base import Var +@dataclasses.dataclass() class MatchTag(Tag): """A match tag.""" # The condition to determine which case to match. - cond: Var[Any] + cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True)) # The list of match cases to be matched. - match_cases: List[Any] + match_cases: List[Any] = dataclasses.field(default_factory=list) # The catchall case to match. - default: Any + default: Any = dataclasses.field(default=Var.create(None)) diff --git a/reflex/components/tags/tag.py b/reflex/components/tags/tag.py index 9a8cca11f..d577abc6e 100644 --- a/reflex/components/tags/tag.py +++ b/reflex/components/tags/tag.py @@ -2,23 +2,23 @@ from __future__ import annotations -from typing import Any, Dict, List, Optional, Set, Tuple, Union +import dataclasses +from typing import Any, Dict, List, Optional, Tuple, Union -from reflex.base import Base from reflex.event import EventChain -from reflex.ivars.base import LiteralVar from reflex.utils import format, types -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var -class Tag(Base): +@dataclasses.dataclass() +class Tag: """A React tag.""" # The name of the tag. name: str = "" # The props of the tag. - props: Dict[str, Any] = {} + props: Dict[str, Any] = dataclasses.field(default_factory=dict) # The inner contents of the tag. contents: str = "" @@ -27,25 +27,18 @@ class Tag(Base): args: Optional[Tuple[str, ...]] = None # Special props that aren't key value pairs. - special_props: Set[Var] = set() + special_props: List[Var] = dataclasses.field(default_factory=list) # The children components. - children: List[Any] = [] + children: List[Any] = dataclasses.field(default_factory=list) - def __init__(self, *args, **kwargs): - """Initialize the tag. - - Args: - *args: Args to initialize the tag. - **kwargs: Kwargs to initialize the tag. - """ - # Convert any props to vars. - if "props" in kwargs: - kwargs["props"] = { - name: LiteralVar.create(value) - for name, value in kwargs["props"].items() - } - super().__init__(*args, **kwargs) + def __post_init__(self): + """Post initialize the tag.""" + object.__setattr__( + self, + "props", + {name: LiteralVar.create(value) for name, value in self.props.items()}, + ) def format_props(self) -> List: """Format the tag's props. @@ -55,6 +48,29 @@ class Tag(Base): """ return format.format_props(*self.special_props, **self.props) + def set(self, **kwargs: Any): + """Set the tag's fields. + + Args: + kwargs: The fields to set. + + Returns: + The tag with the fields + """ + for name, value in kwargs.items(): + setattr(self, name, value) + + return self + + def __iter__(self): + """Iterate over the tag's fields. + + Yields: + Tuple[str, Any]: The field name and value. + """ + for field in dataclasses.fields(self): + yield field.name, getattr(self, field.name) + def add_props(self, **kwargs: Optional[Any]) -> Tag: """Add props to the tag. diff --git a/reflex/constants/base.py b/reflex/constants/base.py index a858a69b1..df64a1006 100644 --- a/reflex/constants/base.py +++ b/reflex/constants/base.py @@ -45,6 +45,8 @@ class Dirs(SimpleNamespace): REFLEX_JSON = "reflex.json" # The name of the postcss config file. POSTCSS_JS = "postcss.config.js" + # The name of the states directory. + STATES = "states" class Reflex(SimpleNamespace): @@ -103,7 +105,7 @@ class Templates(SimpleNamespace): # The reflex.build backend host REFLEX_BUILD_BACKEND = os.environ.get( - "REFLEX_BUILD_BACKEND", "https://rxh-prod-flexgen.fly.dev" + "REFLEX_BUILD_BACKEND", "https://flexgen-prod-flexgen.fly.dev" ) # The URL to redirect to reflex.build @@ -115,7 +117,9 @@ class Templates(SimpleNamespace): REFLEX_BUILD_POLL_URL = REFLEX_BUILD_BACKEND + "/api/init/{reflex_init_token}" # The URL to fetch the generation's reflex code - REFLEX_BUILD_CODE_URL = REFLEX_BUILD_BACKEND + "/api/gen/{generation_hash}" + REFLEX_BUILD_CODE_URL = ( + REFLEX_BUILD_BACKEND + "/api/gen/{generation_hash}/refactored" + ) class Dirs(SimpleNamespace): """Folders used by the template system of Reflex.""" diff --git a/reflex/constants/event.py b/reflex/constants/event.py index 351a1ac52..d454e6ea8 100644 --- a/reflex/constants/event.py +++ b/reflex/constants/event.py @@ -11,6 +11,7 @@ class Endpoint(Enum): EVENT = "_event" UPLOAD = "_upload" AUTH_CODESPACE = "auth-codespace" + HEALTH = "_health" def __str__(self) -> str: """Get the string representation of the endpoint. diff --git a/reflex/constants/installer.py b/reflex/constants/installer.py index 4a7027ee8..6f31b08f1 100644 --- a/reflex/constants/installer.py +++ b/reflex/constants/installer.py @@ -111,6 +111,7 @@ class PackageJson(SimpleNamespace): PATH = "package.json" DEPENDENCIES = { + "@babel/standalone": "7.25.3", "@emotion/react": "11.11.1", "axios": "1.6.0", "json5": "2.2.3", diff --git a/reflex/custom_components/custom_components.py b/reflex/custom_components/custom_components.py index a47de6feb..e6957f8fd 100644 --- a/reflex/custom_components/custom_components.py +++ b/reflex/custom_components/custom_components.py @@ -65,7 +65,9 @@ def _create_package_config(module_name: str, package_name: str): with open(CustomComponents.PYPROJECT_TOML, "w") as f: f.write( templates.CUSTOM_COMPONENTS_PYPROJECT_TOML.render( - module_name=module_name, package_name=package_name + module_name=module_name, + package_name=package_name, + reflex_version=constants.Reflex.VERSION, ) ) diff --git a/reflex/event.py b/reflex/event.py index 6d0577c6f..fe3a6bfb4 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -2,7 +2,9 @@ from __future__ import annotations +import dataclasses import inspect +import types import urllib.parse from base64 import b64encode from typing import ( @@ -17,13 +19,13 @@ from typing import ( ) from reflex import constants -from reflex.base import Base -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.ivars.function import FunctionStringVar, FunctionVar -from reflex.ivars.object import ObjectVar from reflex.utils import format +from reflex.utils.exceptions import EventFnArgMismatch, EventHandlerArgMismatch from reflex.utils.types import ArgsSpec -from reflex.vars import ImmutableVarData, Var +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionStringVar, FunctionVar +from reflex.vars.object import ObjectVar try: from typing import Annotated @@ -31,7 +33,11 @@ except ImportError: from typing_extensions import Annotated -class Event(Base): +@dataclasses.dataclass( + init=True, + frozen=True, +) +class Event: """An event that describes any state change in the app.""" # The token to specify the client that the event is for. @@ -41,10 +47,10 @@ class Event(Base): name: str # The routing data where event occurred - router_data: Dict[str, Any] = {} + router_data: Dict[str, Any] = dataclasses.field(default_factory=dict) # The event payload. - payload: Dict[str, Any] = {} + payload: Dict[str, Any] = dataclasses.field(default_factory=dict) @property def substate_token(self) -> str: @@ -79,11 +85,15 @@ def background(fn): return fn -class EventActionsMixin(Base): +@dataclasses.dataclass( + init=True, + frozen=True, +) +class EventActionsMixin: """Mixin for DOM event actions.""" # Whether to `preventDefault` or `stopPropagation` on the event. - event_actions: Dict[str, Union[bool, int]] = {} + event_actions: Dict[str, Union[bool, int]] = dataclasses.field(default_factory=dict) @property def stop_propagation(self): @@ -92,8 +102,9 @@ class EventActionsMixin(Base): Returns: New EventHandler-like with stopPropagation set to True. """ - return self.copy( - update={"event_actions": {"stopPropagation": True, **self.event_actions}}, + return dataclasses.replace( + self, + event_actions={"stopPropagation": True, **self.event_actions}, ) @property @@ -103,8 +114,9 @@ class EventActionsMixin(Base): Returns: New EventHandler-like with preventDefault set to True. """ - return self.copy( - update={"event_actions": {"preventDefault": True, **self.event_actions}}, + return dataclasses.replace( + self, + event_actions={"preventDefault": True, **self.event_actions}, ) def throttle(self, limit_ms: int): @@ -116,8 +128,9 @@ class EventActionsMixin(Base): Returns: New EventHandler-like with throttle set to limit_ms. """ - return self.copy( - update={"event_actions": {"throttle": limit_ms, **self.event_actions}}, + return dataclasses.replace( + self, + event_actions={"throttle": limit_ms, **self.event_actions}, ) def debounce(self, delay_ms: int): @@ -129,26 +142,25 @@ class EventActionsMixin(Base): Returns: New EventHandler-like with debounce set to delay_ms. """ - return self.copy( - update={"event_actions": {"debounce": delay_ms, **self.event_actions}}, + return dataclasses.replace( + self, + event_actions={"debounce": delay_ms, **self.event_actions}, ) +@dataclasses.dataclass( + init=True, + frozen=True, +) class EventHandler(EventActionsMixin): """An event handler responds to an event to update the state.""" # The function to call in response to the event. - fn: Any + fn: Any = dataclasses.field(default=None) # The full name of the state class this event handler is attached to. # Empty string means this event handler is a server side event. - state_full_name: str = "" - - class Config: - """The Pydantic config.""" - - # Needed to allow serialization of Callable. - frozen = True + state_full_name: str = dataclasses.field(default="") @classmethod def __class_getitem__(cls, args_spec: str) -> Annotated: @@ -189,7 +201,7 @@ class EventHandler(EventActionsMixin): # Get the function args. fn_args = inspect.getfullargspec(self.fn).args[1:] - fn_args = (ImmutableVar.create_safe(arg) for arg in fn_args) + fn_args = (Var(_js_expr=arg) for arg in fn_args) # Construct the payload. values = [] @@ -205,7 +217,7 @@ class EventHandler(EventActionsMixin): raise EventHandlerTypeError( f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." ) from e - payload = tuple(zip(fn_args, values)) + payload = tuple(zip(fn_args, values, strict=False)) # Return the event spec. return EventSpec( @@ -213,6 +225,10 @@ class EventHandler(EventActionsMixin): ) +@dataclasses.dataclass( + init=True, + frozen=True, +) class EventSpec(EventActionsMixin): """An event specification. @@ -221,19 +237,35 @@ class EventSpec(EventActionsMixin): """ # The event handler. - handler: EventHandler + handler: EventHandler = dataclasses.field(default=None) # type: ignore # The handler on the client to process event. - client_handler_name: str = "" + client_handler_name: str = dataclasses.field(default="") # The arguments to pass to the function. - args: Tuple[Tuple[Var, Var], ...] = () + args: Tuple[Tuple[Var, Var], ...] = dataclasses.field(default_factory=tuple) - class Config: - """The Pydantic config.""" + def __init__( + self, + handler: EventHandler, + event_actions: Dict[str, Union[bool, int]] | None = None, + client_handler_name: str = "", + args: Tuple[Tuple[Var, Var], ...] = tuple(), + ): + """Initialize an EventSpec. - # Required to allow tuple fields. - frozen = True + Args: + event_actions: The event actions. + handler: The event handler. + client_handler_name: The client handler name. + args: The arguments to pass to the function. + """ + if event_actions is None: + event_actions = {} + object.__setattr__(self, "event_actions", event_actions) + object.__setattr__(self, "handler", handler) + object.__setattr__(self, "client_handler_name", client_handler_name) + object.__setattr__(self, "args", args or tuple()) def with_args(self, args: Tuple[Tuple[Var, Var], ...]) -> EventSpec: """Copy the event spec, with updated args. @@ -267,7 +299,7 @@ class EventSpec(EventActionsMixin): # Get the remaining unfilled function args. fn_args = inspect.getfullargspec(self.handler.fn).args[1 + len(self.args) :] - fn_args = (ImmutableVar.create_safe(arg) for arg in fn_args) + fn_args = (Var(_js_expr=arg) for arg in fn_args) # Construct the payload. values = [] @@ -278,10 +310,13 @@ class EventSpec(EventActionsMixin): raise EventHandlerTypeError( f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." ) from e - new_payload = tuple(zip(fn_args, values)) + new_payload = tuple(zip(fn_args, values, strict=False)) return self.with_args(self.args + new_payload) +@dataclasses.dataclass( + frozen=True, +) class CallableEventSpec(EventSpec): """Decorate an EventSpec-returning function to act as both a EventSpec and a function. @@ -301,10 +336,13 @@ class CallableEventSpec(EventSpec): if fn is not None: default_event_spec = fn() super().__init__( - fn=fn, # type: ignore - **default_event_spec.dict(), + event_actions=default_event_spec.event_actions, + client_handler_name=default_event_spec.client_handler_name, + args=default_event_spec.args, + handler=default_event_spec.handler, **kwargs, ) + object.__setattr__(self, "fn", fn) else: super().__init__(**kwargs) @@ -328,12 +366,16 @@ class CallableEventSpec(EventSpec): return self.fn(*args, **kwargs) +@dataclasses.dataclass( + init=True, + frozen=True, +) class EventChain(EventActionsMixin): """Container for a chain of events that will be executed in order.""" - events: List[EventSpec] + events: List[EventSpec] = dataclasses.field(default_factory=list) - args_spec: Optional[Callable] + args_spec: Optional[Callable] = dataclasses.field(default=None) # These chains can be used for their side effects when no other events are desired. @@ -341,14 +383,22 @@ stop_propagation = EventChain(events=[], args_spec=lambda: []).stop_propagation prevent_default = EventChain(events=[], args_spec=lambda: []).prevent_default -class Target(Base): +@dataclasses.dataclass( + init=True, + frozen=True, +) +class Target: """A Javascript event target.""" checked: bool = False value: Any = None -class FrontendEvent(Base): +@dataclasses.dataclass( + init=True, + frozen=True, +) +class FrontendEvent: """A Javascript event.""" target: Target = Target() @@ -356,7 +406,11 @@ class FrontendEvent(Base): value: Any = None -class FileUpload(Base): +@dataclasses.dataclass( + init=True, + frozen=True, +) +class FileUpload: """Class to represent a file upload.""" upload_id: Optional[str] = None @@ -391,15 +445,15 @@ class FileUpload(Base): upload_id = self.upload_id or DEFAULT_UPLOAD_ID spec_args = [ ( - ImmutableVar.create_safe("files"), - ImmutableVar( - _var_name="filesById", + Var(_js_expr="files"), + Var( + _js_expr="filesById", _var_type=Dict[str, Any], - _var_data=ImmutableVarData.merge(upload_files_context_var_data), + _var_data=VarData.merge(upload_files_context_var_data), ).to(ObjectVar)[LiteralVar.create(upload_id)], ), ( - ImmutableVar.create_safe("upload_id"), + Var(_js_expr="upload_id"), LiteralVar.create(upload_id), ), ] @@ -428,7 +482,7 @@ class FileUpload(Base): formatted_chain = str(format.format_prop(on_upload_progress_chain)) spec_args.append( ( - ImmutableVar.create_safe("on_upload_progress"), + Var(_js_expr="on_upload_progress"), FunctionStringVar( formatted_chain.strip("{}"), ).to(FunctionVar, EventChain), @@ -468,7 +522,7 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec: handler=EventHandler(fn=fn), args=tuple( ( - ImmutableVar.create_safe(k), + Var(_js_expr=k), LiteralVar.create(v), ) for k, v in kwargs.items() @@ -715,14 +769,14 @@ def download( elif isinstance(data, Var): # Need to check on the frontend if the Var already looks like a data: URI. - is_data_url = (data._type() == "string") & ( + is_data_url = (data.js_type() == "string") & ( data.to(str).startswith("data:") ) # type: ignore # If it's a data: URI, use it as is, otherwise convert the Var to JSON in a data: URI. url = cond( # type: ignore is_data_url, - data, + data.to(str), "data:text/plain," + data.to_string(), # type: ignore ) elif isinstance(data, bytes): @@ -831,7 +885,7 @@ def call_event_handler( arg_spec: The lambda that define the argument(s) to pass to the event handler. Raises: - ValueError: if number of arguments expected by event_handler doesn't match the spec. + EventHandlerArgMismatch: if number of arguments expected by event_handler doesn't match the spec. Returns: The event spec from calling the event handler. @@ -843,13 +897,16 @@ def call_event_handler( return event_handler.add_args(*parsed_args) args = inspect.getfullargspec(event_handler.fn).args - if len(args) == len(["self", *parsed_args]): + n_args = len(args) - 1 # subtract 1 for bound self arg + if n_args == len(parsed_args): return event_handler(*parsed_args) # type: ignore else: - source = inspect.getsource(arg_spec) # type: ignore - raise ValueError( - f"number of arguments in {event_handler.fn.__qualname__} " - f"doesn't match the definition of the event trigger '{source.strip().strip(',')}'" + raise EventHandlerArgMismatch( + "The number of arguments accepted by " + f"{event_handler.fn.__qualname__} ({n_args}) " + "does not match the arguments passed by the event trigger: " + f"{[str(v) for v in parsed_args]}\n" + "See https://reflex.dev/docs/events/event-arguments/" ) @@ -866,66 +923,66 @@ def parse_args_spec(arg_spec: ArgsSpec): annotations = get_type_hints(arg_spec) return arg_spec( *[ - ImmutableVar(f"_{l_arg}").to( - ObjectVar, annotations.get(l_arg, FrontendEvent) - ) + Var(f"_{l_arg}").to(annotations.get(l_arg, FrontendEvent)) for l_arg in spec.args ] ) -def call_event_fn(fn: Callable, arg: Union[Var, ArgsSpec]) -> list[EventSpec] | Var: +def call_event_fn(fn: Callable, arg_spec: ArgsSpec) -> list[EventSpec] | Var: """Call a function to a list of event specs. The function should return a single EventSpec, a list of EventSpecs, or a - single Var. If the function takes in an arg, the arg will be passed to the - function. Otherwise, the function will be called with no args. + single Var. The function signature must match the passed arg_spec or + EventFnArgsMismatch will be raised. Args: fn: The function to call. - arg: The argument to pass to the function. + arg_spec: The argument spec for the event trigger. Returns: The event specs from calling the function or a Var. Raises: - EventHandlerValueError: If the lambda has an invalid signature. + EventFnArgMismatch: If the function signature doesn't match the arg spec. + EventHandlerValueError: If the lambda returns an unusable value. """ # Import here to avoid circular imports. from reflex.event import EventHandler, EventSpec from reflex.utils.exceptions import EventHandlerValueError - # Get the args of the lambda. - args = inspect.getfullargspec(fn).args + # Check that fn signature matches arg_spec + fn_args = inspect.getfullargspec(fn).args + n_fn_args = len(fn_args) + if isinstance(fn, types.MethodType): + n_fn_args -= 1 # subtract 1 for bound self arg + parsed_args = parse_args_spec(arg_spec) + if len(parsed_args) != n_fn_args: + raise EventFnArgMismatch( + "The number of arguments accepted by " + f"{fn} ({n_fn_args}) " + "does not match the arguments passed by the event trigger: " + f"{[str(v) for v in parsed_args]}\n" + "See https://reflex.dev/docs/events/event-arguments/" + ) - if isinstance(arg, ArgsSpec): - out = fn(*parse_args_spec(arg)) # type: ignore - else: - # Call the lambda. - if len(args) == 0: - out = fn() - elif len(args) == 1: - out = fn(arg) - else: - raise EventHandlerValueError(f"Lambda {fn} must have 0 or 1 arguments.") + # Call the function with the parsed args. + out = fn(*parsed_args) # If the function returns a Var, assume it's an EventChain and render it directly. if isinstance(out, Var): return out # Convert the output to a list. - if not isinstance(out, List): + if not isinstance(out, list): out = [out] # Convert any event specs to event specs. events = [] for e in out: - # Convert handlers to event specs. if isinstance(e, EventHandler): - if len(args) == 0: - e = e() - elif len(args) == 1: - e = e(arg) # type: ignore + # An un-called EventHandler gets all of the args of the event trigger. + e = call_event_handler(e, arg_spec) # Make sure the event spec is valid. if not isinstance(e, EventSpec): @@ -940,7 +997,9 @@ def call_event_fn(fn: Callable, arg: Union[Var, ArgsSpec]) -> list[EventSpec] | return events -def get_handler_args(event_spec: EventSpec) -> tuple[tuple[Var, Var], ...]: +def get_handler_args( + event_spec: EventSpec, +) -> tuple[tuple[Var, Var], ...]: """Get the handler args for the given event spec. Args: @@ -991,7 +1050,7 @@ def fix_events( e = e() assert isinstance(e, EventSpec), f"Unexpected event type, {type(e)}." name = format.format_event_handler(e.handler) - payload = {k._var_name: v._decode() for k, v in e.args} # type: ignore + payload = {k._js_expr: v._decode() for k, v in e.args} # type: ignore # Filter router_data to reduce payload size event_router_data = { diff --git a/reflex/experimental/__init__.py b/reflex/experimental/__init__.py index f0eca0c84..0c11deb85 100644 --- a/reflex/experimental/__init__.py +++ b/reflex/experimental/__init__.py @@ -32,18 +32,39 @@ class ExperimentalNamespace(SimpleNamespace): Returns: The toast namespace. """ - if "toast" not in _EMITTED_PROMOTION_WARNINGS: - _EMITTED_PROMOTION_WARNINGS.add("toast") - warn(f"`rx._x.toast` was promoted to `rx.toast`.") + self.register_component_warning("toast") return toast + @property + def progress(self): + """Temporary property returning the toast namespace. + + Remove this property when toast is fully promoted. + + Returns: + The toast namespace. + """ + self.register_component_warning("progress") + return progress + + @staticmethod + def register_component_warning(component_name: str): + """Add component to emitted warnings and throw a warning if it + doesn't exist. + + Args: + component_name: name of the component. + """ + if component_name not in _EMITTED_PROMOTION_WARNINGS: + _EMITTED_PROMOTION_WARNINGS.add(component_name) + warn(f"`rx._x.{component_name}` was promoted to `rx.{component_name}`.") + _x = ExperimentalNamespace( asset=asset, client_state=ClientStateVar.create, hooks=hooks, layout=layout, - progress=progress, PropsBase=PropsBase, run_in_thread=run_in_thread, ) diff --git a/reflex/experimental/client_state.py b/reflex/experimental/client_state.py index af3056c4d..9601ca58b 100644 --- a/reflex/experimental/client_state.py +++ b/reflex/experimental/client_state.py @@ -4,14 +4,17 @@ from __future__ import annotations import dataclasses import sys -from typing import Any, Callable, Optional, Type, Union +from typing import Any, Callable, Union from reflex import constants from reflex.event import EventChain, EventHandler, EventSpec, call_script -from reflex.ivars.base import ImmutableVar, LiteralVar -from reflex.ivars.function import FunctionVar from reflex.utils.imports import ImportVar -from reflex.vars import ImmutableVarData, Var, VarData, get_unique_variable_name +from reflex.vars import ( + VarData, + get_unique_variable_name, +) +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionVar NoValue = object() @@ -35,36 +38,19 @@ def _client_state_ref(var_name: str) -> str: @dataclasses.dataclass( eq=False, + frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) class ClientStateVar(Var): """A Var that exists on the client via useState.""" - # The name of the var. - _var_name: str = dataclasses.field() - # Track the names of the getters and setters - _setter_name: str = dataclasses.field() - _getter_name: str = dataclasses.field() + _setter_name: str = dataclasses.field(default="") + _getter_name: str = dataclasses.field(default="") # Whether to add the var and setter to the global `refs` object for use in any Component. _global_ref: bool = dataclasses.field(default=True) - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - def __hash__(self) -> int: """Define a hash function for a var. @@ -72,7 +58,7 @@ class ClientStateVar(Var): The hash of the var. """ return hash( - (self._var_name, str(self._var_type), self._getter_name, self._setter_name) + (self._js_expr, str(self._var_type), self._getter_name, self._setter_name) ) @classmethod @@ -111,16 +97,14 @@ class ClientStateVar(Var): var_name = get_unique_variable_name() assert isinstance(var_name, str), "var_name must be a string." if default is NoValue: - default_var = ImmutableVar.create_safe( - "", _var_is_local=False, _var_is_string=False - ) + default_var = Var(_js_expr="") elif not isinstance(default, Var): default_var = LiteralVar.create(default) else: default_var = default setter_name = f"set{var_name.capitalize()}" hooks = { - f"const [{var_name}, {setter_name}] = useState({default_var._var_name_unwrapped})": None, + f"const [{var_name}, {setter_name}] = useState({str(default_var)})": None, } imports = { "react": [ImportVar(tag="useState")], @@ -130,16 +114,14 @@ class ClientStateVar(Var): hooks[f"{_client_state_ref(setter_name)} = {setter_name}"] = None imports.update(_refs_import) return cls( - _var_name="", + _js_expr="", _setter_name=setter_name, _getter_name=var_name, _global_ref=global_ref, - _var_is_local=False, - _var_is_string=False, _var_type=default_var._var_type, _var_data=VarData.merge( default_var._var_data, - VarData( # type: ignore + VarData( hooks=hooks, imports=imports, ), @@ -158,10 +140,12 @@ class ClientStateVar(Var): an accessor for the client state variable. """ return ( - ImmutableVar.create_safe( - _client_state_ref(self._getter_name) - if self._global_ref - else self._getter_name + Var( + _js_expr=( + _client_state_ref(self._getter_name) + if self._global_ref + else self._getter_name + ) ) .to(self._var_type) ._replace( @@ -190,18 +174,18 @@ class ClientStateVar(Var): else self._setter_name ) if value is not NoValue: + import re + # This is a hack to make it work like an EventSpec taking an arg - value = LiteralVar.create(value) - if not value._var_is_string and value._var_full_name.startswith("_"): - arg = value._var_name_unwrapped.partition(".")[0] - else: - arg = "" - setter = f"({arg}) => {setter}({value._var_name_unwrapped})" - return ImmutableVar( - _var_name=setter, - _var_data=ImmutableVarData( - imports=_refs_import if self._global_ref else {} - ), + value_str = str(LiteralVar.create(value)) + + # remove patterns of ["*"] from the value_str using regex + arg = re.sub(r"\[\".*\"\]", "", value_str) + + setter = f"({arg}) => {setter}({str(value)})" + return Var( + _js_expr=setter, + _var_data=VarData(imports=_refs_import if self._global_ref else {}), ).to(FunctionVar, EventChain) @property diff --git a/reflex/experimental/hooks.py b/reflex/experimental/hooks.py index 848ad7fb7..7d648225a 100644 --- a/reflex/experimental/hooks.py +++ b/reflex/experimental/hooks.py @@ -3,7 +3,8 @@ from __future__ import annotations from reflex.utils.imports import ImportVar -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import Var def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]: @@ -21,10 +22,8 @@ def const(name, value) -> Var: The constant Var. """ if isinstance(name, list): - return Var.create_safe( - f"const [{', '.join(name)}] = {value}", _var_is_string=False - ) - return Var.create_safe(f"const {name} = {value}", _var_is_string=False) + return Var(_js_expr=f"const [{', '.join(name)}] = {value}") + return Var(_js_expr=f"const {name} = {value}") def useCallback(func, deps) -> Var: @@ -37,9 +36,8 @@ def useCallback(func, deps) -> Var: Returns: The useCallback hook. """ - return Var.create_safe( - f"useCallback({func}, {deps})" if deps else f"useCallback({func})", - _var_is_string=False, + return Var( + _js_expr=f"useCallback({func}, {deps})" if deps else f"useCallback({func})", _var_data=VarData(imports=_compose_react_imports(["useCallback"])), ) @@ -53,9 +51,8 @@ def useContext(context) -> Var: Returns: The useContext hook. """ - return Var.create_safe( - f"useContext({context})", - _var_is_string=False, + return Var( + _js_expr=f"useContext({context})", _var_data=VarData(imports=_compose_react_imports(["useContext"])), ) @@ -69,9 +66,8 @@ def useRef(default) -> Var: Returns: The useRef hook. """ - return Var.create_safe( - f"useRef({default})", - _var_is_string=False, + return Var( + _js_expr=f"useRef({default})", _var_data=VarData(imports=_compose_react_imports(["useRef"])), ) @@ -88,9 +84,8 @@ def useState(var_name, default=None) -> Var: """ return const( [var_name, f"set{var_name.capitalize()}"], - Var.create_safe( - f"useState({default})", - _var_is_string=False, + Var( + _js_expr=f"useState({default})", _var_data=VarData(imports=_compose_react_imports(["useState"])), ), ) diff --git a/reflex/experimental/layout.py b/reflex/experimental/layout.py index cf39ccb6c..a3b76581a 100644 --- a/reflex/experimental/layout.py +++ b/reflex/experimental/layout.py @@ -16,7 +16,7 @@ from reflex.event import call_script from reflex.experimental import hooks from reflex.state import ComponentState from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Sidebar(Box, MemoizationLeaf): @@ -55,7 +55,7 @@ class Sidebar(Box, MemoizationLeaf): open = ( self.State.open # type: ignore if self.State - else Var.create_safe("open", _var_is_string=False) + else Var(_js_expr="open") ) sidebar.style["display"] = spacer.style["display"] = cond(open, "block", "none") @@ -172,8 +172,8 @@ class SidebarTrigger(Fragment): open, toggle = sidebar.State.open, sidebar.State.toggle # type: ignore else: open, toggle = ( - Var.create_safe("open", _var_is_string=False), - call_script(Var.create_safe("setOpen(!open)", _var_is_string=False)), + Var(_js_expr="open"), + call_script(Var(_js_expr="setOpen(!open)")), ) trigger_props["left"] = cond(open, f"calc({sidebar_width} - 32px)", "0") diff --git a/reflex/experimental/layout.pyi b/reflex/experimental/layout.pyi index 8799b4961..d9b576eeb 100644 --- a/reflex/experimental/layout.pyi +++ b/reflex/experimental/layout.pyi @@ -13,7 +13,7 @@ from reflex.components.radix.themes.layout.box import Box from reflex.event import EventHandler, EventSpec from reflex.state import ComponentState from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class Sidebar(Box, MemoizationLeaf): @overload @@ -21,30 +21,30 @@ class Sidebar(Box, MemoizationLeaf): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -124,8 +124,8 @@ class DrawerSidebar(DrawerRoot): modal: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, @@ -262,30 +262,30 @@ class Layout(Box): cls, *children, sidebar: Optional[Component] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -350,30 +350,30 @@ class LayoutNamespace(ComponentNamespace): def __call__( *children, sidebar: Optional[Component] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, diff --git a/reflex/ivars/base.py b/reflex/ivars/base.py deleted file mode 100644 index 3ccbb5393..000000000 --- a/reflex/ivars/base.py +++ /dev/null @@ -1,1798 +0,0 @@ -"""Collection of base classes.""" - -from __future__ import annotations - -import contextlib -import dataclasses -import datetime -import dis -import functools -import inspect -import json -import sys -import warnings -from types import CodeType, FunctionType -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Generic, - List, - Literal, - Optional, - Sequence, - Set, - Tuple, - Type, - TypeVar, - Union, - cast, - get_args, - overload, -) - -from typing_extensions import ParamSpec, get_origin, get_type_hints, override - -from reflex import constants -from reflex.base import Base -from reflex.constants.colors import Color -from reflex.utils import console, imports, serializers, types -from reflex.utils.exceptions import VarDependencyError, VarTypeError, VarValueError -from reflex.utils.format import format_state_name -from reflex.vars import ( - ComputedVar, - ImmutableVarData, - Var, - VarData, - _decode_var_immutable, - _extract_var_data, - _global_vars, -) - -if TYPE_CHECKING: - from reflex.state import BaseState - - from .function import FunctionVar, ToFunctionOperation - from .number import ( - BooleanVar, - NumberVar, - ToBooleanVarOperation, - ToNumberVarOperation, - ) - from .object import ObjectVar, ToObjectOperation - from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation - - -VAR_TYPE = TypeVar("VAR_TYPE") - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ImmutableVar(Var, Generic[VAR_TYPE]): - """Base class for immutable vars.""" - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: types.GenericType = dataclasses.field(default=Any) - - # Extra metadata associated with the Var - _var_data: Optional[ImmutableVarData] = dataclasses.field(default=None) - - def __str__(self) -> str: - """String representation of the var. Guaranteed to be a valid Javascript expression. - - Returns: - The name of the var. - """ - return self._var_name - - @property - def _var_is_local(self) -> bool: - """Whether this is a local javascript variable. - - Returns: - False - """ - return False - - @property - def _var_is_string(self) -> bool: - """Whether the var is a string literal. - - Returns: - False - """ - return False - - @property - def _var_full_name_needs_state_prefix(self) -> bool: - """Whether the full name of the var needs a _var_state prefix. - - Returns: - False - """ - return False - - def __post_init__(self): - """Post-initialize the var.""" - # Decode any inline Var markup and apply it to the instance - _var_data, _var_name = _decode_var_immutable(self._var_name) - - if _var_data or _var_name != self._var_name: - self.__init__( - _var_name=_var_name, - _var_type=self._var_type, - _var_data=ImmutableVarData.merge(self._var_data, _var_data), - ) - - def __hash__(self) -> int: - """Define a hash function for the var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, self._var_type, self._var_data)) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return self._var_data - - def _replace(self, merge_var_data=None, **kwargs: Any): - """Make a copy of this Var with updated fields. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - A new ImmutableVar with the updated fields overwriting the corresponding fields in this Var. - - Raises: - TypeError: If _var_is_local, _var_is_string, or _var_full_name_needs_state_prefix is not None. - """ - if kwargs.get("_var_is_local", False) is not False: - raise TypeError( - "The _var_is_local argument is not supported for ImmutableVar." - ) - - if kwargs.get("_var_is_string", False) is not False: - raise TypeError( - "The _var_is_string argument is not supported for ImmutableVar." - ) - - if kwargs.get("_var_full_name_needs_state_prefix", False) is not False: - raise TypeError( - "The _var_full_name_needs_state_prefix argument is not supported for ImmutableVar." - ) - - return dataclasses.replace( - self, - _var_data=ImmutableVarData.merge( - kwargs.get("_var_data", self._var_data), merge_var_data - ), - **kwargs, - ) - - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool | None = None, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> ImmutableVar | Var | None: - """Create a var from a value. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. Deprecated. - _var_is_string: Whether the var is a string literal. Deprecated. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - VarTypeError: If the value is JSON-unserializable. - TypeError: If _var_is_local or _var_is_string is not None. - """ - if _var_is_local is not None: - raise TypeError( - "The _var_is_local argument is not supported for ImmutableVar." - ) - - if _var_is_string is not None: - raise TypeError( - "The _var_is_string argument is not supported for ImmutableVar." - ) - - from reflex.utils import format - - # Check for none values. - if value is None: - return None - - # If the value is already a var, do nothing. - if isinstance(value, Var): - return value - - # Try to pull the imports and hooks from contained values. - if not isinstance(value, str): - _var_data = VarData.merge(*_extract_var_data(value), _var_data) - - # Try to serialize the value. - type_ = type(value) - if type_ in types.JSONType: - name = value - else: - name, _serialized_type = serializers.serialize(value, get_type=True) - if name is None: - raise VarTypeError( - f"No JSON serializer found for var {value} of type {type_}." - ) - name = name if isinstance(name, str) else format.json_dumps(name) - - return cls( - _var_name=name, - _var_type=type_, - _var_data=( - ImmutableVarData( - state=_var_data.state, - imports=_var_data.imports, - hooks=_var_data.hooks, - ) - if _var_data - else None - ), - ) - - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool | None = None, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Var | ImmutableVar: - """Create a var from a value, asserting that it is not None. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. Deprecated. - _var_is_string: Whether the var is a string literal. Deprecated. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - var = cls.create( - value, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - _var_data=_var_data, - ) - assert var is not None - return var - - def __format__(self, format_spec: str) -> str: - """Format the var into a Javascript equivalent to an f-string. - - Args: - format_spec: The format specifier (Ignored for now). - - Returns: - The formatted var. - """ - hashed_var = hash(self) - - _global_vars[hashed_var] = self - - # Encode the _var_data into the formatted output for tracking purposes. - return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._var_name}" - - @overload - def to( - self, output: Type[NumberVar], var_type: type[int] | type[float] = float - ) -> ToNumberVarOperation: ... - - @overload - def to(self, output: Type[BooleanVar]) -> ToBooleanVarOperation: ... - - @overload - def to( - self, - output: Type[ArrayVar], - var_type: type[list] | type[tuple] | type[set] = list, - ) -> ToArrayOperation: ... - - @overload - def to(self, output: Type[StringVar]) -> ToStringOperation: ... - - @overload - def to( - self, output: Type[ObjectVar], var_type: types.GenericType = dict - ) -> ToObjectOperation: ... - - @overload - def to( - self, output: Type[FunctionVar], var_type: Type[Callable] = Callable - ) -> ToFunctionOperation: ... - - @overload - def to( - self, - output: Type[OUTPUT] | types.GenericType, - var_type: types.GenericType | None = None, - ) -> OUTPUT: ... - - def to( - self, - output: Type[OUTPUT] | types.GenericType, - var_type: types.GenericType | None = None, - ) -> Var: - """Convert the var to a different type. - - Args: - output: The output type. - var_type: The type of the var. - - Raises: - TypeError: If the var_type is not a supported type for the output. - - Returns: - The converted var. - """ - from .function import FunctionVar, ToFunctionOperation - from .number import ( - BooleanVar, - NumberVar, - ToBooleanVarOperation, - ToNumberVarOperation, - ) - from .object import ObjectVar, ToObjectOperation - from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation - - base_type = var_type - if types.is_optional(base_type): - base_type = types.get_args(base_type)[0] - - fixed_type = get_origin(base_type) or base_type - - fixed_output_type = get_origin(output) or output - - # If the first argument is a python type, we map it to the corresponding Var type. - if fixed_output_type is dict: - return self.to(ObjectVar, output) - if fixed_output_type in (list, tuple, set): - return self.to(ArrayVar, output) - if fixed_output_type in (int, float): - return self.to(NumberVar, output) - if fixed_output_type is str: - return self.to(StringVar, output) - if fixed_output_type is bool: - return self.to(BooleanVar, output) - - if issubclass(output, NumberVar): - if fixed_type is not None and not issubclass(fixed_type, (int, float)): - raise TypeError( - f"Unsupported type {var_type} for NumberVar. Must be int or float." - ) - return ToNumberVarOperation.create(self, var_type or float) - - if issubclass(output, BooleanVar): - return ToBooleanVarOperation.create(self) - - if issubclass(output, ArrayVar): - if fixed_type is not None and not issubclass( - fixed_type, (list, tuple, set) - ): - raise TypeError( - f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set." - ) - return ToArrayOperation.create(self, var_type or list) - - if issubclass(output, StringVar): - return ToStringOperation.create(self) - - if issubclass(output, (ObjectVar, Base)): - return ToObjectOperation.create(self, var_type or dict) - - if issubclass(output, FunctionVar): - # if fixed_type is not None and not issubclass(fixed_type, Callable): - # raise TypeError( - # f"Unsupported type {var_type} for FunctionVar. Must be Callable." - # ) - return ToFunctionOperation.create(self, var_type or Callable) - - # If we can't determine the first argument, we just replace the _var_type. - if not issubclass(output, Var) or var_type is None: - return dataclasses.replace( - self, - _var_type=output, - ) - - # We couldn't determine the output type to be any other Var type, so we replace the _var_type. - if var_type is not None: - return dataclasses.replace( - self, - _var_type=var_type, - ) - - return self - - def guess_type(self) -> ImmutableVar: - """Guesses the type of the variable based on its `_var_type` attribute. - - Returns: - ImmutableVar: The guessed type of the variable. - - Raises: - TypeError: If the type is not supported for guessing. - """ - from .number import NumberVar - from .object import ObjectVar - from .sequence import ArrayVar, StringVar - - var_type = self._var_type - if types.is_optional(var_type): - var_type = types.get_args(var_type)[0] - - if var_type is Any: - return self - - fixed_type = get_origin(var_type) or var_type - - if fixed_type is Union: - return self - - if not inspect.isclass(fixed_type): - raise TypeError(f"Unsupported type {var_type} for guess_type.") - - if issubclass(fixed_type, (int, float)): - return self.to(NumberVar, self._var_type) - if issubclass(fixed_type, dict): - return self.to(ObjectVar, self._var_type) - if issubclass(fixed_type, (list, tuple, set)): - return self.to(ArrayVar, self._var_type) - if issubclass(fixed_type, str): - return self.to(StringVar) - if issubclass(fixed_type, Base): - return self.to(ObjectVar, self._var_type) - return self - - def get_default_value(self) -> Any: - """Get the default value of the var. - - Returns: - The default value of the var. - - Raises: - ImportError: If the var is a dataframe and pandas is not installed. - """ - if types.is_optional(self._var_type): - return None - - type_ = ( - get_origin(self._var_type) - if types.is_generic_alias(self._var_type) - else self._var_type - ) - if type_ is Literal: - args = get_args(self._var_type) - return args[0] if args else None - if issubclass(type_, str): - return "" - if issubclass(type_, types.get_args(Union[int, float])): - return 0 - if issubclass(type_, bool): - return False - if issubclass(type_, list): - return [] - if issubclass(type_, dict): - return {} - if issubclass(type_, tuple): - return () - if types.is_dataframe(type_): - try: - import pandas as pd - - return pd.DataFrame() - except ImportError as e: - raise ImportError( - "Please install pandas to use dataframes in your app." - ) from e - return set() if issubclass(type_, set) else None - - def get_setter_name(self, include_state: bool = True) -> str: - """Get the name of the var's generated setter function. - - Args: - include_state: Whether to include the state name in the setter name. - - Returns: - The name of the setter function. - """ - var_name_parts = self._var_name.split(".") - setter = constants.SETTER_PREFIX + var_name_parts[-1] - if self._var_data is None: - return setter - if not include_state or self._var_data.state == "": - return setter - return ".".join((self._var_data.state, setter)) - - def get_setter(self) -> Callable[[BaseState, Any], None]: - """Get the var's setter function. - - Returns: - A function that that creates a setter for the var. - """ - actual_name = self._var_name.split(".")[-1] - - def setter(state: BaseState, value: Any): - """Get the setter for the var. - - Args: - state: The state within which we add the setter function. - value: The value to set. - """ - if self._var_type in [int, float]: - try: - value = self._var_type(value) - setattr(state, actual_name, value) - except ValueError: - console.debug( - f"{type(state).__name__}.{self._var_name}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.", - ) - else: - setattr(state, actual_name, value) - - setter.__qualname__ = self.get_setter_name() - - return setter - - def __eq__(self, other: Var | Any) -> BooleanVar: - """Check if the current variable is equal to the given variable. - - Args: - other (Var | Any): The variable to compare with. - - Returns: - BooleanVar: A BooleanVar object representing the result of the equality check. - """ - from .number import EqualOperation - - return EqualOperation.create(self, other) - - def __ne__(self, other: Var | Any) -> BooleanVar: - """Check if the current object is not equal to the given object. - - Parameters: - other (Var | Any): The object to compare with. - - Returns: - BooleanVar: A BooleanVar object representing the result of the comparison. - """ - from .number import EqualOperation - - return ~EqualOperation.create(self, other) - - def __gt__(self, other: Var | Any) -> BooleanVar: - """Compare the current instance with another variable and return a BooleanVar representing the result of the greater than operation. - - Args: - other (Var | Any): The variable to compare with. - - Returns: - BooleanVar: A BooleanVar representing the result of the greater than operation. - """ - from .number import GreaterThanOperation - - return GreaterThanOperation.create(self, other) - - def __ge__(self, other: Var | Any) -> BooleanVar: - """Check if the value of this variable is greater than or equal to the value of another variable or object. - - Args: - other (Var | Any): The variable or object to compare with. - - Returns: - BooleanVar: A BooleanVar object representing the result of the comparison. - """ - from .number import GreaterThanOrEqualOperation - - return GreaterThanOrEqualOperation.create(self, other) - - def __lt__(self, other: Var | Any) -> BooleanVar: - """Compare the current instance with another variable using the less than (<) operator. - - Args: - other: The variable to compare with. - - Returns: - A `BooleanVar` object representing the result of the comparison. - """ - from .number import LessThanOperation - - return LessThanOperation.create(self, other) - - def __le__(self, other: Var | Any) -> BooleanVar: - """Compare if the current instance is less than or equal to the given value. - - Args: - other: The value to compare with. - - Returns: - A BooleanVar object representing the result of the comparison. - """ - from .number import LessThanOrEqualOperation - - return LessThanOrEqualOperation.create(self, other) - - def bool(self) -> BooleanVar: - """Convert the var to a boolean. - - Returns: - The boolean var. - """ - from .number import ToBooleanVarOperation - - return ToBooleanVarOperation.create(self) - - def __and__(self, other: Var | Any) -> ImmutableVar: - """Perform a logical AND operation on the current instance and another variable. - - Args: - other: The variable to perform the logical AND operation with. - - Returns: - A `BooleanVar` object representing the result of the logical AND operation. - """ - return AndOperation.create(self, other) - - def __rand__(self, other: Var | Any) -> ImmutableVar: - """Perform a logical AND operation on the current instance and another variable. - - Args: - other: The variable to perform the logical AND operation with. - - Returns: - A `BooleanVar` object representing the result of the logical AND operation. - """ - return AndOperation.create(other, self) - - def __or__(self, other: Var | Any) -> ImmutableVar: - """Perform a logical OR operation on the current instance and another variable. - - Args: - other: The variable to perform the logical OR operation with. - - Returns: - A `BooleanVar` object representing the result of the logical OR operation. - """ - return OrOperation.create(self, other) - - def __ror__(self, other: Var | Any) -> ImmutableVar: - """Perform a logical OR operation on the current instance and another variable. - - Args: - other: The variable to perform the logical OR operation with. - - Returns: - A `BooleanVar` object representing the result of the logical OR operation. - """ - return OrOperation.create(other, self) - - def __invert__(self) -> BooleanVar: - """Perform a logical NOT operation on the current instance. - - Returns: - A `BooleanVar` object representing the result of the logical NOT operation. - """ - from .number import BooleanNotOperation - - return BooleanNotOperation.create(self.bool()) - - def to_string(self) -> ImmutableVar: - """Convert the var to a string. - - Returns: - The string var. - """ - from .function import JSON_STRINGIFY - from .sequence import StringVar - - return JSON_STRINGIFY.call(self).to(StringVar) - - def as_ref(self) -> ImmutableVar: - """Get a reference to the var. - - Returns: - The reference to the var. - """ - from .object import ObjectVar - - refs = ImmutableVar( - _var_name="refs", - _var_data=ImmutableVarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")] - } - ), - ).to(ObjectVar) - return refs[LiteralVar.create(str(self))] - - def _type(self) -> StringVar: - """Returns the type of the object. - - This method uses the `typeof` function from the `FunctionStringVar` class - to determine the type of the object. - - Returns: - StringVar: A string variable representing the type of the object. - """ - from .function import FunctionStringVar - from .sequence import StringVar - - type_of = FunctionStringVar("typeof") - return type_of.call(self).to(StringVar) - - -OUTPUT = TypeVar("OUTPUT", bound=ImmutableVar) - - -class LiteralVar(ImmutableVar): - """Base class for immutable literal vars.""" - - @classmethod - def create( - cls, - value: Any, - _var_data: VarData | None = None, - ) -> Var: - """Create a var from a value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - TypeError: If the value is not a supported type for LiteralVar. - """ - from .number import LiteralBooleanVar, LiteralNumberVar - from .object import LiteralObjectVar - from .sequence import LiteralArrayVar, LiteralStringVar - - if isinstance(value, Var): - if _var_data is None: - return value - return value._replace(merge_var_data=_var_data) - - if isinstance(value, str): - return LiteralStringVar.create(value, _var_data=_var_data) - - if isinstance(value, bool): - return LiteralBooleanVar.create(value, _var_data=_var_data) - - if isinstance(value, (int, float)): - return LiteralNumberVar.create(value, _var_data=_var_data) - - if isinstance(value, dict): - return LiteralObjectVar.create(value, _var_data=_var_data) - - if isinstance(value, Color): - return LiteralStringVar.create(f"{value}", _var_data=_var_data) - - if isinstance(value, (list, tuple, set)): - return LiteralArrayVar.create(value, _var_data=_var_data) - - if value is None: - return ImmutableVar.create_safe("null", _var_data=_var_data) - - from reflex.event import EventChain, EventSpec - from reflex.utils.format import get_event_handler_parts - - from .function import ArgsFunctionOperation, FunctionStringVar - from .object import LiteralObjectVar - - if isinstance(value, EventSpec): - event_name = LiteralVar.create( - ".".join(filter(None, get_event_handler_parts(value.handler))) - ) - event_args = LiteralVar.create( - {str(name): value for name, value in value.args} - ) - event_client_name = LiteralVar.create(value.client_handler_name) - return FunctionStringVar("Event").call( - event_name, - event_args, - *([event_client_name] if value.client_handler_name else []), - ) - - if isinstance(value, EventChain): - sig = inspect.signature(value.args_spec) # type: ignore - if sig.parameters: - arg_def = tuple((f"_{p}" for p in sig.parameters)) - arg_def_expr = LiteralVar.create( - [ImmutableVar.create_safe(arg) for arg in arg_def] - ) - else: - # add a default argument for addEvents if none were specified in value.args_spec - # used to trigger the preventDefault() on the event. - arg_def = ("...args",) - arg_def_expr = ImmutableVar.create_safe("args") - - return ArgsFunctionOperation.create( - arg_def, - FunctionStringVar.create("addEvents").call( - LiteralVar.create( - [LiteralVar.create(event) for event in value.events] - ), - arg_def_expr, - LiteralVar.create(value.event_actions), - ), - ) - - try: - from plotly.graph_objects import Figure, layout - from plotly.io import to_json - - if isinstance(value, Figure): - return LiteralObjectVar.create( - json.loads(str(to_json(value))), - _var_type=Figure, - _var_data=_var_data, - ) - - if isinstance(value, layout.Template): - return LiteralObjectVar.create( - { - "data": json.loads(str(to_json(value.data))), - "layout": json.loads(str(to_json(value.layout))), - }, - _var_type=layout.Template, - _var_data=_var_data, - ) - except ImportError: - pass - - try: - import base64 - import io - - from PIL.Image import MIME - from PIL.Image import Image as Img - - if isinstance(value, Img): - with io.BytesIO() as buffer: - image_format = getattr(value, "format", None) or "PNG" - value.save(buffer, format=image_format) - try: - # Newer method to get the mime type, but does not always work. - mimetype = value.get_format_mimetype() # type: ignore - except AttributeError: - try: - # Fallback method - mimetype = MIME[image_format] - except KeyError: - # Unknown mime_type: warn and return image/png and hope the browser can sort it out. - warnings.warn( # noqa: B028 - f"Unknown mime type for {value} {image_format}. Defaulting to image/png" - ) - mimetype = "image/png" - return LiteralStringVar.create( - f"data:{mimetype};base64,{base64.b64encode(buffer.getvalue()).decode()}", - _var_data=_var_data, - ) - except ImportError: - pass - - if isinstance(value, Base): - return LiteralObjectVar.create( - {k: (None if callable(v) else v) for k, v in value.dict().items()}, - _var_type=type(value), - _var_data=_var_data, - ) - - raise TypeError( - f"Unsupported type {type(value)} for LiteralVar. Tried to create a LiteralVar from {value}." - ) - - def __post_init__(self): - """Post-initialize the var.""" - - def json(self) -> str: - """Serialize the var to a JSON string. - - Raises: - NotImplementedError: If the method is not implemented. - """ - raise NotImplementedError( - "LiteralVar subclasses must implement the json method." - ) - - -P = ParamSpec("P") -T = TypeVar("T", bound=ImmutableVar) - - -def var_operation(*, output: Type[T]) -> Callable[[Callable[P, str]], Callable[P, T]]: - """Decorator for creating a var operation. - - Example: - ```python - @var_operation(output=NumberVar) - def add(a: NumberVar, b: NumberVar): - return f"({a} + {b})" - ``` - - Args: - output: The output type of the operation. - - Returns: - The decorator. - """ - - def decorator(func: Callable[P, str], output=output): - @functools.wraps(func) - def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: - args_vars = [ - LiteralVar.create(arg) if not isinstance(arg, Var) else arg - for arg in args - ] - kwargs_vars = { - key: LiteralVar.create(value) if not isinstance(value, Var) else value - for key, value in kwargs.items() - } - return output( - _var_name=func(*args_vars, **kwargs_vars), # type: ignore - _var_data=VarData.merge( - *[arg._get_all_var_data() for arg in args if isinstance(arg, Var)], - *[ - arg._get_all_var_data() - for arg in kwargs.values() - if isinstance(arg, Var) - ], - ), - ) - - return wrapper - - return decorator - - -def unionize(*args: Type) -> Type: - """Unionize the types. - - Args: - args: The types to unionize. - - Returns: - The unionized types. - """ - if not args: - return Any - first, *rest = args - if not rest: - return first - return Union[first, unionize(*rest)] - - -def figure_out_type(value: Any) -> types.GenericType: - """Figure out the type of the value. - - Args: - value: The value to figure out the type of. - - Returns: - The type of the value. - """ - if isinstance(value, list): - return List[unionize(*(figure_out_type(v) for v in value))] - if isinstance(value, set): - return Set[unionize(*(figure_out_type(v) for v in value))] - if isinstance(value, tuple): - return Tuple[unionize(*(figure_out_type(v) for v in value)), ...] - if isinstance(value, dict): - return Dict[ - unionize(*(figure_out_type(k) for k in value)), - unionize(*(figure_out_type(v) for v in value.values())), - ] - if isinstance(value, Var): - return value._var_type - return type(value) - - -class cached_property_no_lock(functools.cached_property): - """A special version of functools.cached_property that does not use a lock.""" - - def __init__(self, func): - """Initialize the cached_property_no_lock. - - Args: - func: The function to cache. - """ - super().__init__(func) - self.lock = contextlib.nullcontext() - - -class CachedVarOperation: - """Base class for cached var operations to lower boilerplate code.""" - - def __post_init__(self): - """Post-initialize the CachedVarOperation.""" - object.__delattr__(self, "_var_name") - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute. - """ - if name == "_var_name": - return self._cached_var_name - - parent_classes = inspect.getmro(self.__class__) - - return parent_classes[parent_classes.index(CachedVarOperation) + 1].__getattr__( # type: ignore - self, name - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - @cached_property_no_lock - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get the cached VarData. - - Returns: - The cached VarData. - """ - return ImmutableVarData.merge( - *map( - lambda value: ( - value._get_all_var_data() if isinstance(value, Var) else None - ), - map( - lambda field: getattr(self, field.name), - dataclasses.fields(self), # type: ignore - ), - ), - self._var_data, - ) - - def __hash__(self) -> int: - """Calculate the hash of the object. - - Returns: - The hash of the object. - """ - return hash( - ( - self.__class__.__name__, - *[ - getattr(self, field.name) - for field in dataclasses.fields(self) # type: ignore - if field.name not in ["_var_name", "_var_data", "_var_type"] - ], - ) - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class AndOperation(CachedVarOperation, ImmutableVar): - """Class for the logical AND operation.""" - - # The first var. - _var1: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - # The second var. - _var2: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """Get the cached var name. - - Returns: - The cached var name. - """ - return f"({str(self._var1)} && {str(self._var2)})" - - def __hash__(self) -> int: - """Calculates the hash value of the object. - - Returns: - int: The hash value of the object. - """ - return hash((self.__class__.__name__, self._var1, self._var2)) - - @classmethod - def create( - cls, var1: Var | Any, var2: Var | Any, _var_data: VarData | None = None - ) -> AndOperation: - """Create an AndOperation. - - Args: - var1: The first var. - var2: The second var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The AndOperation. - """ - var1, var2 = map(LiteralVar.create, (var1, var2)) - return AndOperation( - _var_name="", - _var_type=unionize(var1._var_type, var2._var_type), - _var_data=ImmutableVarData.merge(_var_data), - _var1=var1, - _var2=var2, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class OrOperation(CachedVarOperation, ImmutableVar): - """Class for the logical OR operation.""" - - # The first var. - _var1: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - # The second var. - _var2: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """Get the cached var name. - - Returns: - The cached var name. - """ - return f"({str(self._var1)} || {str(self._var2)})" - - def __hash__(self) -> int: - """Calculates the hash value for the object. - - Returns: - int: The hash value of the object. - """ - return hash((self.__class__.__name__, self._var1, self._var2)) - - @classmethod - def create( - cls, var1: Var | Any, var2: Var | Any, _var_data: VarData | None = None - ) -> OrOperation: - """Create an OrOperation. - - Args: - var1: The first var. - var2: The second var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The OrOperation. - """ - var1, var2 = map(LiteralVar.create, (var1, var2)) - return OrOperation( - _var_name="", - _var_type=unionize(var1._var_type, var2._var_type), - _var_data=ImmutableVarData.merge(_var_data), - _var1=var1, - _var2=var2, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ImmutableCallableVar(ImmutableVar): - """Decorate a Var-returning function to act as both a Var and a function. - - This is used as a compatibility shim for replacing Var objects in the - API with functions that return a family of Var. - """ - - fn: Callable[..., Var] = dataclasses.field( - default_factory=lambda: lambda: ImmutableVar(_var_name="undefined") - ) - original_var: Var = dataclasses.field( - default_factory=lambda: ImmutableVar(_var_name="undefined") - ) - - def __init__(self, fn: Callable[..., Var]): - """Initialize a CallableVar. - - Args: - fn: The function to decorate (must return Var) - """ - original_var = fn() - super(ImmutableCallableVar, self).__init__( - _var_name=original_var._var_name, - _var_type=original_var._var_type, - _var_data=ImmutableVarData.merge(original_var._get_all_var_data()), - ) - object.__setattr__(self, "fn", fn) - object.__setattr__(self, "original_var", original_var) - - def __call__(self, *args, **kwargs) -> Var: - """Call the decorated function. - - Args: - *args: The args to pass to the function. - **kwargs: The kwargs to pass to the function. - - Returns: - The Var returned from calling the function. - """ - return self.fn(*args, **kwargs) - - def __hash__(self) -> int: - """Calculate the hash of the object. - - Returns: - The hash of the object. - """ - return hash((self.__class__.__name__, self.original_var)) - - -RETURN_TYPE = TypeVar("RETURN_TYPE") - -DICT_KEY = TypeVar("DICT_KEY") -DICT_VAL = TypeVar("DICT_VAL") - -LIST_INSIDE = TypeVar("LIST_INSIDE") - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ImmutableComputedVar(ImmutableVar[RETURN_TYPE]): - """A field with computed getters.""" - - # Whether to track dependencies and cache computed values - _cache: bool = dataclasses.field(default=False) - - # Whether the computed var is a backend var - _backend: bool = dataclasses.field(default=False) - - # The initial value of the computed var - _initial_value: RETURN_TYPE | types.Unset = dataclasses.field(default=types.Unset()) - - # Explicit var dependencies to track - _static_deps: set[str] = dataclasses.field(default_factory=set) - - # Whether var dependencies should be auto-determined - _auto_deps: bool = dataclasses.field(default=True) - - # Interval at which the computed var should be updated - _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None) - - _fget: Callable[[BaseState], RETURN_TYPE] = dataclasses.field( - default_factory=lambda: lambda _: None - ) # type: ignore - - def __init__( - self, - fget: Callable[[BASE_STATE], RETURN_TYPE], - initial_value: RETURN_TYPE | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[int, datetime.timedelta]] = None, - backend: bool | None = None, - **kwargs, - ): - """Initialize a ComputedVar. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - **kwargs: additional attributes to set on the instance - - Raises: - TypeError: If the computed var dependencies are not Var instances or var names. - """ - hints = get_type_hints(fget) - hint = hints.get("return", Any) - - kwargs["_var_name"] = kwargs.pop("_var_name", fget.__name__) - kwargs["_var_type"] = kwargs.pop("_var_type", hint) - - super(ImmutableComputedVar, self).__init__( - _var_name=kwargs.pop("_var_name"), - _var_type=kwargs.pop("_var_type"), - _var_data=ImmutableVarData.merge(kwargs.pop("_var_data", None)), - ) - - if backend is None: - backend = fget.__name__.startswith("_") - - object.__setattr__(self, "_backend", backend) - object.__setattr__(self, "_initial_value", initial_value) - object.__setattr__(self, "_cache", cache) - - if isinstance(interval, int): - interval = datetime.timedelta(seconds=interval) - - object.__setattr__(self, "_update_interval", interval) - - if deps is None: - deps = [] - else: - for dep in deps: - if isinstance(dep, Var): - continue - if isinstance(dep, str) and dep != "": - continue - raise TypeError( - "ComputedVar dependencies must be Var instances or var names (non-empty strings)." - ) - object.__setattr__( - self, - "_static_deps", - {dep._var_name if isinstance(dep, Var) else dep for dep in deps}, - ) - object.__setattr__(self, "_auto_deps", auto_deps) - - object.__setattr__(self, "_fget", fget) - - @override - def _replace(self, merge_var_data=None, **kwargs: Any) -> ImmutableComputedVar: - """Replace the attributes of the ComputedVar. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - The new ComputedVar instance. - - Raises: - TypeError: If kwargs contains keys that are not allowed. - """ - field_values = dict( - fget=kwargs.pop("fget", self._fget), - initial_value=kwargs.pop("initial_value", self._initial_value), - cache=kwargs.pop("cache", self._cache), - deps=kwargs.pop("deps", self._static_deps), - auto_deps=kwargs.pop("auto_deps", self._auto_deps), - interval=kwargs.pop("interval", self._update_interval), - backend=kwargs.pop("backend", self._backend), - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_data=kwargs.pop( - "_var_data", VarData.merge(self._var_data, merge_var_data) - ), - ) - - if kwargs: - unexpected_kwargs = ", ".join(kwargs.keys()) - raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") - - return ImmutableComputedVar(**field_values) - - @property - def _cache_attr(self) -> str: - """Get the attribute used to cache the value on the instance. - - Returns: - An attribute name. - """ - return f"__cached_{self._var_name}" - - @property - def _last_updated_attr(self) -> str: - """Get the attribute used to store the last updated timestamp. - - Returns: - An attribute name. - """ - return f"__last_updated_{self._var_name}" - - def needs_update(self, instance: BaseState) -> bool: - """Check if the computed var needs to be updated. - - Args: - instance: The state instance that the computed var is attached to. - - Returns: - True if the computed var needs to be updated, False otherwise. - """ - if self._update_interval is None: - return False - last_updated = getattr(instance, self._last_updated_attr, None) - if last_updated is None: - return True - return datetime.datetime.now() - last_updated > self._update_interval - - @overload - def __get__( - self: ImmutableComputedVar[int] | ImmutableComputedVar[float], - instance: None, - owner: Type, - ) -> NumberVar: ... - - @overload - def __get__( - self: ImmutableComputedVar[str], - instance: None, - owner: Type, - ) -> StringVar: ... - - @overload - def __get__( - self: ImmutableComputedVar[dict[DICT_KEY, DICT_VAL]], - instance: None, - owner: Type, - ) -> ObjectVar[dict[DICT_KEY, DICT_VAL]]: ... - - @overload - def __get__( - self: ImmutableComputedVar[list[LIST_INSIDE]], - instance: None, - owner: Type, - ) -> ArrayVar[list[LIST_INSIDE]]: ... - - @overload - def __get__( - self: ImmutableComputedVar[set[LIST_INSIDE]], - instance: None, - owner: Type, - ) -> ArrayVar[set[LIST_INSIDE]]: ... - - @overload - def __get__( - self: ImmutableComputedVar[tuple[LIST_INSIDE, ...]], - instance: None, - owner: Type, - ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ... - - @overload - def __get__( - self, instance: None, owner: Type - ) -> ImmutableComputedVar[RETURN_TYPE]: ... - - @overload - def __get__(self, instance: BaseState, owner: Type) -> RETURN_TYPE: ... - - def __get__(self, instance: BaseState | None, owner): - """Get the ComputedVar value. - - If the value is already cached on the instance, return the cached value. - - Args: - instance: the instance of the class accessing this computed var. - owner: the class that this descriptor is attached to. - - Returns: - The value of the var for the given instance. - """ - if instance is None: - from reflex.state import BaseState - - path_to_function = self.fget.__qualname__.split(".") - class_name_where_defined = ( - path_to_function[-2] if len(path_to_function) > 1 else owner.__name__ - ) - - def contains_class_name(states: Sequence[Type]) -> bool: - return any(c.__name__ == class_name_where_defined for c in states) - - def is_not_mixin(state: Type[BaseState]) -> bool: - return not state._mixin - - def length_of_state(state: Type[BaseState]) -> int: - return len(inspect.getmro(state)) - - class_where_defined = cast( - Type[BaseState], - min( - filter( - lambda state: state.__module__ == self.fget.__module__, - filter( - is_not_mixin, - filter( - lambda state: contains_class_name( - inspect.getmro(state) - ), - inspect.getmro(owner), - ), - ), - ), - default=owner, - key=length_of_state, - ), - ) - - return self._replace( - _var_name=format_state_name(class_where_defined.get_full_name()) - + "." - + self._var_name, - merge_var_data=ImmutableVarData.from_state(class_where_defined), - ).guess_type() - - if not self._cache: - return self.fget(instance) - - # handle caching - if not hasattr(instance, self._cache_attr) or self.needs_update(instance): - # Set cache attr on state instance. - setattr(instance, self._cache_attr, self.fget(instance)) - # Ensure the computed var gets serialized to redis. - instance._was_touched = True - # Set the last updated timestamp on the state instance. - setattr(instance, self._last_updated_attr, datetime.datetime.now()) - return getattr(instance, self._cache_attr) - - def _deps( - self, - objclass: Type, - obj: FunctionType | CodeType | None = None, - self_name: Optional[str] = None, - ) -> set[str]: - """Determine var dependencies of this ComputedVar. - - Save references to attributes accessed on "self". Recursively called - when the function makes a method call on "self" or define comprehensions - or nested functions that may reference "self". - - Args: - objclass: the class obj this ComputedVar is attached to. - obj: the object to disassemble (defaults to the fget function). - self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions. - - Returns: - A set of variable names accessed by the given obj. - - Raises: - VarValueError: if the function references the get_state, parent_state, or substates attributes - (cannot track deps in a related state, only implicitly via parent state). - """ - if not self._auto_deps: - return self._static_deps - d = self._static_deps.copy() - if obj is None: - fget = self._fget - if fget is not None: - obj = cast(FunctionType, fget) - else: - return set() - with contextlib.suppress(AttributeError): - # unbox functools.partial - obj = cast(FunctionType, obj.func) # type: ignore - with contextlib.suppress(AttributeError): - # unbox EventHandler - obj = cast(FunctionType, obj.fn) # type: ignore - - if self_name is None and isinstance(obj, FunctionType): - try: - # the first argument to the function is the name of "self" arg - self_name = obj.__code__.co_varnames[0] - except (AttributeError, IndexError): - self_name = None - if self_name is None: - # cannot reference attributes on self if method takes no args - return set() - - invalid_names = ["get_state", "parent_state", "substates", "get_substate"] - self_is_top_of_stack = False - for instruction in dis.get_instructions(obj): - if ( - instruction.opname in ("LOAD_FAST", "LOAD_DEREF") - and instruction.argval == self_name - ): - # bytecode loaded the class instance to the top of stack, next load instruction - # is referencing an attribute on self - self_is_top_of_stack = True - continue - if self_is_top_of_stack and instruction.opname in ( - "LOAD_ATTR", - "LOAD_METHOD", - ): - try: - ref_obj = getattr(objclass, instruction.argval) - except Exception: - ref_obj = None - if instruction.argval in invalid_names: - raise VarValueError( - f"Cached var {self._var_full_name} cannot access arbitrary state via `{instruction.argval}`." - ) - if callable(ref_obj): - # recurse into callable attributes - d.update( - self._deps( - objclass=objclass, - obj=ref_obj, - ) - ) - # recurse into property fget functions - elif isinstance(ref_obj, property) and not isinstance( - ref_obj, ImmutableComputedVar - ): - d.update( - self._deps( - objclass=objclass, - obj=ref_obj.fget, # type: ignore - ) - ) - elif ( - instruction.argval in objclass.backend_vars - or instruction.argval in objclass.vars - ): - # var access - d.add(instruction.argval) - elif instruction.opname == "LOAD_CONST" and isinstance( - instruction.argval, CodeType - ): - # recurse into nested functions / comprehensions, which can reference - # instance attributes from the outer scope - d.update( - self._deps( - objclass=objclass, - obj=instruction.argval, - self_name=self_name, - ) - ) - self_is_top_of_stack = False - return d - - def mark_dirty(self, instance) -> None: - """Mark this ComputedVar as dirty. - - Args: - instance: the state instance that needs to recompute the value. - """ - with contextlib.suppress(AttributeError): - delattr(instance, self._cache_attr) - - def _determine_var_type(self) -> Type: - """Get the type of the var. - - Returns: - The type of the var. - """ - hints = get_type_hints(self._fget) - if "return" in hints: - return hints["return"] - return Any - - @property - def __class__(self) -> Type: - """Get the class of the var. - - Returns: - The class of the var. - """ - return ComputedVar - - @property - def fget(self) -> Callable[[BaseState], RETURN_TYPE]: - """Get the getter function. - - Returns: - The getter function. - """ - return self._fget - - -if TYPE_CHECKING: - BASE_STATE = TypeVar("BASE_STATE", bound=BaseState) - - -@overload -def immutable_computed_var( - fget: None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - backend: bool | None = None, - **kwargs, -) -> Callable[ - [Callable[[BASE_STATE], RETURN_TYPE]], ImmutableComputedVar[RETURN_TYPE] -]: ... - - -@overload -def immutable_computed_var( - fget: Callable[[BASE_STATE], RETURN_TYPE], - initial_value: RETURN_TYPE | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - backend: bool | None = None, - **kwargs, -) -> ImmutableComputedVar[RETURN_TYPE]: ... - - -def immutable_computed_var( - fget: Callable[[BASE_STATE], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - backend: bool | None = None, - **kwargs, -) -> ( - ImmutableComputedVar | Callable[[Callable[[BASE_STATE], Any]], ImmutableComputedVar] -): - """A ComputedVar decorator with or without kwargs. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - **kwargs: additional attributes to set on the instance - - Returns: - A ComputedVar instance. - - Raises: - ValueError: If caching is disabled and an update interval is set. - VarDependencyError: If user supplies dependencies without caching. - """ - if cache is False and interval is not None: - raise ValueError("Cannot set update interval without caching.") - - if cache is False and (deps is not None or auto_deps is False): - raise VarDependencyError("Cannot track dependencies without caching.") - - if fget is not None: - return ImmutableComputedVar(fget, cache=cache) - - def wrapper(fget: Callable[[BASE_STATE], Any]) -> ImmutableComputedVar: - return ImmutableComputedVar( - fget, - initial_value=initial_value, - cache=cache, - deps=deps, - auto_deps=auto_deps, - interval=interval, - backend=backend, - **kwargs, - ) - - return wrapper diff --git a/reflex/ivars/number.py b/reflex/ivars/number.py deleted file mode 100644 index 241a1b595..000000000 --- a/reflex/ivars/number.py +++ /dev/null @@ -1,1203 +0,0 @@ -"""Immutable number vars.""" - -from __future__ import annotations - -import dataclasses -import json -import sys -from typing import Any, Union - -from reflex.vars import ImmutableVarData, Var, VarData - -from .base import ( - CachedVarOperation, - ImmutableVar, - LiteralVar, - cached_property_no_lock, - unionize, -) - - -class NumberVar(ImmutableVar[Union[int, float]]): - """Base class for immutable number vars.""" - - def __add__(self, other: number_types | boolean_types) -> NumberAddOperation: - """Add two numbers. - - Args: - other: The other number. - - Returns: - The number addition operation. - """ - return NumberAddOperation.create(self, +other) - - def __radd__(self, other: number_types | boolean_types) -> NumberAddOperation: - """Add two numbers. - - Args: - other: The other number. - - Returns: - The number addition operation. - """ - return NumberAddOperation.create(+other, self) - - def __sub__(self, other: number_types | boolean_types) -> NumberSubtractOperation: - """Subtract two numbers. - - Args: - other: The other number. - - Returns: - The number subtraction operation. - """ - return NumberSubtractOperation.create(self, +other) - - def __rsub__(self, other: number_types | boolean_types) -> NumberSubtractOperation: - """Subtract two numbers. - - Args: - other: The other number. - - Returns: - The number subtraction operation. - """ - return NumberSubtractOperation.create(+other, self) - - def __abs__(self) -> NumberAbsoluteOperation: - """Get the absolute value of the number. - - Returns: - The number absolute operation. - """ - return NumberAbsoluteOperation.create(self) - - def __mul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation: - """Multiply two numbers. - - Args: - other: The other number. - - Returns: - The number multiplication operation. - """ - return NumberMultiplyOperation.create(self, +other) - - def __rmul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation: - """Multiply two numbers. - - Args: - other: The other number. - - Returns: - The number multiplication operation. - """ - return NumberMultiplyOperation.create(+other, self) - - def __truediv__(self, other: number_types | boolean_types) -> NumberTrueDivision: - """Divide two numbers. - - Args: - other: The other number. - - Returns: - The number true division operation. - """ - return NumberTrueDivision.create(self, +other) - - def __rtruediv__(self, other: number_types | boolean_types) -> NumberTrueDivision: - """Divide two numbers. - - Args: - other: The other number. - - Returns: - The number true division operation. - """ - return NumberTrueDivision.create(+other, self) - - def __floordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision: - """Floor divide two numbers. - - Args: - other: The other number. - - Returns: - The number floor division operation. - """ - return NumberFloorDivision.create(self, +other) - - def __rfloordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision: - """Floor divide two numbers. - - Args: - other: The other number. - - Returns: - The number floor division operation. - """ - return NumberFloorDivision.create(+other, self) - - def __mod__(self, other: number_types | boolean_types) -> NumberModuloOperation: - """Modulo two numbers. - - Args: - other: The other number. - - Returns: - The number modulo operation. - """ - return NumberModuloOperation.create(self, +other) - - def __rmod__(self, other: number_types | boolean_types) -> NumberModuloOperation: - """Modulo two numbers. - - Args: - other: The other number. - - Returns: - The number modulo operation. - """ - return NumberModuloOperation.create(+other, self) - - def __pow__(self, other: number_types | boolean_types) -> NumberExponentOperation: - """Exponentiate two numbers. - - Args: - other: The other number. - - Returns: - The number exponent operation. - """ - return NumberExponentOperation.create(self, +other) - - def __rpow__(self, other: number_types | boolean_types) -> NumberExponentOperation: - """Exponentiate two numbers. - - Args: - other: The other number. - - Returns: - The number exponent operation. - """ - return NumberExponentOperation.create(+other, self) - - def __neg__(self) -> NumberNegateOperation: - """Negate the number. - - Returns: - The number negation operation. - """ - return NumberNegateOperation.create(self) - - def __invert__(self) -> BooleanNotOperation: - """Boolean NOT the number. - - Returns: - The boolean NOT operation. - """ - return BooleanNotOperation.create(self.bool()) - - def __pos__(self) -> NumberVar: - """Positive the number. - - Returns: - The number. - """ - return self - - def __round__(self) -> NumberRoundOperation: - """Round the number. - - Returns: - The number round operation. - """ - return NumberRoundOperation.create(self) - - def __ceil__(self) -> NumberCeilOperation: - """Ceil the number. - - Returns: - The number ceil operation. - """ - return NumberCeilOperation.create(self) - - def __floor__(self) -> NumberFloorOperation: - """Floor the number. - - Returns: - The number floor operation. - """ - return NumberFloorOperation.create(self) - - def __trunc__(self) -> NumberTruncOperation: - """Trunc the number. - - Returns: - The number trunc operation. - """ - return NumberTruncOperation.create(self) - - def __lt__(self, other: Any) -> LessThanOperation: - """Less than comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return LessThanOperation.create(self, +other) - return LessThanOperation.create(self, other) - - def __le__(self, other: Any) -> LessThanOrEqualOperation: - """Less than or equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return LessThanOrEqualOperation.create(self, +other) - return LessThanOrEqualOperation.create(self, other) - - def __eq__(self, other: Any) -> EqualOperation: - """Equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return EqualOperation.create(self, +other) - return EqualOperation.create(self, other) - - def __ne__(self, other: Any) -> NotEqualOperation: - """Not equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return NotEqualOperation.create(self, +other) - return NotEqualOperation.create(self, other) - - def __gt__(self, other: Any) -> GreaterThanOperation: - """Greater than comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return GreaterThanOperation.create(self, +other) - return GreaterThanOperation.create(self, other) - - def __ge__(self, other: Any) -> GreaterThanOrEqualOperation: - """Greater than or equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - if isinstance(other, (NumberVar, BooleanVar, int, float, bool)): - return GreaterThanOrEqualOperation.create(self, +other) - return GreaterThanOrEqualOperation.create(self, other) - - def bool(self) -> NotEqualOperation: - """Boolean conversion. - - Returns: - The boolean value of the number. - """ - return NotEqualOperation.create(self, 0) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BinaryNumberOperation(CachedVarOperation, NumberVar): - """Base class for immutable number vars that are the result of a binary operation.""" - - _lhs: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - _rhs: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses - """ - raise NotImplementedError( - "BinaryNumberOperation must implement _cached_var_name" - ) - - @classmethod - def create( - cls, lhs: number_types, rhs: number_types, _var_data: VarData | None = None - ): - """Create the binary number operation var. - - Args: - lhs: The first number. - rhs: The second number. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The binary number operation var. - """ - _lhs, _rhs = map( - lambda v: LiteralNumberVar.create(v) if not isinstance(v, NumberVar) else v, - (lhs, rhs), - ) - return cls( - _var_name="", - _var_type=unionize(_lhs._var_type, _rhs._var_type), - _var_data=ImmutableVarData.merge(_var_data), - _lhs=_lhs, - _rhs=_rhs, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class UnaryNumberOperation(CachedVarOperation, NumberVar): - """Base class for immutable number vars that are the result of a unary operation.""" - - _value: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "UnaryNumberOperation must implement _cached_var_name" - ) - - @classmethod - def create(cls, value: NumberVar, _var_data: VarData | None = None): - """Create the unary number operation var. - - Args: - value: The number. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The unary number operation var. - """ - return cls( - _var_name="", - _var_type=value._var_type, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -class NumberAddOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of an addition operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} + {str(self._rhs)})" - - -class NumberSubtractOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a subtraction operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} - {str(self._rhs)})" - - -class NumberAbsoluteOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of an absolute operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.abs({str(self._value)})" - - -class NumberMultiplyOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a multiplication operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} * {str(self._rhs)})" - - -class NumberNegateOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a negation operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"-({str(self._value)})" - - -class NumberTrueDivision(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a true division operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} / {str(self._rhs)})" - - -class NumberFloorDivision(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a floor division operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.floor({str(self._lhs)} / {str(self._rhs)})" - - -class NumberModuloOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a modulo operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} % {str(self._rhs)})" - - -class NumberExponentOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of an exponent operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} ** {str(self._rhs)})" - - -class NumberRoundOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a round operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.round({str(self._value)})" - - -class NumberCeilOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a ceil operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.ceil({str(self._value)})" - - -class NumberFloorOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a floor operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.floor({str(self._value)})" - - -class NumberTruncOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a trunc operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Math.trunc({str(self._value)})" - - -class BooleanVar(ImmutableVar[bool]): - """Base class for immutable boolean vars.""" - - def __invert__(self) -> BooleanNotOperation: - """NOT the boolean. - - Returns: - The boolean NOT operation. - """ - return BooleanNotOperation.create(self) - - def __int__(self) -> BooleanToIntOperation: - """Convert the boolean to an int. - - Returns: - The boolean to int operation. - """ - return BooleanToIntOperation.create(self) - - def __pos__(self) -> BooleanToIntOperation: - """Convert the boolean to an int. - - Returns: - The boolean to int operation. - """ - return BooleanToIntOperation.create(self) - - def bool(self) -> BooleanVar: - """Boolean conversion. - - Returns: - The boolean value of the boolean. - """ - return self - - def __lt__(self, other: boolean_types | number_types) -> LessThanOperation: - """Less than comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return LessThanOperation.create(+self, +other) - - def __le__(self, other: boolean_types | number_types) -> LessThanOrEqualOperation: - """Less than or equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return LessThanOrEqualOperation.create(+self, +other) - - def __eq__(self, other: boolean_types | number_types) -> EqualOperation: - """Equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return EqualOperation.create(+self, +other) - - def __ne__(self, other: boolean_types | number_types) -> NotEqualOperation: - """Not equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return NotEqualOperation.create(+self, +other) - - def __gt__(self, other: boolean_types | number_types) -> GreaterThanOperation: - """Greater than comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return GreaterThanOperation.create(+self, +other) - - def __ge__( - self, other: boolean_types | number_types - ) -> GreaterThanOrEqualOperation: - """Greater than or equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return GreaterThanOrEqualOperation.create(+self, +other) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BooleanToIntOperation(CachedVarOperation, NumberVar): - """Base class for immutable number vars that are the result of a boolean to int operation.""" - - _value: BooleanVar = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._value)} ? 1 : 0)" - - @classmethod - def create(cls, value: BooleanVar, _var_data: VarData | None = None): - """Create the boolean to int operation var. - - Args: - value: The boolean. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The boolean to int operation var. - """ - return cls( - _var_name="", - _var_type=int, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ComparisonOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a comparison operation.""" - - _lhs: Var = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - _rhs: Var = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError("ComparisonOperation must implement _cached_var_name") - - @classmethod - def create(cls, lhs: Var | Any, rhs: Var | Any, _var_data: VarData | None = None): - """Create the comparison operation var. - - Args: - lhs: The first value. - rhs: The second value. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The comparison operation var. - """ - lhs, rhs = map(LiteralVar.create, (lhs, rhs)) - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _lhs=lhs, - _rhs=rhs, - ) - - -class GreaterThanOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of a greater than operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} > {str(self._rhs)})" - - -class GreaterThanOrEqualOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of a greater than or equal operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} >= {str(self._rhs)})" - - -class LessThanOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of a less than operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} < {str(self._rhs)})" - - -class LessThanOrEqualOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of a less than or equal operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} <= {str(self._rhs)})" - - -class EqualOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of an equal operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} === {str(self._rhs)})" - - -class NotEqualOperation(ComparisonOperation): - """Base class for immutable boolean vars that are the result of a not equal operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self._lhs)} !== {str(self._rhs)})" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LogicalOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a logical operation.""" - - _lhs: BooleanVar = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - _rhs: BooleanVar = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError("LogicalOperation must implement _cached_var_name") - - @classmethod - def create( - cls, lhs: boolean_types, rhs: boolean_types, _var_data: VarData | None = None - ): - """Create the logical operation var. - - Args: - lhs: The first boolean. - rhs: The second boolean. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The logical operation var. - """ - lhs, rhs = map( - lambda v: ( - LiteralBooleanVar.create(v) if not isinstance(v, BooleanVar) else v - ), - (lhs, rhs), - ) - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _lhs=lhs, - _rhs=rhs, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BooleanNotOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a logical NOT operation.""" - - _value: BooleanVar = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"!({str(self._value)})" - - @classmethod - def create(cls, value: boolean_types, _var_data: VarData | None = None): - """Create the logical NOT operation var. - - Args: - value: The value. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The logical NOT operation var. - """ - value = value if isinstance(value, Var) else LiteralBooleanVar.create(value) - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralBooleanVar(LiteralVar, BooleanVar): - """Base class for immutable literal boolean vars.""" - - _var_value: bool = dataclasses.field(default=False) - - def json(self) -> str: - """Get the JSON representation of the var. - - Returns: - The JSON representation of the var. - """ - return "true" if self._var_value else "false" - - def __hash__(self) -> int: - """Calculate the hash value of the object. - - Returns: - int: The hash value of the object. - """ - return hash((self.__class__.__name__, self._var_value)) - - @classmethod - def create(cls, value: bool, _var_data: VarData | None = None): - """Create the boolean var. - - Args: - value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The boolean var. - """ - return cls( - _var_name="true" if value else "false", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _var_value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralNumberVar(LiteralVar, NumberVar): - """Base class for immutable literal number vars.""" - - _var_value: float | int = dataclasses.field(default=0) - - def json(self) -> str: - """Get the JSON representation of the var. - - Returns: - The JSON representation of the var. - """ - return json.dumps(self._var_value) - - def __hash__(self) -> int: - """Calculate the hash value of the object. - - Returns: - int: The hash value of the object. - """ - return hash((self.__class__.__name__, self._var_value)) - - @classmethod - def create(cls, value: float | int, _var_data: VarData | None = None): - """Create the number var. - - Args: - value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The number var. - """ - return cls( - _var_name=str(value), - _var_type=type(value), - _var_data=ImmutableVarData.merge(_var_data), - _var_value=value, - ) - - -number_types = Union[NumberVar, int, float] -boolean_types = Union[BooleanVar, bool] - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToNumberVarOperation(CachedVarOperation, NumberVar): - """Base class for immutable number vars that are the result of a number operation.""" - - _original_value: Var = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_value) - - @classmethod - def create( - cls, - value: Var, - _var_type: type[int] | type[float] = float, - _var_data: VarData | None = None, - ): - """Create the number var. - - Args: - value: The value of the var. - _var_type: The type of the Var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The number var. - """ - return cls( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - _original_value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToBooleanVarOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a boolean operation.""" - - _original_value: Var = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Boolean({str(self._original_value)})" - - @classmethod - def create( - cls, - value: Var, - _var_data: VarData | None = None, - ): - """Create the boolean var. - - Args: - value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The boolean var. - """ - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _original_value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class TernaryOperator(CachedVarOperation, ImmutableVar): - """Base class for immutable vars that are the result of a ternary operation.""" - - _condition: BooleanVar = dataclasses.field( - default_factory=lambda: LiteralBooleanVar.create(False) - ) - _if_true: Var = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - _if_false: Var = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return ( - f"({str(self._condition)} ? {str(self._if_true)} : {str(self._if_false)})" - ) - - @classmethod - def create( - cls, - condition: boolean_types, - if_true: Var | Any, - if_false: Var | Any, - _var_data: VarData | None = None, - ): - """Create the ternary operation var. - - Args: - condition: The condition. - if_true: The value if the condition is true. - if_false: The value if the condition is false. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The ternary operation var. - """ - condition = ( - condition - if isinstance(condition, Var) - else LiteralBooleanVar.create(condition) - ) - _if_true, _if_false = map( - lambda v: (LiteralVar.create(v) if not isinstance(v, Var) else v), - (if_true, if_false), - ) - return TernaryOperator( - _var_name="", - _var_type=unionize(_if_true._var_type, _if_false._var_type), - _var_data=ImmutableVarData.merge(_var_data), - _condition=condition, - _if_true=_if_true, - _if_false=_if_false, - ) diff --git a/reflex/ivars/sequence.py b/reflex/ivars/sequence.py deleted file mode 100644 index d05ec5aad..000000000 --- a/reflex/ivars/sequence.py +++ /dev/null @@ -1,1650 +0,0 @@ -"""Collection of string classes and utilities.""" - -from __future__ import annotations - -import dataclasses -import inspect -import json -import re -import sys -import typing -from typing import ( - TYPE_CHECKING, - Any, - Dict, - List, - Literal, - Set, - Tuple, - Type, - TypeVar, - Union, - overload, -) - -from typing_extensions import get_origin - -from reflex import constants -from reflex.constants.base import REFLEX_VAR_OPENING_TAG -from reflex.utils.types import GenericType -from reflex.vars import ( - ImmutableVarData, - Var, - VarData, - _global_vars, -) - -from .base import ( - CachedVarOperation, - ImmutableVar, - LiteralVar, - cached_property_no_lock, - figure_out_type, - unionize, -) -from .number import ( - BooleanVar, - LiteralNumberVar, - NotEqualOperation, - NumberVar, -) - -if TYPE_CHECKING: - from .object import ObjectVar - - -class StringVar(ImmutableVar[str]): - """Base class for immutable string vars.""" - - def __add__(self, other: StringVar | str) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation.create(self, other) - - def __radd__(self, other: StringVar | str) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation.create(other, self) - - def __mul__(self, other: NumberVar | int) -> StringVar: - """Multiply the sequence by a number or an integer. - - Args: - other (NumberVar | int): The number or integer to multiply the sequence by. - - Returns: - StringVar: The resulting sequence after multiplication. - """ - return (self.split() * other).join() - - def __rmul__(self, other: NumberVar | int) -> StringVar: - """Multiply the sequence by a number or an integer. - - Args: - other (NumberVar | int): The number or integer to multiply the sequence by. - - Returns: - StringVar: The resulting sequence after multiplication. - """ - return (self.split() * other).join() - - @overload - def __getitem__(self, i: slice) -> ArrayJoinOperation: ... - - @overload - def __getitem__(self, i: int | NumberVar) -> StringItemOperation: ... - - def __getitem__( - self, i: slice | int | NumberVar - ) -> ArrayJoinOperation | StringItemOperation: - """Get a slice of the string. - - Args: - i: The slice. - - Returns: - The string slice operation. - """ - if isinstance(i, slice): - return self.split()[i].join() - return StringItemOperation.create(self, i) - - def length(self) -> NumberVar: - """Get the length of the string. - - Returns: - The string length operation. - """ - return self.split().length() - - def lower(self) -> StringVar: - """Convert the string to lowercase. - - Returns: - The string lower operation. - """ - return StringLowerOperation.create(self) - - def upper(self) -> StringVar: - """Convert the string to uppercase. - - Returns: - The string upper operation. - """ - return StringUpperOperation.create(self) - - def strip(self) -> StringVar: - """Strip the string. - - Returns: - The string strip operation. - """ - return StringStripOperation.create(self) - - def bool(self) -> NotEqualOperation: - """Boolean conversion. - - Returns: - The boolean value of the string. - """ - return NotEqualOperation.create(self.length(), 0) - - def reversed(self) -> ArrayJoinOperation: - """Reverse the string. - - Returns: - The string reverse operation. - """ - return self.split().reverse().join() - - def contains(self, other: StringVar | str) -> StringContainsOperation: - """Check if the string contains another string. - - Args: - other: The other string. - - Returns: - The string contains operation. - """ - return StringContainsOperation.create(self, other) - - def split(self, separator: StringVar | str = "") -> StringSplitOperation: - """Split the string. - - Args: - separator: The separator. - - Returns: - The string split operation. - """ - return StringSplitOperation.create(self, separator) - - def startswith(self, prefix: StringVar | str) -> StringStartsWithOperation: - """Check if the string starts with a prefix. - - Args: - prefix: The prefix. - - Returns: - The string starts with operation. - """ - return StringStartsWithOperation.create(self, prefix) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringToStringOperation(CachedVarOperation, StringVar): - """Base class for immutable string vars that are the result of a string to string operation.""" - - _value: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "StringToStringOperation must implement _cached_var_name" - ) - - @classmethod - def create( - cls, - value: StringVar, - _var_data: VarData | None = None, - ) -> StringVar: - """Create a var from a string value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -class StringLowerOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string lower operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._value)}.toLowerCase()" - - -class StringUpperOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string upper operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._value)}.toUpperCase()" - - -class StringStripOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string strip operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._value)}.trim()" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringContainsOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a string contains operation.""" - - _haystack: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - _needle: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._haystack)}.includes({str(self._needle)})" - - @classmethod - def create( - cls, - haystack: StringVar | str, - needle: StringVar | str, - _var_data: VarData | None = None, - ) -> StringContainsOperation: - """Create a var from a string value. - - Args: - haystack: The haystack. - needle: The needle. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _haystack=( - haystack - if isinstance(haystack, Var) - else LiteralStringVar.create(haystack) - ), - _needle=( - needle if isinstance(needle, Var) else LiteralStringVar.create(needle) - ), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringStartsWithOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of a string starts with operation.""" - - _full_string: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - _prefix: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._full_string)}.startsWith({str(self._prefix)})" - - @classmethod - def create( - cls, - full_string: StringVar | str, - prefix: StringVar | str, - _var_data: VarData | None = None, - ) -> StringStartsWithOperation: - """Create a var from a string value. - - Args: - full_string: The full string. - prefix: The prefix. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _full_string=( - full_string - if isinstance(full_string, Var) - else LiteralStringVar.create(full_string) - ), - _prefix=( - prefix if isinstance(prefix, Var) else LiteralStringVar.create(prefix) - ), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringItemOperation(CachedVarOperation, StringVar): - """Base class for immutable string vars that are the result of a string item operation.""" - - _string: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - _index: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._string)}.at({str(self._index)})" - - @classmethod - def create( - cls, - string: StringVar | str, - index: NumberVar | int, - _var_data: VarData | None = None, - ) -> StringItemOperation: - """Create a var from a string value. - - Args: - string: The string. - index: The index. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _string=( - string if isinstance(string, Var) else LiteralStringVar.create(string) - ), - _index=( - index if isinstance(index, Var) else LiteralNumberVar.create(index) - ), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayJoinOperation(CachedVarOperation, StringVar): - """Base class for immutable string vars that are the result of an array join operation.""" - - _array: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _sep: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._array)}.join({str(self._sep)})" - - @classmethod - def create( - cls, - array: ArrayVar, - sep: StringVar | str = "", - _var_data: VarData | None = None, - ) -> ArrayJoinOperation: - """Create a var from a string value. - - Args: - array: The array. - sep: The separator. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _array=array, - _sep=sep if isinstance(sep, Var) else LiteralStringVar.create(sep), - ) - - -# Compile regex for finding reflex var tags. -_decode_var_pattern_re = ( - rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" -) -_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralStringVar(LiteralVar, StringVar): - """Base class for immutable literal string vars.""" - - _var_value: str = dataclasses.field(default="") - - @classmethod - def create( - cls, - value: str, - _var_data: VarData | None = None, - ) -> LiteralStringVar | ConcatVarOperation: - """Create a var from a string value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - if REFLEX_VAR_OPENING_TAG in value: - strings_and_vals: list[Var | str] = [] - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads( - var_data_config.json_loads(f'"{s}"') - ) - - # Find all tags - while m := _decode_var_pattern.search(value): - start, end = m.span() - - strings_and_vals.append(value[:start]) - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - strings_and_vals.append(var) - value = value[(end + len(var._var_name)) :] - else: - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [ - (realstart, realstart + string_length) - ] - var_content = value[end : (end + string_length)] - if ( - var_content[0] == "{" - and var_content[-1] == "}" - and strings_and_vals - and strings_and_vals[-1][-1] == "$" - ): - strings_and_vals[-1] = strings_and_vals[-1][:-1] - var_content = "(" + var_content[1:-1] + ")" - strings_and_vals.append( - ImmutableVar.create_safe(var_content, _var_data=var_data) - ) - value = value[(end + string_length) :] - - offset += end - start - - strings_and_vals.append(value) - - filtered_strings_and_vals = [ - s for s in strings_and_vals if isinstance(s, Var) or s - ] - - if len(filtered_strings_and_vals) == 1: - return filtered_strings_and_vals[0].to(StringVar) # type: ignore - - return ConcatVarOperation.create( - *filtered_strings_and_vals, - _var_data=_var_data, - ) - - return LiteralStringVar( - _var_name=json.dumps(value), - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _var_value=value, - ) - - def __hash__(self) -> int: - """Get the hash of the var. - - Returns: - The hash of the var. - """ - return hash((self.__class__.__name__, self._var_value)) - - def json(self) -> str: - """Get the JSON representation of the var. - - Returns: - The JSON representation of the var. - """ - return json.dumps(self._var_value) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ConcatVarOperation(CachedVarOperation, StringVar): - """Representing a concatenation of literal string vars.""" - - _var_value: Tuple[Var, ...] = dataclasses.field(default_factory=tuple) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - list_of_strs: List[Union[str, Var]] = [] - last_string = "" - for var in self._var_value: - if isinstance(var, LiteralStringVar): - last_string += var._var_value - else: - if last_string: - list_of_strs.append(last_string) - last_string = "" - list_of_strs.append(var) - - if last_string: - list_of_strs.append(last_string) - - list_of_strs_filtered = [ - str(LiteralVar.create(s)) for s in list_of_strs if isinstance(s, Var) or s - ] - - if len(list_of_strs_filtered) == 1: - return list_of_strs_filtered[0] - - return "(" + "+".join(list_of_strs_filtered) + ")" - - @cached_property_no_lock - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all the VarData associated with the Var. - - Returns: - The VarData associated with the Var. - """ - return ImmutableVarData.merge( - *[ - var._get_all_var_data() - for var in self._var_value - if isinstance(var, Var) - ], - self._var_data, - ) - - @classmethod - def create( - cls, - *value: Var | str, - _var_data: VarData | None = None, - ) -> ConcatVarOperation: - """Create a var from a string value. - - Args: - value: The values to concatenate. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _var_value=tuple(map(LiteralVar.create, value)), - ) - - -ARRAY_VAR_TYPE = TypeVar("ARRAY_VAR_TYPE", bound=Union[List, Tuple, Set]) - -OTHER_TUPLE = TypeVar("OTHER_TUPLE") - -INNER_ARRAY_VAR = TypeVar("INNER_ARRAY_VAR") - -KEY_TYPE = TypeVar("KEY_TYPE") -VALUE_TYPE = TypeVar("VALUE_TYPE") - - -class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]): - """Base class for immutable array vars.""" - - def join(self, sep: StringVar | str = "") -> ArrayJoinOperation: - """Join the elements of the array. - - Args: - sep: The separator between elements. - - Returns: - The joined elements. - """ - return ArrayJoinOperation.create(self, sep) - - def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]: - """Reverse the array. - - Returns: - The reversed array. - """ - return ArrayReverseOperation.create(self) - - def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayConcatOperation: - """Concatenate two arrays. - - Parameters: - other (ArrayVar[ARRAY_VAR_TYPE]): The other array to concatenate. - - Returns: - ArrayConcatOperation: The concatenation of the two arrays. - """ - return ArrayConcatOperation.create(self, other) - - @overload - def __getitem__(self, i: slice) -> ArrayVar[ARRAY_VAR_TYPE]: ... - - @overload - def __getitem__( - self: ( - ArrayVar[Tuple[int, OTHER_TUPLE]] - | ArrayVar[Tuple[float, OTHER_TUPLE]] - | ArrayVar[Tuple[int | float, OTHER_TUPLE]] - ), - i: Literal[0, -2], - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ( - ArrayVar[Tuple[OTHER_TUPLE, int]] - | ArrayVar[Tuple[OTHER_TUPLE, float]] - | ArrayVar[Tuple[OTHER_TUPLE, int | float]] - ), - i: Literal[1, -1], - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[str, OTHER_TUPLE]], i: Literal[0, -2] - ) -> StringVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[OTHER_TUPLE, str]], i: Literal[1, -1] - ) -> StringVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[bool, OTHER_TUPLE]], i: Literal[0, -2] - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[OTHER_TUPLE, bool]], i: Literal[1, -1] - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ( - ARRAY_VAR_OF_LIST_ELEMENT[int] - | ARRAY_VAR_OF_LIST_ELEMENT[float] - | ARRAY_VAR_OF_LIST_ELEMENT[int | float] - ), - i: int | NumberVar, - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[str], i: int | NumberVar - ) -> StringVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[bool], i: int | NumberVar - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]], - i: int | NumberVar, - ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Set[INNER_ARRAY_VAR]], - i: int | NumberVar, - ) -> ArrayVar[Set[INNER_ARRAY_VAR]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]], - i: int | NumberVar, - ) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Dict[KEY_TYPE, VALUE_TYPE]], - i: int | NumberVar, - ) -> ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]: ... - - @overload - def __getitem__(self, i: int | NumberVar) -> ImmutableVar: ... - - def __getitem__( - self, i: slice | int | NumberVar - ) -> ArrayVar[ARRAY_VAR_TYPE] | ImmutableVar: - """Get a slice of the array. - - Args: - i: The slice. - - Returns: - The array slice operation. - """ - if isinstance(i, slice): - return ArraySliceOperation.create(self, i) - return ArrayItemOperation.create(self, i).guess_type() - - def length(self) -> NumberVar: - """Get the length of the array. - - Returns: - The length of the array. - """ - return ArrayLengthOperation.create(self) - - @overload - @classmethod - def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... - - @overload - @classmethod - def range( - cls, - start: int | NumberVar, - end: int | NumberVar, - step: int | NumberVar = 1, - /, - ) -> ArrayVar[List[int]]: ... - - @classmethod - def range( - cls, - first_endpoint: int | NumberVar, - second_endpoint: int | NumberVar | None = None, - step: int | NumberVar | None = None, - ) -> ArrayVar[List[int]]: - """Create a range of numbers. - - Args: - first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range. - second_endpoint: The end of the range. - step: The step of the range. - - Returns: - The range of numbers. - """ - if second_endpoint is None: - start = 0 - end = first_endpoint - else: - start = first_endpoint - end = second_endpoint - - return RangeOperation.create(start, end, step or 1) - - def contains(self, other: Any) -> BooleanVar: - """Check if the array contains an element. - - Args: - other: The element to check for. - - Returns: - The array contains operation. - """ - return ArrayContainsOperation.create(self, other) - - def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]: - """Multiply the sequence by a number or integer. - - Parameters: - other (NumberVar | int): The number or integer to multiply the sequence by. - - Returns: - ArrayVar[ARRAY_VAR_TYPE]: The result of multiplying the sequence by the given number or integer. - """ - return ArrayRepeatOperation.create(self, other) - - __rmul__ = __mul__ # type: ignore - - -LIST_ELEMENT = TypeVar("LIST_ELEMENT") - -ARRAY_VAR_OF_LIST_ELEMENT = Union[ - ArrayVar[List[LIST_ELEMENT]], - ArrayVar[Set[LIST_ELEMENT]], - ArrayVar[Tuple[LIST_ELEMENT, ...]], -] - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]): - """Base class for immutable literal array vars.""" - - _var_value: Union[ - List[Union[Var, Any]], Set[Union[Var, Any]], Tuple[Union[Var, Any], ...] - ] = dataclasses.field(default_factory=list) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return ( - "[" - + ", ".join( - [str(LiteralVar.create(element)) for element in self._var_value] - ) - + "]" - ) - - @cached_property_no_lock - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all the VarData associated with the Var. - - Returns: - The VarData associated with the Var. - """ - return ImmutableVarData.merge( - *[ - LiteralVar.create(element)._get_all_var_data() - for element in self._var_value - ], - self._var_data, - ) - - def __hash__(self) -> int: - """Get the hash of the var. - - Returns: - The hash of the var. - """ - return hash((self.__class__.__name__, self._var_name)) - - def json(self) -> str: - """Get the JSON representation of the var. - - Returns: - The JSON representation of the var. - """ - return ( - "[" - + ", ".join( - [LiteralVar.create(element).json() for element in self._var_value] - ) - + "]" - ) - - @classmethod - def create( - cls, - value: ARRAY_VAR_TYPE, - _var_type: Type[ARRAY_VAR_TYPE] | None = None, - _var_data: VarData | None = None, - ) -> LiteralArrayVar[ARRAY_VAR_TYPE]: - """Create a var from a string value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=figure_out_type(value) if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - _var_value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringSplitOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of a string split operation.""" - - _string: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - _sep: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._string)}.split({str(self._sep)})" - - @classmethod - def create( - cls, - string: StringVar | str, - sep: StringVar | str, - _var_data: VarData | None = None, - ) -> StringSplitOperation: - """Create a var from a string value. - - Args: - string: The string. - sep: The separator. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=List[str], - _var_data=ImmutableVarData.merge(_var_data), - _string=( - string if isinstance(string, Var) else LiteralStringVar.create(string) - ), - _sep=(sep if isinstance(sep, Var) else LiteralStringVar.create(sep)), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayToArrayOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of an array to array operation.""" - - _value: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "ArrayToArrayOperation must implement _cached_var_name" - ) - - @classmethod - def create( - cls, - value: ArrayVar, - _var_data: VarData | None = None, - ) -> ArrayToArrayOperation: - """Create a var from a string value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=value._var_type, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArraySliceOperation(CachedVarOperation, ArrayVar): - """Base class for immutable string vars that are the result of a string slice operation.""" - - _array: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _slice: slice = dataclasses.field(default_factory=lambda: slice(None, None, None)) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - - Raises: - ValueError: If the slice step is zero. - """ - start, end, step = self._slice.start, self._slice.stop, self._slice.step - - normalized_start = ( - LiteralVar.create(start) - if start is not None - else ImmutableVar.create_safe("undefined") - ) - normalized_end = ( - LiteralVar.create(end) - if end is not None - else ImmutableVar.create_safe("undefined") - ) - if step is None: - return f"{str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)})" - if not isinstance(step, Var): - if step < 0: - actual_start = end + 1 if end is not None else 0 - actual_end = start + 1 if start is not None else self._array.length() - return str( - ArraySliceOperation.create( - ArrayReverseOperation.create( - ArraySliceOperation.create( - self._array, slice(actual_start, actual_end) - ) - ), - slice(None, None, -step), - ) - ) - if step == 0: - raise ValueError("slice step cannot be zero") - return f"{str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0)" - - actual_start_reverse = end + 1 if end is not None else 0 - actual_end_reverse = start + 1 if start is not None else self._array.length() - - return f"{str(self.step)} > 0 ? {str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0) : {str(self._array)}.slice({str(actual_start_reverse)}, {str(actual_end_reverse)}).reverse().filter((_, i) => i % {str(-step)} === 0)" - - @classmethod - def create( - cls, - array: ArrayVar, - slice: slice, - _var_data: VarData | None = None, - ) -> ArraySliceOperation: - """Create a var from a string value. - - Args: - array: The array. - slice: The slice. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=array._var_type, - _var_data=ImmutableVarData.merge(_var_data), - _array=array, - _slice=slice, - ) - - -class ArrayReverseOperation(ArrayToArrayOperation): - """Base class for immutable string vars that are the result of a string reverse operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._value)}.slice().reverse()" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayToNumberOperation(CachedVarOperation, NumberVar): - """Base class for immutable number vars that are the result of an array to number operation.""" - - _array: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]), - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "StringToNumberOperation must implement _cached_var_name" - ) - - @classmethod - def create( - cls, - array: ArrayVar, - _var_data: VarData | None = None, - ) -> ArrayToNumberOperation: - """Create a var from a string value. - - Args: - array: The array. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=int, - _var_data=ImmutableVarData.merge(_var_data), - _array=array, - ) - - -class ArrayLengthOperation(ArrayToNumberOperation): - """Base class for immutable number vars that are the result of an array length operation.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._array)}.length" - - -def is_tuple_type(t: GenericType) -> bool: - """Check if a type is a tuple type. - - Args: - t: The type to check. - - Returns: - Whether the type is a tuple type. - """ - if inspect.isclass(t): - return issubclass(t, tuple) - return get_origin(t) is tuple - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayItemOperation(CachedVarOperation, ImmutableVar): - """Base class for immutable array vars that are the result of an array item operation.""" - - _array: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _index: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._array)}.at({str(self._index)})" - - @classmethod - def create( - cls, - array: ArrayVar, - index: NumberVar | int, - _var_type: GenericType | None = None, - _var_data: VarData | None = None, - ) -> ArrayItemOperation: - """Create a var from a string value. - - Args: - array: The array. - index: The index. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - args = typing.get_args(array._var_type) - if args and isinstance(index, int) and is_tuple_type(array._var_type): - element_type = args[index % len(args)] - else: - element_type = unionize(*args) - - return cls( - _var_name="", - _var_type=element_type if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - _array=array, - _index=index if isinstance(index, Var) else LiteralNumberVar.create(index), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class RangeOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of a range operation.""" - - _start: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - _stop: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - _step: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(1) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - start, end, step = self._start, self._stop, self._step - return f"Array.from({{ length: ({str(end)} - {str(start)}) / {str(step)} }}, (_, i) => {str(start)} + i * {str(step)})" - - @classmethod - def create( - cls, - start: NumberVar | int, - stop: NumberVar | int, - step: NumberVar | int, - _var_data: VarData | None = None, - ) -> RangeOperation: - """Create a var from a string value. - - Args: - start: The start of the range. - stop: The end of the range. - step: The step of the range. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=List[int], - _var_data=ImmutableVarData.merge(_var_data), - _start=start if isinstance(start, Var) else LiteralNumberVar.create(start), - _stop=stop if isinstance(stop, Var) else LiteralNumberVar.create(stop), - _step=step if isinstance(step, Var) else LiteralNumberVar.create(step), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayContainsOperation(CachedVarOperation, BooleanVar): - """Base class for immutable boolean vars that are the result of an array contains operation.""" - - _haystack: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _needle: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self._haystack)}.includes({str(self._needle)})" - - @classmethod - def create( - cls, - haystack: ArrayVar, - needle: Any | Var, - _var_data: VarData | None = None, - ) -> ArrayContainsOperation: - """Create a var from a string value. - - Args: - haystack: The array. - needle: The element to check for. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _haystack=haystack, - _needle=needle if isinstance(needle, Var) else LiteralVar.create(needle), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToStringOperation(CachedVarOperation, StringVar): - """Base class for immutable string vars that are the result of a to string operation.""" - - _original_var: Var = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_var) - - @classmethod - def create( - cls, - original_var: Var, - _var_data: VarData | None = None, - ) -> ToStringOperation: - """Create a var from a string value. - - Args: - original_var: The original var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - _original_var=original_var, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToArrayOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of a to array operation.""" - - _original_var: Var = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_var) - - @classmethod - def create( - cls, - original_var: Var, - _var_type: type[list] | type[set] | type[tuple] | None = None, - _var_data: VarData | None = None, - ) -> ToArrayOperation: - """Create a var from a string value. - - Args: - original_var: The original var. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=list if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - _original_var=original_var, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayRepeatOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of an array repeat operation.""" - - _array: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _count: NumberVar = dataclasses.field( - default_factory=lambda: LiteralNumberVar.create(0) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"Array.from({{ length: {str(self._count)} }}).flatMap(() => {str(self._array)})" - - @classmethod - def create( - cls, - array: ArrayVar, - count: NumberVar | int, - _var_data: VarData | None = None, - ) -> ArrayRepeatOperation: - """Create a var from a string value. - - Args: - array: The array. - count: The number of times to repeat the array. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - return cls( - _var_name="", - _var_type=array._var_type, - _var_data=ImmutableVarData.merge(_var_data), - _array=array, - _count=count if isinstance(count, Var) else LiteralNumberVar.create(count), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayConcatOperation(CachedVarOperation, ArrayVar): - """Base class for immutable array vars that are the result of an array concat operation.""" - - _lhs: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - _rhs: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar.create([]) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"[...{str(self._lhs)}, ...{str(self._rhs)}]" - - @classmethod - def create( - cls, - lhs: ArrayVar, - rhs: ArrayVar, - _var_data: VarData | None = None, - ) -> ArrayConcatOperation: - """Create a var from a string value. - - Args: - lhs: The left-hand side array. - rhs: The right-hand side array. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - # TODO: Figure out how to merge the types of a and b - return cls( - _var_name="", - _var_type=Union[lhs._var_type, rhs._var_type], - _var_data=ImmutableVarData.merge(_var_data), - _lhs=lhs, - _rhs=rhs, - ) diff --git a/reflex/middleware/hydrate_middleware.py b/reflex/middleware/hydrate_middleware.py index b5694e22f..46b524cd7 100644 --- a/reflex/middleware/hydrate_middleware.py +++ b/reflex/middleware/hydrate_middleware.py @@ -2,6 +2,7 @@ from __future__ import annotations +import dataclasses from typing import TYPE_CHECKING, Optional from reflex import constants @@ -14,6 +15,7 @@ if TYPE_CHECKING: from reflex.app import App +@dataclasses.dataclass(init=True) class HydrateMiddleware(Middleware): """Middleware to handle initial app hydration.""" diff --git a/reflex/middleware/middleware.py b/reflex/middleware/middleware.py index 76cbcfe9a..ef9de0bde 100644 --- a/reflex/middleware/middleware.py +++ b/reflex/middleware/middleware.py @@ -2,10 +2,9 @@ from __future__ import annotations -from abc import ABC +from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Optional -from reflex.base import Base from reflex.event import Event from reflex.state import BaseState, StateUpdate @@ -13,9 +12,10 @@ if TYPE_CHECKING: from reflex.app import App -class Middleware(Base, ABC): +class Middleware(ABC): """Middleware to preprocess and postprocess requests.""" + @abstractmethod async def preprocess( self, app: App, state: BaseState, event: Event ) -> Optional[StateUpdate]: diff --git a/reflex/model.py b/reflex/model.py index 71e26f76a..fefb1f9e9 100644 --- a/reflex/model.py +++ b/reflex/model.py @@ -15,6 +15,7 @@ import alembic.runtime.environment import alembic.script import alembic.util import sqlalchemy +import sqlalchemy.exc import sqlalchemy.orm from reflex import constants @@ -51,6 +52,27 @@ def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine: return sqlmodel.create_engine(url, echo=echo_db_query, connect_args=connect_args) +async def get_db_status() -> bool: + """Checks the status of the database connection. + + Attempts to connect to the database and execute a simple query to verify connectivity. + + Returns: + bool: The status of the database connection: + - True: The database is accessible. + - False: The database is not accessible. + """ + status = True + try: + engine = get_engine() + with engine.connect() as connection: + connection.execute(sqlalchemy.text("SELECT 1")) + except sqlalchemy.exc.OperationalError: + status = False + + return status + + SQLModelOrSqlAlchemy = Union[ Type[sqlmodel.SQLModel], Type[sqlalchemy.orm.DeclarativeBase] ] diff --git a/reflex/page.py b/reflex/page.py index 1e5e8603d..27a3c4fa8 100644 --- a/reflex/page.py +++ b/reflex/page.py @@ -63,15 +63,3 @@ def page( return render_fn return decorator - - -def get_decorated_pages() -> list[dict]: - """Get the decorated pages. - - Returns: - The decorated pages. - """ - return sorted( - [page_data for _, page_data in DECORATED_PAGES[get_config().app_name]], - key=lambda x: x["route"], - ) diff --git a/reflex/reflex.py b/reflex/reflex.py index 741873f4e..c90e328e4 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -16,6 +16,7 @@ from reflex_cli.utils import dependency from reflex import constants from reflex.config import get_config from reflex.custom_components.custom_components import custom_components_cli +from reflex.state import reset_disk_state_manager from reflex.utils import console, redir, telemetry # Disable typer+rich integration for help panels @@ -180,6 +181,9 @@ def _run( if prerequisites.needs_reinit(frontend=frontend): _init(name=config.app_name, loglevel=loglevel) + # Delete the states folder if it exists. + reset_disk_state_manager() + # Find the next available open port if applicable. if frontend: frontend_port = processes.handle_port( diff --git a/reflex/state.py b/reflex/state.py index 6712edd81..5223be7e5 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -5,12 +5,14 @@ from __future__ import annotations import asyncio import contextlib import copy +import dataclasses import functools import inspect import os import uuid from abc import ABC, abstractmethod from collections import defaultdict +from pathlib import Path from types import FunctionType, MethodType from typing import ( TYPE_CHECKING, @@ -23,6 +25,7 @@ from typing import ( Optional, Sequence, Set, + Tuple, Type, Union, cast, @@ -32,7 +35,14 @@ import dill from sqlalchemy.orm import DeclarativeBase from reflex.config import get_config -from reflex.ivars.base import ImmutableComputedVar, ImmutableVar, immutable_computed_var +from reflex.vars.base import ( + ComputedVar, + DynamicRouteVar, + Var, + computed_var, + dispatch, + is_computed_var, +) try: import pydantic.v1 as pydantic @@ -52,36 +62,41 @@ from reflex.event import ( EventSpec, fix_events, ) -from reflex.utils import console, format, prerequisites, types -from reflex.utils.exceptions import ImmutableStateError, LockExpiredError +from reflex.utils import console, format, path_ops, prerequisites, types +from reflex.utils.exceptions import ( + ComputedVarShadowsBaseVars, + ComputedVarShadowsStateVar, + DynamicRouteArgShadowsStateVar, + EventHandlerShadowsBuiltInStateMethod, + ImmutableStateError, + LockExpiredError, +) from reflex.utils.exec import is_testing_env from reflex.utils.serializers import SerializedType, serialize, serializer from reflex.utils.types import override -from reflex.vars import ( - ComputedVar, - ImmutableVarData, - Var, -) +from reflex.vars import VarData if TYPE_CHECKING: from reflex.components.component import Component Delta = Dict[str, Any] -var = immutable_computed_var +var = computed_var # If the state is this large, it's considered a performance issue. TOO_LARGE_SERIALIZED_STATE = 100 * 1024 # 100kb -class HeaderData(Base): +@dataclasses.dataclass(frozen=True) +class HeaderData: """An object containing headers data.""" host: str = "" origin: str = "" upgrade: str = "" connection: str = "" + cookie: str = "" pragma: str = "" cache_control: str = "" user_agent: str = "" @@ -97,13 +112,16 @@ class HeaderData(Base): Args: router_data: the router_data dict. """ - super().__init__() if router_data: for k, v in router_data.get(constants.RouteVar.HEADERS, {}).items(): - setattr(self, format.to_snake_case(k), v) + object.__setattr__(self, format.to_snake_case(k), v) + else: + for k in dataclasses.fields(self): + object.__setattr__(self, k.name, "") -class PageData(Base): +@dataclasses.dataclass(frozen=True) +class PageData: """An object containing page data.""" host: str = "" # repeated with self.headers.origin (remove or keep the duplicate?) @@ -111,7 +129,7 @@ class PageData(Base): raw_path: str = "" full_path: str = "" full_raw_path: str = "" - params: dict = {} + params: dict = dataclasses.field(default_factory=dict) def __init__(self, router_data: Optional[dict] = None): """Initalize the PageData object based on router_data. @@ -119,17 +137,34 @@ class PageData(Base): Args: router_data: the router_data dict. """ - super().__init__() if router_data: - self.host = router_data.get(constants.RouteVar.HEADERS, {}).get("origin") - self.path = router_data.get(constants.RouteVar.PATH, "") - self.raw_path = router_data.get(constants.RouteVar.ORIGIN, "") - self.full_path = f"{self.host}{self.path}" - self.full_raw_path = f"{self.host}{self.raw_path}" - self.params = router_data.get(constants.RouteVar.QUERY, {}) + object.__setattr__( + self, + "host", + router_data.get(constants.RouteVar.HEADERS, {}).get("origin", ""), + ) + object.__setattr__( + self, "path", router_data.get(constants.RouteVar.PATH, "") + ) + object.__setattr__( + self, "raw_path", router_data.get(constants.RouteVar.ORIGIN, "") + ) + object.__setattr__(self, "full_path", f"{self.host}{self.path}") + object.__setattr__(self, "full_raw_path", f"{self.host}{self.raw_path}") + object.__setattr__( + self, "params", router_data.get(constants.RouteVar.QUERY, {}) + ) + else: + object.__setattr__(self, "host", "") + object.__setattr__(self, "path", "") + object.__setattr__(self, "raw_path", "") + object.__setattr__(self, "full_path", "") + object.__setattr__(self, "full_raw_path", "") + object.__setattr__(self, "params", {}) -class SessionData(Base): +@dataclasses.dataclass(frozen=True, init=False) +class SessionData: """An object containing session data.""" client_token: str = "" @@ -142,19 +177,24 @@ class SessionData(Base): Args: router_data: the router_data dict. """ - super().__init__() if router_data: - self.client_token = router_data.get(constants.RouteVar.CLIENT_TOKEN, "") - self.client_ip = router_data.get(constants.RouteVar.CLIENT_IP, "") - self.session_id = router_data.get(constants.RouteVar.SESSION_ID, "") + client_token = router_data.get(constants.RouteVar.CLIENT_TOKEN, "") + client_ip = router_data.get(constants.RouteVar.CLIENT_IP, "") + session_id = router_data.get(constants.RouteVar.SESSION_ID, "") + else: + client_token = client_ip = session_id = "" + object.__setattr__(self, "client_token", client_token) + object.__setattr__(self, "client_ip", client_ip) + object.__setattr__(self, "session_id", session_id) -class RouterData(Base): +@dataclasses.dataclass(frozen=True, init=False) +class RouterData: """An object containing RouterData.""" - session: SessionData = SessionData() - headers: HeaderData = HeaderData() - page: PageData = PageData() + session: SessionData = dataclasses.field(default_factory=SessionData) + headers: HeaderData = dataclasses.field(default_factory=HeaderData) + page: PageData = dataclasses.field(default_factory=PageData) def __init__(self, router_data: Optional[dict] = None): """Initialize the RouterData object. @@ -162,10 +202,9 @@ class RouterData(Base): Args: router_data: the router_data dict. """ - super().__init__() - self.session = SessionData(router_data) - self.headers = HeaderData(router_data) - self.page = PageData(router_data) + object.__setattr__(self, "session", SessionData(router_data)) + object.__setattr__(self, "headers", HeaderData(router_data)) + object.__setattr__(self, "page", PageData(router_data)) def _no_chain_background_task( @@ -241,10 +280,11 @@ def _split_substate_key(substate_key: str) -> tuple[str, str]: return token, state_name +@dataclasses.dataclass(frozen=True, init=False) class EventHandlerSetVar(EventHandler): """A special event handler to wrap setvar functionality.""" - state_cls: Type[BaseState] + state_cls: Type[BaseState] = dataclasses.field(init=False) def __init__(self, state_cls: Type[BaseState]): """Initialize the EventHandlerSetVar. @@ -255,8 +295,8 @@ class EventHandlerSetVar(EventHandler): super().__init__( fn=type(self).setvar, state_full_name=state_cls.get_full_name(), - state_cls=state_cls, # type: ignore ) + object.__setattr__(self, "state_cls", state_cls) def setvar(self, var_name: str, value: Any): """Set the state variable to the value of the event. @@ -297,6 +337,29 @@ class EventHandlerSetVar(EventHandler): return super().__call__(*args) +if TYPE_CHECKING: + from pydantic.v1.fields import ModelField + + +def get_var_for_field(cls: Type[BaseState], f: ModelField): + """Get a Var instance for a Pydantic field. + + Args: + cls: The state class. + f: The Pydantic field. + + Returns: + The Var instance. + """ + field_name = format.format_state_name(cls.get_full_name()) + "." + f.name + + return dispatch( + field_name=field_name, + var_data=VarData.from_state(cls, f.name), + result_var_type=f.outer_type_, + ) + + class BaseState(Base, ABC, extra=pydantic.Extra.allow): """The state of the app.""" @@ -304,10 +367,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): vars: ClassVar[Dict[str, Var]] = {} # The base vars of the class. - base_vars: ClassVar[Dict[str, ImmutableVar]] = {} + base_vars: ClassVar[Dict[str, Var]] = {} # The computed vars of the class. - computed_vars: ClassVar[Dict[str, Union[ComputedVar, ImmutableComputedVar]]] = {} + computed_vars: ClassVar[Dict[str, ComputedVar]] = {} # Vars inherited by the parent state. inherited_vars: ClassVar[Dict[str, Var]] = {} @@ -420,7 +483,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return f"{self.__class__.__name__}({self.dict()})" @classmethod - def _get_computed_vars(cls) -> list[Union[ComputedVar, ImmutableComputedVar]]: + def _get_computed_vars(cls) -> list[ComputedVar]: """Helper function to get all computed vars of a instance. Returns: @@ -429,8 +492,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return [ v for mixin in cls._mixins() + [cls] - for v in mixin.__dict__.values() - if isinstance(v, (ComputedVar, ImmutableComputedVar)) + for name, v in mixin.__dict__.items() + if is_computed_var(v) and name not in cls.inherited_vars ] @classmethod @@ -474,7 +537,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls._check_overridden_methods() # Computed vars should not shadow builtin state props. - cls._check_overriden_basevars() + cls._check_overridden_basevars() # Reset subclass tracking for this class. cls.class_subclasses = set() @@ -492,26 +555,17 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if cls.get_name() in set( c.get_name() for c in parent_state.class_subclasses ): - if is_testing_env(): - # Clear existing subclass with same name when app is reloaded via - # utils.prerequisites.get_app(reload=True) - parent_state.class_subclasses = set( - c - for c in parent_state.class_subclasses - if c.get_name() != cls.get_name() - ) - else: - # During normal operation, subclasses cannot have the same name, even if they are - # defined in different modules. - raise StateValueError( - f"The substate class '{cls.get_name()}' has been defined multiple times. " - "Shadowing substate classes is not allowed." - ) + # This should not happen, since we have added module prefix to state names in #3214 + raise StateValueError( + f"The substate class '{cls.get_name()}' has been defined multiple times. " + "Shadowing substate classes is not allowed." + ) # Track this new subclass in the parent state's subclasses set. parent_state.class_subclasses.add(cls) # Get computed vars. computed_vars = cls._get_computed_vars() + cls._check_overridden_computed_vars() new_backend_vars = { name: value @@ -526,16 +580,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Set the base and computed vars. cls.base_vars = { - f.name: ImmutableVar( - _var_name=format.format_state_name(cls.get_full_name()) + "." + f.name, - _var_type=f.outer_type_, - _var_data=ImmutableVarData.from_state(cls), - ).guess_type() + f.name: get_var_for_field(cls, f) for f in cls.get_fields().values() if f.name not in cls.get_skip_vars() } cls.computed_vars = { - v._var_name: v._replace(merge_var_data=ImmutableVarData.from_state(cls)) + v._js_expr: v._replace(merge_var_data=VarData.from_state(cls)) for v in computed_vars } cls.vars = { @@ -558,15 +608,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for mixin in cls._mixins(): for name, value in mixin.__dict__.items(): - if isinstance(value, (ComputedVar, ImmutableComputedVar)): + if name in cls.inherited_vars: + continue + if is_computed_var(value): fget = cls._copy_fn(value.fget) - newcv = value._replace( - fget=fget, _var_data=ImmutableVarData.from_state(cls) - ) + newcv = value._replace(fget=fget, _var_data=VarData.from_state(cls)) # cleanup refs to mixin cls in var_data setattr(cls, name, newcv) - cls.computed_vars[newcv._var_name] = newcv - cls.vars[newcv._var_name] = newcv + cls.computed_vars[newcv._js_expr] = newcv + cls.vars[newcv._js_expr] = newcv continue if types.is_backend_base_variable(name, mixin): cls.backend_vars[name] = copy.deepcopy(value) @@ -589,6 +639,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls.event_handlers[name] = handler setattr(cls, name, handler) + # Initialize per-class var dependency tracking. + cls._computed_var_dependencies = defaultdict(set) + cls._substate_var_dependencies = defaultdict(set) cls._init_var_dependency_dicts() @staticmethod @@ -658,10 +711,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Additional updates tracking dicts for vars and substates that always need to be recomputed. """ - # Initialize per-class var dependency tracking. - cls._computed_var_dependencies = defaultdict(set) - cls._substate_var_dependencies = defaultdict(set) - inherited_vars = set(cls.inherited_vars).union( set(cls.inherited_backend_vars), ) @@ -707,7 +756,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): """Check for shadow methods and raise error if any. Raises: - NameError: When an event handler shadows an inbuilt state method. + EventHandlerShadowsBuiltInStateMethod: When an event handler shadows an inbuilt state method. """ overridden_methods = set() state_base_functions = cls._get_base_functions() @@ -721,21 +770,37 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): overridden_methods.add(method.__name__) for method_name in overridden_methods: - raise NameError( + raise EventHandlerShadowsBuiltInStateMethod( f"The event handler name `{method_name}` shadows a builtin State method; use a different name instead" ) @classmethod - def _check_overriden_basevars(cls): + def _check_overridden_basevars(cls): """Check for shadow base vars and raise error if any. Raises: - NameError: When a computed var shadows a base var. + ComputedVarShadowsBaseVars: When a computed var shadows a base var. """ for computed_var_ in cls._get_computed_vars(): - if computed_var_._var_name in cls.__annotations__: - raise NameError( - f"The computed var name `{computed_var_._var_name}` shadows a base var in {cls.__module__}.{cls.__name__}; use a different name instead" + if computed_var_._js_expr in cls.__annotations__: + raise ComputedVarShadowsBaseVars( + f"The computed var name `{computed_var_._js_expr}` shadows a base var in {cls.__module__}.{cls.__name__}; use a different name instead" + ) + + @classmethod + def _check_overridden_computed_vars(cls) -> None: + """Check for shadow computed vars and raise error if any. + + Raises: + ComputedVarShadowsStateVar: When a computed var shadows another. + """ + for name, cv in cls.__dict__.items(): + if not is_computed_var(cv): + continue + name = cv._js_expr + if name in cls.inherited_vars or name in cls.inherited_backend_vars: + raise ComputedVarShadowsStateVar( + f"The computed var name `{cv._js_expr}` shadows a var in {cls.__module__}.{cls.__name__}; use a different name instead" ) @classmethod @@ -857,7 +922,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return getattr(substate, name) @classmethod - def _init_var(cls, prop: ImmutableVar): + def _init_var(cls, prop: Var): """Initialize a variable. Args: @@ -873,7 +938,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): "State vars must be primitive Python types, " "Plotly figures, Pandas dataframes, " "or subclasses of rx.Base. " - f'Found var "{prop._var_name}" with type {prop._var_type}.' + f'Found var "{prop._js_expr}" with type {prop._var_type}.' ) cls._set_var(prop) cls._create_setter(prop) @@ -900,10 +965,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): ) # create the variable based on name and type - var = ImmutableVar( - _var_name=format.format_state_name(cls.get_full_name()) + "." + name, + var = Var( + _js_expr=format.format_state_name(cls.get_full_name()) + "." + name, _var_type=type_, - _var_data=ImmutableVarData.from_state(cls), + _var_data=VarData.from_state(cls, name), ).guess_type() # add the pydantic field dynamically (must be done before _init_var) @@ -923,18 +988,13 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls._init_var_dependency_dicts() @classmethod - def _set_var(cls, prop: ImmutableVar): + def _set_var(cls, prop: Var): """Set the var as a class member. Args: prop: The var instance to set. """ - acutal_var_name = ( - prop._var_name - if "." not in prop._var_name - else prop._var_name.split(".")[-1] - ) - setattr(cls, acutal_var_name, prop) + setattr(cls, prop._var_field_name, prop) @classmethod def _create_event_handler(cls, fn): @@ -954,7 +1014,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls.setvar = cls.event_handlers["setvar"] = EventHandlerSetVar(state_cls=cls) @classmethod - def _create_setter(cls, prop: ImmutableVar): + def _create_setter(cls, prop: Var): """Create a setter for the var. Args: @@ -967,17 +1027,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): setattr(cls, setter_name, event_handler) @classmethod - def _set_default_value(cls, prop: ImmutableVar): + def _set_default_value(cls, prop: Var): """Set the default value for the var. Args: prop: The var to set the default value for. """ # Get the pydantic field for the var. - if "." in prop._var_name: - field = cls.get_fields()[prop._var_name.split(".")[-1]] - else: - field = cls.get_fields()[prop._var_name] + field = cls.get_fields()[prop._var_field_name] if field.required: default_value = prop.get_default_value() if default_value is not None: @@ -1004,6 +1061,27 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if not func[0].startswith("__") } + @classmethod + def _update_substate_inherited_vars(cls, vars_to_add: dict[str, Var]): + """Update the inherited vars of substates recursively when new vars are added. + + Also updates the var dependency tracking dicts after adding vars. + + Args: + vars_to_add: names to Var instances to add to substates + """ + for substate_class in cls.class_subclasses: + for name, var in vars_to_add.items(): + if types.is_backend_base_variable(name, cls): + substate_class.backend_vars.setdefault(name, var) + substate_class.inherited_backend_vars.setdefault(name, var) + else: + substate_class.vars.setdefault(name, var) + substate_class.inherited_vars.setdefault(name, var) + substate_class._update_substate_inherited_vars(vars_to_add) + # Reinitialize dependency tracking dicts. + cls._init_var_dependency_dicts() + @classmethod def setup_dynamic_args(cls, args: dict[str, str]): """Set up args for easy access in renderer. @@ -1011,21 +1089,24 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Args: args: a dict of args """ + if not args: + return + + cls._check_overwritten_dynamic_args(list(args.keys())) def argsingle_factory(param): - @ComputedVar def inner_func(self) -> str: return self.router.page.params.get(param, "") return inner_func def arglist_factory(param): - @ComputedVar - def inner_func(self) -> List: + def inner_func(self) -> List[str]: return self.router.page.params.get(param, []) return inner_func + dynamic_vars = {} for param, value in args.items(): if value == constants.RouteArgType.SINGLE: func = argsingle_factory(param) @@ -1033,13 +1114,39 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): func = arglist_factory(param) else: continue - # to allow passing as a prop - func._var_name = param - cls.vars[param] = cls.computed_vars[param] = func._var_set_state(cls) # type: ignore - setattr(cls, param, func) + dynamic_vars[param] = DynamicRouteVar( + fget=func, + cache=True, + _js_expr=param, + _var_data=VarData.from_state(cls), + ) + setattr(cls, param, dynamic_vars[param]) - # Reinitialize dependency tracking dicts. - cls._init_var_dependency_dicts() + # Update tracking dicts. + cls.computed_vars.update(dynamic_vars) + cls.vars.update(dynamic_vars) + cls._update_substate_inherited_vars(dynamic_vars) + + @classmethod + def _check_overwritten_dynamic_args(cls, args: list[str]): + """Check if dynamic args are shadowing existing vars. Recursively checks all child states. + + Args: + args: a dict of args + + Raises: + DynamicRouteArgShadowsStateVar: If a dynamic arg is shadowing an existing var. + """ + for arg in args: + if ( + arg in cls.computed_vars + and not isinstance(cls.computed_vars[arg], DynamicRouteVar) + ) or arg in cls.base_vars: + raise DynamicRouteArgShadowsStateVar( + f"Dynamic route arg '{arg}' is shadowing an existing var in {cls.__module__}.{cls.__name__}" + ) + for substate in cls.get_substates(): + substate._check_overwritten_dynamic_args(args) def __getattribute__(self, name: str) -> Any: """Get the state var. @@ -1209,6 +1316,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for part1, part2 in zip( cls.get_full_name().split("."), other.get_full_name().split("."), + strict=False, ): if part1 != part2: break @@ -1668,11 +1776,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): .union(self._always_dirty_computed_vars) ) - subdelta = { - prop: getattr(self, prop) + subdelta: Dict[str, Any] = { + prop: self.get_value(getattr(self, prop)) for prop in delta_vars if not types.is_backend_base_variable(prop, type(self)) } + if len(subdelta) > 0: delta[self.get_full_name()] = subdelta @@ -1786,16 +1895,21 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): self.dirty_vars.update(self._always_dirty_computed_vars) self._mark_dirty() + def dictify(value: Any): + if dataclasses.is_dataclass(value) and not isinstance(value, type): + return dataclasses.asdict(value) + return value + base_vars = { - prop_name: self.get_value(getattr(self, prop_name)) + prop_name: dictify(self.get_value(getattr(self, prop_name))) for prop_name in self.base_vars } - if initial: + if initial and include_computed: computed_vars = { # Include initial computed vars. prop_name: ( cv._initial_value - if isinstance(cv, (ComputedVar, ImmutableComputedVar)) + if is_computed_var(cv) and not isinstance(cv._initial_value, types.Unset) else self.get_value(getattr(self, prop_name)) ) @@ -1867,9 +1981,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return state -EventHandlerSetVar.update_forward_refs() - - class State(BaseState): """The app Base State.""" @@ -2293,25 +2404,37 @@ class StateProxy(wrapt.ObjectProxy): Returns: The state update. """ + original_mutable = self._self_mutable self._self_mutable = True try: return self.__wrapped__._as_state_update(*args, **kwargs) finally: - self._self_mutable = False + self._self_mutable = original_mutable -class StateUpdate(Base): +@dataclasses.dataclass( + frozen=True, +) +class StateUpdate: """A state update sent to the frontend.""" # The state delta. - delta: Delta = {} + delta: Delta = dataclasses.field(default_factory=dict) # Events to be added to the event queue. - events: List[Event] = [] + events: List[Event] = dataclasses.field(default_factory=list) # Whether this is the final state update for the event. final: bool = True + def json(self) -> str: + """Convert the state update to a JSON string. + + Returns: + The state update as a JSON string. + """ + return format.json_dumps(dataclasses.asdict(self)) + class StateManager(Base, ABC): """A class to manage many client states.""" @@ -2339,7 +2462,7 @@ class StateManager(Base, ABC): token_expiration=config.redis_token_expiration, lock_expiration=config.redis_lock_expiration, ) - return StateManagerMemory(state=state) + return StateManagerDisk(state=state) @abstractmethod async def get_state(self, token: str) -> BaseState: @@ -2446,6 +2569,266 @@ class StateManagerMemory(StateManager): await self.set_state(token, state) +def _default_token_expiration() -> int: + """Get the default token expiration time. + + Returns: + The default token expiration time. + """ + return get_config().redis_token_expiration + + +def _serialize_type(type_: Any) -> str: + """Serialize a type. + + Args: + type_: The type to serialize. + + Returns: + The serialized type. + """ + if not inspect.isclass(type_): + return f"{type_}" + return f"{type_.__module__}.{type_.__qualname__}" + + +def state_to_schema( + state: BaseState, +) -> List[ + Tuple[ + str, + str, + Any, + Union[bool, None], + ] +]: + """Convert a state to a schema. + + Args: + state: The state to convert to a schema. + + Returns: + The schema. + """ + return list( + sorted( + ( + field_name, + model_field.name, + _serialize_type(model_field.type_), + ( + model_field.required + if isinstance(model_field.required, bool) + else None + ), + ) + for field_name, model_field in state.__fields__.items() + ) + ) + + +def reset_disk_state_manager(): + """Reset the disk state manager.""" + states_directory = prerequisites.get_web_dir() / constants.Dirs.STATES + if states_directory.exists(): + for path in states_directory.iterdir(): + path.unlink() + + +class StateManagerDisk(StateManager): + """A state manager that stores states in memory.""" + + # The mapping of client ids to states. + states: Dict[str, BaseState] = {} + + # The mutex ensures the dict of mutexes is updated exclusively + _state_manager_lock = asyncio.Lock() + + # The dict of mutexes for each client + _states_locks: Dict[str, asyncio.Lock] = pydantic.PrivateAttr({}) + + # The token expiration time (s). + token_expiration: int = pydantic.Field(default_factory=_default_token_expiration) + + class Config: + """The Pydantic config.""" + + fields = { + "_states_locks": {"exclude": True}, + } + keep_untouched = (functools.cached_property,) + + def __init__(self, state: Type[BaseState]): + """Create a new state manager. + + Args: + state: The state class to use. + """ + super().__init__(state=state) + + path_ops.mkdir(self.states_directory) + + self._purge_expired_states() + + @functools.cached_property + def states_directory(self) -> Path: + """Get the states directory. + + Returns: + The states directory. + """ + return prerequisites.get_web_dir() / constants.Dirs.STATES + + def _purge_expired_states(self): + """Purge expired states from the disk.""" + import time + + for path in path_ops.ls(self.states_directory): + # check path is a pickle file + if path.suffix != ".pkl": + continue + + # load last edited field from file + last_edited = path.stat().st_mtime + + # check if the file is older than the token expiration time + if time.time() - last_edited > self.token_expiration: + # remove the file + path.unlink() + + def token_path(self, token: str) -> Path: + """Get the path for a token. + + Args: + token: The token to get the path for. + + Returns: + The path for the token. + """ + return (self.states_directory / f"{token}.pkl").absolute() + + async def load_state(self, token: str, root_state: BaseState) -> BaseState: + """Load a state object based on the provided token. + + Args: + token: The token used to identify the state object. + root_state: The root state object. + + Returns: + The loaded state object. + """ + if token in self.states: + return self.states[token] + + client_token, substate_address = _split_substate_key(token) + + token_path = self.token_path(token) + + if token_path.exists(): + try: + with token_path.open(mode="rb") as file: + (substate_schema, substate) = dill.load(file) + if substate_schema == state_to_schema(substate): + await self.populate_substates(client_token, substate, root_state) + return substate + except Exception: + pass + + return root_state.get_substate(substate_address.split(".")[1:]) + + async def populate_substates( + self, client_token: str, state: BaseState, root_state: BaseState + ): + """Populate the substates of a state object. + + Args: + client_token: The client token. + state: The state object to populate. + root_state: The root state object. + """ + for substate in state.get_substates(): + substate_token = _substate_key(client_token, substate) + + substate = await self.load_state(substate_token, root_state) + + state.substates[substate.get_name()] = substate + substate.parent_state = state + + @override + async def get_state( + self, + token: str, + ) -> BaseState: + """Get the state for a token. + + Args: + token: The token to get the state for. + + Returns: + The state for the token. + """ + client_token, substate_address = _split_substate_key(token) + + root_state_token = _substate_key(client_token, substate_address.split(".")[0]) + + return await self.load_state( + root_state_token, self.state(_reflex_internal_init=True) + ) + + async def set_state_for_substate(self, client_token: str, substate: BaseState): + """Set the state for a substate. + + Args: + client_token: The client token. + substate: The substate to set. + """ + substate_token = _substate_key(client_token, substate) + + self.states[substate_token] = substate + + state_dilled = dill.dumps((state_to_schema(substate), substate)) + if not self.states_directory.exists(): + self.states_directory.mkdir(parents=True, exist_ok=True) + self.token_path(substate_token).write_bytes(state_dilled) + + for substate_substate in substate.substates.values(): + await self.set_state_for_substate(client_token, substate_substate) + + @override + async def set_state(self, token: str, state: BaseState): + """Set the state for a token. + + Args: + token: The token to set the state for. + state: The state to set. + """ + client_token, substate = _split_substate_key(token) + await self.set_state_for_substate(client_token, state) + + @override + @contextlib.asynccontextmanager + async def modify_state(self, token: str) -> AsyncIterator[BaseState]: + """Modify the state for a token while holding exclusive lock. + + Args: + token: The token to modify the state for. + + Yields: + The state for the token. + """ + # Memory state manager ignores the substate suffix and always returns the top-level state. + client_token, substate = _split_substate_key(token) + if client_token not in self._states_locks: + async with self._state_manager_lock: + if client_token not in self._states_locks: + self._states_locks[client_token] = asyncio.Lock() + + async with self._states_locks[client_token]: + state = await self.get_state(token) + yield state + await self.set_state(token, state) + + # Workaround https://github.com/cloudpipe/cloudpickle/issues/408 for dynamic pydantic classes if not isinstance(State.validate.__func__, FunctionType): cython_function_or_method = type(State.validate.__func__) @@ -2474,15 +2857,6 @@ def _default_lock_expiration() -> int: return get_config().redis_lock_expiration -def _default_token_expiration() -> int: - """Get the default token expiration time. - - Returns: - The default token expiration time. - """ - return get_config().redis_token_expiration - - class StateManagerRedis(StateManager): """A state manager that stores states in redis.""" @@ -3361,5 +3735,7 @@ def reload_state_module( if subclass.__module__ == module and module is not None: state.class_subclasses.remove(subclass) state._always_dirty_substates.discard(subclass.get_name()) - state._init_var_dependency_dicts() + state._computed_var_dependencies = defaultdict(set) + state._substate_var_dependencies = defaultdict(set) + state._init_var_dependency_dicts() state.get_class_substate.cache_clear() diff --git a/reflex/style.py b/reflex/style.py index 0a8bb8db4..01e5378ed 100644 --- a/reflex/style.py +++ b/reflex/style.py @@ -6,14 +6,13 @@ from typing import Any, Literal, Tuple, Type from reflex import constants from reflex.components.core.breakpoints import Breakpoints, breakpoints_values -from reflex.event import EventChain -from reflex.ivars.base import ImmutableCallableVar, ImmutableVar, LiteralVar -from reflex.ivars.function import FunctionVar +from reflex.event import EventChain, EventHandler from reflex.utils import format +from reflex.utils.exceptions import ReflexError from reflex.utils.imports import ImportVar -from reflex.vars import ImmutableVarData, Var, VarData - -VarData.update_forward_refs() # Ensure all type definitions are resolved +from reflex.vars import VarData +from reflex.vars.base import CallableVar, LiteralVar, Var +from reflex.vars.function import FunctionVar SYSTEM_COLOR_MODE: str = "system" LIGHT_COLOR_MODE: str = "light" @@ -27,27 +26,27 @@ color_mode_imports = { } -def _color_mode_var(_var_name: str, _var_type: Type = str) -> ImmutableVar: - """Create a Var that destructs the _var_name from ColorModeContext. +def _color_mode_var(_js_expr: str, _var_type: Type = str) -> Var: + """Create a Var that destructs the _js_expr from ColorModeContext. Args: - _var_name: The name of the variable to get from ColorModeContext. + _js_expr: The name of the variable to get from ColorModeContext. _var_type: The type of the Var. Returns: The Var that resolves to the color mode. """ - return ImmutableVar( - _var_name=_var_name, + return Var( + _js_expr=_js_expr, _var_type=_var_type, - _var_data=ImmutableVarData( + _var_data=VarData( imports=color_mode_imports, - hooks={f"const {{ {_var_name} }} = useContext(ColorModeContext)": None}, + hooks={f"const {{ {_js_expr} }} = useContext(ColorModeContext)": None}, ), ).guess_type() -@ImmutableCallableVar +@CallableVar def set_color_mode( new_color_mode: LiteralColorMode | Var[LiteralColorMode] | None = None, ) -> Var[EventChain]: @@ -63,7 +62,7 @@ def set_color_mode( The EventChain Var that can be passed to an event trigger. """ base_setter = _color_mode_var( - _var_name=constants.ColorMode.SET, + _js_expr=constants.ColorMode.SET, _var_type=EventChain, ) if new_color_mode is None: @@ -72,21 +71,21 @@ def set_color_mode( if not isinstance(new_color_mode, Var): new_color_mode = LiteralVar.create(new_color_mode) - return ImmutableVar( + return Var( f"() => {str(base_setter)}({str(new_color_mode)})", - _var_data=ImmutableVarData.merge( + _var_data=VarData.merge( base_setter._get_all_var_data(), new_color_mode._get_all_var_data() ), - ).to(FunctionVar, EventChain) + ).to(FunctionVar, EventChain) # type: ignore # Var resolves to the current color mode for the app ("light", "dark" or "system") -color_mode = _color_mode_var(_var_name=constants.ColorMode.NAME) +color_mode = _color_mode_var(_js_expr=constants.ColorMode.NAME) # Var resolves to the resolved color mode for the app ("light" or "dark") -resolved_color_mode = _color_mode_var(_var_name=constants.ColorMode.RESOLVED_NAME) +resolved_color_mode = _color_mode_var(_js_expr=constants.ColorMode.RESOLVED_NAME) # Var resolves to a function invocation that toggles the color mode toggle_color_mode = _color_mode_var( - _var_name=constants.ColorMode.TOGGLE, + _js_expr=constants.ColorMode.TOGGLE, _var_type=EventChain, ) @@ -116,7 +115,7 @@ def media_query(breakpoint_expr: str): def convert_item( style_item: int | str | Var, -) -> tuple[str | Var, VarData | ImmutableVarData | None]: +) -> tuple[str | Var, VarData | None]: """Format a single value in a style dictionary. Args: @@ -124,7 +123,16 @@ def convert_item( Returns: The formatted style item and any associated VarData. + + Raises: + ReflexError: If an EventHandler is used as a style value """ + if isinstance(style_item, EventHandler): + raise ReflexError( + "EventHandlers cannot be used as style values. " + "Please use a Var or a literal value." + ) + if isinstance(style_item, Var): return style_item, style_item._get_all_var_data() @@ -285,7 +293,6 @@ def _format_emotion_style_pseudo_selector(key: str) -> str: """ prefix = None if key.startswith("_"): - # Handle pseudo selectors in chakra style format. prefix = "&:" key = key[1:] if key.startswith(":"): diff --git a/reflex/testing.py b/reflex/testing.py index c52396fc6..503db6c2f 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -45,6 +45,8 @@ import reflex.utils.prerequisites import reflex.utils.processes from reflex.state import ( BaseState, + StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, reload_state_module, @@ -126,7 +128,7 @@ class AppHarness: frontend_output_thread: Optional[threading.Thread] = None backend_thread: Optional[threading.Thread] = None backend: Optional[uvicorn.Server] = None - state_manager: Optional[StateManagerMemory | StateManagerRedis] = None + state_manager: Optional[StateManager] = None _frontends: list["WebDriver"] = dataclasses.field(default_factory=list) _decorated_pages: list = dataclasses.field(default_factory=list) @@ -290,6 +292,8 @@ class AppHarness: if isinstance(self.app_instance._state_manager, StateManagerRedis): # Create our own redis connection for testing. self.state_manager = StateManagerRedis.create(self.app_instance.state) + elif isinstance(self.app_instance._state_manager, StateManagerDisk): + self.state_manager = StateManagerDisk.create(self.app_instance.state) else: self.state_manager = self.app_instance._state_manager @@ -327,7 +331,8 @@ class AppHarness: ) ) self.backend.shutdown = self._get_backend_shutdown_handler() - self.backend_thread = threading.Thread(target=self.backend.run) + with chdir(self.app_path): + self.backend_thread = threading.Thread(target=self.backend.run) self.backend_thread.start() async def _reset_backend_state_manager(self): @@ -787,7 +792,7 @@ class AppHarness: raise RuntimeError("App is not running.") state_manager = self.app_instance.state_manager assert isinstance( - state_manager, StateManagerMemory + state_manager, (StateManagerMemory, StateManagerDisk) ), "Only works with memory state manager" if not self._poll_for( target=lambda: state_manager.states, diff --git a/reflex/utils/exceptions.py b/reflex/utils/exceptions.py index d219dcf0c..95d68c3b8 100644 --- a/reflex/utils/exceptions.py +++ b/reflex/utils/exceptions.py @@ -79,3 +79,35 @@ class LockExpiredError(ReflexError): class MatchTypeError(ReflexError, TypeError): """Raised when the return types of match cases are different.""" + + +class EventHandlerArgMismatch(ReflexError, TypeError): + """Raised when the number of args accepted by an EventHandler is differs from that provided by the event trigger.""" + + +class EventFnArgMismatch(ReflexError, TypeError): + """Raised when the number of args accepted by a lambda differs from that provided by the event trigger.""" + + +class DynamicRouteArgShadowsStateVar(ReflexError, NameError): + """Raised when a dynamic route arg shadows a state var.""" + + +class ComputedVarShadowsStateVar(ReflexError, NameError): + """Raised when a computed var shadows a state var.""" + + +class ComputedVarShadowsBaseVars(ReflexError, NameError): + """Raised when a computed var shadows a base var.""" + + +class EventHandlerShadowsBuiltInStateMethod(ReflexError, NameError): + """Raised when an event handler shadows a built-in state method.""" + + +class GeneratedCodeHasNoFunctionDefs(ReflexError): + """Raised when refactored code generated with flexgen has no functions defined.""" + + +class PrimitiveUnserializableToJSON(ReflexError, ValueError): + """Raised when a primitive type is unserializable to JSON. Usually with NaN and Infinity.""" diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 77df98116..417d6fbe7 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -18,22 +18,11 @@ from reflex import constants from reflex.config import get_config from reflex.utils import console, path_ops from reflex.utils.prerequisites import get_web_dir -from reflex.utils.watch import AssetFolderWatch # For uvicorn windows bug fix (#2335) frontend_process = None -def start_watching_assets_folder(root): - """Start watching assets folder. - - Args: - root: root path of the project. - """ - asset_watch = AssetFolderWatch(root) - asset_watch.start() - - def detect_package_change(json_file_path: str) -> str: """Calculates the SHA-256 hash of a JSON file and returns it as a hexadecimal string. @@ -149,8 +138,6 @@ def run_frontend(root: Path, port: str, backend_present=True): """ from reflex.utils import prerequisites - # Start watching asset folder. - start_watching_assets_folder(root) # validate dependencies before run prerequisites.validate_frontend_dependencies(init=False) @@ -215,7 +202,6 @@ def run_backend( log_level=loglevel.value, reload=True, reload_dirs=[config.app_name], - reload_excludes=[str(web_dir)], ) diff --git a/reflex/utils/format.py b/reflex/utils/format.py index e7d85a93e..86b4d96c9 100644 --- a/reflex/utils/format.py +++ b/reflex/utils/format.py @@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union from reflex import constants from reflex.utils import exceptions, types -from reflex.vars import BaseVar, Var +from reflex.utils.console import deprecate if TYPE_CHECKING: from reflex.components.component import ComponentStyle @@ -263,34 +263,6 @@ def format_string(string: str) -> str: return _wrap_js_string(_escape_js_string(string)) -def format_f_string_prop(prop: BaseVar) -> str: - """Format the string in a given prop as an f-string. - - Args: - prop: The prop to format. - - Returns: - The formatted string. - """ - from reflex.ivars.base import VarData - - s = prop._var_full_name - var_data = VarData.merge(prop._get_all_var_data()) - interps = var_data.interpolations if var_data else [] - parts: List[str] = [] - - if interps: - for i, (start, end) in enumerate(interps): - prev_end = interps[i - 1][1] if i > 0 else 0 - parts.append(_escape_js_string(s[prev_end:start])) - parts.append(s[start:end]) - parts.append(_escape_js_string(s[interps[-1][1] :])) - else: - parts.append(_escape_js_string(s)) - - return _wrap_js_string("".join(parts)) - - def format_var(var: Var) -> str: """Format the given Var as a javascript value. @@ -300,13 +272,7 @@ def format_var(var: Var) -> str: Returns: The formatted Var. """ - if not var._var_is_local or var._var_is_string: - return str(var) - if types._issubclass(var._var_type, str): - return format_string(var._var_full_name) - if is_wrapped(var._var_full_name, "{"): - return var._var_full_name - return json_dumps(var._var_full_name) + return str(var) def format_route(route: str, format_case=True) -> str: @@ -331,46 +297,11 @@ def format_route(route: str, format_case=True) -> str: return route -def format_cond( +def format_match( cond: str | Var, - true_value: str | Var, - false_value: str | Var = '""', - is_prop=False, + match_cases: List[List[Var]], + default: Var, ) -> str: - """Format a conditional expression. - - Args: - cond: The cond. - true_value: The value to return if the cond is true. - false_value: The value to return if the cond is false. - is_prop: Whether the cond is a prop - - Returns: - The formatted conditional expression. - """ - # Use Python truthiness. - cond = f"isTrue({cond})" - - def create_var(cond_part): - return Var.create_safe(cond_part, _var_is_string=isinstance(cond_part, str)) - - # Format prop conds. - if is_prop: - true_value = create_var(true_value) - prop1 = true_value._replace( - _var_is_local=True, - ) - - false_value = create_var(false_value) - prop2 = false_value._replace(_var_is_local=True) - # unwrap '{}' to avoid f-string semantics for Var - return f"{cond} ? {prop1._var_name_unwrapped} : {prop2._var_name_unwrapped}" - - # Format component conds. - return wrap(f"{cond} ? {true_value} : {false_value}", "{") - - -def format_match(cond: str | Var, match_cases: List[BaseVar], default: Var) -> str: """Format a match expression whose return type is a Var. Args: @@ -389,17 +320,12 @@ def format_match(cond: str | Var, match_cases: List[BaseVar], default: Var) -> s return_value = case[-1] case_conditions = " ".join( - [ - f"case JSON.stringify({condition._var_name_unwrapped}):" - for condition in conditions - ] - ) - case_code = ( - f"{case_conditions} return ({return_value._var_name_unwrapped}); break;" + [f"case JSON.stringify({str(condition)}):" for condition in conditions] ) + case_code = f"{case_conditions} return ({str(return_value)}); break;" switch_code += case_code - switch_code += f"default: return ({default._var_name_unwrapped}); break;" + switch_code += f"default: return ({str(default)}); break;" switch_code += "};})()" return switch_code @@ -423,22 +349,15 @@ def format_prop( # import here to avoid circular import. from reflex.event import EventChain from reflex.utils import serializers - from reflex.vars import VarData + from reflex.vars import Var try: # Handle var props. if isinstance(prop, Var): - if not prop._var_is_local or prop._var_is_string: - return str(prop) - if isinstance(prop, BaseVar) and types._issubclass(prop._var_type, str): - var_data = VarData.merge(prop._get_all_var_data()) - if var_data and var_data.interpolations: - return format_f_string_prop(prop) - return format_string(prop._var_full_name) - prop = prop._var_full_name + return str(prop) # Handle event props. - elif isinstance(prop, EventChain): + if isinstance(prop, EventChain): sig = inspect.signature(prop.args_spec) # type: ignore if sig.parameters: arg_def = ",".join(f"_{p}" for p in sig.parameters) @@ -487,26 +406,15 @@ def format_props(*single_props, **key_value_props) -> list[str]: The formatted props list. """ # Format all the props. - from reflex.ivars.base import ImmutableVar, LiteralVar + from reflex.vars.base import LiteralVar, Var return [ ( - f"{name}={format_prop(prop)}" - if isinstance(prop, Var) and not isinstance(prop, ImmutableVar) - else ( - f"{name}={{{format_prop(prop if isinstance(prop, Var) else LiteralVar.create(prop))}}}" - ) + f"{name}={{{format_prop(prop if isinstance(prop, Var) else LiteralVar.create(prop))}}}" ) for name, prop in sorted(key_value_props.items()) if prop is not None - ] + [ - ( - str(prop) - if isinstance(prop, Var) and not isinstance(prop, ImmutableVar) - else f"{{{str(LiteralVar.create(prop))}}}" - ) - for prop in single_props - ] + ] + [(f"{str(LiteralVar.create(prop))}") for prop in single_props] def get_event_handler_parts(handler: EventHandler) -> tuple[str, str]: @@ -567,14 +475,14 @@ def format_event(event_spec: EventSpec) -> str: [ ":".join( ( - name._var_name, + name._js_expr, ( wrap( - json.dumps(val._var_name).strip('"').replace("`", "\\`"), + json.dumps(val._js_expr).strip('"').replace("`", "\\`"), "`", ) if val._var_is_string - else val._var_full_name + else str(val) ), ) ) @@ -591,45 +499,40 @@ def format_event(event_spec: EventSpec) -> str: return f"Event({', '.join(event_args)})" +if TYPE_CHECKING: + from reflex.vars import Var + + def format_event_chain( event_chain: EventChain | Var[EventChain], event_arg: Var | None = None, ) -> str: - """Format an event chain as a javascript invocation. + """DEPRECATED: format an event chain as a javascript invocation. + + Use str(rx.Var.create(event_chain)) instead. Args: - event_chain: The event chain to queue on the frontend. - event_arg: The browser-native event (only used to preventDefault). + event_chain: The event chain to format. + event_arg: this argument is ignored. Returns: Compiled javascript code to queue the given event chain on the frontend. - - Raises: - ValueError: When the given event chain is not a valid event chain. """ - if isinstance(event_chain, Var): - from reflex.event import EventChain - - if event_chain._var_type is not EventChain: - raise ValueError(f"Invalid event chain: {event_chain}") - return "".join( - [ - "(() => {", - format_var(event_chain), - f"; preventDefault({format_var(event_arg)})" if event_arg else "", - "})()", - ] - ) - - chain = ",".join([format_event(event) for event in event_chain.events]) - return "".join( - [ - f"addEvents([{chain}]", - f", {format_var(event_arg)}" if event_arg else "", - ")", - ] + deprecate( + feature_name="format_event_chain", + reason="Use str(rx.Var.create(event_chain)) instead", + deprecation_version="0.6.0", + removal_version="0.7.0", ) + from reflex.vars import Var + from reflex.vars.function import ArgsFunctionOperation + + result = Var.create(event_chain) + if isinstance(result, ArgsFunctionOperation): + result = result._return_expr + return str(result) + def format_queue_events( events: ( @@ -666,10 +569,10 @@ def format_queue_events( call_event_fn, call_event_handler, ) - from reflex.ivars import FunctionVar, ImmutableVar + from reflex.vars import FunctionVar, Var if not events: - return ImmutableVar("(() => null)").to(FunctionVar, EventChain) + return Var("(() => null)").to(FunctionVar, EventChain) # type: ignore # If no spec is provided, the function will take no arguments. def _default_args_spec(): @@ -702,10 +605,10 @@ def format_queue_events( # Return the final code snippet, expecting queueEvents, processEvent, and socket to be in scope. # Typically this snippet will _only_ run from within an rx.call_script eval context. - return ImmutableVar( + return Var( f"{arg_def} => {{queueEvents([{','.join(payloads)}], {constants.CompileVars.SOCKET}); " f"processEvent({constants.CompileVars.SOCKET})}}", - ).to(FunctionVar, EventChain) + ).to(FunctionVar, EventChain) # type: ignore def format_query_params(router_data: dict[str, Any]) -> dict[str, str]: @@ -792,41 +695,6 @@ def format_ref(ref: str) -> str: return f"ref_{clean_ref}" -def format_array_ref(refs: str, idx: Var | None) -> str: - """Format a ref accessed by array. - - Args: - refs : The ref array to access. - idx : The index of the ref in the array. - - Returns: - The formatted ref. - """ - clean_ref = re.sub(r"[^\w]+", "_", refs) - if idx is not None: - # idx._var_is_local = True - return f"refs_{clean_ref}[{str(idx)}]" - return f"refs_{clean_ref}" - - -def format_breadcrumbs(route: str) -> list[tuple[str, str]]: - """Take a route and return a list of tuple for use in breadcrumb. - - Args: - route: The route to transform. - - Returns: - list[tuple[str, str]]: the list of tuples for the breadcrumb. - """ - route_parts = route.lstrip("/").split("/") - - # create and return breadcrumbs - return [ - (part, "/".join(["", *route_parts[: i + 1]])) - for i, part in enumerate(route_parts) - ] - - def format_library_name(library_fullname: str): """Format the name of a library. @@ -836,6 +704,8 @@ def format_library_name(library_fullname: str): Returns: The name without the @version if it was part of the name """ + if library_fullname.startswith("https://"): + return library_fullname lib, at, version = library_fullname.rpartition("@") if not lib: lib = at + version @@ -857,42 +727,6 @@ def json_dumps(obj: Any) -> str: return json.dumps(obj, ensure_ascii=False, default=serializers.serialize) -def unwrap_vars(value: str) -> str: - """Unwrap var values from a JSON string. - - For example, "{var}" will be unwrapped to "var". - - Args: - value: The JSON string to unwrap. - - Returns: - The unwrapped JSON string. - """ - - def unescape_double_quotes_in_var(m: re.Match) -> str: - prefix = m.group(1) or "" - # Since the outer quotes are removed, the inner escaped quotes must be unescaped. - return prefix + re.sub('\\\\"', '"', m.group(2)) - - # This substitution is necessary to unwrap var values. - return ( - re.sub( - pattern=r""" - (?.*?)? # Optional encoded VarData (non-greedy) - {(.*?)} # extract the value between curly braces (non-greedy) - " # match must end with an unescaped double quote - """, - repl=unescape_double_quotes_in_var, - string=value, - flags=re.VERBOSE, - ) - .replace('"`', "`") - .replace('`"', "`") - ) - - def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]: """Collapse keys with consecutive suffixes into a single list value. @@ -915,6 +749,23 @@ def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]: return collapsed +def format_array_ref(refs: str, idx: Var | None) -> str: + """Format a ref accessed by array. + + Args: + refs : The ref array to access. + idx : The index of the ref in the array. + + Returns: + The formatted ref. + """ + clean_ref = re.sub(r"[^\w]+", "_", refs) + if idx is not None: + # idx._var_is_local = True + return f"refs_{clean_ref}[{str(idx)}]" + return f"refs_{clean_ref}" + + def format_data_editor_column(col: str | dict): """Format a given column into the proper format. @@ -927,6 +778,8 @@ def format_data_editor_column(col: str | dict): Returns: The formatted column. """ + from reflex.vars import Var + if isinstance(col, str): return {"title": col, "id": col.lower(), "type": "str"} @@ -939,7 +792,7 @@ def format_data_editor_column(col: str | dict): col["overlayIcon"] = None return col - if isinstance(col, BaseVar): + if isinstance(col, Var): return col raise ValueError( @@ -956,9 +809,9 @@ def format_data_editor_cell(cell: Any): Returns: The formatted cell. """ - from reflex.ivars.base import ImmutableVar + from reflex.vars.base import Var return { - "kind": ImmutableVar.create("GridCellKind.Text"), + "kind": Var(_js_expr="GridCellKind.Text"), "data": cell, } diff --git a/reflex/utils/imports.py b/reflex/utils/imports.py index d58c2bf3f..8f53ed07a 100644 --- a/reflex/utils/imports.py +++ b/reflex/utils/imports.py @@ -2,10 +2,9 @@ from __future__ import annotations +import dataclasses from collections import defaultdict -from typing import Dict, List, Optional, Tuple, Union - -from reflex.base import Base +from typing import DefaultDict, Dict, List, Optional, Tuple, Union def merge_imports( @@ -19,12 +18,22 @@ def merge_imports( Returns: The merged import dicts. """ - all_imports = defaultdict(list) + all_imports: DefaultDict[str, List[ImportVar]] = defaultdict(list) for import_dict in imports: for lib, fields in ( import_dict if isinstance(import_dict, tuple) else import_dict.items() ): - all_imports[lib].extend(fields) + if isinstance(fields, (list, tuple, set)): + all_imports[lib].extend( + ( + ImportVar(field) if isinstance(field, str) else field + for field in fields + ) + ) + else: + all_imports[lib].append( + ImportVar(fields) if isinstance(fields, str) else fields + ) return all_imports @@ -75,7 +84,8 @@ def collapse_imports( } -class ImportVar(Base): +@dataclasses.dataclass(order=True, frozen=True) +class ImportVar: """An import var.""" # The name of the import tag. @@ -111,73 +121,6 @@ class ImportVar(Base): else: return self.tag or "" - def __lt__(self, other: ImportVar) -> bool: - """Compare two ImportVar objects. - - Args: - other: The other ImportVar object to compare. - - Returns: - Whether this ImportVar object is less than the other. - """ - return ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) < ( - other.tag, - other.is_default, - other.alias, - other.install, - other.render, - other.transpile, - ) - - def __eq__(self, other: ImportVar) -> bool: - """Check if two ImportVar objects are equal. - - Args: - other: The other ImportVar object to compare. - - Returns: - Whether the two ImportVar objects are equal. - """ - return ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) == ( - other.tag, - other.is_default, - other.alias, - other.install, - other.render, - other.transpile, - ) - - def __hash__(self) -> int: - """Hash the ImportVar object. - - Returns: - The hash of the ImportVar object. - """ - return hash( - ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) - ) - ImportTypes = Union[str, ImportVar, List[Union[str, ImportVar]], List[ImportVar]] ImportDict = Dict[str, ImportTypes] diff --git a/reflex/utils/net.py b/reflex/utils/net.py new file mode 100644 index 000000000..83e25559c --- /dev/null +++ b/reflex/utils/net.py @@ -0,0 +1,43 @@ +"""Helpers for downloading files from the network.""" + +import os + +import httpx + +from . import console + + +def _httpx_verify_kwarg() -> bool: + """Get the value of the HTTPX verify keyword argument. + + Returns: + True if SSL verification is enabled, False otherwise + """ + ssl_no_verify = os.environ.get("SSL_NO_VERIFY", "").lower() in ["true", "1", "yes"] + return not ssl_no_verify + + +def get(url: str, **kwargs) -> httpx.Response: + """Make an HTTP GET request. + + Args: + url: The URL to request. + **kwargs: Additional keyword arguments to pass to httpx.get. + + Returns: + The response object. + + Raises: + httpx.ConnectError: If the connection cannot be established. + """ + kwargs.setdefault("verify", _httpx_verify_kwarg()) + try: + return httpx.get(url, **kwargs) + except httpx.ConnectError as err: + if "CERTIFICATE_VERIFY_FAILED" in str(err): + # If the error is a certificate verification error, recommend mitigating steps. + console.error( + f"Certificate verification failed for {url}. Set environment variable SSL_CERT_FILE to the " + "path of the certificate file or SSL_NO_VERIFY=1 to disable verification." + ) + raise diff --git a/reflex/utils/path_ops.py b/reflex/utils/path_ops.py index 39f2138f8..21065db99 100644 --- a/reflex/utils/path_ops.py +++ b/reflex/utils/path_ops.py @@ -81,6 +81,18 @@ def mkdir(path: str | Path): Path(path).mkdir(parents=True, exist_ok=True) +def ls(path: str | Path) -> list[Path]: + """List the contents of a directory. + + Args: + path: The path to the directory. + + Returns: + A list of paths to the contents of the directory. + """ + return list(Path(path).iterdir()) + + def ln(src: str | Path, dest: str | Path, overwrite: bool = False) -> bool: """Create a symbolic link. @@ -197,4 +209,4 @@ def find_replace(directory: str | Path, find: str, replace: str): filepath = Path(root, file) text = filepath.read_text(encoding="utf-8") text = re.sub(find, replace, text) - filepath.write_text(text) + filepath.write_text(text, encoding="utf-8") diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index f71f707ee..6433cd346 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -2,6 +2,7 @@ from __future__ import annotations +import dataclasses import functools import glob import importlib @@ -15,7 +16,7 @@ import shutil import stat import sys import tempfile -import textwrap +import time import zipfile from datetime import datetime from fileinput import FileInput @@ -28,20 +29,22 @@ import typer from alembic.util.exc import CommandError from packaging import version from redis import Redis as RedisSync +from redis import exceptions from redis.asyncio import Redis from reflex import constants, model -from reflex.base import Base from reflex.compiler import templates from reflex.config import Config, get_config -from reflex.utils import console, path_ops, processes +from reflex.utils import console, net, path_ops, processes +from reflex.utils.exceptions import GeneratedCodeHasNoFunctionDefs from reflex.utils.format import format_library_name from reflex.utils.registry import _get_best_registry CURRENTLY_INSTALLING_NODE = False -class Template(Base): +@dataclasses.dataclass(frozen=True) +class Template: """A template for a Reflex app.""" name: str @@ -50,7 +53,8 @@ class Template(Base): demo_url: str -class CpuInfo(Base): +@dataclasses.dataclass(frozen=True) +class CpuInfo: """Model to save cpu info.""" manufacturer_id: Optional[str] @@ -80,7 +84,7 @@ def check_latest_package_version(package_name: str): # Get the latest version from PyPI current_version = importlib.metadata.version(package_name) url = f"https://pypi.org/pypi/{package_name}/json" - response = httpx.get(url) + response = net.get(url) latest_version = response.json()["info"]["version"] if ( version.parse(current_version) < version.parse(latest_version) @@ -324,24 +328,43 @@ def parse_redis_url() -> str | dict | None: """Parse the REDIS_URL in config if applicable. Returns: - If redis-py syntax, return the URL as it is. Otherwise, return the host/port/db as a dict. + If url is non-empty, return the URL as it is. + + Raises: + ValueError: If the REDIS_URL is not a supported scheme. """ config = get_config() if not config.redis_url: return None - if config.redis_url.startswith(("redis://", "rediss://", "unix://")): - return config.redis_url - console.deprecate( - feature_name="host[:port] style redis urls", - reason="redis-py url syntax is now being used", - deprecation_version="0.3.6", - removal_version="0.6.0", - ) - redis_url, has_port, redis_port = config.redis_url.partition(":") - if not has_port: - redis_port = 6379 - console.info(f"Using redis at {config.redis_url}") - return dict(host=redis_url, port=int(redis_port), db=0) + if not config.redis_url.startswith(("redis://", "rediss://", "unix://")): + raise ValueError( + "REDIS_URL must start with 'redis://', 'rediss://', or 'unix://'." + ) + return config.redis_url + + +async def get_redis_status() -> bool | None: + """Checks the status of the Redis connection. + + Attempts to connect to Redis and send a ping command to verify connectivity. + + Returns: + bool or None: The status of the Redis connection: + - True: Redis is accessible and responding. + - False: Redis is not accessible due to a connection error. + - None: Redis not used i.e redis_url is not set in rxconfig. + """ + try: + status = True + redis_client = get_redis_sync() + if redis_client is not None: + redis_client.ping() + else: + status = None + except exceptions.RedisError: + status = False + + return status def validate_app_name(app_name: str | None = None) -> str: @@ -670,7 +693,7 @@ def download_and_run(url: str, *args, show_status: bool = False, **env): """ # Download the script console.debug(f"Downloading {url}") - response = httpx.get(url) + response = net.get(url) if response.status_code != httpx.codes.OK: response.raise_for_status() @@ -700,11 +723,11 @@ def download_and_extract_fnm_zip(): try: # Download the FNM zip release. # TODO: show progress to improve UX - with httpx.stream("GET", url, follow_redirects=True) as response: - response.raise_for_status() - with open(fnm_zip_file, "wb") as output_file: - for chunk in response.iter_bytes(): - output_file.write(chunk) + response = net.get(url, follow_redirects=True) + response.raise_for_status() + with open(fnm_zip_file, "wb") as output_file: + for chunk in response.iter_bytes(): + output_file.write(chunk) # Extract the downloaded zip file. with zipfile.ZipFile(fnm_zip_file, "r") as zip_ref: @@ -1222,7 +1245,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]: """ def get_release_by_tag(tag: str) -> dict | None: - response = httpx.get(constants.Reflex.RELEASES_URL) + response = net.get(constants.Reflex.RELEASES_URL) response.raise_for_status() releases = response.json() for release in releases: @@ -1243,7 +1266,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]: else: templates_url = asset["browser_download_url"] - templates_data = httpx.get(templates_url, follow_redirects=True).json()["templates"] + templates_data = net.get(templates_url, follow_redirects=True).json()["templates"] for template in templates_data: if template["name"] == "blank": @@ -1257,11 +1280,16 @@ def fetch_app_templates(version: str) -> dict[str, Template]: ), None, ) - return { - tp["name"]: Template.parse_obj(tp) - for tp in templates_data - if not tp["hidden"] and tp["code_url"] is not None - } + + filtered_templates = {} + for tp in templates_data: + if tp["hidden"] or tp["code_url"] is None: + continue + known_fields = set(f.name for f in dataclasses.fields(Template)) + filtered_templates[tp["name"]] = Template( + **{k: v for k, v in tp.items() if k in known_fields} + ) + return filtered_templates def create_config_init_app_from_remote_template(app_name: str, template_url: str): @@ -1286,7 +1314,7 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str zip_file_path = Path(temp_dir) / "template.zip" try: # Note: following redirects can be risky. We only allow this for reflex built templates at the moment. - response = httpx.get(template_url, follow_redirects=True) + response = net.get(template_url, follow_redirects=True) console.debug(f"Server responded download request: {response}") response.raise_for_status() except httpx.HTTPError as he: @@ -1415,19 +1443,37 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash: Args: app_name: The name of the app. generation_hash: The generation hash from reflex.build. + + Raises: + GeneratedCodeHasNoFunctionDefs: If the fetched code has no function definitions + (the refactored reflex code is expected to have at least one root function defined). """ # Download the reflex code for the generation. - resp = httpx.get( - constants.Templates.REFLEX_BUILD_CODE_URL.format( - generation_hash=generation_hash + url = constants.Templates.REFLEX_BUILD_CODE_URL.format( + generation_hash=generation_hash + ) + resp = net.get(url) + while resp.status_code == httpx.codes.SERVICE_UNAVAILABLE: + console.debug("Waiting for the code to be generated...") + time.sleep(1) + resp = net.get(url) + resp.raise_for_status() + + # Determine the name of the last function, which renders the generated code. + defined_funcs = re.findall(r"def ([a-zA-Z_]+)\(", resp.text) + if not defined_funcs: + raise GeneratedCodeHasNoFunctionDefs( + f"No function definitions found in generated code from {url!r}." ) - ).raise_for_status() + render_func_name = defined_funcs[-1] def replace_content(_match): return "\n".join( [ - "def index() -> rx.Component:", - textwrap.indent("return " + resp.text, " "), + resp.text, + "", + "" "def index() -> rx.Component:", + f" return {render_func_name}()", "", "", ], diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py index f96a4c046..3c00b0427 100644 --- a/reflex/utils/pyi_generator.py +++ b/reflex/utils/pyi_generator.py @@ -20,7 +20,7 @@ from typing import Any, Callable, Iterable, Type, get_args from reflex.components.component import Component from reflex.utils import types as rx_types -from reflex.vars import Var +from reflex.vars.base import Var logger = logging.getLogger("pyi_generator") @@ -69,10 +69,10 @@ DEFAULT_TYPING_IMPORTS = { # TODO: fix import ordering and unused imports with ruff later DEFAULT_IMPORTS = { "typing": sorted(DEFAULT_TYPING_IMPORTS), - "reflex.vars": ["Var", "BaseVar", "ComputedVar"], "reflex.components.core.breakpoints": ["Breakpoints"], "reflex.event": ["EventChain", "EventHandler", "EventSpec"], "reflex.style": ["Style"], + "reflex.vars.base": ["Var"], } @@ -150,7 +150,7 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: if args: inner_container_type_args = ( - [repr(arg) for arg in args] + sorted((repr(arg) for arg in args)) if rx_types.is_literal(value) else [ _get_type_hint(arg, type_hint_globals, is_optional=False) @@ -184,7 +184,7 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: if arg is not type(None) ] if len(types) > 1: - res = ", ".join(types) + res = ", ".join(sorted(types)) res = f"Union[{res}]" elif isinstance(value, str): ev = eval(value, type_hint_globals) @@ -902,7 +902,13 @@ class PyiGenerator: # construct the import statement and handle special cases for aliases sub_mod_attrs_imports = [ f"from .{path} import {mod if not isinstance(mod, tuple) else mod[0]} as {mod if not isinstance(mod, tuple) else mod[1]}" - + (" # type: ignore" if mod in pyright_ignore_imports else "") + + ( + " # type: ignore" + if mod in pyright_ignore_imports + else " # noqa" # ignore ruff formatting here for cases like rx.list. + if isinstance(mod, tuple) + else "" + ) for mod, path in sub_mod_attrs.items() ] sub_mod_attrs_imports.append("") diff --git a/reflex/utils/serializers.py b/reflex/utils/serializers.py index 6c36647cc..42fb82916 100644 --- a/reflex/utils/serializers.py +++ b/reflex/utils/serializers.py @@ -2,9 +2,9 @@ from __future__ import annotations +import dataclasses import functools import json -import types as builtin_types import warnings from datetime import date, datetime, time, timedelta from enum import Enum @@ -26,11 +26,11 @@ from typing import ( from reflex.base import Base from reflex.constants.colors import Color, format_color -from reflex.utils import exceptions, types +from reflex.utils import types # Mapping from type to a serializer. # The serializer should convert the type to a JSON object. -SerializedType = Union[str, bool, int, float, list, dict] +SerializedType = Union[str, bool, int, float, list, dict, None] Serializer = Callable[[Type], SerializedType] @@ -125,6 +125,8 @@ def serialize( # If there is no serializer, return None. if serializer is None: + if dataclasses.is_dataclass(value) and not isinstance(value, type): + return serialize(dataclasses.asdict(value)) if get_type: return None, None return None @@ -226,7 +228,7 @@ def serialize_str(value: str) -> str: @serializer -def serialize_primitive(value: Union[bool, int, float, None]) -> str: +def serialize_primitive(value: Union[bool, int, float, None]): """Serialize a primitive type. Args: @@ -235,13 +237,11 @@ def serialize_primitive(value: Union[bool, int, float, None]) -> str: Returns: The serialized number/bool/None. """ - from reflex.utils import format - - return format.json_dumps(value) + return value @serializer -def serialize_base(value: Base) -> str: +def serialize_base(value: Base) -> dict: """Serialize a Base instance. Args: @@ -250,11 +250,11 @@ def serialize_base(value: Base) -> str: Returns: The serialized Base. """ - return value.json() + return {k: serialize(v) for k, v in value.dict().items() if not callable(v)} @serializer -def serialize_list(value: Union[List, Tuple, Set]) -> str: +def serialize_list(value: Union[List, Tuple, Set]) -> list: """Serialize a list to a JSON string. Args: @@ -263,17 +263,11 @@ def serialize_list(value: Union[List, Tuple, Set]) -> str: Returns: The serialized list. """ - from reflex.utils import format - - # Dump the list to a string. - fprop = format.json_dumps(list(value)) - - # Unwrap var values. - return format.unwrap_vars(fprop) + return [serialize(item) for item in value] @serializer -def serialize_dict(prop: Dict[str, Any]) -> str: +def serialize_dict(prop: Dict[str, Any]) -> dict: """Serialize a dictionary to a JSON string. Args: @@ -281,30 +275,8 @@ def serialize_dict(prop: Dict[str, Any]) -> str: Returns: The serialized dictionary. - - Raises: - InvalidStylePropError: If the style prop is invalid. """ - # Import here to avoid circular imports. - from reflex.event import EventHandler - from reflex.utils import format - - prop_dict = {} - - for key, value in prop.items(): - if types._issubclass(type(value), Callable): - raise exceptions.InvalidStylePropError( - f"The style prop `{format.to_snake_case(key)}` cannot have " # type: ignore - f"`{value.fn.__qualname__ if isinstance(value, EventHandler) else value.__qualname__ if isinstance(value, builtin_types.FunctionType) else value}`, " - f"an event handler or callable as its value" - ) - prop_dict[key] = value - - # Dump the dict to a string. - fprop = format.json_dumps(prop_dict) - - # Unwrap var values. - return format.unwrap_vars(fprop) + return {k: serialize(v) for k, v in prop.items()} @serializer(to=str) diff --git a/reflex/utils/telemetry.py b/reflex/utils/telemetry.py index e027ed81a..b2507e656 100644 --- a/reflex/utils/telemetry.py +++ b/reflex/utils/telemetry.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio +import dataclasses import multiprocessing import platform import warnings @@ -120,7 +121,7 @@ def _prepare_event(event: str, **kwargs) -> dict: return {} if UTC is None: - # for python 3.8, 3.9 & 3.10 + # for python 3.10 stamp = datetime.utcnow().isoformat() else: # for python 3.11 & 3.12 @@ -144,7 +145,7 @@ def _prepare_event(event: str, **kwargs) -> dict: "python_version": get_python_version(), "cpu_count": get_cpu_count(), "memory": get_memory(), - "cpu_info": dict(cpuinfo) if cpuinfo else {}, + "cpu_info": dataclasses.asdict(cpuinfo) if cpuinfo else {}, **additional_fields, }, "timestamp": stamp, diff --git a/reflex/utils/types.py b/reflex/utils/types.py index c164bb93e..ed74131a0 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -3,10 +3,11 @@ from __future__ import annotations import contextlib +import dataclasses import inspect import sys import types -from functools import cached_property, wraps +from functools import cached_property, lru_cache, wraps from typing import ( Any, Callable, @@ -21,9 +22,11 @@ from typing import ( Union, _GenericAlias, # type: ignore get_args, - get_origin, get_type_hints, ) +from typing import ( + get_origin as get_origin_og, +) import sqlalchemy @@ -109,6 +112,11 @@ RESERVED_BACKEND_VAR_NAMES = { "_was_touched", } +if sys.version_info >= (3, 11): + from typing import Self as Self +else: + from typing_extensions import Self as Self + class Unset: """A class to represent an unset value. @@ -133,6 +141,20 @@ class Unset: return False +@lru_cache() +def get_origin(tp): + """Get the origin of a class. + + Args: + tp: The class to get the origin of. + + Returns: + The origin of the class. + """ + return get_origin_og(tp) + + +@lru_cache() def is_generic_alias(cls: GenericType) -> bool: """Check whether the class is a generic alias. @@ -157,6 +179,7 @@ def is_none(cls: GenericType) -> bool: return cls is type(None) or cls is None +@lru_cache() def is_union(cls: GenericType) -> bool: """Check if a class is a Union. @@ -169,6 +192,7 @@ def is_union(cls: GenericType) -> bool: return get_origin(cls) in UnionTypes +@lru_cache() def is_literal(cls: GenericType) -> bool: """Check if a class is a Literal. @@ -222,9 +246,14 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None """ from reflex.model import Model - attr = getattr(cls, name, None) + try: + attr = getattr(cls, name, None) + except NotImplementedError: + attr = None + if hint := get_property_hint(attr): return hint + if ( hasattr(cls, "__fields__") and name in cls.__fields__ @@ -314,6 +343,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None return None # Attribute is not accessible. +@lru_cache() def get_base_class(cls: GenericType) -> Type: """Get the base class of a class. @@ -451,7 +481,11 @@ def is_valid_var_type(type_: Type) -> bool: if is_union(type_): return all((is_valid_var_type(arg) for arg in get_args(type_))) - return _issubclass(type_, StateVar) or serializers.has_serializer(type_) + return ( + _issubclass(type_, StateVar) + or serializers.has_serializer(type_) + or dataclasses.is_dataclass(type_) + ) def is_backend_base_variable(name: str, cls: Type) -> bool: @@ -485,14 +519,14 @@ def is_backend_base_variable(name: str, cls: Type) -> bool: if name in cls.inherited_backend_vars: return False + from reflex.vars.base import is_computed_var + if name in cls.__dict__: value = cls.__dict__[name] if type(value) == classmethod: return False if callable(value): return False - from reflex.ivars.base import ImmutableComputedVar - from reflex.vars import ComputedVar if isinstance( value, @@ -500,10 +534,8 @@ def is_backend_base_variable(name: str, cls: Type) -> bool: types.FunctionType, property, cached_property, - ComputedVar, - ImmutableComputedVar, ), - ): + ) or is_computed_var(value): return False return True @@ -600,7 +632,7 @@ def validate_parameter_literals(func): annotations = {param[0]: param[1].annotation for param in func_params} # validate args - for param, arg in zip(annotations, args): + for param, arg in zip(annotations, args, strict=False): if annotations[param] is inspect.Parameter.empty: continue validate_literal(param, arg, annotations[param], func.__name__) diff --git a/reflex/utils/watch.py b/reflex/utils/watch.py deleted file mode 100644 index 39b177695..000000000 --- a/reflex/utils/watch.py +++ /dev/null @@ -1,96 +0,0 @@ -"""General utility functions.""" - -import contextlib -import os -import shutil -import time - -from watchdog.events import FileSystemEvent, FileSystemEventHandler -from watchdog.observers import Observer - -from reflex.constants import Dirs -from reflex.utils.prerequisites import get_web_dir - - -class AssetFolderWatch: - """Asset folder watch class.""" - - def __init__(self, root): - """Initialize the Watch Class. - - Args: - root: root path of the public. - """ - self.path = str(root / Dirs.APP_ASSETS) - self.event_handler = AssetFolderHandler(root) - - def start(self): - """Start watching asset folder.""" - self.observer = Observer() - self.observer.schedule(self.event_handler, self.path, recursive=True) - self.observer.start() - - -class AssetFolderHandler(FileSystemEventHandler): - """Asset folder event handler.""" - - def __init__(self, root): - """Initialize the AssetFolderHandler Class. - - Args: - root: root path of the public. - """ - super().__init__() - self.root = root - - def on_modified(self, event: FileSystemEvent): - """Event handler when a file or folder was modified. - - This is called every time after a file is created, modified and deleted. - - Args: - event: Event information. - """ - dest_path = self.get_dest_path(event.src_path) - - # wait 1 sec for fully saved - time.sleep(1) - - if os.path.isfile(event.src_path): - with contextlib.suppress(PermissionError): - shutil.copyfile(event.src_path, dest_path) - if os.path.isdir(event.src_path): - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - with contextlib.suppress(PermissionError): - shutil.copytree(event.src_path, dest_path) - - def on_deleted(self, event: FileSystemEvent): - """Event hander when a file or folder was deleted. - - Args: - event: Event infomation. - """ - dest_path = self.get_dest_path(event.src_path) - - if os.path.isfile(dest_path): - # when event is about a file, pass - # this will be deleted at on_modified function - return - - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - - def get_dest_path(self, src_path: str) -> str: - """Get public file path. - - Args: - src_path: The asset file path. - - Returns: - The public file path. - """ - return src_path.replace( - str(self.root / Dirs.APP_ASSETS), - str(self.root / get_web_dir() / Dirs.PUBLIC), - ) diff --git a/reflex/vars.py b/reflex/vars.py deleted file mode 100644 index a3d40722d..000000000 --- a/reflex/vars.py +++ /dev/null @@ -1,2651 +0,0 @@ -"""Define a state var.""" - -from __future__ import annotations - -import contextlib -import dataclasses -import datetime -import dis -import functools -import inspect -import json -import random -import re -import string -import sys -from types import CodeType, FunctionType -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Iterable, - List, - Literal, - Optional, - Tuple, - Type, - Union, - _GenericAlias, # type: ignore - cast, - get_args, - get_origin, - get_type_hints, -) - -from reflex import constants -from reflex.base import Base -from reflex.utils import console, imports, serializers, types -from reflex.utils.exceptions import ( - VarAttributeError, - VarDependencyError, - VarTypeError, - VarValueError, -) - -# This module used to export ImportVar itself, so we still import it for export here -from reflex.utils.imports import ( - ImmutableParsedImportDict, - ImportDict, - ImportVar, - ParsedImportDict, - parse_imports, -) -from reflex.utils.types import override - -if TYPE_CHECKING: - from reflex.state import BaseState - - -# Set of unique variable names. -USED_VARIABLES = set() - -# Supported operators for all types. -ALL_OPS = ["==", "!=", "!==", "===", "&&", "||"] -# Delimiters used between function args or operands. -DELIMITERS = [","] -# Mapping of valid operations for different type combinations. -OPERATION_MAPPING = { - (int, int): { - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "&", - }, - (int, str): {"*"}, - (int, list): {"*"}, - (str, str): {"+", ">", "<", "<=", ">="}, - (float, float): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="}, - (float, int): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="}, - (list, list): {"+", ">", "<", "<=", ">="}, -} - -# These names were changed in reflex 0.3.0 -REPLACED_NAMES = { - "full_name": "_var_full_name", - "name": "_var_name", - "state": "_var_data.state", - "type_": "_var_type", - "is_local": "_var_is_local", - "is_string": "_var_is_string", - "set_state": "_var_set_state", - "deps": "_deps", -} - -PYTHON_JS_TYPE_MAP = { - (int, float): "number", - (str,): "string", - (bool,): "boolean", - (list, tuple): "Array", - (dict,): "Object", - (None,): "null", -} - - -def get_unique_variable_name() -> str: - """Get a unique variable name. - - Returns: - The unique variable name. - """ - name = "".join([random.choice(string.ascii_lowercase) for _ in range(8)]) - if name not in USED_VARIABLES: - USED_VARIABLES.add(name) - return name - return get_unique_variable_name() - - -class VarData(Base): - """Metadata associated with a Var.""" - - # The name of the enclosing state. - state: str = "" - - # Imports needed to render this var - imports: ParsedImportDict = {} - - # Hooks that need to be present in the component to render this var - hooks: Dict[str, None] = {} - - # Positions of interpolated strings. This is used by the decoder to figure - # out where the interpolations are and only escape the non-interpolated - # segments. - interpolations: List[Tuple[int, int]] = [] - - def __init__( - self, imports: Union[ImportDict, ParsedImportDict] | None = None, **kwargs: Any - ): - """Initialize the var data. - - Args: - imports: The imports needed to render this var. - **kwargs: The var data fields. - """ - if imports: - kwargs["imports"] = parse_imports(imports) - super().__init__(**kwargs) - - @classmethod - def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: - """Merge multiple var data objects. - - Args: - *others: The var data objects to merge. - - Returns: - The merged var data object. - """ - state = "" - _imports = {} - hooks = {} - interpolations = [] - for var_data in others: - if var_data is None: - continue - state = state or var_data.state - _imports = imports.merge_imports(_imports, var_data.imports) - hooks.update( - var_data.hooks - if isinstance(var_data.hooks, dict) - else {k: None for k in var_data.hooks} - ) - interpolations += ( - var_data.interpolations if isinstance(var_data, VarData) else [] - ) - - return ( - cls( - state=state, - imports=_imports, - hooks=hooks, - interpolations=interpolations, - ) - or None - ) - - def __bool__(self) -> bool: - """Check if the var data is non-empty. - - Returns: - True if any field is set to a non-default value. - """ - return bool(self.state or self.imports or self.hooks or self.interpolations) - - def __eq__(self, other: Any) -> bool: - """Check if two var data objects are equal. - - Args: - other: The other var data object to compare. - - Returns: - True if all fields are equal and collapsed imports are equal. - """ - if not isinstance(other, VarData): - return False - - # Don't compare interpolations - that's added in by the decoder, and - # not part of the vardata itself. - return ( - self.state == other.state - and self.hooks.keys() == other.hooks.keys() - and imports.collapse_imports(self.imports) - == imports.collapse_imports(other.imports) - ) - - def dict(self) -> dict: - """Convert the var data to a dictionary. - - Returns: - The var data dictionary. - """ - return { - "state": self.state, - "interpolations": list(self.interpolations), - "imports": { - lib: [import_var.dict() for import_var in import_vars] - for lib, import_vars in self.imports.items() - }, - "hooks": self.hooks, - } - - -@dataclasses.dataclass( - eq=True, - frozen=True, -) -class ImmutableVarData: - """Metadata associated with a Var.""" - - # The name of the enclosing state. - state: str = dataclasses.field(default="") - - # Imports needed to render this var - imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple) - - # Hooks that need to be present in the component to render this var - hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple) - - def __init__( - self, - state: str = "", - imports: ImportDict | ParsedImportDict | None = None, - hooks: dict[str, None] | None = None, - ): - """Initialize the var data. - - Args: - state: The name of the enclosing state. - imports: Imports needed to render this var. - hooks: Hooks that need to be present in the component to render this var. - """ - immutable_imports: ImmutableParsedImportDict = tuple( - sorted( - ((k, tuple(sorted(v))) for k, v in parse_imports(imports or {}).items()) - ) - ) - object.__setattr__(self, "state", state) - object.__setattr__(self, "imports", immutable_imports) - object.__setattr__(self, "hooks", tuple(hooks or {})) - - @classmethod - def merge( - cls, *others: ImmutableVarData | VarData | None - ) -> ImmutableVarData | None: - """Merge multiple var data objects. - - Args: - *others: The var data objects to merge. - - Returns: - The merged var data object. - """ - state = "" - _imports = {} - hooks = {} - for var_data in others: - if var_data is None: - continue - state = state or var_data.state - _imports = imports.merge_imports(_imports, var_data.imports) - hooks.update( - var_data.hooks - if isinstance(var_data.hooks, dict) - else {k: None for k in var_data.hooks} - ) - - return ( - ImmutableVarData( - state=state, - imports=_imports, - hooks=hooks, - ) - or None - ) - - def __bool__(self) -> bool: - """Check if the var data is non-empty. - - Returns: - True if any field is set to a non-default value. - """ - return bool(self.state or self.imports or self.hooks) - - def __eq__(self, other: Any) -> bool: - """Check if two var data objects are equal. - - Args: - other: The other var data object to compare. - - Returns: - True if all fields are equal and collapsed imports are equal. - """ - if not isinstance(other, (ImmutableVarData, VarData)): - return False - - # Don't compare interpolations - that's added in by the decoder, and - # not part of the vardata itself. - return ( - self.state == other.state - and self.hooks - == ( - other.hooks - if isinstance(other, ImmutableVarData) - else tuple(other.hooks.keys()) - ) - and imports.collapse_imports(self.imports) - == imports.collapse_imports(other.imports) - ) - - @classmethod - def from_state(cls, state: Type[BaseState] | str) -> ImmutableVarData: - """Set the state of the var. - - Args: - state: The state to set or the full name of the state. - - Returns: - The var with the set state. - """ - from reflex.utils import format - - state_name = state if isinstance(state, str) else state.get_full_name() - new_var_data = ImmutableVarData( - state=state_name, - hooks={ - "const {0} = useContext(StateContexts.{0})".format( - format.format_state_name(state_name) - ): None - }, - imports={ - f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")], - "react": [ImportVar(tag="useContext")], - }, - ) - return new_var_data - - -def _decode_var_immutable(value: str) -> tuple[ImmutableVarData | None, str]: - """Decode the state name from a formatted var. - - Args: - value: The value to extract the state name from. - - Returns: - The extracted state name and the value without the state name. - """ - var_datas = [] - if isinstance(value, str): - # fast path if there is no encoded VarData - if constants.REFLEX_VAR_OPENING_TAG not in value: - return None, value - - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"')) - - # Find all tags. - while m := _decode_var_pattern.search(value): - start, end = m.span() - value = value[:start] + value[end:] - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - var_data = var._get_all_var_data() - - if var_data is not None: - realstart = start + offset - - var_datas.append(var_data) - else: - # Read the JSON, pull out the string length, parse the rest as VarData. - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [(realstart, realstart + string_length)] - - var_datas.append(var_data) - offset += end - start - - return ImmutableVarData.merge(*var_datas) if var_datas else None, value - - -def _encode_var(value: Var) -> str: - """Encode the state name into a formatted var. - - Args: - value: The value to encode the state name into. - - Returns: - The encoded var. - """ - if value._var_data: - from reflex.utils.serializers import serialize - - final_value = str(value) - data = value._var_data.dict() - data["string_length"] = len(final_value) - data_json = value._var_data.__config__.json_dumps(data, default=serialize) - - return ( - f"{constants.REFLEX_VAR_OPENING_TAG}{data_json}{constants.REFLEX_VAR_CLOSING_TAG}" - + final_value - ) - - return str(value) - - -# Compile regex for finding reflex var tags. -_decode_var_pattern_re = ( - rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" -) -_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) - -# Defined global immutable vars. -_global_vars: Dict[int, Var] = {} - - -def _decode_var(value: str) -> tuple[VarData | None, str]: - """Decode the state name from a formatted var. - - Args: - value: The value to extract the state name from. - - Returns: - The extracted state name and the value without the state name. - """ - var_datas = [] - if isinstance(value, str): - # fast path if there is no encoded VarData - if constants.REFLEX_VAR_OPENING_TAG not in value: - return None, value - - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"')) - - # Find all tags. - while m := _decode_var_pattern.search(value): - start, end = m.span() - value = value[:start] + value[end:] - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - var_data = var._var_data - - if var_data is not None: - realstart = start + offset - - var_datas.append(var_data) - else: - # Read the JSON, pull out the string length, parse the rest as VarData. - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [(realstart, realstart + string_length)] - - var_datas.append(var_data) - offset += end - start - - return VarData.merge(*var_datas) if var_datas else None, value - - -def _extract_var_data(value: Iterable) -> list[VarData | None]: - """Extract the var imports and hooks from an iterable containing a Var. - - Args: - value: The iterable to extract the VarData from - - Returns: - The extracted VarDatas. - """ - from reflex.style import Style - - var_datas = [] - with contextlib.suppress(TypeError): - for sub in value: - if isinstance(sub, Var): - var_datas.append(sub._var_data) - elif not isinstance(sub, str): - # Recurse into dict values. - if hasattr(sub, "values") and callable(sub.values): - var_datas.extend(_extract_var_data(sub.values())) - # Recurse into iterable values (or dict keys). - var_datas.extend(_extract_var_data(sub)) - - # Style objects should already have _var_data. - if isinstance(value, Style): - var_datas.append(value._var_data) - else: - # Recurse when value is a dict itself. - values = getattr(value, "values", None) - if callable(values): - var_datas.extend(_extract_var_data(values())) - return var_datas - - -class Var: - """An abstract var.""" - - # The name of the var. - _var_name: str - - # The type of the var. - _var_type: Type - - # Whether this is a local javascript variable. - _var_is_local: bool - - # Whether the var is a string literal. - _var_is_string: bool - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool - - # Extra metadata associated with the Var - _var_data: Optional[VarData] - - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: Optional[VarData] = None, - ) -> Var | None: - """Create a var from a value. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. - _var_is_string: Whether the var is a string literal. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - VarTypeError: If the value is JSON-unserializable. - """ - from reflex.utils import format - - # Check for none values. - if value is None: - return None - - # If the value is already a var, do nothing. - if isinstance(value, Var): - return value - - # Try to pull the imports and hooks from contained values. - if not isinstance(value, str): - _var_data = VarData.merge(*_extract_var_data(value), _var_data) - - # Try to serialize the value. - type_ = type(value) - if type_ in types.JSONType: - name = value - else: - name, serialized_type = serializers.serialize(value, get_type=True) - if ( - serialized_type is not None - and _var_is_string is None - and issubclass(serialized_type, str) - ): - _var_is_string = True - if name is None: - raise VarTypeError( - f"No JSON serializer found for var {value} of type {type_}." - ) - name = name if isinstance(name, str) else format.json_dumps(name) - - if _var_is_string is None and type_ is str: - console.deprecate( - feature_name=f"Creating a Var ({value}) from a string without specifying _var_is_string", - reason=( - "Specify _var_is_string=False to create a Var that is not a string literal. " - "In the future, creating a Var from a string will be treated as a string literal " - "by default." - ), - deprecation_version="0.5.4", - removal_version="0.6.0", - ) - - return BaseVar( - _var_name=name, - _var_type=type_, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string if _var_is_string is not None else False, - _var_data=_var_data, - ) - - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: Optional[VarData] = None, - ) -> Var: - """Create a var from a value, asserting that it is not None. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. - _var_is_string: Whether the var is a string literal. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - var = cls.create( - value, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - _var_data=_var_data, - ) - assert var is not None - return var - - @classmethod - def __class_getitem__(cls, type_: str) -> _GenericAlias: - """Get a typed var. - - Args: - type_: The type of the var. - - Returns: - The var class item. - """ - return _GenericAlias(cls, type_) - - def __post_init__(self) -> None: - """Post-initialize the var.""" - # Decode any inline Var markup and apply it to the instance - _var_data, _var_name = _decode_var(self._var_name) - if _var_data: - self._var_name = _var_name - self._var_data = VarData.merge(self._var_data, _var_data) - - def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: - """Make a copy of this Var with updated fields. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - A new BaseVar with the updated fields overwriting the corresponding fields in this Var. - - Raises: - TypeError: If kwargs contains keys that are not allowed. - """ - field_values = dict( - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_is_local=kwargs.pop("_var_is_local", self._var_is_local), - _var_is_string=kwargs.pop("_var_is_string", self._var_is_string), - _var_full_name_needs_state_prefix=kwargs.pop( - "_var_full_name_needs_state_prefix", - self._var_full_name_needs_state_prefix, - ), - _var_data=VarData.merge( - kwargs.pop("_var_data", self._var_data), merge_var_data - ), - ) - - if kwargs: - unexpected_kwargs = ", ".join(kwargs.keys()) - raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") - - return BaseVar(**field_values) - - def _decode(self) -> Any: - """Decode Var as a python value. - - Note that Var with state set cannot be decoded python-side and will be - returned as full_name. - - Returns: - The decoded value or the Var name. - """ - if self._var_is_string: - return self._var_name - try: - return json.loads(self._var_name) - except ValueError: - try: - return json.loads(self.json()) - except (ValueError, NotImplementedError): - return self._var_name - - def equals(self, other: Var) -> bool: - """Check if two vars are equal. - - Args: - other: The other var to compare. - - Returns: - Whether the vars are equal. - """ - from reflex.ivars import ImmutableVar - - if isinstance(other, ImmutableVar) or isinstance(self, ImmutableVar): - return ( - self._var_name == other._var_name - and self._var_type == other._var_type - and ImmutableVarData.merge(self._get_all_var_data()) - == ImmutableVarData.merge(other._get_all_var_data()) - ) - - return ( - self._var_name == other._var_name - and self._var_type == other._var_type - and self._var_is_local == other._var_is_local - and self._var_full_name_needs_state_prefix - == other._var_full_name_needs_state_prefix - and self._var_data == other._var_data - ) - - def _merge(self, other) -> Var: - """Merge two or more dicts. - - Args: - other: The other var to merge. - - Returns: - The merged var. - """ - if other is None: - return self._replace() - if not isinstance(other, Var): - other = Var.create(other, _var_is_string=False) - return self._replace( - _var_name=f"{{...{self._var_name}, ...{other._var_name}}}" # type: ignore - ) - - def to_string(self, json: bool = True) -> Var: - """Convert a var to a string. - - Args: - json: Whether to convert to a JSON string. - - Returns: - The stringified var. - """ - fn = "JSON.stringify" if json else "String" - return self.operation(fn=fn, type_=str) - - def to_int(self) -> Var: - """Convert a var to an int. - - Returns: - The parseInt var. - """ - return self.operation(fn="parseInt", type_=int) - - def __hash__(self) -> int: - """Define a hash function for a var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, str(self._var_type))) - - def __str__(self) -> str: - """Wrap the var so it can be used in templates. - - Returns: - The wrapped var, i.e. {state.var}. - """ - from reflex.utils import format - - if self._var_is_local: - console.deprecate( - feature_name="Local Vars", - reason=( - "Setting _var_is_local to True does not have any effect anymore. " - "Use the new ImmutableVar instead." - ), - deprecation_version="0.5.9", - removal_version="0.6.0", - ) - out = self._var_full_name - else: - out = format.wrap(self._var_full_name, "{") - if self._var_is_string: - out = format.format_string(out) - return out - - def __bool__(self) -> bool: - """Raise exception if using Var in a boolean context. - - Raises: - VarTypeError: when attempting to bool-ify the Var. - """ - raise VarTypeError( - f"Cannot convert Var {self._var_full_name!r} to bool for use with `if`, `and`, `or`, and `not`. " - "Instead use `rx.cond` and bitwise operators `&` (and), `|` (or), `~` (invert)." - ) - - def __iter__(self) -> Any: - """Raise exception if using Var in an iterable context. - - Raises: - VarTypeError: when attempting to iterate over the Var. - """ - raise VarTypeError( - f"Cannot iterate over Var {self._var_full_name!r}. Instead use `rx.foreach`." - ) - - def __format__(self, format_spec: str) -> str: - """Format the var into a Javascript equivalent to an f-string. - - Args: - format_spec: The format specifier (Ignored for now). - - Returns: - The formatted var. - """ - # Encode the _var_data into the formatted output for tracking purposes. - str_self = _encode_var(self) - if self._var_is_local: - return str_self - return f"${str_self}" - - def __getitem__(self, i: Any) -> Var: - """Index into a var. - - Args: - i: The index to index into. - - Returns: - The indexed var. - - Raises: - VarTypeError: If the var is not indexable. - """ - from reflex.utils import format - - # Indexing is only supported for strings, lists, tuples, dicts, and dataframes. - if not ( - types._issubclass(self._var_type, Union[List, Dict, Tuple, str]) - or types.is_dataframe(self._var_type) - ): - if self._var_type == Any: - raise VarTypeError( - "Could not index into var of type Any. (If you are trying to index into a state var, " - "add the correct type annotation to the var.)" - ) - raise VarTypeError( - f"Var {self._var_name} of type {self._var_type} does not support indexing." - ) - - # The type of the indexed var. - type_ = Any - - # Convert any vars to local vars. - if isinstance(i, Var): - i = i._replace(_var_is_local=True) - - # Handle list/tuple/str indexing. - if types._issubclass(self._var_type, Union[List, Tuple, str]): - # List/Tuple/String indices must be ints, slices, or vars. - if ( - not isinstance(i, types.get_args(Union[int, slice, Var])) - or isinstance(i, Var) - and not i._var_type == int - ): - raise VarTypeError("Index must be an integer or an integer var.") - - # Handle slices first. - if isinstance(i, slice): - # Get the start and stop indices. - start = i.start or 0 - stop = i.stop or "undefined" - - # Use the slice function. - return self._replace( - _var_name=f"{self._var_name}.slice({start}, {stop})", - _var_is_string=False, - ) - - # Get the type of the indexed var. - if types.is_generic_alias(self._var_type): - index = i if not isinstance(i, Var) else 0 - type_ = types.get_args(self._var_type) - type_ = type_[index % len(type_)] if type_ else Any - elif types._issubclass(self._var_type, str): - type_ = str - - # Use `at` to support negative indices. - return self._replace( - _var_name=f"{self._var_name}.at({i})", - _var_type=type_, - _var_is_string=False, - ) - - # Dictionary / dataframe indexing. - # Tuples are currently not supported as indexes. - if ( - ( - types._issubclass(self._var_type, Dict) - or types.is_dataframe(self._var_type) - ) - and not isinstance(i, types.get_args(Union[int, str, float, Var])) - ) or ( - isinstance(i, Var) - and not types._issubclass( - i._var_type, types.get_args(Union[int, str, float]) - ) - ): - raise VarTypeError( - "Index must be one of the following types: int, str, int or str Var" - ) - # Get the type of the indexed var. - if isinstance(i, str): - i = format.wrap(i, '"') - type_ = ( - types.get_args(self._var_type)[1] - if types.is_generic_alias(self._var_type) - else Any - ) - - # Use normal indexing here. - return self._replace( - _var_name=f"{self._var_name}[{i}]", - _var_type=type_, - _var_is_string=False, - ) - - def __getattribute__(self, name: str) -> Any: - """Get a var attribute. - - Args: - name: The name of the attribute. - - Returns: - The var attribute. - - Raises: - VarAttributeError: If the attribute cannot be found, or if __getattr__ fallback should be used. - """ - try: - var_attribute = super().__getattribute__(name) - if ( - not name.startswith("_") - and name not in Var.__dict__ - and name not in BaseVar.__dict__ - ): - # Check if the attribute should be accessed through the Var instead of - # accessing one of the Var operations - type_ = types.get_attribute_access_type( - super().__getattribute__("_var_type"), name - ) - if type_ is not None: - raise VarAttributeError( - f"{name} is being accessed through the Var." - ) - # Return the attribute as-is. - return var_attribute - except VarAttributeError: - raise # fall back to __getattr__ anyway - - def __getattr__(self, name: str) -> Var: - """Get a var attribute. - - Args: - name: The name of the attribute. - - Returns: - The var attribute. - - Raises: - VarAttributeError: If the var is wrongly annotated or can't find attribute. - VarTypeError: If an annotation to the var isn't provided. - """ - # Check if the attribute is one of the class fields. - if not name.startswith("_"): - if self._var_type == Any: - raise VarTypeError( - f"You must provide an annotation for the state var `{self._var_full_name}`. Annotation cannot be `{self._var_type}`" - ) from None - is_optional = types.is_optional(self._var_type) - type_ = types.get_attribute_access_type(self._var_type, name) - - if type_ is not None: - return self._replace( - _var_name=f"{self._var_name}{'?' if is_optional else ''}.{name}", - _var_type=type_, - ) - - if name in REPLACED_NAMES: - raise VarAttributeError( - f"Field {name!r} was renamed to {REPLACED_NAMES[name]!r}" - ) - - raise VarAttributeError( - f"The State var `{self._var_full_name}` has no attribute '{name}' or may have been annotated " - f"wrongly." - ) - - raise VarAttributeError( - f"The State var has no attribute '{name}' or may have been annotated wrongly.", - ) - - def operation( - self, - op: str = "", - other: Var | None = None, - type_: Type | None = None, - flip: bool = False, - fn: str | None = None, - invoke_fn: bool = False, - ) -> Var: - """Perform an operation on a var. - - Args: - op: The operation to perform. - other: The other var to perform the operation on. - type_: The type of the operation result. - flip: Whether to flip the order of the operation. - fn: A function to apply to the operation. - invoke_fn: Whether to invoke the function. - - Returns: - The operation result. - - Raises: - VarTypeError: If the operation between two operands is invalid. - VarValueError: If flip is set to true and value of operand is not provided - """ - from reflex.utils import format - - if isinstance(other, str): - other = Var.create(json.dumps(other), _var_is_string=False) - else: - other = Var.create(other, _var_is_string=False) - - type_ = type_ or self._var_type - - if other is None and flip: - raise VarValueError( - "flip_operands cannot be set to True if the value of 'other' operand is not provided" - ) - - left_operand, right_operand = (other, self) if flip else (self, other) - - def get_operand_full_name(operand): - # operand vars that are string literals need to be wrapped in back ticks. - return ( - operand._var_name_unwrapped - if operand._var_is_string - and not operand._var_state - and operand._var_is_local - else operand._var_full_name - ) - - if other is not None: - # check if the operation between operands is valid. - if op and not self.is_valid_operation( - types.get_base_class(left_operand._var_type), # type: ignore - types.get_base_class(right_operand._var_type), # type: ignore - op, - ): - raise VarTypeError( - f"Unsupported Operand type(s) for {op}: `{left_operand._var_full_name}` of type {left_operand._var_type.__name__} and `{right_operand._var_full_name}` of type {right_operand._var_type.__name__}" # type: ignore - ) - - left_operand_full_name = get_operand_full_name(left_operand) - right_operand_full_name = get_operand_full_name(right_operand) - - left_operand_full_name = format.wrap(left_operand_full_name, "(") - right_operand_full_name = format.wrap(right_operand_full_name, "(") - - # apply function to operands - if fn is not None: - if invoke_fn: - # invoke the function on left operand. - operation_name = ( - f"{left_operand_full_name}.{fn}({right_operand_full_name})" # type: ignore - ) - else: - # pass the operands as arguments to the function. - operation_name = ( - f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore - ) - operation_name = f"{fn}({operation_name})" - else: - # apply operator to operands (left operand right_operand) - operation_name = ( - f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore - ) - operation_name = format.wrap(operation_name, "(") - else: - # apply operator to left operand ( left_operand) - operation_name = f"{op}{get_operand_full_name(self)}" - # apply function to operands - if fn is not None: - operation_name = ( - f"{fn}({operation_name})" - if not invoke_fn - else f"{get_operand_full_name(self)}.{fn}()" - ) - - return self._replace( - _var_name=operation_name, - _var_type=type_, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - merge_var_data=other._var_data if other is not None else None, - ) - - @staticmethod - def is_valid_operation( - operand1_type: Type, operand2_type: Type, operator: str - ) -> bool: - """Check if an operation between two operands is valid. - - Args: - operand1_type: Type of the operand - operand2_type: Type of the second operand - operator: The operator. - - Returns: - Whether operation is valid or not - - """ - if operator in ALL_OPS or operator in DELIMITERS: - return True - - # bools are subclasses of ints - pair = tuple( - sorted( - [ - int if operand1_type == bool else operand1_type, - int if operand2_type == bool else operand2_type, - ], - key=lambda x: x.__name__, - ) - ) - return pair in OPERATION_MAPPING and operator in OPERATION_MAPPING[pair] - - def compare(self, op: str, other: Var) -> Var: - """Compare two vars with inequalities. - - Args: - op: The comparison operator. - other: The other var to compare with. - - Returns: - The comparison result. - """ - return self.operation(op, other, bool) - - def __invert__(self) -> Var: - """Invert a var. - - Returns: - The inverted var. - """ - return self.operation("!", type_=bool) - - def __neg__(self) -> Var: - """Negate a var. - - Returns: - The negated var. - """ - return self.operation(fn="-") - - def __abs__(self) -> Var: - """Get the absolute value of a var. - - Returns: - A var with the absolute value. - """ - return self.operation(fn="Math.abs") - - def length(self) -> Var: - """Get the length of a list var. - - Returns: - A var with the absolute value. - - Raises: - VarTypeError: If the var is not a list. - """ - if not types._issubclass(self._var_type, List): - raise VarTypeError(f"Cannot get length of non-list var {self}.") - return self._replace( - _var_name=f"{self._var_name}.length", - _var_type=int, - _var_is_string=False, - ) - - def _type(self) -> Var: - """Get the type of the Var in Javascript. - - Returns: - A var representing the type check. - """ - return self._replace( - _var_name=f"typeof {self._var_full_name}", - _var_type=str, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - def __eq__(self, other: Union[Var, Type]) -> Var: - """Perform an equality comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the equality comparison. - """ - for python_types, js_type in PYTHON_JS_TYPE_MAP.items(): - if not isinstance(other, Var) and other in python_types: - return self.compare("===", Var.create(js_type, _var_is_string=True)) # type: ignore - return self.compare("===", other) - - def __ne__(self, other: Union[Var, Type]) -> Var: - """Perform an inequality comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the inequality comparison. - """ - for python_types, js_type in PYTHON_JS_TYPE_MAP.items(): - if not isinstance(other, Var) and other in python_types: - return self.compare("!==", Var.create(js_type, _var_is_string=True)) # type: ignore - return self.compare("!==", other) - - def __gt__(self, other: Var) -> Var: - """Perform a greater than comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the greater than comparison. - """ - return self.compare(">", other) - - def __ge__(self, other: Var) -> Var: - """Perform a greater than or equal to comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the greater than or equal to comparison. - """ - return self.compare(">=", other) - - def __lt__(self, other: Var) -> Var: - """Perform a less than comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the less than comparison. - """ - return self.compare("<", other) - - def __le__(self, other: Var) -> Var: - """Perform a less than or equal to comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the less than or equal to comparison. - """ - return self.compare("<=", other) - - def __add__(self, other: Var, flip=False) -> Var: - """Add two vars. - - Args: - other: The other var to add. - flip: Whether to flip operands. - - Returns: - A var representing the sum. - """ - other_type = other._var_type if isinstance(other, Var) else type(other) - # For list-list addition, javascript concatenates the content of the lists instead of - # merging the list, and for that reason we use the spread operator available through spreadArraysOrObjects - # utility function - if ( - types.get_base_class(self._var_type) == list - and types.get_base_class(other_type) == list - ): - return self.operation( - ",", other, fn="spreadArraysOrObjects", flip=flip - )._replace( - merge_var_data=VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": [ - ImportVar(tag="spreadArraysOrObjects") - ] - }, - ), - ) - return self.operation("+", other, flip=flip) - - def __radd__(self, other: Var) -> Var: - """Add two vars. - - Args: - other: The other var to add. - - Returns: - A var representing the sum. - """ - return self.__add__(other=other, flip=True) - - def __sub__(self, other: Var) -> Var: - """Subtract two vars. - - Args: - other: The other var to subtract. - - Returns: - A var representing the difference. - """ - return self.operation("-", other) - - def __rsub__(self, other: Var) -> Var: - """Subtract two vars. - - Args: - other: The other var to subtract. - - Returns: - A var representing the difference. - """ - return self.operation("-", other, flip=True) - - def __mul__(self, other: Var, flip=True) -> Var: - """Multiply two vars. - - Args: - other: The other var to multiply. - flip: Whether to flip operands - - Returns: - A var representing the product. - """ - other_type = other._var_type if isinstance(other, Var) else type(other) - # For str-int multiplication, we use the repeat function. - # i.e "hello" * 2 is equivalent to "hello".repeat(2) in js. - if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [ - (int, str), - (str, int), - ]: - return self.operation(other=other, fn="repeat", invoke_fn=True) - - # For list-int multiplication, we use the Array function. - # i.e ["hello"] * 2 is equivalent to Array(2).fill().map(() => ["hello"]).flat() in js. - if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [ - (int, list), - (list, int), - ]: - other_name = other._var_full_name if isinstance(other, Var) else other - name = f"Array({other_name}).fill().map(() => {self._var_full_name}).flat()" - return self._replace( - _var_name=name, - _var_type=str, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - return self.operation("*", other) - - def __rmul__(self, other: Var) -> Var: - """Multiply two vars. - - Args: - other: The other var to multiply. - - Returns: - A var representing the product. - """ - return self.__mul__(other=other, flip=True) - - def __pow__(self, other: Var) -> Var: - """Raise a var to a power. - - Args: - other: The power to raise to. - - Returns: - A var representing the power. - """ - return self.operation(",", other, fn="Math.pow") - - def __rpow__(self, other: Var) -> Var: - """Raise a var to a power. - - Args: - other: The power to raise to. - - Returns: - A var representing the power. - """ - return self.operation(",", other, flip=True, fn="Math.pow") - - def __truediv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other) - - def __rtruediv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other, flip=True) - - def __floordiv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other, fn="Math.floor") - - def __mod__(self, other: Var) -> Var: - """Get the remainder of two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the remainder. - """ - return self.operation("%", other) - - def __rmod__(self, other: Var) -> Var: - """Get the remainder of two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the remainder. - """ - return self.operation("%", other, flip=True) - - def __and__(self, other: Var) -> Var: - """Perform a logical and. - - Args: - other: The other var to perform the logical AND with. - - Returns: - A var representing the logical AND. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '&&' operator) of a logical AND operation. - In JavaScript, the - logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical AND 'and' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. - Therefore, this method leverages the - bitwise AND '__and__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 & var2 - >>> print(js_code._var_full_name) - '(true && false)' - """ - return self.operation("&&", other, type_=bool) - - def __rand__(self, other: Var) -> Var: - """Perform a logical and. - - Args: - other: The other var to perform the logical AND with. - - Returns: - A var representing the logical AND. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '&&' operator) of a logical AND operation. - In JavaScript, the - logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical AND 'and' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. - Therefore, this method leverages the - bitwise AND '__rand__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 & var2 - >>> print(js_code._var_full_name) - '(false && true)' - """ - return self.operation("&&", other, type_=bool, flip=True) - - def __or__(self, other: Var) -> Var: - """Perform a logical or. - - Args: - other: The other var to perform the logical or with. - - Returns: - A var representing the logical or. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the - logical OR operator '||' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical OR 'or' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. Therefore, this method leverages the - bitwise OR '__or__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 | var2 - >>> print(js_code._var_full_name) - '(true || false)' - """ - return self.operation("||", other, type_=bool) - - def __ror__(self, other: Var) -> Var: - """Perform a logical or. - - Args: - other: The other var to perform the logical or with. - - Returns: - A var representing the logical or. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the - logical OR operator '||' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical OR 'or' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. Therefore, this method leverages the - bitwise OR '__or__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 | var2 - >>> print(js_code) - 'false || true' - """ - return self.operation("||", other, type_=bool, flip=True) - - def __contains__(self, _: Any) -> Var: - """Override the 'in' operator to alert the user that it is not supported. - - Raises: - VarTypeError: the operation is not supported - """ - raise VarTypeError( - "'in' operator not supported for Var types, use Var.contains() instead." - ) - - def contains(self, other: Any, field: Union[Var, None] = None) -> Var: - """Check if a var contains the object `other`. - - Args: - other: The object to check. - field: Optionally specify a field to check on both object and the other var. - - Raises: - VarTypeError: If the var is not a valid type: dict, list, tuple or str. - - Returns: - A var representing the contain check. - """ - if not (types._issubclass(self._var_type, Union[dict, list, tuple, str, set])): - raise VarTypeError( - f"Var {self._var_full_name} of type {self._var_type} does not support contains check." - ) - method = ( - "hasOwnProperty" - if types.get_base_class(self._var_type) == dict - else "includes" - ) - if isinstance(other, str): - other = Var.create(json.dumps(other), _var_is_string=True) - elif not isinstance(other, Var): - other = Var.create(other, _var_is_string=False) - if types._issubclass(self._var_type, Dict): - return self._replace( - _var_name=f"{self._var_name}.{method}({other._var_full_name})", - _var_type=bool, - _var_is_string=False, - merge_var_data=other._var_data, - ) - else: # str, list, tuple - # For strings, the left operand must be a string. - if types._issubclass(self._var_type, str) and not types._issubclass( - other._var_type, str - ): - raise VarTypeError( - f"'in ' requires string as left operand, not {other._var_type}" - ) - - _var_name = None - if field is None: - _var_name = f"{self._var_name}.includes({other._var_full_name})" - else: - field = Var.create_safe(field, _var_is_string=isinstance(field, str)) - _var_name = f"{self._var_name}.some(e=>e[{field._var_name_unwrapped}]==={other._var_full_name})" - - return self._replace( - _var_name=_var_name, - _var_type=bool, - _var_is_string=False, - merge_var_data=other._var_data, - ) - - def reverse(self) -> Var: - """Reverse a list var. - - Raises: - VarTypeError: If the var is not a list. - - Returns: - A var with the reversed list. - """ - if not types._issubclass(self._var_type, list): - raise VarTypeError(f"Cannot reverse non-list var {self._var_full_name}.") - - return self._replace( - _var_name=f"[...{self._var_full_name}].reverse()", - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - def lower(self) -> Var: - """Convert a string var to lowercase. - - Returns: - A var with the lowercase string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError( - f"Cannot convert non-string var {self._var_full_name} to lowercase." - ) - - return self._replace( - _var_name=f"{self._var_name}.toLowerCase()", - _var_is_string=False, - _var_type=str, - ) - - def upper(self) -> Var: - """Convert a string var to uppercase. - - Returns: - A var with the uppercase string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError( - f"Cannot convert non-string var {self._var_full_name} to uppercase." - ) - - return self._replace( - _var_name=f"{self._var_name}.toUpperCase()", - _var_is_string=False, - _var_type=str, - ) - - def strip(self, other: str | Var[str] = " ") -> Var: - """Strip a string var. - - Args: - other: The string to strip the var with. - - Returns: - A var with the stripped string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError(f"Cannot strip non-string var {self._var_full_name}.") - - other = ( - Var.create_safe(json.dumps(other), _var_is_string=False) - if isinstance(other, str) - else other - ) - - return self._replace( - _var_name=f"{self._var_name}.replace(/^${other._var_full_name}|${other._var_full_name}$/g, '')", - _var_is_string=False, - merge_var_data=other._var_data, - ) - - def split(self, other: str | Var[str] = " ") -> Var: - """Split a string var into a list. - - Args: - other: The string to split the var with. - - Returns: - A var with the list. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError(f"Cannot split non-string var {self._var_full_name}.") - - other = ( - Var.create_safe(json.dumps(other), _var_is_string=False) - if isinstance(other, str) - else other - ) - - return self._replace( - _var_name=f"{self._var_name}.split({other._var_full_name})", - _var_is_string=False, - _var_type=List[str], - merge_var_data=other._var_data, - ) - - def join(self, other: str | Var[str] | None = None) -> Var: - """Join a list var into a string. - - Args: - other: The string to join the list with. - - Returns: - A var with the string. - - Raises: - VarTypeError: If the var is not a list. - """ - if not types._issubclass(self._var_type, list): - raise VarTypeError(f"Cannot join non-list var {self._var_full_name}.") - - if other is None: - other = Var.create_safe('""', _var_is_string=False) - if isinstance(other, str): - other = Var.create_safe(json.dumps(other), _var_is_string=False) - else: - other = Var.create_safe(other, _var_is_string=False) - - return self._replace( - _var_name=f"{self._var_name}.join({other._var_full_name})", - _var_is_string=False, - _var_type=str, - merge_var_data=other._var_data, - ) - - def foreach(self, fn: Callable) -> Var: - """Return a list of components. after doing a foreach on this var. - - Args: - fn: The function to call on each component. - - Returns: - A var representing foreach operation. - - Raises: - VarTypeError: If the var is not a list. - """ - inner_types = get_args(self._var_type) - if not inner_types: - raise VarTypeError( - f"Cannot foreach over non-sequence var {self._var_full_name} of type {self._var_type}." - ) - arg = BaseVar( - _var_name=get_unique_variable_name(), - _var_type=inner_types[0], - ) - index = BaseVar( - _var_name=get_unique_variable_name(), - _var_type=int, - ) - fn_signature = inspect.signature(fn) - fn_args = (arg, index) - fn_ret = fn(*fn_args[: len(fn_signature.parameters)]) - return self._replace( - _var_name=f"{self._var_full_name}.map(({arg._var_name}, {index._var_name}) => {fn_ret})", - _var_is_string=False, - ) - - @classmethod - def range( - cls, - v1: Var | int = 0, - v2: Var | int | None = None, - step: Var | int | None = None, - ) -> Var: - """Return an iterator over indices from v1 to v2 (or 0 to v1). - - Args: - v1: The start of the range or end of range if v2 is not given. - v2: The end of the range. - step: The number of numbers between each item. - - Returns: - A var representing range operation. - - Raises: - VarTypeError: If the var is not an int. - """ - if not isinstance(v1, Var): - v1 = Var.create_safe(v1) - if v1._var_type != int: - raise VarTypeError(f"Cannot get range on non-int var {v1._var_full_name}.") - if not isinstance(v2, Var): - v2 = Var.create(v2) - if v2 is None: - v2 = Var.create_safe("undefined", _var_is_string=False) - elif v2._var_type != int: - raise VarTypeError(f"Cannot get range on non-int var {v2._var_full_name}.") - - if not isinstance(step, Var): - step = Var.create(step) - if step is None: - step = Var.create_safe(1) - elif step._var_type != int: - raise VarTypeError( - f"Cannot get range on non-int var {step._var_full_name}." - ) - - return BaseVar( - _var_name=f"Array.from(range({v1._var_full_name}, {v2._var_full_name}, {step._var_name}))", - _var_type=List[int], - _var_is_local=False, - _var_data=VarData.merge( - v1._var_data, - v2._var_data, - step._var_data, - VarData( - imports={ - "/utils/helpers/range.js": [ - ImportVar(tag="range", is_default=True), - ], - }, - ), - ), - ) - - def to(self, type_: Type) -> Var: - """Convert the type of the var. - - Args: - type_: The type to convert to. - - Returns: - The converted var. - """ - return self._replace(_var_type=type_) - - def as_ref(self) -> Var: - """Convert the var to a ref. - - Returns: - The var as a ref. - """ - return self._replace( - _var_name=f"refs['{self._var_full_name}']", - _var_is_local=True, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - merge_var_data=VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")], - }, - ), - ) - - @property - def _var_full_name(self) -> str: - """Get the full name of the var. - - Returns: - The full name of the var. - """ - from reflex.utils import format - - if not self._var_full_name_needs_state_prefix: - return self._var_name - return ( - self._var_name - if self._var_data is None or self._var_data.state == "" - else ".".join( - [format.format_state_name(self._var_data.state), self._var_name] - ) - ) - - def _var_set_state(self, state: Type[BaseState] | str) -> Any: - """Set the state of the var. - - Args: - state: The state to set or the full name of the state. - - Returns: - The var with the set state. - """ - from reflex.utils import format - - state_name = state if isinstance(state, str) else state.get_full_name() - new_var_data = VarData( - state=state_name, - hooks={ - "const {0} = useContext(StateContexts.{0})".format( - format.format_state_name(state_name) - ): None - }, - imports={ - f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")], - "react": [ImportVar(tag="useContext")], - }, - ) - self._var_data = VarData.merge(self._var_data, new_var_data) - self._var_full_name_needs_state_prefix = True - return self - - @property - def _var_state(self) -> str: - """Compat method for getting the state. - - Returns: - The state name associated with the var. - """ - return self._var_data.state if self._var_data else "" - - def _get_all_var_data(self) -> VarData | None: - """Get all the var data. - - Returns: - The var data. - """ - return self._var_data - - def json(self) -> str: - """Serialize the var to a JSON string. - - Raises: - NotImplementedError: If the method is not implemented. - """ - raise NotImplementedError("Var subclasses must implement the json method.") - - @property - def _var_name_unwrapped(self) -> str: - """Get the var str without wrapping in curly braces. - - Returns: - The str var without the wrapped curly braces - """ - from reflex.style import Style - - generic_alias = types.is_generic_alias(self._var_type) - - type_ = get_origin(self._var_type) if generic_alias else self._var_type - wrapped_var = str(self) - - return ( - wrapped_var - if not self._var_state - and not generic_alias - and (types._issubclass(type_, dict) or types._issubclass(type_, Style)) - else wrapped_var.strip("{}") - ) - - -# Allow automatic serialization of Var within JSON structures -serializers.serializer(_encode_var) - - -@dataclasses.dataclass( - eq=False, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BaseVar(Var): - """A base (non-computed) var of the app state.""" - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - - def __hash__(self) -> int: - """Define a hash function for a var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, str(self._var_type))) - - def get_default_value(self) -> Any: - """Get the default value of the var. - - Returns: - The default value of the var. - - Raises: - ImportError: If the var is a dataframe and pandas is not installed. - """ - if types.is_optional(self._var_type): - return None - - type_ = ( - get_origin(self._var_type) - if types.is_generic_alias(self._var_type) - else self._var_type - ) - if type_ is Literal: - args = get_args(self._var_type) - return args[0] if args else None - if issubclass(type_, str): - return "" - if issubclass(type_, types.get_args(Union[int, float])): - return 0 - if issubclass(type_, bool): - return False - if issubclass(type_, list): - return [] - if issubclass(type_, dict): - return {} - if issubclass(type_, tuple): - return () - if types.is_dataframe(type_): - try: - import pandas as pd - - return pd.DataFrame() - except ImportError as e: - raise ImportError( - "Please install pandas to use dataframes in your app." - ) from e - return set() if issubclass(type_, set) else None - - def get_setter_name(self, include_state: bool = True) -> str: - """Get the name of the var's generated setter function. - - Args: - include_state: Whether to include the state name in the setter name. - - Returns: - The name of the setter function. - """ - setter = constants.SETTER_PREFIX + self._var_name - if self._var_data is None: - return setter - if not include_state or self._var_data.state == "": - return setter - return ".".join((self._var_data.state, setter)) - - def get_setter(self) -> Callable[[BaseState, Any], None]: - """Get the var's setter function. - - Returns: - A function that that creates a setter for the var. - """ - - def setter(state: BaseState, value: Any): - """Get the setter for the var. - - Args: - state: The state within which we add the setter function. - value: The value to set. - """ - if self._var_type in [int, float]: - try: - value = self._var_type(value) - setattr(state, self._var_name, value) - except ValueError: - console.debug( - f"{type(state).__name__}.{self._var_name}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.", - ) - else: - setattr(state, self._var_name, value) - - setter.__qualname__ = self.get_setter_name() - - return setter - - -@dataclasses.dataclass(init=False, eq=False) -class ComputedVar(Var, property): - """A field with computed getters.""" - - # Whether to track dependencies and cache computed values - _cache: bool = dataclasses.field(default=False) - - # Whether the computed var is a backend var - _backend: bool = dataclasses.field(default=False) - - # The initial value of the computed var - _initial_value: Any | types.Unset = dataclasses.field(default=types.Unset()) - - # Explicit var dependencies to track - _static_deps: set[str] = dataclasses.field(default_factory=set) - - # Whether var dependencies should be auto-determined - _auto_deps: bool = dataclasses.field(default=True) - - # Interval at which the computed var should be updated - _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None) - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - - def __init__( - self, - fget: Callable[[BaseState], Any], - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[int, datetime.timedelta]] = None, - backend: bool | None = None, - **kwargs, - ): - """Initialize a ComputedVar. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - **kwargs: additional attributes to set on the instance - - Raises: - TypeError: If the computed var dependencies are not Var instances or var names. - """ - if backend is None: - backend = fget.__name__.startswith("_") - self._backend = backend - - self._initial_value = initial_value - self._cache = cache - if isinstance(interval, int): - interval = datetime.timedelta(seconds=interval) - self._update_interval = interval - if deps is None: - deps = [] - else: - for dep in deps: - if isinstance(dep, Var): - continue - if isinstance(dep, str) and dep != "": - continue - raise TypeError( - "ComputedVar dependencies must be Var instances or var names (non-empty strings)." - ) - self._static_deps = { - dep._var_name if isinstance(dep, Var) else dep for dep in deps - } - self._auto_deps = auto_deps - property.__init__(self, fget) - kwargs["_var_name"] = kwargs.pop("_var_name", fget.__name__) - kwargs["_var_type"] = kwargs.pop("_var_type", self._determine_var_type()) - BaseVar.__init__(self, **kwargs) # type: ignore - - @override - def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: - """Replace the attributes of the ComputedVar. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - The new ComputedVar instance. - - Raises: - TypeError: If kwargs contains keys that are not allowed. - """ - field_values = dict( - fget=kwargs.pop("fget", self.fget), - initial_value=kwargs.pop("initial_value", self._initial_value), - cache=kwargs.pop("cache", self._cache), - deps=kwargs.pop("deps", self._static_deps), - auto_deps=kwargs.pop("auto_deps", self._auto_deps), - interval=kwargs.pop("interval", self._update_interval), - backend=kwargs.pop("backend", self._backend), - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_is_local=kwargs.pop("_var_is_local", self._var_is_local), - _var_is_string=kwargs.pop("_var_is_string", self._var_is_string), - _var_full_name_needs_state_prefix=kwargs.pop( - "_var_full_name_needs_state_prefix", - self._var_full_name_needs_state_prefix, - ), - _var_data=VarData.merge(self._var_data, merge_var_data), - ) - - if kwargs: - unexpected_kwargs = ", ".join(kwargs.keys()) - raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") - - return ComputedVar(**field_values) - - @property - def _cache_attr(self) -> str: - """Get the attribute used to cache the value on the instance. - - Returns: - An attribute name. - """ - return f"__cached_{self._var_name}" - - @property - def _last_updated_attr(self) -> str: - """Get the attribute used to store the last updated timestamp. - - Returns: - An attribute name. - """ - return f"__last_updated_{self._var_name}" - - def needs_update(self, instance: BaseState) -> bool: - """Check if the computed var needs to be updated. - - Args: - instance: The state instance that the computed var is attached to. - - Returns: - True if the computed var needs to be updated, False otherwise. - """ - if self._update_interval is None: - return False - last_updated = getattr(instance, self._last_updated_attr, None) - if last_updated is None: - return True - return datetime.datetime.now() - last_updated > self._update_interval - - def __get__(self, instance: BaseState | None, owner): - """Get the ComputedVar value. - - If the value is already cached on the instance, return the cached value. - - Args: - instance: the instance of the class accessing this computed var. - owner: the class that this descriptor is attached to. - - Returns: - The value of the var for the given instance. - """ - if instance is None or not self._cache: - return super().__get__(instance, owner) - - # handle caching - if not hasattr(instance, self._cache_attr) or self.needs_update(instance): - # Set cache attr on state instance. - setattr(instance, self._cache_attr, super().__get__(instance, owner)) - # Ensure the computed var gets serialized to redis. - instance._was_touched = True - # Set the last updated timestamp on the state instance. - setattr(instance, self._last_updated_attr, datetime.datetime.now()) - return getattr(instance, self._cache_attr) - - def _deps( - self, - objclass: Type, - obj: FunctionType | CodeType | None = None, - self_name: Optional[str] = None, - ) -> set[str]: - """Determine var dependencies of this ComputedVar. - - Save references to attributes accessed on "self". Recursively called - when the function makes a method call on "self" or define comprehensions - or nested functions that may reference "self". - - Args: - objclass: the class obj this ComputedVar is attached to. - obj: the object to disassemble (defaults to the fget function). - self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions. - - Returns: - A set of variable names accessed by the given obj. - - Raises: - VarValueError: if the function references the get_state, parent_state, or substates attributes - (cannot track deps in a related state, only implicitly via parent state). - """ - if not self._auto_deps: - return self._static_deps - d = self._static_deps.copy() - if obj is None: - fget = property.__getattribute__(self, "fget") - if fget is not None: - obj = cast(FunctionType, fget) - else: - return set() - with contextlib.suppress(AttributeError): - # unbox functools.partial - obj = cast(FunctionType, obj.func) # type: ignore - with contextlib.suppress(AttributeError): - # unbox EventHandler - obj = cast(FunctionType, obj.fn) # type: ignore - - if self_name is None and isinstance(obj, FunctionType): - try: - # the first argument to the function is the name of "self" arg - self_name = obj.__code__.co_varnames[0] - except (AttributeError, IndexError): - self_name = None - if self_name is None: - # cannot reference attributes on self if method takes no args - return set() - - invalid_names = ["get_state", "parent_state", "substates", "get_substate"] - self_is_top_of_stack = False - for instruction in dis.get_instructions(obj): - if ( - instruction.opname in ("LOAD_FAST", "LOAD_DEREF") - and instruction.argval == self_name - ): - # bytecode loaded the class instance to the top of stack, next load instruction - # is referencing an attribute on self - self_is_top_of_stack = True - continue - if self_is_top_of_stack and instruction.opname in ( - "LOAD_ATTR", - "LOAD_METHOD", - ): - try: - ref_obj = getattr(objclass, instruction.argval) - except Exception: - ref_obj = None - if instruction.argval in invalid_names: - raise VarValueError( - f"Cached var {self._var_full_name} cannot access arbitrary state via `{instruction.argval}`." - ) - if callable(ref_obj): - # recurse into callable attributes - d.update( - self._deps( - objclass=objclass, - obj=ref_obj, - ) - ) - # recurse into property fget functions - elif isinstance(ref_obj, property) and not isinstance( - ref_obj, ComputedVar - ): - d.update( - self._deps( - objclass=objclass, - obj=ref_obj.fget, # type: ignore - ) - ) - elif ( - instruction.argval in objclass.backend_vars - or instruction.argval in objclass.vars - ): - # var access - d.add(instruction.argval) - elif instruction.opname == "LOAD_CONST" and isinstance( - instruction.argval, CodeType - ): - # recurse into nested functions / comprehensions, which can reference - # instance attributes from the outer scope - d.update( - self._deps( - objclass=objclass, - obj=instruction.argval, - self_name=self_name, - ) - ) - self_is_top_of_stack = False - return d - - def mark_dirty(self, instance) -> None: - """Mark this ComputedVar as dirty. - - Args: - instance: the state instance that needs to recompute the value. - """ - with contextlib.suppress(AttributeError): - delattr(instance, self._cache_attr) - - def _determine_var_type(self) -> Type: - """Get the type of the var. - - Returns: - The type of the var. - """ - hints = get_type_hints(property.__getattribute__(self, "fget")) - if "return" in hints: - return hints["return"] - return Any - - -def computed_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - backend: bool | None = None, - _deprecated_cached_var: bool = False, - **kwargs, -) -> ComputedVar | Callable[[Callable[[BaseState], Any]], ComputedVar]: - """A ComputedVar decorator with or without kwargs. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - _deprecated_cached_var: Indicate usage of deprecated cached_var partial function. - **kwargs: additional attributes to set on the instance - - Returns: - A ComputedVar instance. - - Raises: - ValueError: If caching is disabled and an update interval is set. - VarDependencyError: If user supplies dependencies without caching. - """ - if _deprecated_cached_var: - console.deprecate( - feature_name="cached_var", - reason=("Use @rx.var(cache=True) instead of @rx.cached_var."), - deprecation_version="0.5.6", - removal_version="0.6.0", - ) - - if cache is False and interval is not None: - raise ValueError("Cannot set update interval without caching.") - - if cache is False and (deps is not None or auto_deps is False): - raise VarDependencyError("Cannot track dependencies without caching.") - - if fget is not None: - return ComputedVar(fget=fget, cache=cache) - - def wrapper(fget: Callable[[BaseState], Any]) -> ComputedVar: - return ComputedVar( - fget=fget, - initial_value=initial_value, - cache=cache, - deps=deps, - auto_deps=auto_deps, - interval=interval, - backend=backend, - **kwargs, - ) - - return wrapper - - -# Partial function of computed_var with cache=True -cached_var = functools.partial(computed_var, cache=True, _deprecated_cached_var=True) - - -class CallableVar(BaseVar): - """Decorate a Var-returning function to act as both a Var and a function. - - This is used as a compatibility shim for replacing Var objects in the - API with functions that return a family of Var. - """ - - def __init__(self, fn: Callable[..., BaseVar]): - """Initialize a CallableVar. - - Args: - fn: The function to decorate (must return Var) - """ - self.fn = fn - default_var = fn() - super().__init__(**dataclasses.asdict(default_var)) - - def __call__(self, *args, **kwargs) -> BaseVar: - """Call the decorated function. - - Args: - *args: The args to pass to the function. - **kwargs: The kwargs to pass to the function. - - Returns: - The Var returned from calling the function. - """ - return self.fn(*args, **kwargs) - - -def get_uuid_string_var() -> Var: - """Return a Var that generates a single memoized UUID via .web/utils/state.js. - - useMemo with an empty dependency array ensures that the generated UUID is - consistent across re-renders of the component. - - Returns: - A Var that generates a UUID at runtime. - """ - from reflex.utils.imports import ImportVar - - unique_uuid_var = get_unique_variable_name() - unique_uuid_var_data = VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}, # type: ignore - "react": "useMemo", - }, - hooks={f"const {unique_uuid_var} = useMemo(generateUUID, [])": None}, - ) - - return BaseVar( - _var_name=unique_uuid_var, - _var_type=str, - _var_data=unique_uuid_var_data, - ) diff --git a/reflex/vars.pyi b/reflex/vars.pyi deleted file mode 100644 index 8c923f03e..000000000 --- a/reflex/vars.pyi +++ /dev/null @@ -1,221 +0,0 @@ -"""Generated with stubgen from mypy, then manually edited, do not regen.""" - -from __future__ import annotations - -import datetime -from dataclasses import dataclass -from types import FunctionType -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Optional, - Set, - Tuple, - Type, - Union, - _GenericAlias, # type: ignore - overload, -) - -from _typeshed import Incomplete - -from reflex import constants as constants -from reflex.base import Base as Base -from reflex.state import BaseState as BaseState -from reflex.state import State as State -from reflex.utils import console as console -from reflex.utils import format as format -from reflex.utils import types as types -from reflex.utils.imports import ImmutableParsedImportDict, ImportDict, ParsedImportDict - -USED_VARIABLES: Incomplete - -def get_unique_variable_name() -> str: ... -def _encode_var(value: Var) -> str: ... - -_global_vars: Dict[int, Var] - -def _decode_var(value: str) -> tuple[VarData, str]: ... -def _extract_var_data(value: Iterable) -> list[VarData | None]: ... - -class VarData(Base): - state: str = "" - imports: Union[ImportDict, ParsedImportDict] = {} - hooks: Dict[str, None] = {} - interpolations: List[Tuple[int, int]] = [] - @classmethod - def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: ... - -class ImmutableVarData: - state: str = "" - imports: ImmutableParsedImportDict = tuple() - hooks: Tuple[str, ...] = tuple() - def __init__( - self, - state: str = "", - imports: ImportDict | ParsedImportDict | None = None, - hooks: dict[str, None] | None = None, - ) -> None: ... - @classmethod - def merge( - cls, *others: ImmutableVarData | VarData | None - ) -> ImmutableVarData | None: ... - @classmethod - def from_state(cls, state: Type[BaseState] | str) -> ImmutableVarData: ... - -def _decode_var_immutable(value: str) -> tuple[ImmutableVarData, str]: ... - -class Var: - _var_name: str - _var_type: Type - _var_is_local: bool = False - _var_is_string: bool = False - _var_full_name_needs_state_prefix: bool = False - _var_data: VarData | None = None - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Optional[Var]: ... - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Var: ... - @classmethod - def __class_getitem__(cls, type_: Type) -> _GenericAlias: ... - def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: ... - def equals(self, other: Var) -> bool: ... - def to_string(self) -> Var: ... - def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getitem__(self, i: Any) -> Var: ... - def __getattribute__(self, name: str) -> Var: ... - def operation( - self, - op: str = ..., - other: Optional[Var] = ..., - type_: Optional[Type] = ..., - flip: bool = ..., - fn: Optional[str] = ..., - ) -> Var: ... - def compare(self, op: str, other: Var) -> Var: ... - def __invert__(self) -> Var: ... - def __neg__(self) -> Var: ... - def __abs__(self) -> Var: ... - def length(self) -> Var: ... - def __eq__(self, other: Var) -> Var: ... - def __ne__(self, other: Var) -> Var: ... - def __gt__(self, other: Var) -> Var: ... - def __ge__(self, other: Var) -> Var: ... - def __lt__(self, other: Var) -> Var: ... - def __le__(self, other: Var) -> Var: ... - def __add__(self, other: Var) -> Var: ... - def __radd__(self, other: Var) -> Var: ... - def __sub__(self, other: Var) -> Var: ... - def __rsub__(self, other: Var) -> Var: ... - def __mul__(self, other: Var) -> Var: ... - def __rmul__(self, other: Var) -> Var: ... - def __pow__(self, other: Var) -> Var: ... - def __rpow__(self, other: Var) -> Var: ... - def __truediv__(self, other: Var) -> Var: ... - def __rtruediv__(self, other: Var) -> Var: ... - def __floordiv__(self, other: Var) -> Var: ... - def __mod__(self, other: Var) -> Var: ... - def __rmod__(self, other: Var) -> Var: ... - def __and__(self, other: Var) -> Var: ... - def __rand__(self, other: Var) -> Var: ... - def __or__(self, other: Var) -> Var: ... - def __ror__(self, other: Var) -> Var: ... - def __contains__(self, _: Any) -> Var: ... - def contains(self, other: Any, field: Union[Var, None] = None) -> Var: ... - def reverse(self) -> Var: ... - def foreach(self, fn: Callable) -> Var: ... - @classmethod - def range( - cls, - v1: Var | int = 0, - v2: Var | int | None = None, - step: Var | int | None = None, - ) -> Var: ... - def to(self, type_: Type) -> Var: ... - def as_ref(self) -> Var: ... - @property - def _var_full_name(self) -> str: ... - def _var_set_state(self, state: Type[BaseState] | str) -> Any: ... - def _get_all_var_data(self) -> VarData | ImmutableVarData: ... - def json(self) -> str: ... - def _type(self) -> Var: ... - -@dataclass(eq=False) -class BaseVar(Var): - _var_name: str - _var_type: Any - _var_is_local: bool = False - _var_is_string: bool = False - _var_full_name_needs_state_prefix: bool = False - _var_data: VarData | None = None - def __hash__(self) -> int: ... - def get_default_value(self) -> Any: ... - def get_setter_name(self, include_state: bool = ...) -> str: ... - def get_setter(self) -> Callable[[BaseState, Any], None]: ... - -@dataclass(init=False) -class ComputedVar(Var): - _var_cache: bool - fget: FunctionType - @property - def _cache_attr(self) -> str: ... - def __get__(self, instance, owner): ... - def _deps(self, objclass: Type, obj: Optional[FunctionType] = ...) -> Set[str]: ... - def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: ... - def mark_dirty(self, instance) -> None: ... - def needs_update(self, instance) -> bool: ... - def _determine_var_type(self) -> Type: ... - @overload - def __init__( - self, - fget: Callable[[BaseState], Any], - **kwargs, - ) -> None: ... - @overload - def __init__(self, func) -> None: ... - -@overload -def computed_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - **kwargs, -) -> Callable[[Callable[[Any], Any]], ComputedVar]: ... -@overload -def computed_var(fget: Callable[[Any], Any]) -> ComputedVar: ... -@overload -def cached_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - **kwargs, -) -> Callable[[Callable[[Any], Any]], ComputedVar]: ... -@overload -def cached_var(fget: Callable[[Any], Any]) -> ComputedVar: ... - -class CallableVar(BaseVar): - def __init__(self, fn: Callable[..., BaseVar]): ... - def __call__(self, *args, **kwargs) -> BaseVar: ... - -def get_uuid_string_var() -> Var: ... diff --git a/reflex/ivars/__init__.py b/reflex/vars/__init__.py similarity index 73% rename from reflex/ivars/__init__.py rename to reflex/vars/__init__.py index 8fa5196ff..56d304cd6 100644 --- a/reflex/ivars/__init__.py +++ b/reflex/vars/__init__.py @@ -1,8 +1,12 @@ -"""Experimental Immutable-Based Var System.""" +"""Immutable-Based Var System.""" -from .base import ImmutableVar as ImmutableVar from .base import LiteralVar as LiteralVar +from .base import Var as Var +from .base import VarData as VarData +from .base import get_unique_variable_name as get_unique_variable_name +from .base import get_uuid_string_var as get_uuid_string_var from .base import var_operation as var_operation +from .base import var_operation_return as var_operation_return from .function import FunctionStringVar as FunctionStringVar from .function import FunctionVar as FunctionVar from .function import VarOperationCall as VarOperationCall @@ -12,7 +16,6 @@ from .number import LiteralNumberVar as LiteralNumberVar from .number import NumberVar as NumberVar from .object import LiteralObjectVar as LiteralObjectVar from .object import ObjectVar as ObjectVar -from .sequence import ArrayJoinOperation as ArrayJoinOperation from .sequence import ArrayVar as ArrayVar from .sequence import ConcatVarOperation as ConcatVarOperation from .sequence import LiteralArrayVar as LiteralArrayVar diff --git a/reflex/vars/base.py b/reflex/vars/base.py new file mode 100644 index 000000000..eb5362090 --- /dev/null +++ b/reflex/vars/base.py @@ -0,0 +1,2822 @@ +"""Collection of base classes.""" + +from __future__ import annotations + +import contextlib +import dataclasses +import datetime +import dis +import functools +import inspect +import json +import random +import re +import string +import sys +import warnings +from types import CodeType, FunctionType +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + FrozenSet, + Generic, + Iterable, + List, + Literal, + NoReturn, + Optional, + Set, + Tuple, + Type, + TypeVar, + Union, + cast, + get_args, + overload, +) + +from typing_extensions import ParamSpec, TypeGuard, deprecated, get_type_hints, override + +from reflex import constants +from reflex.base import Base +from reflex.utils import console, imports, serializers, types +from reflex.utils.exceptions import ( + VarAttributeError, + VarDependencyError, + VarTypeError, + VarValueError, +) +from reflex.utils.format import format_state_name +from reflex.utils.imports import ( + ImmutableParsedImportDict, + ImportDict, + ImportVar, + ParsedImportDict, + parse_imports, +) +from reflex.utils.types import GenericType, Self, get_origin + +if TYPE_CHECKING: + from reflex.state import BaseState + + from .function import FunctionVar, ToFunctionOperation + from .number import ( + BooleanVar, + NumberVar, + ToBooleanVarOperation, + ToNumberVarOperation, + ) + from .object import ObjectVar, ToObjectOperation + from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation + + +VAR_TYPE = TypeVar("VAR_TYPE", covariant=True) +OTHER_VAR_TYPE = TypeVar("OTHER_VAR_TYPE") + +warnings.filterwarnings("ignore", message="fields may not start with an underscore") + + +@dataclasses.dataclass( + eq=False, + frozen=True, +) +class Var(Generic[VAR_TYPE]): + """Base class for immutable vars.""" + + # The name of the var. + _js_expr: str = dataclasses.field() + + # The type of the var. + _var_type: types.GenericType = dataclasses.field(default=Any) + + # Extra metadata associated with the Var + _var_data: Optional[VarData] = dataclasses.field(default=None) + + def __str__(self) -> str: + """String representation of the var. Guaranteed to be a valid Javascript expression. + + Returns: + The name of the var. + """ + return self._js_expr + + @property + def _var_is_local(self) -> bool: + """Whether this is a local javascript variable. + + Returns: + False + """ + return False + + @property + @deprecated("Use `_js_expr` instead.") + def _var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return self._js_expr + + @property + def _var_field_name(self) -> str: + """The name of the field. + + Returns: + The name of the field. + """ + var_data = self._get_all_var_data() + field_name = var_data.field_name if var_data else None + return field_name or self._js_expr + + @property + @deprecated("Use `_js_expr` instead.") + def _var_name_unwrapped(self) -> str: + """The name of the var without extra curly braces. + + Returns: + The name of the var. + """ + return self._js_expr + + @property + def _var_is_string(self) -> bool: + """Whether the var is a string literal. + + Returns: + False + """ + return False + + def __post_init__(self): + """Post-initialize the var.""" + # Decode any inline Var markup and apply it to the instance + _var_data, _js_expr = _decode_var_immutable(self._js_expr) + + if _var_data or _js_expr != self._js_expr: + self.__init__( + _js_expr=_js_expr, + _var_type=self._var_type, + _var_data=VarData.merge(self._var_data, _var_data), + ) + + def __hash__(self) -> int: + """Define a hash function for the var. + + Returns: + The hash of the var. + """ + return hash((self._js_expr, self._var_type, self._var_data)) + + def _get_all_var_data(self) -> VarData | None: + """Get all VarData associated with the Var. + + Returns: + The VarData of the components and all of its children. + """ + return self._var_data + + def equals(self, other: Var) -> bool: + """Check if two vars are equal. + + Args: + other: The other var to compare. + + Returns: + Whether the vars are equal. + """ + return ( + self._js_expr == other._js_expr + and self._var_type == other._var_type + and self._get_all_var_data() == other._get_all_var_data() + ) + + @overload + def _replace( + self, _var_type: Type[OTHER_VAR_TYPE], merge_var_data=None, **kwargs: Any + ) -> Var[OTHER_VAR_TYPE]: ... + + @overload + def _replace( + self, _var_type: GenericType | None = None, merge_var_data=None, **kwargs: Any + ) -> Self: ... + + def _replace( + self, _var_type: GenericType | None = None, merge_var_data=None, **kwargs: Any + ) -> Self | Var: + """Make a copy of this Var with updated fields. + + Args: + merge_var_data: VarData to merge into the existing VarData. + **kwargs: Var fields to update. + + Returns: + A new Var with the updated fields overwriting the corresponding fields in this Var. + + Raises: + TypeError: If _var_is_local, _var_is_string, or _var_full_name_needs_state_prefix is not None. + """ + if kwargs.get("_var_is_local", False) is not False: + raise TypeError("The _var_is_local argument is not supported for Var.") + + if kwargs.get("_var_is_string", False) is not False: + raise TypeError("The _var_is_string argument is not supported for Var.") + + if kwargs.get("_var_full_name_needs_state_prefix", False) is not False: + raise TypeError( + "The _var_full_name_needs_state_prefix argument is not supported for Var." + ) + + value_with_replaced = dataclasses.replace( + self, + _var_type=_var_type or self._var_type, + _var_data=VarData.merge( + kwargs.get("_var_data", self._var_data), merge_var_data + ), + **kwargs, + ) + + if (js_expr := kwargs.get("_js_expr", None)) is not None: + object.__setattr__(value_with_replaced, "_js_expr", js_expr) + + return value_with_replaced + + @classmethod + def create( + cls, + value: Any, + _var_is_local: bool | None = None, + _var_is_string: bool | None = None, + _var_data: VarData | None = None, + ) -> Var: + """Create a var from a value. + + Args: + value: The value to create the var from. + _var_is_local: Whether the var is local. Deprecated. + _var_is_string: Whether the var is a string literal. Deprecated. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + if _var_is_local is not None: + console.deprecate( + feature_name="_var_is_local", + reason="The _var_is_local argument is not supported for Var." + "If you want to create a Var from a raw Javascript expression, use the constructor directly", + deprecation_version="0.6.0", + removal_version="0.7.0", + ) + if _var_is_string is not None: + console.deprecate( + feature_name="_var_is_string", + reason="The _var_is_string argument is not supported for Var." + "If you want to create a Var from a raw Javascript expression, use the constructor directly", + deprecation_version="0.6.0", + removal_version="0.7.0", + ) + + # If the value is already a var, do nothing. + if isinstance(value, Var): + return value + + # Try to pull the imports and hooks from contained values. + if not isinstance(value, str): + return LiteralVar.create(value) + + if _var_is_string is False or _var_is_local is True: + return cls( + _js_expr=value, + _var_data=_var_data, + ) + + return LiteralVar.create(value, _var_data=_var_data) + + @classmethod + @deprecated("Use `.create()` instead.") + def create_safe( + cls, + *args: Any, + **kwargs: Any, + ) -> Var: + """Create a var from a value. + + Args: + *args: The arguments to create the var from. + **kwargs: The keyword arguments to create the var from. + + Returns: + The var. + """ + return cls.create(*args, **kwargs) + + def __format__(self, format_spec: str) -> str: + """Format the var into a Javascript equivalent to an f-string. + + Args: + format_spec: The format specifier (Ignored for now). + + Returns: + The formatted var. + """ + hashed_var = hash(self) + + _global_vars[hashed_var] = self + + # Encode the _var_data into the formatted output for tracking purposes. + return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._js_expr}" + + @overload + def to(self, output: Type[StringVar]) -> ToStringOperation: ... + + @overload + def to(self, output: Type[str]) -> ToStringOperation: ... + + @overload + def to(self, output: Type[BooleanVar]) -> ToBooleanVarOperation: ... + + @overload + def to( + self, output: Type[NumberVar], var_type: type[int] | type[float] = float + ) -> ToNumberVarOperation: ... + + @overload + def to( + self, + output: Type[ArrayVar], + var_type: type[list] | type[tuple] | type[set] = list, + ) -> ToArrayOperation: ... + + @overload + def to( + self, output: Type[ObjectVar], var_type: types.GenericType = dict + ) -> ToObjectOperation: ... + + @overload + def to( + self, output: Type[FunctionVar], var_type: Type[Callable] = Callable + ) -> ToFunctionOperation: ... + + @overload + def to( + self, + output: Type[OUTPUT] | types.GenericType, + var_type: types.GenericType | None = None, + ) -> OUTPUT: ... + + def to( + self, + output: Type[OUTPUT] | types.GenericType, + var_type: types.GenericType | None = None, + ) -> Var: + """Convert the var to a different type. + + Args: + output: The output type. + var_type: The type of the var. + + Raises: + TypeError: If the var_type is not a supported type for the output. + + Returns: + The converted var. + """ + from .function import FunctionVar, ToFunctionOperation + from .number import ( + BooleanVar, + NumberVar, + ToBooleanVarOperation, + ToNumberVarOperation, + ) + from .object import ObjectVar, ToObjectOperation + from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation + + base_type = var_type + if types.is_optional(base_type): + base_type = types.get_args(base_type)[0] + + fixed_type = get_origin(base_type) or base_type + + fixed_output_type = get_origin(output) or output + + # If the first argument is a python type, we map it to the corresponding Var type. + if fixed_output_type is dict: + return self.to(ObjectVar, output) + if fixed_output_type in (list, tuple, set): + return self.to(ArrayVar, output) + if fixed_output_type in (int, float): + return self.to(NumberVar, output) + if fixed_output_type is str: + return self.to(StringVar, output) + if fixed_output_type is bool: + return self.to(BooleanVar, output) + if fixed_output_type is None: + return ToNoneOperation.create(self) + if issubclass(fixed_output_type, Base): + return self.to(ObjectVar, output) + if dataclasses.is_dataclass(fixed_output_type) and not issubclass( + fixed_output_type, Var + ): + return self.to(ObjectVar, output) + + if issubclass(output, BooleanVar): + return ToBooleanVarOperation.create(self) + + if issubclass(output, NumberVar): + if fixed_type is not None: + if fixed_type is Union: + inner_types = get_args(base_type) + if not all(issubclass(t, (int, float)) for t in inner_types): + raise TypeError( + f"Unsupported type {var_type} for NumberVar. Must be int or float." + ) + + elif not issubclass(fixed_type, (int, float)): + raise TypeError( + f"Unsupported type {var_type} for NumberVar. Must be int or float." + ) + return ToNumberVarOperation.create(self, var_type or float) + + if issubclass(output, ArrayVar): + if fixed_type is not None and not issubclass( + fixed_type, (list, tuple, set) + ): + raise TypeError( + f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set." + ) + return ToArrayOperation.create(self, var_type or list) + + if issubclass(output, StringVar): + return ToStringOperation.create(self, var_type or str) + + if issubclass(output, (ObjectVar, Base)): + return ToObjectOperation.create(self, var_type or dict) + + if dataclasses.is_dataclass(output): + return ToObjectOperation.create(self, var_type or dict) + + if issubclass(output, FunctionVar): + # if fixed_type is not None and not issubclass(fixed_type, Callable): + # raise TypeError( + # f"Unsupported type {var_type} for FunctionVar. Must be Callable." + # ) + return ToFunctionOperation.create(self, var_type or Callable) + + if issubclass(output, NoneVar): + return ToNoneOperation.create(self) + + # If we can't determine the first argument, we just replace the _var_type. + if not issubclass(output, Var) or var_type is None: + return dataclasses.replace( + self, + _var_type=output, + ) + + # We couldn't determine the output type to be any other Var type, so we replace the _var_type. + if var_type is not None: + return dataclasses.replace( + self, + _var_type=var_type, + ) + + return self + + def guess_type(self) -> Var: + """Guesses the type of the variable based on its `_var_type` attribute. + + Returns: + Var: The guessed type of the variable. + + Raises: + TypeError: If the type is not supported for guessing. + """ + from .number import BooleanVar, NumberVar + from .object import ObjectVar + from .sequence import ArrayVar, StringVar + + var_type = self._var_type + if var_type is None: + return self.to(None) + if types.is_optional(var_type): + var_type = types.get_args(var_type)[0] + + if var_type is Any: + return self + + fixed_type = get_origin(var_type) or var_type + + if fixed_type is Union: + inner_types = get_args(var_type) + + if all( + inspect.isclass(t) and issubclass(t, (int, float)) for t in inner_types + ): + return self.to(NumberVar, self._var_type) + + if all( + inspect.isclass(t) + and (issubclass(t, Base) or dataclasses.is_dataclass(t)) + for t in inner_types + ): + return self.to(ObjectVar, self._var_type) + + return self + + if not inspect.isclass(fixed_type): + raise TypeError(f"Unsupported type {var_type} for guess_type.") + + if issubclass(fixed_type, bool): + return self.to(BooleanVar, self._var_type) + if issubclass(fixed_type, (int, float)): + return self.to(NumberVar, self._var_type) + if issubclass(fixed_type, dict): + return self.to(ObjectVar, self._var_type) + if issubclass(fixed_type, (list, tuple, set)): + return self.to(ArrayVar, self._var_type) + if issubclass(fixed_type, str): + return self.to(StringVar, self._var_type) + if issubclass(fixed_type, Base): + return self.to(ObjectVar, self._var_type) + if dataclasses.is_dataclass(fixed_type): + return self.to(ObjectVar, self._var_type) + return self + + def get_default_value(self) -> Any: + """Get the default value of the var. + + Returns: + The default value of the var. + + Raises: + ImportError: If the var is a dataframe and pandas is not installed. + """ + if types.is_optional(self._var_type): + return None + + type_ = ( + get_origin(self._var_type) + if types.is_generic_alias(self._var_type) + else self._var_type + ) + if type_ is Literal: + args = get_args(self._var_type) + return args[0] if args else None + if issubclass(type_, str): + return "" + if issubclass(type_, types.get_args(Union[int, float])): + return 0 + if issubclass(type_, bool): + return False + if issubclass(type_, list): + return [] + if issubclass(type_, dict): + return {} + if issubclass(type_, tuple): + return () + if types.is_dataframe(type_): + try: + import pandas as pd + + return pd.DataFrame() + except ImportError as e: + raise ImportError( + "Please install pandas to use dataframes in your app." + ) from e + return set() if issubclass(type_, set) else None + + def get_setter_name(self, include_state: bool = True) -> str: + """Get the name of the var's generated setter function. + + Args: + include_state: Whether to include the state name in the setter name. + + Returns: + The name of the setter function. + """ + setter = constants.SETTER_PREFIX + self._var_field_name + var_data = self._get_all_var_data() + if var_data is None: + return setter + if not include_state or var_data.state == "": + return setter + return ".".join((var_data.state, setter)) + + def get_setter(self) -> Callable[[BaseState, Any], None]: + """Get the var's setter function. + + Returns: + A function that that creates a setter for the var. + """ + actual_name = self._var_field_name + + def setter(state: BaseState, value: Any): + """Get the setter for the var. + + Args: + state: The state within which we add the setter function. + value: The value to set. + """ + if self._var_type in [int, float]: + try: + value = self._var_type(value) + setattr(state, actual_name, value) + except ValueError: + console.debug( + f"{type(state).__name__}.{self._js_expr}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.", + ) + else: + setattr(state, actual_name, value) + + setter.__qualname__ = self.get_setter_name() + + return setter + + def _var_set_state(self, state: type[BaseState] | str): + """Set the state of the var. + + Args: + state: The state to set. + + Returns: + The var with the state set. + """ + formatted_state_name = ( + state + if isinstance(state, str) + else format_state_name(state.get_full_name()) + ) + + return StateOperation.create( + formatted_state_name, + self, + _var_data=VarData.merge( + VarData.from_state(state, self._js_expr), self._var_data + ), + ).guess_type() + + def __eq__(self, other: Var | Any) -> BooleanVar: + """Check if the current variable is equal to the given variable. + + Args: + other (Var | Any): The variable to compare with. + + Returns: + BooleanVar: A BooleanVar object representing the result of the equality check. + """ + from .number import equal_operation + + return equal_operation(self, other) + + def __ne__(self, other: Var | Any) -> BooleanVar: + """Check if the current object is not equal to the given object. + + Parameters: + other (Var | Any): The object to compare with. + + Returns: + BooleanVar: A BooleanVar object representing the result of the comparison. + """ + from .number import equal_operation + + return ~equal_operation(self, other) + + def bool(self) -> BooleanVar: + """Convert the var to a boolean. + + Returns: + The boolean var. + """ + from .number import boolify + + return boolify(self) + + def __and__(self, other: Var | Any) -> Var: + """Perform a logical AND operation on the current instance and another variable. + + Args: + other: The variable to perform the logical AND operation with. + + Returns: + A `BooleanVar` object representing the result of the logical AND operation. + """ + return and_operation(self, other) + + def __rand__(self, other: Var | Any) -> Var: + """Perform a logical AND operation on the current instance and another variable. + + Args: + other: The variable to perform the logical AND operation with. + + Returns: + A `BooleanVar` object representing the result of the logical AND operation. + """ + return and_operation(other, self) + + def __or__(self, other: Var | Any) -> Var: + """Perform a logical OR operation on the current instance and another variable. + + Args: + other: The variable to perform the logical OR operation with. + + Returns: + A `BooleanVar` object representing the result of the logical OR operation. + """ + return or_operation(self, other) + + def __ror__(self, other: Var | Any) -> Var: + """Perform a logical OR operation on the current instance and another variable. + + Args: + other: The variable to perform the logical OR operation with. + + Returns: + A `BooleanVar` object representing the result of the logical OR operation. + """ + return or_operation(other, self) + + def __invert__(self) -> BooleanVar: + """Perform a logical NOT operation on the current instance. + + Returns: + A `BooleanVar` object representing the result of the logical NOT operation. + """ + return ~self.bool() + + def to_string(self): + """Convert the var to a string. + + Returns: + The string var. + """ + from .function import JSON_STRINGIFY + from .sequence import StringVar + + return JSON_STRINGIFY.call(self).to(StringVar) + + def as_ref(self) -> Var: + """Get a reference to the var. + + Returns: + The reference to the var. + """ + from .object import ObjectVar + + refs = Var( + _js_expr="refs", + _var_data=VarData( + imports={ + f"/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")] + } + ), + ).to(ObjectVar, Dict[str, str]) + return refs[LiteralVar.create(str(self))] + + @deprecated("Use `.js_type()` instead.") + def _type(self) -> StringVar: + """Returns the type of the object. + + This method uses the `typeof` function from the `FunctionStringVar` class + to determine the type of the object. + + Returns: + StringVar: A string variable representing the type of the object. + """ + return self.js_type() + + def js_type(self) -> StringVar: + """Returns the javascript type of the object. + + This method uses the `typeof` function from the `FunctionStringVar` class + to determine the type of the object. + + Returns: + StringVar: A string variable representing the type of the object. + """ + from .function import FunctionStringVar + from .sequence import StringVar + + type_of = FunctionStringVar("typeof") + return type_of.call(self).to(StringVar) + + def without_data(self): + """Create a copy of the var without the data. + + Returns: + The var without the data. + """ + return dataclasses.replace(self, _var_data=None) + + def contains(self, value: Any = None, field: Any = None): + """Get an attribute of the var. + + Args: + value: The value to check for. + field: The field to check for. + + Raises: + TypeError: If the var does not support contains check. + """ + raise TypeError( + f"Var of type {self._var_type} does not support contains check." + ) + + def __get__(self, instance: Any, owner: Any): + """Get the var. + + Args: + instance: The instance to get the var from. + owner: The owner of the var. + + Returns: + The var. + """ + return self + + def reverse(self): + """Reverse the var. + + Raises: + TypeError: If the var does not support reverse. + """ + raise TypeError("Cannot reverse non-list var.") + + def __getattr__(self, name: str): + """Get an attribute of the var. + + Args: + name: The name of the attribute. + + Returns: + The attribute. + + Raises: + VarAttributeError: If the attribute does not exist. + TypeError: If the var type is Any. + """ + if name.startswith("_"): + return self.__getattribute__(name) + + if self._var_type is Any: + raise TypeError( + f"You must provide an annotation for the state var `{str(self)}`. Annotation cannot be `{self._var_type}`." + ) + + if name in REPLACED_NAMES: + raise VarAttributeError( + f"Field {name!r} was renamed to {REPLACED_NAMES[name]!r}" + ) + + raise VarAttributeError( + f"The State var has no attribute '{name}' or may have been annotated wrongly.", + ) + + def _decode(self) -> Any: + """Decode Var as a python value. + + Note that Var with state set cannot be decoded python-side and will be + returned as full_name. + + Returns: + The decoded value or the Var name. + """ + if isinstance(self, LiteralVar): + return self._var_value # type: ignore + try: + return json.loads(str(self)) + except ValueError: + try: + return json.loads(self.json()) + except (ValueError, NotImplementedError): + return str(self) + + @property + def _var_state(self) -> str: + """Compat method for getting the state. + + Returns: + The state name associated with the var. + """ + var_data = self._get_all_var_data() + return var_data.state if var_data else "" + + @overload + @classmethod + def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... + + @overload + @classmethod + def range( + cls, + start: int | NumberVar, + end: int | NumberVar, + step: int | NumberVar = 1, + /, + ) -> ArrayVar[List[int]]: ... + + @classmethod + def range( + cls, + first_endpoint: int | NumberVar, + second_endpoint: int | NumberVar | None = None, + step: int | NumberVar | None = None, + ) -> ArrayVar[List[int]]: + """Create a range of numbers. + + Args: + first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range. + second_endpoint: The end of the range. + step: The step of the range. + + Returns: + The range of numbers. + """ + from .sequence import ArrayVar + + return ArrayVar.range(first_endpoint, second_endpoint, step) + + def __bool__(self) -> bool: + """Raise exception if using Var in a boolean context. + + Raises: + VarTypeError: when attempting to bool-ify the Var. + """ + raise VarTypeError( + f"Cannot convert Var {str(self)!r} to bool for use with `if`, `and`, `or`, and `not`. " + "Instead use `rx.cond` and bitwise operators `&` (and), `|` (or), `~` (invert)." + ) + + def __iter__(self) -> Any: + """Raise exception if using Var in an iterable context. + + Raises: + VarTypeError: when attempting to iterate over the Var. + """ + raise VarTypeError( + f"Cannot iterate over Var {str(self)!r}. Instead use `rx.foreach`." + ) + + def __contains__(self, _: Any) -> Var: + """Override the 'in' operator to alert the user that it is not supported. + + Raises: + VarTypeError: the operation is not supported + """ + raise VarTypeError( + "'in' operator not supported for Var types, use Var.contains() instead." + ) + + def json(self) -> str: + """Serialize the var to a JSON string. + + Raises: + NotImplementedError: If the method is not implemented. + """ + raise NotImplementedError("Var subclasses must implement the json method.") + + +OUTPUT = TypeVar("OUTPUT", bound=Var) + + +class LiteralVar(Var): + """Base class for immutable literal vars.""" + + @classmethod + def create( + cls, + value: Any, + _var_data: VarData | None = None, + ) -> Var: + """Create a var from a value. + + Args: + value: The value to create the var from. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + + Raises: + TypeError: If the value is not a supported type for LiteralVar. + """ + from .number import LiteralBooleanVar, LiteralNumberVar + from .object import LiteralObjectVar + from .sequence import LiteralArrayVar, LiteralStringVar + + if isinstance(value, Var): + if _var_data is None: + return value + return value._replace(merge_var_data=_var_data) + + if isinstance(value, str): + return LiteralStringVar.create(value, _var_data=_var_data) + + if isinstance(value, bool): + return LiteralBooleanVar.create(value, _var_data=_var_data) + + if isinstance(value, (int, float)): + return LiteralNumberVar.create(value, _var_data=_var_data) + + if isinstance(value, dict): + return LiteralObjectVar.create(value, _var_data=_var_data) + + if isinstance(value, (list, tuple, set)): + return LiteralArrayVar.create(value, _var_data=_var_data) + + if value is None: + return LiteralNoneVar.create(_var_data=_var_data) + + from reflex.event import EventChain, EventHandler, EventSpec + from reflex.utils.format import get_event_handler_parts + + from .function import ArgsFunctionOperation, FunctionStringVar + from .object import LiteralObjectVar + + if isinstance(value, EventSpec): + event_name = LiteralVar.create( + ".".join(filter(None, get_event_handler_parts(value.handler))) + ) + event_args = LiteralVar.create( + {str(name): value for name, value in value.args} + ) + event_client_name = LiteralVar.create(value.client_handler_name) + return FunctionStringVar("Event").call( + event_name, + event_args, + *([event_client_name] if value.client_handler_name else []), + ) + + if isinstance(value, EventChain): + sig = inspect.signature(value.args_spec) # type: ignore + if sig.parameters: + arg_def = tuple((f"_{p}" for p in sig.parameters)) + arg_def_expr = LiteralVar.create([Var(_js_expr=arg) for arg in arg_def]) + else: + # add a default argument for addEvents if none were specified in value.args_spec + # used to trigger the preventDefault() on the event. + arg_def = ("...args",) + arg_def_expr = Var(_js_expr="args") + + return ArgsFunctionOperation.create( + arg_def, + FunctionStringVar.create("addEvents").call( + LiteralVar.create( + [LiteralVar.create(event) for event in value.events] + ), + arg_def_expr, + LiteralVar.create(value.event_actions), + ), + ) + + if isinstance(value, EventHandler): + return Var(_js_expr=".".join(filter(None, get_event_handler_parts(value)))) + + serialized_value = serializers.serialize(value) + if serialized_value is not None: + if isinstance(serialized_value, dict): + return LiteralObjectVar.create( + serialized_value, + _var_type=type(value), + _var_data=_var_data, + ) + if isinstance(serialized_value, str): + return LiteralStringVar.create( + serialized_value, _var_type=type(value), _var_data=_var_data + ) + return LiteralVar.create(serialized_value, _var_data=_var_data) + + if isinstance(value, Base): + # get the fields of the pydantic class + fields = value.__fields__.keys() + one_level_dict = {field: getattr(value, field) for field in fields} + + return LiteralObjectVar.create( + { + field: value + for field, value in one_level_dict.items() + if not callable(value) + }, + _var_type=type(value), + _var_data=_var_data, + ) + + if dataclasses.is_dataclass(value) and not isinstance(value, type): + return LiteralObjectVar.create( + { + k: (None if callable(v) else v) + for k, v in dataclasses.asdict(value).items() + }, + _var_type=type(value), + _var_data=_var_data, + ) + + raise TypeError( + f"Unsupported type {type(value)} for LiteralVar. Tried to create a LiteralVar from {value}." + ) + + def __post_init__(self): + """Post-initialize the var.""" + + def json(self) -> str: + """Serialize the var to a JSON string. + + Raises: + NotImplementedError: If the method is not implemented. + """ + raise NotImplementedError( + "LiteralVar subclasses must implement the json method." + ) + + +@serializers.serializer +def serialize_literal(value: LiteralVar): + """Serialize a Literal type. + + Args: + value: The Literal to serialize. + + Returns: + The serialized Literal. + """ + return serializers.serialize(value._var_value) + + +P = ParamSpec("P") +T = TypeVar("T") + + +# NoReturn is used to match CustomVarOperationReturn with no type hint. +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[NoReturn]], +) -> Callable[P, Var]: ... + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[bool]], +) -> Callable[P, BooleanVar]: ... + + +NUMBER_T = TypeVar("NUMBER_T", int, float, Union[int, float]) + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[NUMBER_T]], +) -> Callable[P, NumberVar[NUMBER_T]]: ... + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[str]], +) -> Callable[P, StringVar]: ... + + +LIST_T = TypeVar("LIST_T", bound=Union[List[Any], Tuple, Set]) + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[LIST_T]], +) -> Callable[P, ArrayVar[LIST_T]]: ... + + +OBJECT_TYPE = TypeVar("OBJECT_TYPE", bound=Dict) + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[OBJECT_TYPE]], +) -> Callable[P, ObjectVar[OBJECT_TYPE]]: ... + + +def var_operation( + func: Callable[P, CustomVarOperationReturn[T]], +) -> Callable[P, Var[T]]: + """Decorator for creating a var operation. + + Example: + ```python + @var_operation + def add(a: NumberVar, b: NumberVar): + return custom_var_operation(f"{a} + {b}") + ``` + + Args: + func: The function to decorate. + + Returns: + The decorated function. + """ + + @functools.wraps(func) + def wrapper(*args: P.args, **kwargs: P.kwargs) -> Var[T]: + func_args = list(inspect.signature(func).parameters) + args_vars = { + func_args[i]: (LiteralVar.create(arg) if not isinstance(arg, Var) else arg) + for i, arg in enumerate(args) + } + kwargs_vars = { + key: LiteralVar.create(value) if not isinstance(value, Var) else value + for key, value in kwargs.items() + } + + return CustomVarOperation.create( + args=tuple(list(args_vars.items()) + list(kwargs_vars.items())), + return_var=func(*args_vars.values(), **kwargs_vars), # type: ignore + ).guess_type() + + return wrapper + + +def unionize(*args: Type) -> Type: + """Unionize the types. + + Args: + args: The types to unionize. + + Returns: + The unionized types. + """ + if not args: + return Any + if len(args) == 1: + return args[0] + # We are bisecting the args list here to avoid hitting the recursion limit + # In Python versions >= 3.11, we can simply do `return Union[*args]` + midpoint = len(args) // 2 + first_half, second_half = args[:midpoint], args[midpoint:] + return Union[unionize(*first_half), unionize(*second_half)] + + +def figure_out_type(value: Any) -> types.GenericType: + """Figure out the type of the value. + + Args: + value: The value to figure out the type of. + + Returns: + The type of the value. + """ + if isinstance(value, list): + return List[unionize(*(figure_out_type(v) for v in value))] + if isinstance(value, set): + return Set[unionize(*(figure_out_type(v) for v in value))] + if isinstance(value, tuple): + return Tuple[unionize(*(figure_out_type(v) for v in value)), ...] + if isinstance(value, dict): + return Dict[ + unionize(*(figure_out_type(k) for k in value)), + unionize(*(figure_out_type(v) for v in value.values())), + ] + if isinstance(value, Var): + return value._var_type + return type(value) + + +class cached_property_no_lock(functools.cached_property): + """A special version of functools.cached_property that does not use a lock.""" + + def __init__(self, func): + """Initialize the cached_property_no_lock. + + Args: + func: The function to cache. + """ + super().__init__(func) + self.lock = contextlib.nullcontext() + + +class CachedVarOperation: + """Base class for cached var operations to lower boilerplate code.""" + + def __post_init__(self): + """Post-initialize the CachedVarOperation.""" + object.__delattr__(self, "_js_expr") + + def __getattr__(self, name: str) -> Any: + """Get an attribute of the var. + + Args: + name: The name of the attribute. + + Returns: + The attribute. + """ + if name == "_js_expr": + return self._cached_var_name + + parent_classes = inspect.getmro(self.__class__) + + next_class = parent_classes[parent_classes.index(CachedVarOperation) + 1] + + return next_class.__getattr__(self, name) # type: ignore + + def _get_all_var_data(self) -> VarData | None: + """Get all VarData associated with the Var. + + Returns: + The VarData of the components and all of its children. + """ + return self._cached_get_all_var_data + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get the cached VarData. + + Returns: + The cached VarData. + """ + return VarData.merge( + *map( + lambda value: ( + value._get_all_var_data() if isinstance(value, Var) else None + ), + map( + lambda field: getattr(self, field.name), + dataclasses.fields(self), # type: ignore + ), + ), + self._var_data, + ) + + def __hash__(self) -> int: + """Calculate the hash of the object. + + Returns: + The hash of the object. + """ + return hash( + ( + self.__class__.__name__, + *[ + getattr(self, field.name) + for field in dataclasses.fields(self) # type: ignore + if field.name not in ["_js_expr", "_var_data", "_var_type"] + ], + ) + ) + + +def and_operation(a: Var | Any, b: Var | Any) -> Var: + """Perform a logical AND operation on two variables. + + Args: + a: The first variable. + b: The second variable. + + Returns: + The result of the logical AND operation. + """ + return _and_operation(a, b) # type: ignore + + +@var_operation +def _and_operation(a: Var, b: Var): + """Perform a logical AND operation on two variables. + + Args: + a: The first variable. + b: The second variable. + + Returns: + The result of the logical AND operation. + """ + return var_operation_return( + js_expression=f"({a} && {b})", + var_type=unionize(a._var_type, b._var_type), + ) + + +def or_operation(a: Var | Any, b: Var | Any) -> Var: + """Perform a logical OR operation on two variables. + + Args: + a: The first variable. + b: The second variable. + + Returns: + The result of the logical OR operation. + """ + return _or_operation(a, b) # type: ignore + + +@var_operation +def _or_operation(a: Var, b: Var): + """Perform a logical OR operation on two variables. + + Args: + a: The first variable. + b: The second variable. + + Returns: + The result of the logical OR operation. + """ + return var_operation_return( + js_expression=f"({a} || {b})", + var_type=unionize(a._var_type, b._var_type), + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class CallableVar(Var): + """Decorate a Var-returning function to act as both a Var and a function. + + This is used as a compatibility shim for replacing Var objects in the + API with functions that return a family of Var. + """ + + fn: Callable[..., Var] = dataclasses.field( + default_factory=lambda: lambda: Var(_js_expr="undefined") + ) + original_var: Var = dataclasses.field( + default_factory=lambda: Var(_js_expr="undefined") + ) + + def __init__(self, fn: Callable[..., Var]): + """Initialize a CallableVar. + + Args: + fn: The function to decorate (must return Var) + """ + original_var = fn() + super(CallableVar, self).__init__( + _js_expr=original_var._js_expr, + _var_type=original_var._var_type, + _var_data=VarData.merge(original_var._get_all_var_data()), + ) + object.__setattr__(self, "fn", fn) + object.__setattr__(self, "original_var", original_var) + + def __call__(self, *args, **kwargs) -> Var: + """Call the decorated function. + + Args: + *args: The args to pass to the function. + **kwargs: The kwargs to pass to the function. + + Returns: + The Var returned from calling the function. + """ + return self.fn(*args, **kwargs) + + def __hash__(self) -> int: + """Calculate the hash of the object. + + Returns: + The hash of the object. + """ + return hash((self.__class__.__name__, self.original_var)) + + +RETURN_TYPE = TypeVar("RETURN_TYPE") + +DICT_KEY = TypeVar("DICT_KEY") +DICT_VAL = TypeVar("DICT_VAL") + +LIST_INSIDE = TypeVar("LIST_INSIDE") + + +class FakeComputedVarBaseClass(property): + """A fake base class for ComputedVar to avoid inheriting from property.""" + + __pydantic_run_validation__ = False + + +def is_computed_var(obj: Any) -> TypeGuard[ComputedVar]: + """Check if the object is a ComputedVar. + + Args: + obj: The object to check. + + Returns: + Whether the object is a ComputedVar. + """ + return isinstance(obj, FakeComputedVarBaseClass) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ComputedVar(Var[RETURN_TYPE]): + """A field with computed getters.""" + + # Whether to track dependencies and cache computed values + _cache: bool = dataclasses.field(default=False) + + # Whether the computed var is a backend var + _backend: bool = dataclasses.field(default=False) + + # The initial value of the computed var + _initial_value: RETURN_TYPE | types.Unset = dataclasses.field(default=types.Unset()) + + # Explicit var dependencies to track + _static_deps: set[str] = dataclasses.field(default_factory=set) + + # Whether var dependencies should be auto-determined + _auto_deps: bool = dataclasses.field(default=True) + + # Interval at which the computed var should be updated + _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None) + + _fget: Callable[[BaseState], RETURN_TYPE] = dataclasses.field( + default_factory=lambda: lambda _: None + ) # type: ignore + + def __init__( + self, + fget: Callable[[BASE_STATE], RETURN_TYPE], + initial_value: RETURN_TYPE | types.Unset = types.Unset(), + cache: bool = False, + deps: Optional[List[Union[str, Var]]] = None, + auto_deps: bool = True, + interval: Optional[Union[int, datetime.timedelta]] = None, + backend: bool | None = None, + **kwargs, + ): + """Initialize a ComputedVar. + + Args: + fget: The getter function. + initial_value: The initial value of the computed var. + cache: Whether to cache the computed value. + deps: Explicit var dependencies to track. + auto_deps: Whether var dependencies should be auto-determined. + interval: Interval at which the computed var should be updated. + backend: Whether the computed var is a backend var. + **kwargs: additional attributes to set on the instance + + Raises: + TypeError: If the computed var dependencies are not Var instances or var names. + """ + hints = get_type_hints(fget) + hint = hints.get("return", Any) + + kwargs["_js_expr"] = kwargs.pop("_js_expr", fget.__name__) + kwargs["_var_type"] = kwargs.pop("_var_type", hint) + + Var.__init__( + self, + _js_expr=kwargs.pop("_js_expr"), + _var_type=kwargs.pop("_var_type"), + _var_data=kwargs.pop("_var_data", None), + ) + + if backend is None: + backend = fget.__name__.startswith("_") + + object.__setattr__(self, "_backend", backend) + object.__setattr__(self, "_initial_value", initial_value) + object.__setattr__(self, "_cache", cache) + + if isinstance(interval, int): + interval = datetime.timedelta(seconds=interval) + + object.__setattr__(self, "_update_interval", interval) + + if deps is None: + deps = [] + else: + for dep in deps: + if isinstance(dep, Var): + continue + if isinstance(dep, str) and dep != "": + continue + raise TypeError( + "ComputedVar dependencies must be Var instances or var names (non-empty strings)." + ) + object.__setattr__( + self, + "_static_deps", + {dep._js_expr if isinstance(dep, Var) else dep for dep in deps}, + ) + object.__setattr__(self, "_auto_deps", auto_deps) + + object.__setattr__(self, "_fget", fget) + + @override + def _replace(self, merge_var_data=None, **kwargs: Any) -> Self: + """Replace the attributes of the ComputedVar. + + Args: + merge_var_data: VarData to merge into the existing VarData. + **kwargs: Var fields to update. + + Returns: + The new ComputedVar instance. + + Raises: + TypeError: If kwargs contains keys that are not allowed. + """ + field_values = dict( + fget=kwargs.pop("fget", self._fget), + initial_value=kwargs.pop("initial_value", self._initial_value), + cache=kwargs.pop("cache", self._cache), + deps=kwargs.pop("deps", self._static_deps), + auto_deps=kwargs.pop("auto_deps", self._auto_deps), + interval=kwargs.pop("interval", self._update_interval), + backend=kwargs.pop("backend", self._backend), + _js_expr=kwargs.pop("_js_expr", self._js_expr), + _var_type=kwargs.pop("_var_type", self._var_type), + _var_data=kwargs.pop( + "_var_data", VarData.merge(self._var_data, merge_var_data) + ), + ) + + if kwargs: + unexpected_kwargs = ", ".join(kwargs.keys()) + raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") + + return type(self)(**field_values) + + @property + def _cache_attr(self) -> str: + """Get the attribute used to cache the value on the instance. + + Returns: + An attribute name. + """ + return f"__cached_{self._js_expr}" + + @property + def _last_updated_attr(self) -> str: + """Get the attribute used to store the last updated timestamp. + + Returns: + An attribute name. + """ + return f"__last_updated_{self._js_expr}" + + def needs_update(self, instance: BaseState) -> bool: + """Check if the computed var needs to be updated. + + Args: + instance: The state instance that the computed var is attached to. + + Returns: + True if the computed var needs to be updated, False otherwise. + """ + if self._update_interval is None: + return False + last_updated = getattr(instance, self._last_updated_attr, None) + if last_updated is None: + return True + return datetime.datetime.now() - last_updated > self._update_interval + + @overload + def __get__( + self: ComputedVar[int] | ComputedVar[float], + instance: None, + owner: Type, + ) -> NumberVar: ... + + @overload + def __get__( + self: ComputedVar[str], + instance: None, + owner: Type, + ) -> StringVar: ... + + @overload + def __get__( + self: ComputedVar[dict[DICT_KEY, DICT_VAL]], + instance: None, + owner: Type, + ) -> ObjectVar[dict[DICT_KEY, DICT_VAL]]: ... + + @overload + def __get__( + self: ComputedVar[list[LIST_INSIDE]], + instance: None, + owner: Type, + ) -> ArrayVar[list[LIST_INSIDE]]: ... + + @overload + def __get__( + self: ComputedVar[set[LIST_INSIDE]], + instance: None, + owner: Type, + ) -> ArrayVar[set[LIST_INSIDE]]: ... + + @overload + def __get__( + self: ComputedVar[tuple[LIST_INSIDE, ...]], + instance: None, + owner: Type, + ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ... + + @overload + def __get__(self, instance: None, owner: Type) -> ComputedVar[RETURN_TYPE]: ... + + @overload + def __get__(self, instance: BaseState, owner: Type) -> RETURN_TYPE: ... + + def __get__(self, instance: BaseState | None, owner): + """Get the ComputedVar value. + + If the value is already cached on the instance, return the cached value. + + Args: + instance: the instance of the class accessing this computed var. + owner: the class that this descriptor is attached to. + + Returns: + The value of the var for the given instance. + """ + if instance is None: + state_where_defined = owner + while self._js_expr in state_where_defined.inherited_vars: + state_where_defined = state_where_defined.get_parent_state() + + field_name = ( + format_state_name(state_where_defined.get_full_name()) + + "." + + self._js_expr + ) + + return dispatch( + field_name, + var_data=VarData.from_state(state_where_defined, self._js_expr), + result_var_type=self._var_type, + existing_var=self, + ) + + if not self._cache: + return self.fget(instance) + + # handle caching + if not hasattr(instance, self._cache_attr) or self.needs_update(instance): + # Set cache attr on state instance. + setattr(instance, self._cache_attr, self.fget(instance)) + # Ensure the computed var gets serialized to redis. + instance._was_touched = True + # Set the last updated timestamp on the state instance. + setattr(instance, self._last_updated_attr, datetime.datetime.now()) + return getattr(instance, self._cache_attr) + + def _deps( + self, + objclass: Type, + obj: FunctionType | CodeType | None = None, + self_name: Optional[str] = None, + ) -> set[str]: + """Determine var dependencies of this ComputedVar. + + Save references to attributes accessed on "self". Recursively called + when the function makes a method call on "self" or define comprehensions + or nested functions that may reference "self". + + Args: + objclass: the class obj this ComputedVar is attached to. + obj: the object to disassemble (defaults to the fget function). + self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions. + + Returns: + A set of variable names accessed by the given obj. + + Raises: + VarValueError: if the function references the get_state, parent_state, or substates attributes + (cannot track deps in a related state, only implicitly via parent state). + """ + if not self._auto_deps: + return self._static_deps + d = self._static_deps.copy() + if obj is None: + fget = self._fget + if fget is not None: + obj = cast(FunctionType, fget) + else: + return set() + with contextlib.suppress(AttributeError): + # unbox functools.partial + obj = cast(FunctionType, obj.func) # type: ignore + with contextlib.suppress(AttributeError): + # unbox EventHandler + obj = cast(FunctionType, obj.fn) # type: ignore + + if self_name is None and isinstance(obj, FunctionType): + try: + # the first argument to the function is the name of "self" arg + self_name = obj.__code__.co_varnames[0] + except (AttributeError, IndexError): + self_name = None + if self_name is None: + # cannot reference attributes on self if method takes no args + return set() + + invalid_names = ["get_state", "parent_state", "substates", "get_substate"] + self_is_top_of_stack = False + for instruction in dis.get_instructions(obj): + if ( + instruction.opname in ("LOAD_FAST", "LOAD_DEREF") + and instruction.argval == self_name + ): + # bytecode loaded the class instance to the top of stack, next load instruction + # is referencing an attribute on self + self_is_top_of_stack = True + continue + if self_is_top_of_stack and instruction.opname in ( + "LOAD_ATTR", + "LOAD_METHOD", + ): + try: + ref_obj = getattr(objclass, instruction.argval) + except Exception: + ref_obj = None + if instruction.argval in invalid_names: + raise VarValueError( + f"Cached var {str(self)} cannot access arbitrary state via `{instruction.argval}`." + ) + if callable(ref_obj): + # recurse into callable attributes + d.update( + self._deps( + objclass=objclass, + obj=ref_obj, + ) + ) + # recurse into property fget functions + elif isinstance(ref_obj, property) and not isinstance( + ref_obj, ComputedVar + ): + d.update( + self._deps( + objclass=objclass, + obj=ref_obj.fget, # type: ignore + ) + ) + elif ( + instruction.argval in objclass.backend_vars + or instruction.argval in objclass.vars + ): + # var access + d.add(instruction.argval) + elif instruction.opname == "LOAD_CONST" and isinstance( + instruction.argval, CodeType + ): + # recurse into nested functions / comprehensions, which can reference + # instance attributes from the outer scope + d.update( + self._deps( + objclass=objclass, + obj=instruction.argval, + self_name=self_name, + ) + ) + self_is_top_of_stack = False + return d + + def mark_dirty(self, instance) -> None: + """Mark this ComputedVar as dirty. + + Args: + instance: the state instance that needs to recompute the value. + """ + with contextlib.suppress(AttributeError): + delattr(instance, self._cache_attr) + + def _determine_var_type(self) -> Type: + """Get the type of the var. + + Returns: + The type of the var. + """ + hints = get_type_hints(self._fget) + if "return" in hints: + return hints["return"] + return Any + + @property + def __class__(self) -> Type: + """Get the class of the var. + + Returns: + The class of the var. + """ + return FakeComputedVarBaseClass + + @property + def fget(self) -> Callable[[BaseState], RETURN_TYPE]: + """Get the getter function. + + Returns: + The getter function. + """ + return self._fget + + +class DynamicRouteVar(ComputedVar[Union[str, List[str]]]): + """A ComputedVar that represents a dynamic route.""" + + pass + + +if TYPE_CHECKING: + BASE_STATE = TypeVar("BASE_STATE", bound=BaseState) + + +@overload +def computed_var( + fget: None = None, + initial_value: Any | types.Unset = types.Unset(), + cache: bool = False, + deps: Optional[List[Union[str, Var]]] = None, + auto_deps: bool = True, + interval: Optional[Union[datetime.timedelta, int]] = None, + backend: bool | None = None, + **kwargs, +) -> Callable[[Callable[[BASE_STATE], RETURN_TYPE]], ComputedVar[RETURN_TYPE]]: ... + + +@overload +def computed_var( + fget: Callable[[BASE_STATE], RETURN_TYPE], + initial_value: RETURN_TYPE | types.Unset = types.Unset(), + cache: bool = False, + deps: Optional[List[Union[str, Var]]] = None, + auto_deps: bool = True, + interval: Optional[Union[datetime.timedelta, int]] = None, + backend: bool | None = None, + **kwargs, +) -> ComputedVar[RETURN_TYPE]: ... + + +def computed_var( + fget: Callable[[BASE_STATE], Any] | None = None, + initial_value: Any | types.Unset = types.Unset(), + cache: bool = False, + deps: Optional[List[Union[str, Var]]] = None, + auto_deps: bool = True, + interval: Optional[Union[datetime.timedelta, int]] = None, + backend: bool | None = None, + **kwargs, +) -> ComputedVar | Callable[[Callable[[BASE_STATE], Any]], ComputedVar]: + """A ComputedVar decorator with or without kwargs. + + Args: + fget: The getter function. + initial_value: The initial value of the computed var. + cache: Whether to cache the computed value. + deps: Explicit var dependencies to track. + auto_deps: Whether var dependencies should be auto-determined. + interval: Interval at which the computed var should be updated. + backend: Whether the computed var is a backend var. + **kwargs: additional attributes to set on the instance + + Returns: + A ComputedVar instance. + + Raises: + ValueError: If caching is disabled and an update interval is set. + VarDependencyError: If user supplies dependencies without caching. + """ + if cache is False and interval is not None: + raise ValueError("Cannot set update interval without caching.") + + if cache is False and (deps is not None or auto_deps is False): + raise VarDependencyError("Cannot track dependencies without caching.") + + if fget is not None: + return ComputedVar(fget, cache=cache) + + def wrapper(fget: Callable[[BASE_STATE], Any]) -> ComputedVar: + return ComputedVar( + fget, + initial_value=initial_value, + cache=cache, + deps=deps, + auto_deps=auto_deps, + interval=interval, + backend=backend, + **kwargs, + ) + + return wrapper + + +RETURN = TypeVar("RETURN") + + +class CustomVarOperationReturn(Var[RETURN]): + """Base class for custom var operations.""" + + @classmethod + def create( + cls, + js_expression: str, + _var_type: Type[RETURN] | None = None, + _var_data: VarData | None = None, + ) -> CustomVarOperationReturn[RETURN]: + """Create a CustomVarOperation. + + Args: + js_expression: The JavaScript expression to evaluate. + _var_type: The type of the var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The CustomVarOperation. + """ + return CustomVarOperationReturn( + _js_expr=js_expression, + _var_type=_var_type or Any, + _var_data=_var_data, + ) + + +def var_operation_return( + js_expression: str, + var_type: Type[RETURN] | None = None, + var_data: VarData | None = None, +) -> CustomVarOperationReturn[RETURN]: + """Shortcut for creating a CustomVarOperationReturn. + + Args: + js_expression: The JavaScript expression to evaluate. + var_type: The type of the var. + var_data: Additional hooks and imports associated with the Var. + + Returns: + The CustomVarOperationReturn. + """ + return CustomVarOperationReturn.create( + js_expression, + var_type, + var_data, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class CustomVarOperation(CachedVarOperation, Var[T]): + """Base class for custom var operations.""" + + _args: Tuple[Tuple[str, Var], ...] = dataclasses.field(default_factory=tuple) + + _return: CustomVarOperationReturn[T] = dataclasses.field( + default_factory=lambda: CustomVarOperationReturn.create("") + ) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """Get the cached var name. + + Returns: + The cached var name. + """ + return str(self._return) + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get the cached VarData. + + Returns: + The cached VarData. + """ + return VarData.merge( + *map( + lambda arg: arg[1]._get_all_var_data(), + self._args, + ), + self._return._get_all_var_data(), + self._var_data, + ) + + @classmethod + def create( + cls, + args: Tuple[Tuple[str, Var], ...], + return_var: CustomVarOperationReturn[T], + _var_data: VarData | None = None, + ) -> CustomVarOperation[T]: + """Create a CustomVarOperation. + + Args: + args: The arguments to the operation. + return_var: The return var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The CustomVarOperation. + """ + return CustomVarOperation( + _js_expr="", + _var_type=return_var._var_type, + _var_data=_var_data, + _args=args, + _return=return_var, + ) + + +class NoneVar(Var[None]): + """A var representing None.""" + + +class LiteralNoneVar(LiteralVar, NoneVar): + """A var representing None.""" + + def json(self) -> str: + """Serialize the var to a JSON string. + + Returns: + The JSON string. + """ + return "null" + + @classmethod + def create( + cls, + _var_data: VarData | None = None, + ) -> LiteralNoneVar: + """Create a var from a value. + + Args: + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + return LiteralNoneVar( + _js_expr="null", + _var_type=None, + _var_data=_var_data, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ToNoneOperation(CachedVarOperation, NoneVar): + """A var operation that converts a var to None.""" + + _original_var: Var = dataclasses.field( + default_factory=lambda: LiteralNoneVar.create() + ) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """Get the cached var name. + + Returns: + The cached var name. + """ + return str(self._original_var) + + @classmethod + def create( + cls, + var: Var, + _var_data: VarData | None = None, + ) -> ToNoneOperation: + """Create a ToNoneOperation. + + Args: + var: The var to convert to None. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The ToNoneOperation. + """ + return ToNoneOperation( + _js_expr="", + _var_type=None, + _var_data=_var_data, + _original_var=var, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class StateOperation(CachedVarOperation, Var): + """A var operation that accesses a field on an object.""" + + _state_name: str = dataclasses.field(default="") + _field: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create()) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """Get the cached var name. + + Returns: + The cached var name. + """ + return f"{str(self._state_name)}.{str(self._field)}" + + def __getattr__(self, name: str) -> Any: + """Get an attribute of the var. + + Args: + name: The name of the attribute. + + Returns: + The attribute. + """ + if name == "_js_expr": + return self._cached_var_name + + return getattr(self._field, name) + + @classmethod + def create( + cls, + state_name: str, + field: Var, + _var_data: VarData | None = None, + ) -> StateOperation: + """Create a DotOperation. + + Args: + state_name: The name of the state. + field: The field of the state. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The DotOperation. + """ + return StateOperation( + _js_expr="", + _var_type=field._var_type, + _var_data=_var_data, + _state_name=state_name, + _field=field, + ) + + +class ToOperation: + """A var operation that converts a var to another type.""" + + def __getattr__(self, name: str) -> Any: + """Get an attribute of the var. + + Args: + name: The name of the attribute. + + Returns: + The attribute of the var. + """ + return getattr(object.__getattribute__(self, "_original"), name) + + def __post_init__(self): + """Post initialization.""" + object.__delattr__(self, "_js_expr") + + def __hash__(self) -> int: + """Calculate the hash value of the object. + + Returns: + int: The hash value of the object. + """ + return hash(object.__getattribute__(self, "_original")) + + def _get_all_var_data(self) -> VarData | None: + """Get all the var data. + + Returns: + The var data. + """ + return VarData.merge( + object.__getattribute__(self, "_original")._get_all_var_data(), + self._var_data, # type: ignore + ) + + @classmethod + def create( + cls, + value: Var, + _var_type: GenericType | None = None, + _var_data: VarData | None = None, + ): + """Create a ToOperation. + + Args: + value: The value of the var. + _var_type: The type of the Var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The ToOperation. + """ + return cls( + _js_expr="", # type: ignore + _var_data=_var_data, # type: ignore + _var_type=_var_type or cls._default_var_type, # type: ignore + _original=value, # type: ignore + ) + + +def get_uuid_string_var() -> Var: + """Return a Var that generates a single memoized UUID via .web/utils/state.js. + + useMemo with an empty dependency array ensures that the generated UUID is + consistent across re-renders of the component. + + Returns: + A Var that generates a UUID at runtime. + """ + from reflex.utils.imports import ImportVar + from reflex.vars import Var + + unique_uuid_var = get_unique_variable_name() + unique_uuid_var_data = VarData( + imports={ + f"/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}, # type: ignore + "react": "useMemo", + }, + hooks={f"const {unique_uuid_var} = useMemo(generateUUID, [])": None}, + ) + + return Var( + _js_expr=unique_uuid_var, + _var_type=str, + _var_data=unique_uuid_var_data, + ) + + +# Set of unique variable names. +USED_VARIABLES = set() + + +def get_unique_variable_name() -> str: + """Get a unique variable name. + + Returns: + The unique variable name. + """ + name = "".join([random.choice(string.ascii_lowercase) for _ in range(8)]) + if name not in USED_VARIABLES: + USED_VARIABLES.add(name) + return name + return get_unique_variable_name() + + +@dataclasses.dataclass( + eq=True, + frozen=True, +) +class VarData: + """Metadata associated with a x.""" + + # The name of the enclosing state. + state: str = dataclasses.field(default="") + + # The name of the field in the state. + field_name: str = dataclasses.field(default="") + + # Imports needed to render this var + imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple) + + # Hooks that need to be present in the component to render this var + hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple) + + def __init__( + self, + state: str = "", + field_name: str = "", + imports: ImportDict | ParsedImportDict | None = None, + hooks: dict[str, None] | None = None, + ): + """Initialize the var data. + + Args: + state: The name of the enclosing state. + field_name: The name of the field in the state. + imports: Imports needed to render this var. + hooks: Hooks that need to be present in the component to render this var. + """ + immutable_imports: ImmutableParsedImportDict = tuple( + sorted( + ((k, tuple(sorted(v))) for k, v in parse_imports(imports or {}).items()) + ) + ) + object.__setattr__(self, "state", state) + object.__setattr__(self, "field_name", field_name) + object.__setattr__(self, "imports", immutable_imports) + object.__setattr__(self, "hooks", tuple(hooks or {})) + + def old_school_imports(self) -> ImportDict: + """Return the imports as a mutable dict. + + Returns: + The imports as a mutable dict. + """ + return dict((k, list(v)) for k, v in self.imports) + + @classmethod + def merge(cls, *others: VarData | None) -> VarData | None: + """Merge multiple var data objects. + + Args: + *others: The var data objects to merge. + + Returns: + The merged var data object. + """ + state = "" + field_name = "" + _imports = {} + hooks = {} + for var_data in others: + if var_data is None: + continue + state = state or var_data.state + field_name = field_name or var_data.field_name + _imports = imports.merge_imports(_imports, var_data.imports) + hooks.update( + var_data.hooks + if isinstance(var_data.hooks, dict) + else {k: None for k in var_data.hooks} + ) + + if state or _imports or hooks or field_name: + return VarData( + state=state, + field_name=field_name, + imports=_imports, + hooks=hooks, + ) + return None + + def __bool__(self) -> bool: + """Check if the var data is non-empty. + + Returns: + True if any field is set to a non-default value. + """ + return bool(self.state or self.imports or self.hooks or self.field_name) + + @classmethod + def from_state(cls, state: Type[BaseState] | str, field_name: str = "") -> VarData: + """Set the state of the var. + + Args: + state: The state to set or the full name of the state. + field_name: The name of the field in the state. Optional. + + Returns: + The var with the set state. + """ + from reflex.utils import format + + state_name = state if isinstance(state, str) else state.get_full_name() + return VarData( + state=state_name, + field_name=field_name, + hooks={ + "const {0} = useContext(StateContexts.{0})".format( + format.format_state_name(state_name) + ): None + }, + imports={ + f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")], + "react": [ImportVar(tag="useContext")], + }, + ) + + +def _decode_var_immutable(value: str) -> tuple[VarData | None, str]: + """Decode the state name from a formatted var. + + Args: + value: The value to extract the state name from. + + Returns: + The extracted state name and the value without the state name. + """ + var_datas = [] + if isinstance(value, str): + # fast path if there is no encoded VarData + if constants.REFLEX_VAR_OPENING_TAG not in value: + return None, value + + offset = 0 + + # Find all tags. + while m := _decode_var_pattern.search(value): + start, end = m.span() + value = value[:start] + value[end:] + + serialized_data = m.group(1) + + if serialized_data.isnumeric() or ( + serialized_data[0] == "-" and serialized_data[1:].isnumeric() + ): + # This is a global immutable var. + var = _global_vars[int(serialized_data)] + var_data = var._get_all_var_data() + + if var_data is not None: + var_datas.append(var_data) + offset += end - start + + return VarData.merge(*var_datas) if var_datas else None, value + + +# Compile regex for finding reflex var tags. +_decode_var_pattern_re = ( + rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" +) +_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) + +# Defined global immutable vars. +_global_vars: Dict[int, Var] = {} + + +def _extract_var_data(value: Iterable) -> list[VarData | None]: + """Extract the var imports and hooks from an iterable containing a Var. + + Args: + value: The iterable to extract the VarData from + + Returns: + The extracted VarDatas. + """ + from reflex.style import Style + from reflex.vars import Var + + var_datas = [] + with contextlib.suppress(TypeError): + for sub in value: + if isinstance(sub, Var): + var_datas.append(sub._var_data) + elif not isinstance(sub, str): + # Recurse into dict values. + if hasattr(sub, "values") and callable(sub.values): + var_datas.extend(_extract_var_data(sub.values())) + # Recurse into iterable values (or dict keys). + var_datas.extend(_extract_var_data(sub)) + + # Style objects should already have _var_data. + if isinstance(value, Style): + var_datas.append(value._var_data) + else: + # Recurse when value is a dict itself. + values = getattr(value, "values", None) + if callable(values): + var_datas.extend(_extract_var_data(values())) + return var_datas + + +# These names were changed in reflex 0.3.0 +REPLACED_NAMES = { + "full_name": "_var_full_name", + "name": "_js_expr", + "state": "_var_data.state", + "type_": "_var_type", + "is_local": "_var_is_local", + "is_string": "_var_is_string", + "set_state": "_var_set_state", + "deps": "_deps", +} + + +dispatchers: Dict[GenericType, Callable[[Var], Var]] = {} + + +def transform(fn: Callable[[Var], Var]) -> Callable[[Var], Var]: + """Register a function to transform a Var. + + Args: + fn: The function to register. + + Returns: + The decorator. + + Raises: + TypeError: If the return type of the function is not a Var. + TypeError: If the Var return type does not have a generic type. + ValueError: If a function for the generic type is already registered. + """ + return_type = fn.__annotations__["return"] + + origin = get_origin(return_type) + + if origin is not Var: + raise TypeError( + f"Expected return type of {fn.__name__} to be a Var, got {origin}." + ) + + generic_args = get_args(return_type) + + if not generic_args: + raise TypeError( + f"Expected Var return type of {fn.__name__} to have a generic type." + ) + + generic_type = get_origin(generic_args[0]) or generic_args[0] + + if generic_type in dispatchers: + raise ValueError(f"Function for {generic_type} already registered.") + + dispatchers[generic_type] = fn + + return fn + + +def generic_type_to_actual_type_map( + generic_type: GenericType, actual_type: GenericType +) -> Dict[TypeVar, GenericType]: + """Map the generic type to the actual type. + + Args: + generic_type: The generic type. + actual_type: The actual type. + + Returns: + The mapping of type variables to actual types. + + Raises: + TypeError: If the generic type and actual type do not match. + TypeError: If the number of generic arguments and actual arguments do not match. + """ + generic_origin = get_origin(generic_type) or generic_type + actual_origin = get_origin(actual_type) or actual_type + + if generic_origin is not actual_origin: + if isinstance(generic_origin, TypeVar): + return {generic_origin: actual_origin} + raise TypeError( + f"Type mismatch: expected {generic_origin}, got {actual_origin}." + ) + + generic_args = get_args(generic_type) + actual_args = get_args(actual_type) + + if len(generic_args) != len(actual_args): + raise TypeError( + f"Number of generic arguments mismatch: expected {len(generic_args)}, got {len(actual_args)}." + ) + + # call recursively for nested generic types and merge the results + return { + k: v + for generic_arg, actual_arg in zip(generic_args, actual_args, strict=False) + for k, v in generic_type_to_actual_type_map(generic_arg, actual_arg).items() + } + + +def resolve_generic_type_with_mapping( + generic_type: GenericType, type_mapping: Dict[TypeVar, GenericType] +): + """Resolve a generic type with a type mapping. + + Args: + generic_type: The generic type. + type_mapping: The type mapping. + + Returns: + The resolved generic type. + """ + if isinstance(generic_type, TypeVar): + return type_mapping.get(generic_type, generic_type) + + generic_origin = get_origin(generic_type) or generic_type + + generic_args = get_args(generic_type) + + if not generic_args: + return generic_type + + mapping_for_older_python = { + list: List, + set: Set, + dict: Dict, + tuple: Tuple, + frozenset: FrozenSet, + } + + return mapping_for_older_python.get(generic_origin, generic_origin)[ + tuple( + resolve_generic_type_with_mapping(arg, type_mapping) for arg in generic_args + ) + ] + + +def resolve_arg_type_from_return_type( + arg_type: GenericType, return_type: GenericType, actual_return_type: GenericType +) -> GenericType: + """Resolve the argument type from the return type. + + Args: + arg_type: The argument type. + return_type: The return type. + actual_return_type: The requested return type. + + Returns: + The argument type without the generics that are resolved. + """ + return resolve_generic_type_with_mapping( + arg_type, generic_type_to_actual_type_map(return_type, actual_return_type) + ) + + +def dispatch( + field_name: str, + var_data: VarData, + result_var_type: GenericType, + existing_var: Var | None = None, +) -> Var: + """Dispatch a Var to the appropriate transformation function. + + Args: + field_name: The name of the field. + var_data: The VarData associated with the Var. + result_var_type: The type of the Var. + existing_var: The existing Var to transform. Optional. + + Returns: + The transformed Var. + + Raises: + TypeError: If the return type of the function is not a Var. + TypeError: If the Var return type does not have a generic type. + TypeError: If the first argument of the function is not a Var. + TypeError: If the first argument of the function does not have a generic type + """ + result_origin_var_type = get_origin(result_var_type) or result_var_type + + if result_origin_var_type in dispatchers: + fn = dispatchers[result_origin_var_type] + fn_first_arg_type = list(inspect.signature(fn).parameters.values())[ + 0 + ].annotation + + fn_return = inspect.signature(fn).return_annotation + + fn_return_origin = get_origin(fn_return) or fn_return + + if fn_return_origin is not Var: + raise TypeError( + f"Expected return type of {fn.__name__} to be a Var, got {fn_return}." + ) + + fn_return_generic_args = get_args(fn_return) + + if not fn_return_generic_args: + raise TypeError(f"Expected generic type of {fn_return} to be a type.") + + arg_origin = get_origin(fn_first_arg_type) or fn_first_arg_type + + if arg_origin is not Var: + raise TypeError( + f"Expected first argument of {fn.__name__} to be a Var, got {fn_first_arg_type}." + ) + + arg_generic_args = get_args(fn_first_arg_type) + + if not arg_generic_args: + raise TypeError( + f"Expected generic type of {fn_first_arg_type} to be a type." + ) + + arg_type = arg_generic_args[0] + fn_return_type = fn_return_generic_args[0] + + var = ( + Var( + field_name, + _var_data=var_data, + _var_type=resolve_arg_type_from_return_type( + arg_type, fn_return_type, result_var_type + ), + ).guess_type() + if existing_var is None + else existing_var._replace( + _var_type=resolve_arg_type_from_return_type( + arg_type, fn_return_type, result_var_type + ), + _var_data=var_data, + _js_expr=field_name, + ).guess_type() + ) + + return fn(var) + + if existing_var is not None: + return existing_var._replace( + _js_expr=field_name, + _var_data=var_data, + _var_type=result_var_type, + ).guess_type() + return Var( + field_name, + _var_data=var_data, + _var_type=result_var_type, + ).guess_type() diff --git a/reflex/ivars/function.py b/reflex/vars/function.py similarity index 72% rename from reflex/ivars/function.py rename to reflex/vars/function.py index 1a987b1cf..a512432b9 100644 --- a/reflex/ivars/function.py +++ b/reflex/vars/function.py @@ -4,15 +4,21 @@ from __future__ import annotations import dataclasses import sys -from typing import Any, Callable, Optional, Tuple, Type, Union +from typing import Any, Callable, ClassVar, Optional, Tuple, Type, Union from reflex.utils.types import GenericType -from reflex.vars import ImmutableVarData, Var, VarData -from .base import CachedVarOperation, ImmutableVar, LiteralVar, cached_property_no_lock +from .base import ( + CachedVarOperation, + LiteralVar, + ToOperation, + Var, + VarData, + cached_property_no_lock, +) -class FunctionVar(ImmutableVar[Callable]): +class FunctionVar(Var[Callable]): """Base class for immutable function vars.""" def __call__(self, *args: Var | Any) -> ArgsFunctionOperation: @@ -26,7 +32,7 @@ class FunctionVar(ImmutableVar[Callable]): """ return ArgsFunctionOperation.create( ("...args",), - VarOperationCall.create(self, *args, ImmutableVar.create_safe("...args")), + VarOperationCall.create(self, *args, Var(_js_expr="...args")), ) def call(self, *args: Var | Any) -> VarOperationCall: @@ -61,9 +67,9 @@ class FunctionStringVar(FunctionVar): The function var. """ return cls( - _var_name=func, + _js_expr=func, _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), + _var_data=_var_data, ) @@ -72,7 +78,7 @@ class FunctionStringVar(FunctionVar): frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) -class VarOperationCall(CachedVarOperation, ImmutableVar): +class VarOperationCall(CachedVarOperation, Var): """Base class for immutable vars that are the result of a function call.""" _func: Optional[FunctionVar] = dataclasses.field(default=None) @@ -88,13 +94,13 @@ class VarOperationCall(CachedVarOperation, ImmutableVar): return f"({str(self._func)}({', '.join([str(LiteralVar.create(arg)) for arg in self._args])}))" @cached_property_no_lock - def _cached_get_all_var_data(self) -> ImmutableVarData | None: + def _cached_get_all_var_data(self) -> VarData | None: """Get all the var data associated with the var. Returns: All the var data associated with the var. """ - return ImmutableVarData.merge( + return VarData.merge( self._func._get_all_var_data() if self._func is not None else None, *[LiteralVar.create(arg)._get_all_var_data() for arg in self._args], self._var_data, @@ -119,9 +125,9 @@ class VarOperationCall(CachedVarOperation, ImmutableVar): The function call var. """ return cls( - _var_name="", + _js_expr="", _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), + _var_data=_var_data, _func=func, _args=args, ) @@ -166,9 +172,9 @@ class ArgsFunctionOperation(CachedVarOperation, FunctionVar): The function var. """ return cls( - _var_name="", + _js_expr="", _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), + _var_data=_var_data, _args_names=args_names, _return_expr=return_expr, ) @@ -179,45 +185,12 @@ class ArgsFunctionOperation(CachedVarOperation, FunctionVar): frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) -class ToFunctionOperation(CachedVarOperation, FunctionVar): +class ToFunctionOperation(ToOperation, FunctionVar): """Base class of converting a var to a function.""" - _original_var: Var = dataclasses.field( - default_factory=lambda: LiteralVar.create(None) - ) + _original: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_var) - - @classmethod - def create( - cls, - original_var: Var, - _var_type: GenericType = Callable, - _var_data: VarData | None = None, - ) -> ToFunctionOperation: - """Create a new function var. - - Args: - original_var: The original var to convert to a function. - _var_type: The type of the function. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The function var. - """ - return cls( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - _original_var=original_var, - ) + _default_var_type: ClassVar[GenericType] = Callable JSON_STRINGIFY = FunctionStringVar.create("JSON.stringify") diff --git a/reflex/vars/number.py b/reflex/vars/number.py new file mode 100644 index 000000000..9a899f220 --- /dev/null +++ b/reflex/vars/number.py @@ -0,0 +1,1158 @@ +"""Immutable number vars.""" + +from __future__ import annotations + +import dataclasses +import json +import math +import sys +from typing import ( + TYPE_CHECKING, + Any, + Callable, + ClassVar, + NoReturn, + Type, + TypeVar, + Union, + overload, +) + +from reflex.constants.base import Dirs +from reflex.utils.exceptions import PrimitiveUnserializableToJSON, VarTypeError +from reflex.utils.imports import ImportDict, ImportVar + +from .base import ( + CustomVarOperationReturn, + LiteralNoneVar, + LiteralVar, + ToOperation, + Var, + VarData, + unionize, + var_operation, + var_operation_return, +) + +NUMBER_T = TypeVar("NUMBER_T", int, float, Union[int, float], bool) + +if TYPE_CHECKING: + from .sequence import ArrayVar + + +def raise_unsupported_operand_types( + operator: str, operands_types: tuple[type, ...] +) -> NoReturn: + """Raise an unsupported operand types error. + + Args: + operator: The operator. + operands_types: The types of the operands. + + Raises: + VarTypeError: The operand types are unsupported. + """ + raise VarTypeError( + f"Unsupported Operand type(s) for {operator}: {', '.join(map(lambda t: t.__name__, operands_types))}" + ) + + +class NumberVar(Var[NUMBER_T]): + """Base class for immutable number vars.""" + + @overload + def __add__(self, other: number_types) -> NumberVar: ... + + @overload + def __add__(self, other: NoReturn) -> NoReturn: ... + + def __add__(self, other: Any): + """Add two numbers. + + Args: + other: The other number. + + Returns: + The number addition operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("+", (type(self), type(other))) + return number_add_operation(self, +other) + + @overload + def __radd__(self, other: number_types) -> NumberVar: ... + + @overload + def __radd__(self, other: NoReturn) -> NoReturn: ... + + def __radd__(self, other: Any): + """Add two numbers. + + Args: + other: The other number. + + Returns: + The number addition operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("+", (type(other), type(self))) + return number_add_operation(+other, self) + + @overload + def __sub__(self, other: number_types) -> NumberVar: ... + + @overload + def __sub__(self, other: NoReturn) -> NoReturn: ... + + def __sub__(self, other: Any): + """Subtract two numbers. + + Args: + other: The other number. + + Returns: + The number subtraction operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("-", (type(self), type(other))) + + return number_subtract_operation(self, +other) + + @overload + def __rsub__(self, other: number_types) -> NumberVar: ... + + @overload + def __rsub__(self, other: NoReturn) -> NoReturn: ... + + def __rsub__(self, other: Any): + """Subtract two numbers. + + Args: + other: The other number. + + Returns: + The number subtraction operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("-", (type(other), type(self))) + + return number_subtract_operation(+other, self) + + def __abs__(self): + """Get the absolute value of the number. + + Returns: + The number absolute operation. + """ + return number_abs_operation(self) + + @overload + def __mul__(self, other: number_types | boolean_types) -> NumberVar: ... + + @overload + def __mul__(self, other: list | tuple | set | ArrayVar) -> ArrayVar: ... + + def __mul__(self, other: Any): + """Multiply two numbers. + + Args: + other: The other number. + + Returns: + The number multiplication operation. + """ + from .sequence import ArrayVar, LiteralArrayVar + + if isinstance(other, (list, tuple, set, ArrayVar)): + if isinstance(other, ArrayVar): + return other * self + return LiteralArrayVar.create(other) * self + + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("*", (type(self), type(other))) + + return number_multiply_operation(self, +other) + + @overload + def __rmul__(self, other: number_types | boolean_types) -> NumberVar: ... + + @overload + def __rmul__(self, other: list | tuple | set | ArrayVar) -> ArrayVar: ... + + def __rmul__(self, other: Any): + """Multiply two numbers. + + Args: + other: The other number. + + Returns: + The number multiplication operation. + """ + from .sequence import ArrayVar, LiteralArrayVar + + if isinstance(other, (list, tuple, set, ArrayVar)): + if isinstance(other, ArrayVar): + return other * self + return LiteralArrayVar.create(other) * self + + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("*", (type(other), type(self))) + + return number_multiply_operation(+other, self) + + @overload + def __truediv__(self, other: number_types) -> NumberVar: ... + + @overload + def __truediv__(self, other: NoReturn) -> NoReturn: ... + + def __truediv__(self, other: Any): + """Divide two numbers. + + Args: + other: The other number. + + Returns: + The number true division operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("/", (type(self), type(other))) + + return number_true_division_operation(self, +other) + + @overload + def __rtruediv__(self, other: number_types) -> NumberVar: ... + + @overload + def __rtruediv__(self, other: NoReturn) -> NoReturn: ... + + def __rtruediv__(self, other: Any): + """Divide two numbers. + + Args: + other: The other number. + + Returns: + The number true division operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("/", (type(other), type(self))) + + return number_true_division_operation(+other, self) + + @overload + def __floordiv__(self, other: number_types) -> NumberVar: ... + + @overload + def __floordiv__(self, other: NoReturn) -> NoReturn: ... + + def __floordiv__(self, other: Any): + """Floor divide two numbers. + + Args: + other: The other number. + + Returns: + The number floor division operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("//", (type(self), type(other))) + + return number_floor_division_operation(self, +other) + + @overload + def __rfloordiv__(self, other: number_types) -> NumberVar: ... + + @overload + def __rfloordiv__(self, other: NoReturn) -> NoReturn: ... + + def __rfloordiv__(self, other: Any): + """Floor divide two numbers. + + Args: + other: The other number. + + Returns: + The number floor division operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("//", (type(other), type(self))) + + return number_floor_division_operation(+other, self) + + @overload + def __mod__(self, other: number_types) -> NumberVar: ... + + @overload + def __mod__(self, other: NoReturn) -> NoReturn: ... + + def __mod__(self, other: Any): + """Modulo two numbers. + + Args: + other: The other number. + + Returns: + The number modulo operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("%", (type(self), type(other))) + + return number_modulo_operation(self, +other) + + @overload + def __rmod__(self, other: number_types) -> NumberVar: ... + + @overload + def __rmod__(self, other: NoReturn) -> NoReturn: ... + + def __rmod__(self, other: Any): + """Modulo two numbers. + + Args: + other: The other number. + + Returns: + The number modulo operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("%", (type(other), type(self))) + + return number_modulo_operation(+other, self) + + @overload + def __pow__(self, other: number_types) -> NumberVar: ... + + @overload + def __pow__(self, other: NoReturn) -> NoReturn: ... + + def __pow__(self, other: Any): + """Exponentiate two numbers. + + Args: + other: The other number. + + Returns: + The number exponent operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("**", (type(self), type(other))) + + return number_exponent_operation(self, +other) + + @overload + def __rpow__(self, other: number_types) -> NumberVar: ... + + @overload + def __rpow__(self, other: NoReturn) -> NoReturn: ... + + def __rpow__(self, other: Any): + """Exponentiate two numbers. + + Args: + other: The other number. + + Returns: + The number exponent operation. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("**", (type(other), type(self))) + + return number_exponent_operation(+other, self) + + def __neg__(self): + """Negate the number. + + Returns: + The number negation operation. + """ + return number_negate_operation(self) + + def __invert__(self): + """Boolean NOT the number. + + Returns: + The boolean NOT operation. + """ + return boolean_not_operation(self.bool()) + + def __pos__(self) -> NumberVar: + """Positive the number. + + Returns: + The number. + """ + return self + + def __round__(self): + """Round the number. + + Returns: + The number round operation. + """ + return number_round_operation(self) + + def __ceil__(self): + """Ceil the number. + + Returns: + The number ceil operation. + """ + return number_ceil_operation(self) + + def __floor__(self): + """Floor the number. + + Returns: + The number floor operation. + """ + return number_floor_operation(self) + + def __trunc__(self): + """Trunc the number. + + Returns: + The number trunc operation. + """ + return number_trunc_operation(self) + + @overload + def __lt__(self, other: number_types) -> BooleanVar: ... + + @overload + def __lt__(self, other: NoReturn) -> NoReturn: ... + + def __lt__(self, other: Any): + """Less than comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("<", (type(self), type(other))) + return less_than_operation(self, +other) + + @overload + def __le__(self, other: number_types) -> BooleanVar: ... + + @overload + def __le__(self, other: NoReturn) -> NoReturn: ... + + def __le__(self, other: Any): + """Less than or equal comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types("<=", (type(self), type(other))) + return less_than_or_equal_operation(self, +other) + + def __eq__(self, other: Any): + """Equal comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if isinstance(other, NUMBER_TYPES): + return equal_operation(self, +other) + return equal_operation(self, other) + + def __ne__(self, other: Any): + """Not equal comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if isinstance(other, NUMBER_TYPES): + return not_equal_operation(self, +other) + return not_equal_operation(self, other) + + @overload + def __gt__(self, other: number_types) -> BooleanVar: ... + + @overload + def __gt__(self, other: NoReturn) -> NoReturn: ... + + def __gt__(self, other: Any): + """Greater than comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types(">", (type(self), type(other))) + return greater_than_operation(self, +other) + + @overload + def __ge__(self, other: number_types) -> BooleanVar: ... + + @overload + def __ge__(self, other: NoReturn) -> NoReturn: ... + + def __ge__(self, other: Any): + """Greater than or equal comparison. + + Args: + other: The other number. + + Returns: + The result of the comparison. + """ + if not isinstance(other, NUMBER_TYPES): + raise_unsupported_operand_types(">=", (type(self), type(other))) + return greater_than_or_equal_operation(self, +other) + + def bool(self): + """Boolean conversion. + + Returns: + The boolean value of the number. + """ + return self != 0 + + def _is_strict_float(self) -> bool: + """Check if the number is a float. + + Returns: + bool: True if the number is a float. + """ + return issubclass(self._var_type, float) + + def _is_strict_int(self) -> bool: + """Check if the number is an int. + + Returns: + bool: True if the number is an int. + """ + return issubclass(self._var_type, int) + + +def binary_number_operation( + func: Callable[[NumberVar, NumberVar], str], +) -> Callable[[number_types, number_types], NumberVar]: + """Decorator to create a binary number operation. + + Args: + func: The binary number operation function. + + Returns: + The binary number operation. + """ + + @var_operation + def operation(lhs: NumberVar, rhs: NumberVar): + return var_operation_return( + js_expression=func(lhs, rhs), + var_type=unionize(lhs._var_type, rhs._var_type), + ) + + def wrapper(lhs: number_types, rhs: number_types) -> NumberVar: + """Create the binary number operation. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The binary number operation. + """ + return operation(lhs, rhs) # type: ignore + + return wrapper + + +@binary_number_operation +def number_add_operation(lhs: NumberVar, rhs: NumberVar): + """Add two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number addition operation. + """ + return f"({lhs} + {rhs})" + + +@binary_number_operation +def number_subtract_operation(lhs: NumberVar, rhs: NumberVar): + """Subtract two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number subtraction operation. + """ + return f"({lhs} - {rhs})" + + +@var_operation +def number_abs_operation(value: NumberVar): + """Get the absolute value of the number. + + Args: + value: The number. + + Returns: + The number absolute operation. + """ + return var_operation_return( + js_expression=f"Math.abs({value})", var_type=value._var_type + ) + + +@binary_number_operation +def number_multiply_operation(lhs: NumberVar, rhs: NumberVar): + """Multiply two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number multiplication operation. + """ + return f"({lhs} * {rhs})" + + +@var_operation +def number_negate_operation( + value: NumberVar[NUMBER_T], +) -> CustomVarOperationReturn[NUMBER_T]: + """Negate the number. + + Args: + value: The number. + + Returns: + The number negation operation. + """ + return var_operation_return(js_expression=f"-({value})", var_type=value._var_type) + + +@binary_number_operation +def number_true_division_operation(lhs: NumberVar, rhs: NumberVar): + """Divide two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number true division operation. + """ + return f"({lhs} / {rhs})" + + +@binary_number_operation +def number_floor_division_operation(lhs: NumberVar, rhs: NumberVar): + """Floor divide two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number floor division operation. + """ + return f"Math.floor({lhs} / {rhs})" + + +@binary_number_operation +def number_modulo_operation(lhs: NumberVar, rhs: NumberVar): + """Modulo two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number modulo operation. + """ + return f"({lhs} % {rhs})" + + +@binary_number_operation +def number_exponent_operation(lhs: NumberVar, rhs: NumberVar): + """Exponentiate two numbers. + + Args: + lhs: The first number. + rhs: The second number. + + Returns: + The number exponent operation. + """ + return f"({lhs} ** {rhs})" + + +@var_operation +def number_round_operation(value: NumberVar): + """Round the number. + + Args: + value: The number. + + Returns: + The number round operation. + """ + return var_operation_return(js_expression=f"Math.round({value})", var_type=int) + + +@var_operation +def number_ceil_operation(value: NumberVar): + """Ceil the number. + + Args: + value: The number. + + Returns: + The number ceil operation. + """ + return var_operation_return(js_expression=f"Math.ceil({value})", var_type=int) + + +@var_operation +def number_floor_operation(value: NumberVar): + """Floor the number. + + Args: + value: The number. + + Returns: + The number floor operation. + """ + return var_operation_return(js_expression=f"Math.floor({value})", var_type=int) + + +@var_operation +def number_trunc_operation(value: NumberVar): + """Trunc the number. + + Args: + value: The number. + + Returns: + The number trunc operation. + """ + return var_operation_return(js_expression=f"Math.trunc({value})", var_type=int) + + +class BooleanVar(NumberVar[bool]): + """Base class for immutable boolean vars.""" + + def __invert__(self): + """NOT the boolean. + + Returns: + The boolean NOT operation. + """ + return boolean_not_operation(self) + + def __int__(self): + """Convert the boolean to an int. + + Returns: + The boolean to int operation. + """ + return boolean_to_number_operation(self) + + def __pos__(self): + """Convert the boolean to an int. + + Returns: + The boolean to int operation. + """ + return boolean_to_number_operation(self) + + def bool(self) -> BooleanVar: + """Boolean conversion. + + Returns: + The boolean value of the boolean. + """ + return self + + def __lt__(self, other: Any): + """Less than comparison. + + Args: + other: The other boolean. + + Returns: + The result of the comparison. + """ + return +self < other + + def __le__(self, other: Any): + """Less than or equal comparison. + + Args: + other: The other boolean. + + Returns: + The result of the comparison. + """ + return +self <= other + + def __gt__(self, other: Any): + """Greater than comparison. + + Args: + other: The other boolean. + + Returns: + The result of the comparison. + """ + return +self > other + + def __ge__(self, other: Any): + """Greater than or equal comparison. + + Args: + other: The other boolean. + + Returns: + The result of the comparison. + """ + return +self >= other + + +@var_operation +def boolean_to_number_operation(value: BooleanVar): + """Convert the boolean to a number. + + Args: + value: The boolean. + + Returns: + The boolean to number operation. + """ + return var_operation_return(js_expression=f"Number({value})", var_type=int) + + +def comparison_operator( + func: Callable[[Var, Var], str], +) -> Callable[[Var | Any, Var | Any], BooleanVar]: + """Decorator to create a comparison operation. + + Args: + func: The comparison operation function. + + Returns: + The comparison operation. + """ + + @var_operation + def operation(lhs: Var, rhs: Var): + return var_operation_return( + js_expression=func(lhs, rhs), + var_type=bool, + ) + + def wrapper(lhs: Var | Any, rhs: Var | Any) -> BooleanVar: + """Create the comparison operation. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The comparison operation. + """ + return operation(lhs, rhs) + + return wrapper + + +@comparison_operator +def greater_than_operation(lhs: Var, rhs: Var): + """Greater than comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} > {rhs})" + + +@comparison_operator +def greater_than_or_equal_operation(lhs: Var, rhs: Var): + """Greater than or equal comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} >= {rhs})" + + +@comparison_operator +def less_than_operation(lhs: Var, rhs: Var): + """Less than comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} < {rhs})" + + +@comparison_operator +def less_than_or_equal_operation(lhs: Var, rhs: Var): + """Less than or equal comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} <= {rhs})" + + +@comparison_operator +def equal_operation(lhs: Var, rhs: Var): + """Equal comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} === {rhs})" + + +@comparison_operator +def not_equal_operation(lhs: Var, rhs: Var): + """Not equal comparison. + + Args: + lhs: The first value. + rhs: The second value. + + Returns: + The result of the comparison. + """ + return f"({lhs} !== {rhs})" + + +@var_operation +def boolean_not_operation(value: BooleanVar): + """Boolean NOT the boolean. + + Args: + value: The boolean. + + Returns: + The boolean NOT operation. + """ + return var_operation_return(js_expression=f"!({value})", var_type=bool) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralBooleanVar(LiteralVar, BooleanVar): + """Base class for immutable literal boolean vars.""" + + _var_value: bool = dataclasses.field(default=False) + + def json(self) -> str: + """Get the JSON representation of the var. + + Returns: + The JSON representation of the var. + """ + return "true" if self._var_value else "false" + + def __hash__(self) -> int: + """Calculate the hash value of the object. + + Returns: + int: The hash value of the object. + """ + return hash((self.__class__.__name__, self._var_value)) + + @classmethod + def create(cls, value: bool, _var_data: VarData | None = None): + """Create the boolean var. + + Args: + value: The value of the var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The boolean var. + """ + return cls( + _js_expr="true" if value else "false", + _var_type=bool, + _var_data=_var_data, + _var_value=value, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralNumberVar(LiteralVar, NumberVar): + """Base class for immutable literal number vars.""" + + _var_value: float | int = dataclasses.field(default=0) + + def json(self) -> str: + """Get the JSON representation of the var. + + Returns: + The JSON representation of the var. + + Raises: + PrimitiveUnserializableToJSON: If the var is unserializable to JSON. + """ + if math.isinf(self._var_value) or math.isnan(self._var_value): + raise PrimitiveUnserializableToJSON( + f"No valid JSON representation for {self}" + ) + return json.dumps(self._var_value) + + def __hash__(self) -> int: + """Calculate the hash value of the object. + + Returns: + int: The hash value of the object. + """ + return hash((self.__class__.__name__, self._var_value)) + + @classmethod + def create(cls, value: float | int, _var_data: VarData | None = None): + """Create the number var. + + Args: + value: The value of the var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The number var. + """ + if math.isinf(value): + js_expr = "Infinity" if value > 0 else "-Infinity" + elif math.isnan(value): + js_expr = "NaN" + else: + js_expr = str(value) + + return cls( + _js_expr=js_expr, + _var_type=type(value), + _var_data=_var_data, + _var_value=value, + ) + + +number_types = Union[NumberVar, int, float] +boolean_types = Union[BooleanVar, bool] + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ToNumberVarOperation(ToOperation, NumberVar): + """Base class for immutable number vars that are the result of a number operation.""" + + _original: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create()) + + _default_var_type: ClassVar[Type] = float + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ToBooleanVarOperation(ToOperation, BooleanVar): + """Base class for immutable boolean vars that are the result of a boolean operation.""" + + _original: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create()) + + _default_var_type: ClassVar[Type] = bool + + +_IS_TRUE_IMPORT: ImportDict = { + f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")], +} + + +@var_operation +def boolify(value: Var): + """Convert the value to a boolean. + + Args: + value: The value. + + Returns: + The boolean value. + """ + return var_operation_return( + js_expression=f"isTrue({value})", + var_type=bool, + var_data=VarData(imports=_IS_TRUE_IMPORT), + ) + + +@var_operation +def ternary_operation(condition: BooleanVar, if_true: Var, if_false: Var): + """Create a ternary operation. + + Args: + condition: The condition. + if_true: The value if the condition is true. + if_false: The value if the condition is false. + + Returns: + The ternary operation. + """ + return var_operation_return( + js_expression=f"({condition} ? {if_true} : {if_false})", + var_type=unionize(if_true._var_type, if_false._var_type), + ) + + +NUMBER_TYPES = (int, float, NumberVar) diff --git a/reflex/ivars/object.py b/reflex/vars/object.py similarity index 55% rename from reflex/ivars/object.py rename to reflex/vars/object.py index 4586ffa0a..1158bba9a 100644 --- a/reflex/ivars/object.py +++ b/reflex/vars/object.py @@ -8,6 +8,7 @@ import typing from inspect import isclass from typing import ( Any, + ClassVar, Dict, List, NoReturn, @@ -19,21 +20,22 @@ from typing import ( overload, ) -from typing_extensions import get_origin - from reflex.utils import types from reflex.utils.exceptions import VarAttributeError -from reflex.utils.types import GenericType, get_attribute_access_type -from reflex.vars import ImmutableVarData, Var, VarData +from reflex.utils.types import GenericType, get_attribute_access_type, get_origin from .base import ( CachedVarOperation, - ImmutableVar, LiteralVar, + ToOperation, + Var, + VarData, cached_property_no_lock, figure_out_type, + var_operation, + var_operation_return, ) -from .number import BooleanVar, NumberVar +from .number import BooleanVar, NumberVar, raise_unsupported_operand_types from .sequence import ArrayVar, StringVar OBJECT_TYPE = TypeVar("OBJECT_TYPE", bound=Dict) @@ -46,7 +48,7 @@ ARRAY_INNER_TYPE = TypeVar("ARRAY_INNER_TYPE") OTHER_KEY_TYPE = TypeVar("OTHER_KEY_TYPE") -class ObjectVar(ImmutableVar[OBJECT_TYPE]): +class ObjectVar(Var[OBJECT_TYPE]): """Base class for immutable object vars.""" def _key_type(self) -> Type: @@ -58,7 +60,9 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): return str @overload - def _value_type(self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]) -> VALUE_TYPE: ... + def _value_type( + self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], + ) -> Type[VALUE_TYPE]: ... @overload def _value_type(self) -> Type: ... @@ -81,7 +85,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The keys of the object. """ - return ObjectKeysOperation.create(self) + return object_keys_operation(self) @overload def values( @@ -97,7 +101,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The values of the object. """ - return ObjectValuesOperation.create(self) + return object_values_operation(self) @overload def entries( @@ -113,9 +117,9 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The entries of the object. """ - return ObjectEntriesOperation.create(self) + return object_entries_operation(self) - def merge(self, other: ObjectVar) -> ObjectMergeOperation: + def merge(self, other: ObjectVar): """Merge two objects. Args: @@ -124,14 +128,14 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The merged object. """ - return ObjectMergeOperation.create(self, other) + return object_merge_operation(self, other) # NoReturn is used here to catch when key value is Any @overload def __getitem__( self: ObjectVar[Dict[KEY_TYPE, NoReturn]], key: Var | Any, - ) -> ImmutableVar: ... + ) -> Var: ... @overload def __getitem__( @@ -173,7 +177,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): key: Var | Any, ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ... - def __getitem__(self, key: Var | Any) -> ImmutableVar: + def __getitem__(self, key: Var | Any) -> Var: """Get an item from the object. Args: @@ -182,6 +186,10 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The item from the object. """ + if not isinstance(key, (StringVar, str, int, NumberVar)) or ( + isinstance(key, NumberVar) and key._is_strict_float() + ): + raise_unsupported_operand_types("[]", (type(self), type(key))) return ObjectItemOperation.create(self, key).guess_type() # NoReturn is used here to catch when key value is Any @@ -189,7 +197,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): def __getattr__( self: ObjectVar[Dict[KEY_TYPE, NoReturn]], name: str, - ) -> ImmutableVar: ... + ) -> Var: ... @overload def __getattr__( @@ -231,7 +239,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): name: str, ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ... - def __getattr__(self, name) -> ImmutableVar: + def __getattr__(self, name) -> Var: """Get an attribute of the var. Args: @@ -272,7 +280,7 @@ class ObjectVar(ImmutableVar[OBJECT_TYPE]): Returns: The result of the check. """ - return ObjectHasOwnProperty.create(self, key) + return object_has_own_property_operation(self, key) @dataclasses.dataclass( @@ -346,16 +354,16 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar): Returns: The hash of the var. """ - return hash((self.__class__.__name__, self._var_name)) + return hash((self.__class__.__name__, self._js_expr)) @cached_property_no_lock - def _cached_get_all_var_data(self) -> ImmutableVarData | None: + def _cached_get_all_var_data(self) -> VarData | None: """Get all the var data. Returns: The var data. """ - return ImmutableVarData.merge( + return VarData.merge( *[LiteralVar.create(var)._get_all_var_data() for var in self._var_value], *[ LiteralVar.create(var)._get_all_var_data() @@ -382,163 +390,79 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar): The literal object var. """ return LiteralObjectVar( - _var_name="", + _js_expr="", _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type), - _var_data=ImmutableVarData.merge(_var_data), + _var_data=_var_data, _var_value=_var_value, ) -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectToArrayOperation(CachedVarOperation, ArrayVar): - """Base class for object to array operations.""" +@var_operation +def object_keys_operation(value: ObjectVar): + """Get the keys of an object. - _value: ObjectVar = dataclasses.field( - default_factory=lambda: LiteralObjectVar.create({}) + Args: + value: The object to get the keys from. + + Returns: + The keys of the object. + """ + return var_operation_return( + js_expression=f"Object.keys({value})", + var_type=List[str], ) - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. - Raises: - NotImplementedError: Must implement _cached_var_name. - """ - raise NotImplementedError( - "ObjectToArrayOperation must implement _cached_var_name" - ) +@var_operation +def object_values_operation(value: ObjectVar): + """Get the values of an object. - @classmethod - def create( - cls, - value: ObjectVar, - _var_type: GenericType | None = None, - _var_data: VarData | None = None, - ) -> ObjectToArrayOperation: - """Create the object to array operation. + Args: + value: The object to get the values from. - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object to array operation. - """ - return cls( - _var_name="", - _var_type=list if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) + Returns: + The values of the object. + """ + return var_operation_return( + js_expression=f"Object.values({value})", + var_type=List[value._value_type()], + ) -class ObjectKeysOperation(ObjectToArrayOperation): - """Operation to get the keys of an object.""" +@var_operation +def object_entries_operation(value: ObjectVar): + """Get the entries of an object. - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. + Args: + value: The object to get the entries from. - Returns: - The name of the operation. - """ - return f"Object.keys({str(self._value)})" - - @classmethod - def create( - cls, - value: ObjectVar, - _var_data: VarData | None = None, - ) -> ObjectKeysOperation: - """Create the object keys operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object keys operation. - """ - return cls( - _var_name="", - _var_type=List[str], - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) + Returns: + The entries of the object. + """ + return var_operation_return( + js_expression=f"Object.entries({value})", + var_type=List[Tuple[str, value._value_type()]], + ) -class ObjectValuesOperation(ObjectToArrayOperation): - """Operation to get the values of an object.""" +@var_operation +def object_merge_operation(lhs: ObjectVar, rhs: ObjectVar): + """Merge two objects. - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. + Args: + lhs: The first object to merge. + rhs: The second object to merge. - Returns: - The name of the operation. - """ - return f"Object.values({str(self._value)})" - - @classmethod - def create( - cls, - value: ObjectVar, - _var_data: VarData | None = None, - ) -> ObjectValuesOperation: - """Create the object values operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object values operation. - """ - return cls( - _var_name="", - _var_type=List[value._value_type()], - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) - - -class ObjectEntriesOperation(ObjectToArrayOperation): - """Operation to get the entries of an object.""" - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"Object.entries({str(self._value)})" - - @classmethod - def create( - cls, - value: ObjectVar, - _var_data: VarData | None = None, - ) -> ObjectEntriesOperation: - """Create the object entries operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object entries operation. - """ - return cls( - _var_name="", - _var_type=List[Tuple[str, value._value_type()]], - _var_data=ImmutableVarData.merge(_var_data), - _value=value, - ) + Returns: + The merged object. + """ + return var_operation_return( + js_expression=f"({{...{lhs}, ...{rhs}}})", + var_type=Dict[ + Union[lhs._key_type(), rhs._key_type()], + Union[lhs._value_type(), rhs._value_type()], + ], + ) @dataclasses.dataclass( @@ -546,58 +470,7 @@ class ObjectEntriesOperation(ObjectToArrayOperation): frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) -class ObjectMergeOperation(CachedVarOperation, ObjectVar): - """Operation to merge two objects.""" - - _lhs: ObjectVar = dataclasses.field( - default_factory=lambda: LiteralObjectVar.create({}) - ) - _rhs: ObjectVar = dataclasses.field( - default_factory=lambda: LiteralObjectVar.create({}) - ) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"({{...{str(self._lhs)}, ...{str(self._rhs)}}})" - - @classmethod - def create( - cls, - lhs: ObjectVar, - rhs: ObjectVar, - _var_data: VarData | None = None, - ) -> ObjectMergeOperation: - """Create the object merge operation. - - Args: - lhs: The left object to merge. - rhs: The right object to merge. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object merge operation. - """ - # TODO: Figure out how to merge the types - return cls( - _var_name="", - _var_type=lhs._var_type, - _var_data=ImmutableVarData.merge(_var_data), - _lhs=lhs, - _rhs=rhs, - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectItemOperation(CachedVarOperation, ImmutableVar): +class ObjectItemOperation(CachedVarOperation, Var): """Operation to get an item from an object.""" _object: ObjectVar = dataclasses.field( @@ -636,9 +509,9 @@ class ObjectItemOperation(CachedVarOperation, ImmutableVar): The object item operation. """ return cls( - _var_name="", + _js_expr="", _var_type=object._value_type() if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), + _var_data=_var_data, _object=object, _key=key if isinstance(key, Var) else LiteralVar.create(key), ) @@ -649,90 +522,41 @@ class ObjectItemOperation(CachedVarOperation, ImmutableVar): frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) -class ToObjectOperation(CachedVarOperation, ObjectVar): +class ToObjectOperation(ToOperation, ObjectVar): """Operation to convert a var to an object.""" - _original_var: Var = dataclasses.field( + _original: Var = dataclasses.field( default_factory=lambda: LiteralObjectVar.create({}) ) - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. + _default_var_type: ClassVar[GenericType] = dict - Returns: - The name of the operation. - """ - return str(self._original_var) - - @classmethod - def create( - cls, - original_var: Var, - _var_type: GenericType | None = None, - _var_data: VarData | None = None, - ) -> ToObjectOperation: - """Create the to object operation. + def __getattr__(self, name: str) -> Any: + """Get an attribute of the var. Args: - original_var: The original var to convert. - _var_type: The type of the var. - _var_data: Additional hooks and imports associated with the operation. + name: The name of the attribute. Returns: - The to object operation. + The attribute of the var. """ - return cls( - _var_name="", - _var_type=dict if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - _original_var=original_var, - ) + if name == "_js_expr": + return self._original._js_expr + return ObjectVar.__getattr__(self, name) -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectHasOwnProperty(CachedVarOperation, BooleanVar): - """Operation to check if an object has a property.""" +@var_operation +def object_has_own_property_operation(object: ObjectVar, key: Var): + """Check if an object has a key. - _object: ObjectVar = dataclasses.field( - default_factory=lambda: LiteralObjectVar.create({}) + Args: + object: The object to check. + key: The key to check. + + Returns: + The result of the check. + """ + return var_operation_return( + js_expression=f"{object}.hasOwnProperty({key})", + var_type=bool, ) - _key: Var | Any = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - @cached_property_no_lock - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"{str(self._object)}.hasOwnProperty({str(self._key)})" - - @classmethod - def create( - cls, - object: ObjectVar, - key: Var | Any, - _var_data: VarData | None = None, - ) -> ObjectHasOwnProperty: - """Create the object has own property operation. - - Args: - object: The object to check. - key: The key to check. - _var_data: Additional hooks and imports associated with the operation. - - Returns: - The object has own property operation. - """ - return cls( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - _object=object, - _key=key if isinstance(key, Var) else LiteralVar.create(key), - ) diff --git a/reflex/vars/sequence.py b/reflex/vars/sequence.py new file mode 100644 index 000000000..ca8967d33 --- /dev/null +++ b/reflex/vars/sequence.py @@ -0,0 +1,1612 @@ +"""Collection of string classes and utilities.""" + +from __future__ import annotations + +import dataclasses +import inspect +import json +import re +import sys +import typing +from typing import ( + TYPE_CHECKING, + Any, + ClassVar, + Dict, + List, + Literal, + NoReturn, + Set, + Tuple, + Type, + TypeVar, + Union, + overload, +) + +from reflex import constants +from reflex.constants.base import REFLEX_VAR_OPENING_TAG +from reflex.utils.exceptions import VarTypeError +from reflex.utils.types import GenericType, get_origin + +from .base import ( + CachedVarOperation, + CustomVarOperationReturn, + LiteralNoneVar, + LiteralVar, + ToOperation, + Var, + VarData, + _global_vars, + cached_property_no_lock, + figure_out_type, + get_unique_variable_name, + unionize, + var_operation, + var_operation_return, +) +from .number import ( + BooleanVar, + LiteralNumberVar, + NumberVar, + raise_unsupported_operand_types, +) + +if TYPE_CHECKING: + from .object import ObjectVar + + +class StringVar(Var[str]): + """Base class for immutable string vars.""" + + @overload + def __add__(self, other: StringVar | str) -> ConcatVarOperation: ... + + @overload + def __add__(self, other: NoReturn) -> NoReturn: ... + + def __add__(self, other: Any) -> ConcatVarOperation: + """Concatenate two strings. + + Args: + other: The other string. + + Returns: + The string concatenation operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types("+", (type(self), type(other))) + + return ConcatVarOperation.create(self, other) + + @overload + def __radd__(self, other: StringVar | str) -> ConcatVarOperation: ... + + @overload + def __radd__(self, other: NoReturn) -> NoReturn: ... + + def __radd__(self, other: Any) -> ConcatVarOperation: + """Concatenate two strings. + + Args: + other: The other string. + + Returns: + The string concatenation operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types("+", (type(other), type(self))) + + return ConcatVarOperation.create(other, self) + + @overload + def __mul__(self, other: NumberVar | int) -> StringVar: ... + + @overload + def __mul__(self, other: NoReturn) -> NoReturn: ... + + def __mul__(self, other: Any) -> StringVar: + """Multiply the sequence by a number or an integer. + + Args: + other: The number or integer to multiply the sequence by. + + Returns: + StringVar: The resulting sequence after multiplication. + """ + if not isinstance(other, (NumberVar, int)): + raise_unsupported_operand_types("*", (type(self), type(other))) + + return (self.split() * other).join() + + @overload + def __rmul__(self, other: NumberVar | int) -> StringVar: ... + + @overload + def __rmul__(self, other: NoReturn) -> NoReturn: ... + + def __rmul__(self, other: Any) -> StringVar: + """Multiply the sequence by a number or an integer. + + Args: + other: The number or integer to multiply the sequence by. + + Returns: + StringVar: The resulting sequence after multiplication. + """ + if not isinstance(other, (NumberVar, int)): + raise_unsupported_operand_types("*", (type(other), type(self))) + + return (self.split() * other).join() + + @overload + def __getitem__(self, i: slice) -> StringVar: ... + + @overload + def __getitem__(self, i: int | NumberVar) -> StringVar: ... + + def __getitem__(self, i: Any) -> StringVar: + """Get a slice of the string. + + Args: + i: The slice. + + Returns: + The string slice operation. + """ + if isinstance(i, slice): + return self.split()[i].join() + if not isinstance(i, (int, NumberVar)) or ( + isinstance(i, NumberVar) and i._is_strict_float() + ): + raise_unsupported_operand_types("[]", (type(self), type(i))) + return string_item_operation(self, i) + + def length(self) -> NumberVar: + """Get the length of the string. + + Returns: + The string length operation. + """ + return self.split().length() + + def lower(self) -> StringVar: + """Convert the string to lowercase. + + Returns: + The string lower operation. + """ + return string_lower_operation(self) + + def upper(self) -> StringVar: + """Convert the string to uppercase. + + Returns: + The string upper operation. + """ + return string_upper_operation(self) + + def strip(self) -> StringVar: + """Strip the string. + + Returns: + The string strip operation. + """ + return string_strip_operation(self) + + def bool(self): + """Boolean conversion. + + Returns: + The boolean value of the string. + """ + return self.length() != 0 + + def reversed(self) -> StringVar: + """Reverse the string. + + Returns: + The string reverse operation. + """ + return self.split().reverse().join() + + @overload + def contains( + self, other: StringVar | str, field: StringVar | str | None = None + ) -> BooleanVar: ... + + @overload + def contains( + self, other: NoReturn, field: StringVar | str | None = None + ) -> NoReturn: ... + + def contains(self, other: Any, field: Any = None) -> BooleanVar: + """Check if the string contains another string. + + Args: + other: The other string. + field: The field to check. + + Returns: + The string contains operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types("contains", (type(self), type(other))) + if field is not None: + if not isinstance(field, (StringVar, str)): + raise_unsupported_operand_types("contains", (type(self), type(field))) + return string_contains_field_operation(self, other, field) + return string_contains_operation(self, other) + + @overload + def split(self, separator: StringVar | str = "") -> ArrayVar[List[str]]: ... + + @overload + def split(self, separator: NoReturn) -> NoReturn: ... + + def split(self, separator: Any = "") -> ArrayVar[List[str]]: + """Split the string. + + Args: + separator: The separator. + + Returns: + The string split operation. + """ + if not isinstance(separator, (StringVar, str)): + raise_unsupported_operand_types("split", (type(self), type(separator))) + return string_split_operation(self, separator) + + @overload + def startswith(self, prefix: StringVar | str) -> BooleanVar: ... + + @overload + def startswith(self, prefix: NoReturn) -> NoReturn: ... + + def startswith(self, prefix: Any) -> BooleanVar: + """Check if the string starts with a prefix. + + Args: + prefix: The prefix. + + Returns: + The string starts with operation. + """ + if not isinstance(prefix, (StringVar, str)): + raise_unsupported_operand_types("startswith", (type(self), type(prefix))) + return string_starts_with_operation(self, prefix) + + @overload + def __lt__(self, other: StringVar | str) -> BooleanVar: ... + + @overload + def __lt__(self, other: NoReturn) -> NoReturn: ... + + def __lt__(self, other: Any): + """Check if the string is less than another string. + + Args: + other: The other string. + + Returns: + The string less than operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types("<", (type(self), type(other))) + + return string_lt_operation(self, other) + + @overload + def __gt__(self, other: StringVar | str) -> BooleanVar: ... + + @overload + def __gt__(self, other: NoReturn) -> NoReturn: ... + + def __gt__(self, other: Any): + """Check if the string is greater than another string. + + Args: + other: The other string. + + Returns: + The string greater than operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types(">", (type(self), type(other))) + + return string_gt_operation(self, other) + + @overload + def __le__(self, other: StringVar | str) -> BooleanVar: ... + + @overload + def __le__(self, other: NoReturn) -> NoReturn: ... + + def __le__(self, other: Any): + """Check if the string is less than or equal to another string. + + Args: + other: The other string. + + Returns: + The string less than or equal operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types("<=", (type(self), type(other))) + + return string_le_operation(self, other) + + @overload + def __ge__(self, other: StringVar | str) -> BooleanVar: ... + + @overload + def __ge__(self, other: NoReturn) -> NoReturn: ... + + def __ge__(self, other: Any): + """Check if the string is greater than or equal to another string. + + Args: + other: The other string. + + Returns: + The string greater than or equal operation. + """ + if not isinstance(other, (StringVar, str)): + raise_unsupported_operand_types(">=", (type(self), type(other))) + + return string_ge_operation(self, other) + + +@var_operation +def string_lt_operation(lhs: StringVar | str, rhs: StringVar | str): + """Check if a string is less than another string. + + Args: + lhs: The left-hand side string. + rhs: The right-hand side string. + + Returns: + The string less than operation. + """ + return var_operation_return(js_expression=f"{lhs} < {rhs}", var_type=bool) + + +@var_operation +def string_gt_operation(lhs: StringVar | str, rhs: StringVar | str): + """Check if a string is greater than another string. + + Args: + lhs: The left-hand side string. + rhs: The right-hand side string. + + Returns: + The string greater than operation. + """ + return var_operation_return(js_expression=f"{lhs} > {rhs}", var_type=bool) + + +@var_operation +def string_le_operation(lhs: StringVar | str, rhs: StringVar | str): + """Check if a string is less than or equal to another string. + + Args: + lhs: The left-hand side string. + rhs: The right-hand side string. + + Returns: + The string less than or equal operation. + """ + return var_operation_return(js_expression=f"{lhs} <= {rhs}", var_type=bool) + + +@var_operation +def string_ge_operation(lhs: StringVar | str, rhs: StringVar | str): + """Check if a string is greater than or equal to another string. + + Args: + lhs: The left-hand side string. + rhs: The right-hand side string. + + Returns: + The string greater than or equal operation. + """ + return var_operation_return(js_expression=f"{lhs} >= {rhs}", var_type=bool) + + +@var_operation +def string_lower_operation(string: StringVar): + """Convert a string to lowercase. + + Args: + string: The string to convert. + + Returns: + The lowercase string. + """ + return var_operation_return(js_expression=f"{string}.toLowerCase()", var_type=str) + + +@var_operation +def string_upper_operation(string: StringVar): + """Convert a string to uppercase. + + Args: + string: The string to convert. + + Returns: + The uppercase string. + """ + return var_operation_return(js_expression=f"{string}.toUpperCase()", var_type=str) + + +@var_operation +def string_strip_operation(string: StringVar): + """Strip a string. + + Args: + string: The string to strip. + + Returns: + The stripped string. + """ + return var_operation_return(js_expression=f"{string}.trim()", var_type=str) + + +@var_operation +def string_contains_field_operation( + haystack: StringVar, needle: StringVar | str, field: StringVar | str +): + """Check if a string contains another string. + + Args: + haystack: The haystack. + needle: The needle. + field: The field to check. + + Returns: + The string contains operation. + """ + return var_operation_return( + js_expression=f"{haystack}.some(obj => obj[{field}] === {needle})", + var_type=bool, + ) + + +@var_operation +def string_contains_operation(haystack: StringVar, needle: StringVar | str): + """Check if a string contains another string. + + Args: + haystack: The haystack. + needle: The needle. + + Returns: + The string contains operation. + """ + return var_operation_return( + js_expression=f"{haystack}.includes({needle})", var_type=bool + ) + + +@var_operation +def string_starts_with_operation(full_string: StringVar, prefix: StringVar | str): + """Check if a string starts with a prefix. + + Args: + full_string: The full string. + prefix: The prefix. + + Returns: + Whether the string starts with the prefix. + """ + return var_operation_return( + js_expression=f"{full_string}.startsWith({prefix})", var_type=bool + ) + + +@var_operation +def string_item_operation(string: StringVar, index: NumberVar | int): + """Get an item from a string. + + Args: + string: The string. + index: The index of the item. + + Returns: + The item from the string. + """ + return var_operation_return(js_expression=f"{string}.at({index})", var_type=str) + + +@var_operation +def array_join_operation(array: ArrayVar, sep: StringVar | str = ""): + """Join the elements of an array. + + Args: + array: The array. + sep: The separator. + + Returns: + The joined elements. + """ + return var_operation_return(js_expression=f"{array}.join({sep})", var_type=str) + + +# Compile regex for finding reflex var tags. +_decode_var_pattern_re = ( + rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" +) +_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralStringVar(LiteralVar, StringVar): + """Base class for immutable literal string vars.""" + + _var_value: str = dataclasses.field(default="") + + @classmethod + def create( + cls, + value: str, + _var_type: GenericType | None = str, + _var_data: VarData | None = None, + ) -> StringVar: + """Create a var from a string value. + + Args: + value: The value to create the var from. + _var_type: The type of the var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + if REFLEX_VAR_OPENING_TAG in value: + strings_and_vals: list[Var | str] = [] + offset = 0 + + # Find all tags + while m := _decode_var_pattern.search(value): + start, end = m.span() + + strings_and_vals.append(value[:start]) + + serialized_data = m.group(1) + + if serialized_data.isnumeric() or ( + serialized_data[0] == "-" and serialized_data[1:].isnumeric() + ): + # This is a global immutable var. + var = _global_vars[int(serialized_data)] + strings_and_vals.append(var) + value = value[(end + len(var._js_expr)) :] + + offset += end - start + + strings_and_vals.append(value) + + filtered_strings_and_vals = [ + s for s in strings_and_vals if isinstance(s, Var) or s + ] + if len(filtered_strings_and_vals) == 1: + only_string = filtered_strings_and_vals[0] + if isinstance(only_string, str): + return LiteralVar.create(only_string).to(StringVar, _var_type) + else: + return only_string.to(StringVar, only_string._var_type) + + concat_result = ConcatVarOperation.create( + *filtered_strings_and_vals, + _var_data=_var_data, + ) + + return ( + concat_result + if _var_type is str + else concat_result.to(StringVar, _var_type) + ) + + return LiteralStringVar( + _js_expr=json.dumps(value), + _var_type=_var_type, + _var_data=_var_data, + _var_value=value, + ) + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._var_value)) + + def json(self) -> str: + """Get the JSON representation of the var. + + Returns: + The JSON representation of the var. + """ + return json.dumps(self._var_value) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ConcatVarOperation(CachedVarOperation, StringVar): + """Representing a concatenation of literal string vars.""" + + _var_value: Tuple[Var, ...] = dataclasses.field(default_factory=tuple) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + list_of_strs: List[Union[str, Var]] = [] + last_string = "" + for var in self._var_value: + if isinstance(var, LiteralStringVar): + last_string += var._var_value + else: + if last_string: + list_of_strs.append(last_string) + last_string = "" + list_of_strs.append(var) + + if last_string: + list_of_strs.append(last_string) + + list_of_strs_filtered = [ + str(LiteralVar.create(s)) for s in list_of_strs if isinstance(s, Var) or s + ] + + if len(list_of_strs_filtered) == 1: + return list_of_strs_filtered[0] + + return "(" + "+".join(list_of_strs_filtered) + ")" + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get all the VarData asVarDatae Var. + + Returns: + The VarData associated with the Var. + """ + return VarData.merge( + *[ + var._get_all_var_data() + for var in self._var_value + if isinstance(var, Var) + ], + self._var_data, + ) + + @classmethod + def create( + cls, + *value: Var | str, + _var_data: VarData | None = None, + ) -> ConcatVarOperation: + """Create a var from a string value. + + Args: + value: The values to concatenate. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + return cls( + _js_expr="", + _var_type=str, + _var_data=_var_data, + _var_value=tuple(map(LiteralVar.create, value)), + ) + + +ARRAY_VAR_TYPE = TypeVar("ARRAY_VAR_TYPE", bound=Union[List, Tuple, Set]) + +OTHER_TUPLE = TypeVar("OTHER_TUPLE") + +INNER_ARRAY_VAR = TypeVar("INNER_ARRAY_VAR") + +KEY_TYPE = TypeVar("KEY_TYPE") +VALUE_TYPE = TypeVar("VALUE_TYPE") + + +class ArrayVar(Var[ARRAY_VAR_TYPE]): + """Base class for immutable array vars.""" + + @overload + def join(self, sep: StringVar | str = "") -> StringVar: ... + + @overload + def join(self, sep: NoReturn) -> NoReturn: ... + + def join(self, sep: Any = "") -> StringVar: + """Join the elements of the array. + + Args: + sep: The separator between elements. + + Returns: + The joined elements. + """ + if not isinstance(sep, (StringVar, str)): + raise_unsupported_operand_types("join", (type(self), type(sep))) + return array_join_operation(self, sep) + + def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]: + """Reverse the array. + + Returns: + The reversed array. + """ + return array_reverse_operation(self) + + @overload + def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayVar[ARRAY_VAR_TYPE]: ... + + @overload + def __add__(self, other: NoReturn) -> NoReturn: ... + + def __add__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]: + """Concatenate two arrays. + + Parameters: + other: The other array to concatenate. + + Returns: + ArrayConcatOperation: The concatenation of the two arrays. + """ + if not isinstance(other, ArrayVar): + raise_unsupported_operand_types("+", (type(self), type(other))) + + return array_concat_operation(self, other) + + @overload + def __getitem__(self, i: slice) -> ArrayVar[ARRAY_VAR_TYPE]: ... + + @overload + def __getitem__( + self: ( + ArrayVar[Tuple[int, OTHER_TUPLE]] + | ArrayVar[Tuple[float, OTHER_TUPLE]] + | ArrayVar[Tuple[int | float, OTHER_TUPLE]] + ), + i: Literal[0, -2], + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ( + ArrayVar[Tuple[OTHER_TUPLE, int]] + | ArrayVar[Tuple[OTHER_TUPLE, float]] + | ArrayVar[Tuple[OTHER_TUPLE, int | float]] + ), + i: Literal[1, -1], + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[str, OTHER_TUPLE]], i: Literal[0, -2] + ) -> StringVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[OTHER_TUPLE, str]], i: Literal[1, -1] + ) -> StringVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[bool, OTHER_TUPLE]], i: Literal[0, -2] + ) -> BooleanVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[OTHER_TUPLE, bool]], i: Literal[1, -1] + ) -> BooleanVar: ... + + @overload + def __getitem__( + self: ( + ARRAY_VAR_OF_LIST_ELEMENT[int] + | ARRAY_VAR_OF_LIST_ELEMENT[float] + | ARRAY_VAR_OF_LIST_ELEMENT[int | float] + ), + i: int | NumberVar, + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[str], i: int | NumberVar + ) -> StringVar: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[bool], i: int | NumberVar + ) -> BooleanVar: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]], + i: int | NumberVar, + ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[Set[INNER_ARRAY_VAR]], + i: int | NumberVar, + ) -> ArrayVar[Set[INNER_ARRAY_VAR]]: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]], + i: int | NumberVar, + ) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ... + + @overload + def __getitem__( + self: ARRAY_VAR_OF_LIST_ELEMENT[Dict[KEY_TYPE, VALUE_TYPE]], + i: int | NumberVar, + ) -> ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]: ... + + @overload + def __getitem__(self, i: int | NumberVar) -> Var: ... + + def __getitem__(self, i: Any) -> ArrayVar[ARRAY_VAR_TYPE] | Var: + """Get a slice of the array. + + Args: + i: The slice. + + Returns: + The array slice operation. + """ + if isinstance(i, slice): + return ArraySliceOperation.create(self, i) + if not isinstance(i, (int, NumberVar)) or ( + isinstance(i, NumberVar) and i._is_strict_float() + ): + raise_unsupported_operand_types("[]", (type(self), type(i))) + return array_item_operation(self, i) + + def length(self) -> NumberVar: + """Get the length of the array. + + Returns: + The length of the array. + """ + return array_length_operation(self) + + @overload + @classmethod + def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... + + @overload + @classmethod + def range( + cls, + start: int | NumberVar, + end: int | NumberVar, + step: int | NumberVar = 1, + /, + ) -> ArrayVar[List[int]]: ... + + @overload + @classmethod + def range( + cls, + first_endpoint: int | NumberVar, + second_endpoint: int | NumberVar | None = None, + step: int | NumberVar | None = None, + ) -> ArrayVar[List[int]]: ... + + @classmethod + def range( + cls, + first_endpoint: int | NumberVar, + second_endpoint: int | NumberVar | None = None, + step: int | NumberVar | None = None, + ) -> ArrayVar[List[int]]: + """Create a range of numbers. + + Args: + first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range. + second_endpoint: The end of the range. + step: The step of the range. + + Returns: + The range of numbers. + """ + if any( + not isinstance(i, (int, NumberVar)) + for i in (first_endpoint, second_endpoint, step) + if i is not None + ): + raise_unsupported_operand_types( + "range", (type(first_endpoint), type(second_endpoint), type(step)) + ) + if second_endpoint is None: + start = 0 + end = first_endpoint + else: + start = first_endpoint + end = second_endpoint + + return array_range_operation(start, end, step or 1) + + @overload + def contains(self, other: Any) -> BooleanVar: ... + + @overload + def contains(self, other: Any, field: StringVar | str) -> BooleanVar: ... + + def contains(self, other: Any, field: Any = None) -> BooleanVar: + """Check if the array contains an element. + + Args: + other: The element to check for. + field: The field to check. + + Returns: + The array contains operation. + """ + if field is not None: + if not isinstance(field, (StringVar, str)): + raise_unsupported_operand_types("contains", (type(self), type(field))) + return array_contains_field_operation(self, other, field) + return array_contains_operation(self, other) + + def pluck(self, field: StringVar | str) -> ArrayVar: + """Pluck a field from the array. + + Args: + field: The field to pluck from the array. + + Returns: + The array pluck operation. + """ + return array_pluck_operation(self, field) + + @overload + def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]: ... + + @overload + def __mul__(self, other: NoReturn) -> NoReturn: ... + + def __mul__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]: + """Multiply the sequence by a number or integer. + + Parameters: + other: The number or integer to multiply the sequence by. + + Returns: + ArrayVar[ARRAY_VAR_TYPE]: The result of multiplying the sequence by the given number or integer. + """ + if not isinstance(other, (NumberVar, int)) or ( + isinstance(other, NumberVar) and other._is_strict_float() + ): + raise_unsupported_operand_types("*", (type(self), type(other))) + + return repeat_array_operation(self, other) + + __rmul__ = __mul__ # type: ignore + + @overload + def __lt__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ... + + @overload + def __lt__(self, other: list | tuple) -> BooleanVar: ... + + def __lt__(self, other: Any): + """Check if the array is less than another array. + + Args: + other: The other array. + + Returns: + The array less than operation. + """ + if not isinstance(other, (ArrayVar, list, tuple)): + raise_unsupported_operand_types("<", (type(self), type(other))) + + return array_lt_operation(self, other) + + @overload + def __gt__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ... + + @overload + def __gt__(self, other: list | tuple) -> BooleanVar: ... + + def __gt__(self, other: Any): + """Check if the array is greater than another array. + + Args: + other: The other array. + + Returns: + The array greater than operation. + """ + if not isinstance(other, (ArrayVar, list, tuple)): + raise_unsupported_operand_types(">", (type(self), type(other))) + + return array_gt_operation(self, other) + + @overload + def __le__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ... + + @overload + def __le__(self, other: list | tuple) -> BooleanVar: ... + + def __le__(self, other: Any): + """Check if the array is less than or equal to another array. + + Args: + other: The other array. + + Returns: + The array less than or equal operation. + """ + if not isinstance(other, (ArrayVar, list, tuple)): + raise_unsupported_operand_types("<=", (type(self), type(other))) + + return array_le_operation(self, other) + + @overload + def __ge__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ... + + @overload + def __ge__(self, other: list | tuple) -> BooleanVar: ... + + def __ge__(self, other: Any): + """Check if the array is greater than or equal to another array. + + Args: + other: The other array. + + Returns: + The array greater than or equal operation. + """ + if not isinstance(other, (ArrayVar, list, tuple)): + raise_unsupported_operand_types(">=", (type(self), type(other))) + + return array_ge_operation(self, other) + + def foreach(self, fn: Any): + """Apply a function to each element of the array. + + Args: + fn: The function to apply. + + Returns: + The array after applying the function. + + Raises: + VarTypeError: If the function takes more than one argument. + """ + from .function import ArgsFunctionOperation + + if not callable(fn): + raise_unsupported_operand_types("foreach", (type(self), type(fn))) + # get the number of arguments of the function + num_args = len(inspect.signature(fn).parameters) + if num_args > 1: + raise VarTypeError( + "The function passed to foreach should take at most one argument." + ) + + if num_args == 0: + return_value = fn() + function_var = ArgsFunctionOperation.create(tuple(), return_value) + else: + # generic number var + number_var = Var("").to(NumberVar) + + first_arg_type = self[number_var]._var_type + + arg_name = get_unique_variable_name() + + # get first argument type + first_arg = Var( + _js_expr=arg_name, + _var_type=first_arg_type, + ).guess_type() + + function_var = ArgsFunctionOperation.create((arg_name,), fn(first_arg)) + + return map_array_operation(self, function_var) + + +LIST_ELEMENT = TypeVar("LIST_ELEMENT") + +ARRAY_VAR_OF_LIST_ELEMENT = Union[ + ArrayVar[List[LIST_ELEMENT]], + ArrayVar[Set[LIST_ELEMENT]], + ArrayVar[Tuple[LIST_ELEMENT, ...]], +] + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]): + """Base class for immutable literal array vars.""" + + _var_value: Union[ + List[Union[Var, Any]], + Set[Union[Var, Any]], + Tuple[Union[Var, Any], ...], + ] = dataclasses.field(default_factory=list) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return ( + "[" + + ", ".join( + [str(LiteralVar.create(element)) for element in self._var_value] + ) + + "]" + ) + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get all the VarData associated with the Var. + + Returns: + The VarData associated with the Var. + """ + return VarData.merge( + *[ + LiteralVar.create(element)._get_all_var_data() + for element in self._var_value + ], + self._var_data, + ) + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._js_expr)) + + def json(self) -> str: + """Get the JSON representation of the var. + + Returns: + The JSON representation of the var. + """ + return ( + "[" + + ", ".join( + [LiteralVar.create(element).json() for element in self._var_value] + ) + + "]" + ) + + @classmethod + def create( + cls, + value: ARRAY_VAR_TYPE, + _var_type: Type[ARRAY_VAR_TYPE] | None = None, + _var_data: VarData | None = None, + ) -> LiteralArrayVar[ARRAY_VAR_TYPE]: + """Create a var from a string value. + + Args: + value: The value to create the var from. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + return cls( + _js_expr="", + _var_type=figure_out_type(value) if _var_type is None else _var_type, + _var_data=_var_data, + _var_value=value, + ) + + +@var_operation +def string_split_operation(string: StringVar, sep: StringVar | str = ""): + """Split a string. + + Args: + string: The string to split. + sep: The separator. + + Returns: + The split string. + """ + return var_operation_return( + js_expression=f"{string}.split({sep})", var_type=List[str] + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ArraySliceOperation(CachedVarOperation, ArrayVar): + """Base class for immutable string vars that are the result of a string slice operation.""" + + _array: ArrayVar = dataclasses.field( + default_factory=lambda: LiteralArrayVar.create([]) + ) + _start: NumberVar | int = dataclasses.field(default_factory=lambda: 0) + _stop: NumberVar | int = dataclasses.field(default_factory=lambda: 0) + _step: NumberVar | int = dataclasses.field(default_factory=lambda: 1) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + + Raises: + ValueError: If the slice step is zero. + """ + start, end, step = self._start, self._stop, self._step + + normalized_start = ( + LiteralVar.create(start) if start is not None else Var(_js_expr="undefined") + ) + normalized_end = ( + LiteralVar.create(end) if end is not None else Var(_js_expr="undefined") + ) + if step is None: + return f"{str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)})" + if not isinstance(step, Var): + if step < 0: + actual_start = end + 1 if end is not None else 0 + actual_end = start + 1 if start is not None else self._array.length() + return str(self._array[actual_start:actual_end].reverse()[::-step]) + if step == 0: + raise ValueError("slice step cannot be zero") + return f"{str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0)" + + actual_start_reverse = end + 1 if end is not None else 0 + actual_end_reverse = start + 1 if start is not None else self._array.length() + + return f"{str(self.step)} > 0 ? {str(self._array)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0) : {str(self._array)}.slice({str(actual_start_reverse)}, {str(actual_end_reverse)}).reverse().filter((_, i) => i % {str(-step)} === 0)" + + @classmethod + def create( + cls, + array: ArrayVar, + slice: slice, + _var_data: VarData | None = None, + ) -> ArraySliceOperation: + """Create a var from a string value. + + Args: + array: The array. + slice: The slice. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + return cls( + _js_expr="", + _var_type=array._var_type, + _var_data=_var_data, + _array=array, + _start=slice.start, + _stop=slice.stop, + _step=slice.step, + ) + + +@var_operation +def array_pluck_operation( + array: ArrayVar[ARRAY_VAR_TYPE], + field: StringVar | str, +) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]: + """Pluck a field from an array of objects. + + Args: + array: The array to pluck from. + field: The field to pluck from the objects in the array. + + Returns: + The reversed array. + """ + return var_operation_return( + js_expression=f"{array}.map(e=>e?.[{field}])", + var_type=array._var_type, + ) + + +@var_operation +def array_reverse_operation( + array: ArrayVar[ARRAY_VAR_TYPE], +) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]: + """Reverse an array. + + Args: + array: The array to reverse. + + Returns: + The reversed array. + """ + return var_operation_return( + js_expression=f"{array}.slice().reverse()", + var_type=array._var_type, + ) + + +@var_operation +def array_lt_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple): + """Check if an array is less than another array. + + Args: + lhs: The left-hand side array. + rhs: The right-hand side array. + + Returns: + The array less than operation. + """ + return var_operation_return(js_expression=f"{lhs} < {rhs}", var_type=bool) + + +@var_operation +def array_gt_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple): + """Check if an array is greater than another array. + + Args: + lhs: The left-hand side array. + rhs: The right-hand side array. + + Returns: + The array greater than operation. + """ + return var_operation_return(js_expression=f"{lhs} > {rhs}", var_type=bool) + + +@var_operation +def array_le_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple): + """Check if an array is less than or equal to another array. + + Args: + lhs: The left-hand side array. + rhs: The right-hand side array. + + Returns: + The array less than or equal operation. + """ + return var_operation_return(js_expression=f"{lhs} <= {rhs}", var_type=bool) + + +@var_operation +def array_ge_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple): + """Check if an array is greater than or equal to another array. + + Args: + lhs: The left-hand side array. + rhs: The right-hand side array. + + Returns: + The array greater than or equal operation. + """ + return var_operation_return(js_expression=f"{lhs} >= {rhs}", var_type=bool) + + +@var_operation +def array_length_operation(array: ArrayVar): + """Get the length of an array. + + Args: + array: The array. + + Returns: + The length of the array. + """ + return var_operation_return( + js_expression=f"{array}.length", + var_type=int, + ) + + +def is_tuple_type(t: GenericType) -> bool: + """Check if a type is a tuple type. + + Args: + t: The type to check. + + Returns: + Whether the type is a tuple type. + """ + if inspect.isclass(t): + return issubclass(t, tuple) + return get_origin(t) is tuple + + +@var_operation +def array_item_operation(array: ArrayVar, index: NumberVar | int): + """Get an item from an array. + + Args: + array: The array. + index: The index of the item. + + Returns: + The item from the array. + """ + args = typing.get_args(array._var_type) + if args and isinstance(index, LiteralNumberVar) and is_tuple_type(array._var_type): + index_value = int(index._var_value) + element_type = args[index_value % len(args)] + else: + element_type = unionize(*args) + + return var_operation_return( + js_expression=f"{str(array)}.at({str(index)})", + var_type=element_type, + ) + + +@var_operation +def array_range_operation( + start: NumberVar | int, stop: NumberVar | int, step: NumberVar | int +): + """Create a range of numbers. + + Args: + start: The start of the range. + stop: The end of the range. + step: The step of the range. + + Returns: + The range of numbers. + """ + return var_operation_return( + js_expression=f"Array.from({{ length: ({str(stop)} - {str(start)}) / {str(step)} }}, (_, i) => {str(start)} + i * {str(step)})", + var_type=List[int], + ) + + +@var_operation +def array_contains_field_operation( + haystack: ArrayVar, needle: Any | Var, field: StringVar | str +): + """Check if an array contains an element. + + Args: + haystack: The array to check. + needle: The element to check for. + field: The field to check. + + Returns: + The array contains operation. + """ + return var_operation_return( + js_expression=f"{haystack}.some(obj => obj[{field}] === {needle})", + var_type=bool, + ) + + +@var_operation +def array_contains_operation(haystack: ArrayVar, needle: Any | Var): + """Check if an array contains an element. + + Args: + haystack: The array to check. + needle: The element to check for. + + Returns: + The array contains operation. + """ + return var_operation_return( + js_expression=f"{haystack}.includes({needle})", + var_type=bool, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ToStringOperation(ToOperation, StringVar): + """Base class for immutable string vars that are the result of a to string operation.""" + + _original: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create()) + + _default_var_type: ClassVar[Type] = str + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ToArrayOperation(ToOperation, ArrayVar): + """Base class for immutable array vars that are the result of a to array operation.""" + + _original: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create()) + + _default_var_type: ClassVar[Type] = List[Any] + + +@var_operation +def repeat_array_operation( + array: ArrayVar[ARRAY_VAR_TYPE], count: NumberVar | int +) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]: + """Repeat an array a number of times. + + Args: + array: The array to repeat. + count: The number of times to repeat the array. + + Returns: + The repeated array. + """ + return var_operation_return( + js_expression=f"Array.from({{ length: {count} }}).flatMap(() => {array})", + var_type=array._var_type, + ) + + +if TYPE_CHECKING: + from .function import FunctionVar + + +@var_operation +def map_array_operation( + array: ArrayVar[ARRAY_VAR_TYPE], + function: FunctionVar, +): + """Map a function over an array. + + Args: + array: The array. + function: The function to map. + + Returns: + The mapped array. + """ + return var_operation_return( + js_expression=f"{array}.map({function})", var_type=List[Any] + ) + + +@var_operation +def array_concat_operation( + lhs: ArrayVar[ARRAY_VAR_TYPE], rhs: ArrayVar[ARRAY_VAR_TYPE] +) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]: + """Concatenate two arrays. + + Args: + lhs: The left-hand side array. + rhs: The right-hand side array. + + Returns: + The concatenated array. + """ + return var_operation_return( + js_expression=f"[...{lhs}, ...{rhs}]", + var_type=Union[lhs._var_type, rhs._var_type], + ) diff --git a/scripts/integration.sh b/scripts/integration.sh index 17ba66ec7..dc8b5d553 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -34,4 +34,4 @@ if [ -f /proc/$pid/winpid ]; then echo "Windows detected, passing winpid $pid to port waiter" fi -python scripts/wait_for_listening_port.py $check_ports --timeout=1800 --server-pid "$pid" +python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid" diff --git a/tests/compiler/test_compiler.py b/tests/compiler/test_compiler.py index 63014cf33..9ff4e1f14 100644 --- a/tests/compiler/test_compiler.py +++ b/tests/compiler/test_compiler.py @@ -100,7 +100,7 @@ def test_compile_imports(import_dict: ParsedImportDict, test_dicts: List[dict]): test_dicts: The expected output. """ imports = utils.compile_imports(import_dict) - for import_dict, test_dict in zip(imports, test_dicts): + for import_dict, test_dict in zip(imports, test_dicts, strict=False): assert import_dict["lib"] == test_dict["lib"] assert import_dict["default"] == test_dict["default"] assert sorted(import_dict["rest"]) == test_dict["rest"] # type: ignore diff --git a/tests/components/base/test_bare.py b/tests/components/base/test_bare.py index adc7ac1b0..c30ffaf15 100644 --- a/tests/components/base/test_bare.py +++ b/tests/components/base/test_bare.py @@ -1,9 +1,9 @@ import pytest from reflex.components.base.bare import Bare -from reflex.ivars.base import ImmutableVar +from reflex.vars.base import Var -STATE_VAR = ImmutableVar.create_safe("default_state.name") +STATE_VAR = Var(_js_expr="default_state.name") @pytest.mark.parametrize( diff --git a/tests/components/base/test_link.py b/tests/components/base/test_link.py new file mode 100644 index 000000000..7713330c4 --- /dev/null +++ b/tests/components/base/test_link.py @@ -0,0 +1,15 @@ +from reflex.components.base.link import RawLink, ScriptTag + + +def test_raw_link(): + raw_link = RawLink.create("https://example.com").render() + assert raw_link["name"] == "link" + assert raw_link["children"][0]["contents"] == '{"https://example.com"}' + + +def test_script_tag(): + script_tag = ScriptTag.create("console.log('Hello, world!');").render() + assert script_tag["name"] == "script" + assert ( + script_tag["children"][0]["contents"] == "{\"console.log('Hello, world!');\"}" + ) diff --git a/tests/components/core/test_banner.py b/tests/components/core/test_banner.py index f46ee16b1..02b030902 100644 --- a/tests/components/core/test_banner.py +++ b/tests/components/core/test_banner.py @@ -19,12 +19,14 @@ def test_websocket_target_url(): def test_connection_banner(): banner = ConnectionBanner.create() _imports = banner._get_all_imports(collapse=True) - assert tuple(_imports) == ( - "react", - "/utils/context", - "/utils/state", - "@radix-ui/themes@^3.0.0", - "/env.json", + assert sorted(tuple(_imports)) == sorted( + ( + "react", + "/utils/context", + "/utils/state", + "@radix-ui/themes@^3.0.0", + "/env.json", + ) ) msg = "Connection error" @@ -35,12 +37,14 @@ def test_connection_banner(): def test_connection_modal(): modal = ConnectionModal.create() _imports = modal._get_all_imports(collapse=True) - assert tuple(_imports) == ( - "react", - "/utils/context", - "/utils/state", - "@radix-ui/themes@^3.0.0", - "/env.json", + assert sorted(tuple(_imports)) == sorted( + ( + "react", + "/utils/context", + "/utils/state", + "@radix-ui/themes@^3.0.0", + "/env.json", + ) ) msg = "Connection error" diff --git a/tests/components/core/test_colors.py b/tests/components/core/test_colors.py index d5d5dc995..a6175d56a 100644 --- a/tests/components/core/test_colors.py +++ b/tests/components/core/test_colors.py @@ -1,9 +1,11 @@ +from typing import Type, Union + import pytest import reflex as rx from reflex.components.datadisplay.code import CodeBlock from reflex.constants.colors import Color -from reflex.ivars.base import LiteralVar +from reflex.vars.base import LiteralVar class ColorState(rx.State): @@ -22,44 +24,45 @@ def create_color_var(color): @pytest.mark.parametrize( - "color, expected", + "color, expected, expected_type", [ - (create_color_var(rx.color("mint")), '"var(--mint-7)"'), - (create_color_var(rx.color("mint", 3)), '"var(--mint-3)"'), - (create_color_var(rx.color("mint", 3, True)), '"var(--mint-a3)"'), + (create_color_var(rx.color("mint")), '"var(--mint-7)"', Color), + (create_color_var(rx.color("mint", 3)), '"var(--mint-3)"', Color), + (create_color_var(rx.color("mint", 3, True)), '"var(--mint-a3)"', Color), ( create_color_var(rx.color(ColorState.color, ColorState.shade)), # type: ignore f'("var(--"+{str(color_state_name)}.color+"-"+{str(color_state_name)}.shade+")")', + Color, ), ( create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore f'("var(--"+{str(color_state_name)}.color+"-"+{str(color_state_name)}.shade+")")', + Color, ), ( create_color_var( rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore ), f'("var(--"+{str(color_state_name)}.color_part+"ato-"+{str(color_state_name)}.shade+")")', + Color, ), ( create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore f'("var(--"+{str(color_state_name)}.color+"-"+{str(color_state_name)}.shade+")")', + str, ), ( create_color_var( f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore ), f'("var(--"+{str(color_state_name)}.color+"-"+{str(color_state_name)}.shade+")")', + str, ), ], ) -def test_color(color, expected): - assert color._var_is_string or color._var_type is str - assert color._var_full_name == expected - if color._var_type == Color: - assert str(color) == f"{{`{expected}`}}" - else: - assert str(color) == expected +def test_color(color, expected, expected_type: Union[Type[str], Type[Color]]): + assert color._var_type is expected_type + assert str(color) == expected @pytest.mark.parametrize( @@ -67,11 +70,11 @@ def test_color(color, expected): [ ( rx.cond(True, rx.color("mint"), rx.color("tomato", 5)), - '(Boolean(true) ? "var(--mint-7)" : "var(--tomato-5)")', + '(true ? "var(--mint-7)" : "var(--tomato-5)")', ), ( rx.cond(True, rx.color(ColorState.color), rx.color(ColorState.color, 5)), # type: ignore - f'(Boolean(true) ? ("var(--"+{str(color_state_name)}.color+"-7)") : ("var(--"+{str(color_state_name)}.color+"-5)"))', + f'(true ? ("var(--"+{str(color_state_name)}.color+"-7)") : ("var(--"+{str(color_state_name)}.color+"-5)"))', ), ( rx.match( diff --git a/tests/components/core/test_cond.py b/tests/components/core/test_cond.py index e3fc40ae3..f5b6c0895 100644 --- a/tests/components/core/test_cond.py +++ b/tests/components/core/test_cond.py @@ -6,10 +6,9 @@ import pytest from reflex.components.base.fragment import Fragment from reflex.components.core.cond import Cond, cond from reflex.components.radix.themes.typography.text import Text -from reflex.ivars.base import ImmutableVar, LiteralVar, immutable_computed_var from reflex.state import BaseState, State from reflex.utils.format import format_state_name -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var, computed_var @pytest.fixture @@ -23,7 +22,7 @@ def cond_state(request): def test_f_string_cond_interpolation(): # make sure backticks inside interpolation don't get escaped var = LiteralVar.create(f"x {cond(True, 'a', 'b')}") - assert str(var) == '("x "+(Boolean(true) ? "a" : "b"))' + assert str(var) == '("x "+(true ? "a" : "b"))' @pytest.mark.parametrize( @@ -76,7 +75,7 @@ def test_validate_cond(cond_state: BaseState): (32, 0), ("hello", ""), (2.3, 0.0), - (Var.create("a"), Var.create("b")), + (LiteralVar.create("a"), LiteralVar.create("b")), ], ) def test_prop_cond(c1: Any, c2: Any): @@ -97,13 +96,13 @@ def test_prop_cond(c1: Any, c2: Any): c1 = json.dumps(c1) if not isinstance(c2, Var): c2 = json.dumps(c2) - assert str(prop_cond) == f"(Boolean(true) ? {c1} : {c2})" + assert str(prop_cond) == f"(true ? {str(c1)} : {str(c2)})" def test_cond_no_mix(): """Test if cond can't mix components and props.""" with pytest.raises(ValueError): - cond(True, Var.create("hello"), Text.create("world")) + cond(True, LiteralVar.create("hello"), Text.create("world")) def test_cond_no_else(): @@ -126,23 +125,22 @@ def test_cond_computed_var(): """Test if cond works with computed vars.""" class CondStateComputed(State): - @immutable_computed_var + @computed_var def computed_int(self) -> int: return 0 - @immutable_computed_var + @computed_var def computed_str(self) -> str: return "a string" comp = cond(True, CondStateComputed.computed_int, CondStateComputed.computed_str) # TODO: shouln't this be a ComputedVar? - assert isinstance(comp, ImmutableVar) + assert isinstance(comp, Var) state_name = format_state_name(CondStateComputed.get_full_name()) assert ( - str(comp) - == f"(Boolean(true) ? {state_name}.computed_int : {state_name}.computed_str)" + str(comp) == f"(true ? {state_name}.computed_int : {state_name}.computed_str)" ) assert comp._var_type == Union[int, str] diff --git a/tests/components/core/test_debounce.py b/tests/components/core/test_debounce.py index 95feb7ae6..656f26c1f 100644 --- a/tests/components/core/test_debounce.py +++ b/tests/components/core/test_debounce.py @@ -4,8 +4,8 @@ import pytest import reflex as rx from reflex.components.core.debounce import DEFAULT_DEBOUNCE_TIMEOUT -from reflex.ivars.base import LiteralVar from reflex.state import BaseState +from reflex.vars.base import LiteralVar, Var def test_create_no_child(): @@ -57,7 +57,7 @@ def test_render_child_props(): on_change=S.on_change, ) )._render() - assert "css" in tag.props and isinstance(tag.props["css"], rx.Var) + assert "css" in tag.props and isinstance(tag.props["css"], rx.vars.Var) for prop in ["foo", "bar", "baz", "quuc"]: assert prop in str(tag.props["css"]) assert tag.props["value"].equals(LiteralVar.create("real")) @@ -73,7 +73,7 @@ def test_render_with_class_name(): class_name="foo baz", ) )._render() - assert isinstance(tag.props["className"], rx.Var) + assert isinstance(tag.props["className"], rx.vars.Var) assert "foo baz" in str(tag.props["className"]) @@ -84,7 +84,7 @@ def test_render_with_ref(): id="foo_bar", ) )._render() - assert isinstance(tag.props["inputRef"], rx.Var) + assert isinstance(tag.props["inputRef"], rx.vars.Var) assert "foo_bar" in str(tag.props["inputRef"]) @@ -95,12 +95,12 @@ def test_render_with_key(): key="foo_bar", ) )._render() - assert isinstance(tag.props["key"], rx.Var) + assert isinstance(tag.props["key"], rx.vars.Var) assert "foo_bar" in str(tag.props["key"]) def test_render_with_special_props(): - special_prop = rx.Var.create_safe("{foo_bar}", _var_is_string=False) + special_prop = Var(_js_expr="{foo_bar}") tag = rx.debounce_input( rx.input( on_change=S.on_change, @@ -149,13 +149,13 @@ def test_render_child_props_recursive(): ), force_notify_by_enter=False, )._render() - assert "css" in tag.props and isinstance(tag.props["css"], rx.Var) + assert "css" in tag.props and isinstance(tag.props["css"], rx.vars.Var) for prop in ["foo", "bar", "baz", "quuc"]: assert prop in str(tag.props["css"]) assert tag.props["value"].equals(LiteralVar.create("outer")) - assert tag.props["forceNotifyOnBlur"]._var_name == "false" - assert tag.props["forceNotifyByEnter"]._var_name == "false" - assert tag.props["debounceTimeout"]._var_name == "42" + assert tag.props["forceNotifyOnBlur"]._js_expr == "false" + assert tag.props["forceNotifyByEnter"]._js_expr == "false" + assert tag.props["debounceTimeout"]._js_expr == "42" assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" @@ -167,7 +167,7 @@ def test_full_control_implicit_debounce(): value=S.value, on_change=S.on_change, )._render() - assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT) + assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT) assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" @@ -179,7 +179,7 @@ def test_full_control_implicit_debounce_text_area(): value=S.value, on_change=S.on_change, )._render() - assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT) + assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT) assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" diff --git a/tests/components/core/test_foreach.py b/tests/components/core/test_foreach.py index f1fae2577..43b9d8d55 100644 --- a/tests/components/core/test_foreach.py +++ b/tests/components/core/test_foreach.py @@ -13,7 +13,9 @@ from reflex.components.core.foreach import ( from reflex.components.radix.themes.layout.box import box from reflex.components.radix.themes.typography.text import text from reflex.state import BaseState, ComponentState -from reflex.vars import Var +from reflex.vars.base import Var +from reflex.vars.number import NumberVar +from reflex.vars.sequence import ArrayVar class ForEachState(BaseState): @@ -113,7 +115,7 @@ def display_colors_set(color): return box(text(color)) -def display_nested_list_element(element: Var[str], index: Var[int]): +def display_nested_list_element(element: ArrayVar[List[str]], index: NumberVar[int]): assert element._var_type == List[str] assert index._var_type == int return box(text(element[index])) @@ -237,9 +239,9 @@ def test_foreach_render(state_var, render_fn, render_dict): # Make sure the index vars are unique. arg_index = rend["arg_index"] assert isinstance(arg_index, Var) - assert arg_index._var_name not in seen_index_vars + assert arg_index._js_expr not in seen_index_vars assert arg_index._var_type == int - seen_index_vars.add(arg_index._var_name) + seen_index_vars.add(arg_index._js_expr) def test_foreach_bad_annotations(): diff --git a/tests/components/core/test_match.py b/tests/components/core/test_match.py index 1843b914d..583bfa1e2 100644 --- a/tests/components/core/test_match.py +++ b/tests/components/core/test_match.py @@ -6,7 +6,7 @@ import reflex as rx from reflex.components.core.match import Match from reflex.state import BaseState from reflex.utils.exceptions import MatchTypeError -from reflex.vars import Var +from reflex.vars.base import Var class MatchState(BaseState): @@ -40,39 +40,39 @@ def test_match_components(): match_cases = match_child["match_cases"] assert len(match_cases) == 6 - assert match_cases[0][0]._var_name == "1" + assert match_cases[0][0]._js_expr == "1" assert match_cases[0][0]._var_type == int first_return_value_render = match_cases[0][1].render() assert first_return_value_render["name"] == "RadixThemesText" assert first_return_value_render["children"][0]["contents"] == '{"first value"}' - assert match_cases[1][0]._var_name == "2" + assert match_cases[1][0]._js_expr == "2" assert match_cases[1][0]._var_type == int - assert match_cases[1][1]._var_name == "3" + assert match_cases[1][1]._js_expr == "3" assert match_cases[1][1]._var_type == int second_return_value_render = match_cases[1][2].render() assert second_return_value_render["name"] == "RadixThemesText" assert second_return_value_render["children"][0]["contents"] == '{"second value"}' - assert match_cases[2][0]._var_name == "[1, 2]" + assert match_cases[2][0]._js_expr == "[1, 2]" assert match_cases[2][0]._var_type == List[int] third_return_value_render = match_cases[2][1].render() assert third_return_value_render["name"] == "RadixThemesText" assert third_return_value_render["children"][0]["contents"] == '{"third value"}' - assert match_cases[3][0]._var_name == '"random"' + assert match_cases[3][0]._js_expr == '"random"' assert match_cases[3][0]._var_type == str fourth_return_value_render = match_cases[3][1].render() assert fourth_return_value_render["name"] == "RadixThemesText" assert fourth_return_value_render["children"][0]["contents"] == '{"fourth value"}' - assert match_cases[4][0]._var_name == '({ ["foo"] : "bar" })' + assert match_cases[4][0]._js_expr == '({ ["foo"] : "bar" })' assert match_cases[4][0]._var_type == Dict[str, str] fifth_return_value_render = match_cases[4][1].render() assert fifth_return_value_render["name"] == "RadixThemesText" assert fifth_return_value_render["children"][0]["contents"] == '{"fifth value"}' - assert match_cases[5][0]._var_name == f"({MatchState.get_name()}.num + 1)" + assert match_cases[5][0]._js_expr == f"({MatchState.get_name()}.num + 1)" assert match_cases[5][0]._var_type == int fifth_return_value_render = match_cases[5][1].render() assert fifth_return_value_render["name"] == "RadixThemesText" @@ -136,7 +136,7 @@ def test_match_vars(cases, expected): """ match_comp = Match.create(MatchState.value, *cases) assert isinstance(match_comp, Var) - assert match_comp._var_full_name == expected + assert str(match_comp) == expected def test_match_on_component_without_default(): @@ -248,7 +248,7 @@ def test_match_case_tuple_elements(match_case): rx.text("default value"), ), 'Match cases should have the same return types. Case 3 with return value `"red"` of type ' - " is not ", + " is not ", ), ( ( @@ -261,7 +261,7 @@ def test_match_case_tuple_elements(match_case): rx.text("default value"), ), 'Match cases should have the same return types. Case 3 with return value ` {"first value"} ` ' - "of type is not ", + "of type is not ", ), ], ) diff --git a/tests/components/core/test_upload.py b/tests/components/core/test_upload.py index e6b27effc..83f04b3e6 100644 --- a/tests/components/core/test_upload.py +++ b/tests/components/core/test_upload.py @@ -8,7 +8,7 @@ from reflex.components.core.upload import ( ) from reflex.event import EventSpec from reflex.state import State -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var class TestUploadState(State): @@ -42,7 +42,7 @@ def test_get_upload_url(): def test__on_drop_spec(): - assert isinstance(_on_drop_spec(Var.create([])), list) + assert isinstance(_on_drop_spec(LiteralVar.create([])), list) def test_upload_create(): diff --git a/tests/components/datadisplay/test_code.py b/tests/components/datadisplay/test_code.py index 49fbae09f..809c68fe5 100644 --- a/tests/components/datadisplay/test_code.py +++ b/tests/components/datadisplay/test_code.py @@ -1,15 +1,16 @@ import pytest -from reflex.components.datadisplay.code import CodeBlock +from reflex.components.datadisplay.code import CodeBlock, Theme @pytest.mark.parametrize( - "theme, expected", [("light", '"one-light"'), ("dark", '"one-dark"')] + "theme, expected", + [(Theme.one_light, "oneLight"), (Theme.one_dark, "oneDark")], ) def test_code_light_dark_theme(theme, expected): code_block = CodeBlock.create(theme=theme) - assert code_block.theme._var_name == expected # type: ignore + assert code_block.theme._js_expr == expected # type: ignore def generate_custom_code(language, expected_case): diff --git a/tests/components/datadisplay/test_table.py b/tests/components/datadisplay/test_table.py deleted file mode 100644 index 8740d4b8c..000000000 --- a/tests/components/datadisplay/test_table.py +++ /dev/null @@ -1,177 +0,0 @@ -import sys -from typing import List, Tuple - -import pytest -from reflex_chakra.components.datadisplay.table import Tbody, Tfoot, Thead - -from reflex.state import BaseState - -PYTHON_GT_V38 = sys.version_info.major >= 3 and sys.version_info.minor > 8 - - -class TableState(BaseState): - """Test State class.""" - - rows_List_List_str: List[List[str]] = [["random", "row"]] - rows_List_List: List[List] = [["random", "row"]] - rows_List_str: List[str] = ["random", "row"] - rows_Tuple_List_str: Tuple[List[str]] = (["random", "row"],) - rows_Tuple_List: Tuple[List] = ["random", "row"] # type: ignore - rows_Tuple_str_str: Tuple[str, str] = ( - "random", - "row", - ) - rows_Tuple_Tuple_str_str: Tuple[Tuple[str, str]] = ( - ( - "random", - "row", - ), - ) - rows_Tuple_Tuple: Tuple[Tuple] = ( - ( - "random", - "row", - ), - ) - rows_str: str = "random, row" - headers_List_str: List[str] = ["header1", "header2"] - headers_Tuple_str_str: Tuple[str, str] = ( - "header1", - "header2", - ) - headers_str: str = "headers1, headers2" - footers_List_str: List[str] = ["footer1", "footer2"] - footers_Tuple_str_str: Tuple[str, str] = ( - "footer1", - "footer2", - ) - footers_str: str = "footer1, footer2" - - if sys.version_info.major >= 3 and sys.version_info.minor > 8: - rows_list_list_str: list[list[str]] = [["random", "row"]] - rows_list_list: list[list] = [["random", "row"]] - rows_list_str: list[str] = ["random", "row"] - rows_tuple_list_str: tuple[list[str]] = (["random", "row"],) - rows_tuple_list: tuple[list] = ["random", "row"] # type: ignore - rows_tuple_str_str: tuple[str, str] = ( - "random", - "row", - ) - rows_tuple_tuple_str_str: tuple[tuple[str, str]] = ( - ( - "random", - "row", - ), - ) - rows_tuple_tuple: tuple[tuple] = ( - ( - "random", - "row", - ), - ) - - -valid_extras = ( - [ - TableState.rows_list_list_str, - TableState.rows_list_list, - TableState.rows_tuple_list_str, - TableState.rows_tuple_list, - TableState.rows_tuple_tuple_str_str, - TableState.rows_tuple_tuple, - ] - if PYTHON_GT_V38 - else [] -) -invalid_extras = ( - [TableState.rows_list_str, TableState.rows_tuple_str_str] if PYTHON_GT_V38 else [] -) - - -@pytest.mark.parametrize( - "rows", - [ - [["random", "row"]], - TableState.rows_List_List_str, - TableState.rows_List_List, - TableState.rows_Tuple_List_str, - TableState.rows_Tuple_List, - TableState.rows_Tuple_Tuple_str_str, - TableState.rows_Tuple_Tuple, - *valid_extras, - ], -) -def test_create_table_body_with_valid_rows_prop(rows): - render_dict = Tbody.create(rows=rows).render() - assert render_dict["name"] == "Tbody" - assert len(render_dict["children"]) == 1 - - -@pytest.mark.parametrize( - "rows", - [ - ["random", "row"], - "random, rows", - TableState.rows_List_str, - TableState.rows_Tuple_str_str, - TableState.rows_str, - *invalid_extras, - ], -) -def test_create_table_body_with_invalid_rows_prop(rows): - with pytest.raises(TypeError): - Tbody.create(rows=rows) - - -@pytest.mark.parametrize( - "headers", - [ - ["random", "header"], - TableState.headers_List_str, - TableState.headers_Tuple_str_str, - ], -) -def test_create_table_head_with_valid_headers_prop(headers): - render_dict = Thead.create(headers=headers).render() - assert render_dict["name"] == "Thead" - assert len(render_dict["children"]) == 1 - assert render_dict["children"][0]["name"] == "Tr" - - -@pytest.mark.parametrize( - "headers", - [ - "random, header", - TableState.headers_str, - ], -) -def test_create_table_head_with_invalid_headers_prop(headers): - with pytest.raises(TypeError): - Thead.create(headers=headers) - - -@pytest.mark.parametrize( - "footers", - [ - ["random", "footers"], - TableState.footers_List_str, - TableState.footers_Tuple_str_str, - ], -) -def test_create_table_footer_with_valid_footers_prop(footers): - render_dict = Tfoot.create(footers=footers).render() - assert render_dict["name"] == "Tfoot" - assert len(render_dict["children"]) == 1 - assert render_dict["children"][0]["name"] == "Tr" - - -@pytest.mark.parametrize( - "footers", - [ - "random, footers", - TableState.footers_str, - ], -) -def test_create_table_footer_with_invalid_footers_prop(footers): - with pytest.raises(TypeError): - Tfoot.create(footers=footers) diff --git a/tests/components/forms/test_form.py b/tests/components/forms/test_form.py index b979d261a..3cbbab3b8 100644 --- a/tests/components/forms/test_form.py +++ b/tests/components/forms/test_form.py @@ -1,13 +1,12 @@ -from reflex_chakra.components.forms.form import Form - +from reflex.components.radix.primitives.form import Form from reflex.event import EventChain -from reflex.vars import BaseVar +from reflex.vars.base import Var def test_render_on_submit(): """Test that on_submit event chain is rendered as a separate function.""" - submit_it = BaseVar( - _var_name="submit_it", + submit_it = Var( + _js_expr="submit_it", _var_type=EventChain, ) f = Form.create(on_submit=submit_it) diff --git a/tests/components/lucide/test_icon.py b/tests/components/lucide/test_icon.py index d61f3a9aa..b0a3475dd 100644 --- a/tests/components/lucide/test_icon.py +++ b/tests/components/lucide/test_icon.py @@ -1,6 +1,6 @@ import pytest -from reflex.components.lucide.icon import LUCIDE_ICON_LIST, RENAMED_ICONS_05, Icon +from reflex.components.lucide.icon import LUCIDE_ICON_LIST, Icon from reflex.utils import format @@ -10,16 +10,6 @@ def test_icon(tag): assert icon.alias == f"Lucide{format.to_title_case(tag)}Icon" -RENAMED_TAGS = [tag for tag in RENAMED_ICONS_05.items()] - - -@pytest.mark.parametrize("tag, new_tag", RENAMED_TAGS) -def test_icon_renamed_tags(tag, new_tag): - Icon.create(tag) - # TODO: need a PR so we can pass the following test. Currently it fails and uses the old tag as the import. - # assert icon.alias == f"Lucide{format.to_title_case(new_tag)}Icon" - - def test_icon_missing_tag(): with pytest.raises(AttributeError): _ = Icon.create() diff --git a/tests/components/media/test_icon.py b/tests/components/media/test_icon.py deleted file mode 100644 index 6a152c587..000000000 --- a/tests/components/media/test_icon.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest -from reflex_chakra.components.media.icon import ICON_LIST, Icon - -from reflex.utils import format - - -def test_no_tag_errors(): - """Test that an icon without a tag raises an error.""" - with pytest.raises(AttributeError): - Icon.create() - - -def test_children_errors(): - """Test that an icon with children raises an error.""" - with pytest.raises(AttributeError): - Icon.create("child", tag="search") - - -@pytest.mark.parametrize( - "tag", - ICON_LIST, -) -def test_valid_icon(tag: str): - """Test that a valid icon does not raise an error. - - Args: - tag: The icon tag. - """ - icon = Icon.create(tag=tag) - assert icon.tag == format.to_title_case(tag) + "Icon" - - -@pytest.mark.parametrize("tag", ["", " ", "invalid", 123]) -def test_invalid_icon(tag): - """Test that an invalid icon raises an error. - - Args: - tag: The icon tag. - """ - with pytest.raises(ValueError): - Icon.create(tag=tag) - - -@pytest.mark.parametrize( - "tag", - ["Check", "Close", "eDit"], -) -def test_tag_with_capital(tag: str): - """Test that an icon that tag with capital does not raise an error. - - Args: - tag: The icon tag. - """ - icon = Icon.create(tag=tag) - assert icon.tag == format.to_title_case(tag) + "Icon" diff --git a/tests/components/media/test_image.py b/tests/components/media/test_image.py index ba8353260..e3d924235 100644 --- a/tests/components/media/test_image.py +++ b/tests/components/media/test_image.py @@ -6,8 +6,8 @@ from PIL.Image import Image as Img import reflex as rx from reflex.components.next.image import Image # type: ignore -from reflex.ivars.sequence import StringVar from reflex.utils.serializers import serialize, serialize_image +from reflex.vars.sequence import StringVar @pytest.fixture @@ -53,7 +53,7 @@ def test_set_src_img(pil_image: Img): pil_image: The image to serialize. """ image = Image.create(src=pil_image) - assert str(image.src._var_name) == '"' + serialize_image(pil_image) + '"' # type: ignore + assert str(image.src._js_expr) == '"' + serialize_image(pil_image) + '"' # type: ignore def test_render(pil_image: Img): diff --git a/tests/components/radix/test_icon_button.py b/tests/components/radix/test_icon_button.py index 852c0c97c..8047cf7b2 100644 --- a/tests/components/radix/test_icon_button.py +++ b/tests/components/radix/test_icon_button.py @@ -3,7 +3,7 @@ import pytest from reflex.components.lucide.icon import Icon from reflex.components.radix.themes.components.icon_button import IconButton from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import LiteralVar def test_icon_button(): @@ -26,5 +26,5 @@ def test_icon_button_size_prop(): ib1 = IconButton.create("activity", size="2") assert isinstance(ib1, IconButton) - ib2 = IconButton.create("activity", size=Var.create("2")) + ib2 = IconButton.create("activity", size=LiteralVar.create("2")) assert isinstance(ib2, IconButton) diff --git a/tests/components/recharts/test_cartesian.py b/tests/components/recharts/test_cartesian.py new file mode 100644 index 000000000..3337427bd --- /dev/null +++ b/tests/components/recharts/test_cartesian.py @@ -0,0 +1,50 @@ +from reflex.components.recharts import ( + Area, + Bar, + Brush, + Line, + Scatter, + XAxis, + YAxis, + ZAxis, +) + + +def test_xaxis(): + x_axis = XAxis.create("x").render() + assert x_axis["name"] == "RechartsXAxis" + + +def test_yaxis(): + x_axis = YAxis.create("y").render() + assert x_axis["name"] == "RechartsYAxis" + + +def test_zaxis(): + x_axis = ZAxis.create("z").render() + assert x_axis["name"] == "RechartsZAxis" + + +def test_brush(): + brush = Brush.create().render() + assert brush["name"] == "RechartsBrush" + + +def test_area(): + area = Area.create().render() + assert area["name"] == "RechartsArea" + + +def test_bar(): + bar = Bar.create().render() + assert bar["name"] == "RechartsBar" + + +def test_line(): + line = Line.create().render() + assert line["name"] == "RechartsLine" + + +def test_scatter(): + scatter = Scatter.create().render() + assert scatter["name"] == "RechartsScatter" diff --git a/tests/components/test_component.py b/tests/components/test_component.py index 45350a5c5..e6a1a40cb 100644 --- a/tests/components/test_component.py +++ b/tests/components/test_component.py @@ -2,8 +2,6 @@ from contextlib import nullcontext from typing import Any, Dict, List, Optional, Type, Union import pytest -import reflex_chakra as rc -from reflex_chakra.components.layout.box import Box import reflex as rx from reflex.base import Base @@ -16,14 +14,16 @@ from reflex.components.component import ( StatefulComponent, custom_component, ) +from reflex.components.radix.themes.layout.box import Box from reflex.constants import EventTriggers from reflex.event import EventChain, EventHandler, parse_args_spec -from reflex.ivars.base import LiteralVar from reflex.state import BaseState from reflex.style import Style from reflex.utils import imports +from reflex.utils.exceptions import EventFnArgMismatch, EventHandlerArgMismatch from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports -from reflex.vars import BaseVar, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var @pytest.fixture @@ -79,6 +79,8 @@ def component2() -> Type[Component]: # A test list prop. arr: Var[List[str]] + on_prop_event: EventHandler[lambda e0: [e0]] + def get_event_triggers(self) -> Dict[str, Any]: """Test controlled triggers. @@ -267,121 +269,121 @@ def test_create_component(component1): [ pytest.param( "text", - Var.create("hello"), + LiteralVar.create("hello"), None, id="text", ), pytest.param( "text", - BaseVar(_var_name="hello", _var_type=Optional[str]), + Var(_js_expr="hello", _var_type=Optional[str]), None, id="text-optional", ), pytest.param( "text", - BaseVar(_var_name="hello", _var_type=Union[str, None]), + Var(_js_expr="hello", _var_type=Union[str, None]), None, id="text-union-str-none", ), pytest.param( "text", - BaseVar(_var_name="hello", _var_type=Union[None, str]), + Var(_js_expr="hello", _var_type=Union[None, str]), None, id="text-union-none-str", ), pytest.param( "text", - Var.create(1), + LiteralVar.create(1), TypeError, id="text-int", ), pytest.param( "number", - Var.create(1), + LiteralVar.create(1), None, id="number", ), pytest.param( "number", - BaseVar(_var_name="1", _var_type=Optional[int]), + Var(_js_expr="1", _var_type=Optional[int]), None, id="number-optional", ), pytest.param( "number", - BaseVar(_var_name="1", _var_type=Union[int, None]), + Var(_js_expr="1", _var_type=Union[int, None]), None, id="number-union-int-none", ), pytest.param( "number", - BaseVar(_var_name="1", _var_type=Union[None, int]), + Var(_js_expr="1", _var_type=Union[None, int]), None, id="number-union-none-int", ), pytest.param( "number", - Var.create("1"), + LiteralVar.create("1"), TypeError, id="number-str", ), pytest.param( "text_or_number", - Var.create("hello"), + LiteralVar.create("hello"), None, id="text_or_number-str", ), pytest.param( "text_or_number", - Var.create(1), + LiteralVar.create(1), None, id="text_or_number-int", ), pytest.param( "text_or_number", - BaseVar(_var_name="hello", _var_type=Optional[str]), + Var(_js_expr="hello", _var_type=Optional[str]), None, id="text_or_number-optional-str", ), pytest.param( "text_or_number", - BaseVar(_var_name="hello", _var_type=Union[str, None]), + Var(_js_expr="hello", _var_type=Union[str, None]), None, id="text_or_number-union-str-none", ), pytest.param( "text_or_number", - BaseVar(_var_name="hello", _var_type=Union[None, str]), + Var(_js_expr="hello", _var_type=Union[None, str]), None, id="text_or_number-union-none-str", ), pytest.param( "text_or_number", - BaseVar(_var_name="1", _var_type=Optional[int]), + Var(_js_expr="1", _var_type=Optional[int]), None, id="text_or_number-optional-int", ), pytest.param( "text_or_number", - BaseVar(_var_name="1", _var_type=Union[int, None]), + Var(_js_expr="1", _var_type=Union[int, None]), None, id="text_or_number-union-int-none", ), pytest.param( "text_or_number", - BaseVar(_var_name="1", _var_type=Union[None, int]), + Var(_js_expr="1", _var_type=Union[None, int]), None, id="text_or_number-union-none-int", ), pytest.param( "text_or_number", - Var.create(1.0), + LiteralVar.create(1.0), TypeError, id="text_or_number-float", ), pytest.param( "text_or_number", - BaseVar(_var_name="hello", _var_type=Optional[Union[str, int]]), + Var(_js_expr="hello", _var_type=Optional[Union[str, int]]), None, id="text_or_number-optional-union-str-int", ), @@ -496,7 +498,7 @@ def test_get_props(component1, component2): component2: A test component. """ assert component1.get_props() == {"text", "number", "text_or_number"} - assert component2.get_props() == {"arr"} + assert component2.get_props() == {"arr", "on_prop_event"} @pytest.mark.parametrize( @@ -574,7 +576,7 @@ def test_get_event_triggers(component1, component2): assert component1().get_event_triggers().keys() == default_triggers assert ( component2().get_event_triggers().keys() - == {"on_open", "on_close"} | default_triggers + == {"on_open", "on_close", "on_prop_event"} | default_triggers ) @@ -635,21 +637,21 @@ def test_component_create_unallowed_types(children, test_component): "props": [], "contents": "", "args": None, - "special_props": set(), + "special_props": [], "children": [ { "name": "RadixThemesText", "props": ['as={"p"}'], "contents": "", "args": None, - "special_props": set(), + "special_props": [], "children": [ { "name": "", "props": [], "contents": '{"first_text"}', "args": None, - "special_props": set(), + "special_props": [], "children": [], "autofocus": False, } @@ -677,13 +679,13 @@ def test_component_create_unallowed_types(children, test_component): "contents": '{"first_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", "props": ['as={"p"}'], - "special_props": set(), + "special_props": [], }, { "args": None, @@ -696,19 +698,19 @@ def test_component_create_unallowed_types(children, test_component): "contents": '{"second_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", "props": ['as={"p"}'], - "special_props": set(), + "special_props": [], }, ], "contents": "", "name": "Fragment", "props": [], - "special_props": set(), + "special_props": [], }, ), ( @@ -728,13 +730,13 @@ def test_component_create_unallowed_types(children, test_component): "contents": '{"first_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", "props": ['as={"p"}'], - "special_props": set(), + "special_props": [], }, { "args": None, @@ -755,31 +757,31 @@ def test_component_create_unallowed_types(children, test_component): "contents": '{"second_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", "props": ['as={"p"}'], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "Fragment", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesBox", "props": [], - "special_props": set(), + "special_props": [], }, ], "contents": "", "name": "Fragment", "props": [], - "special_props": set(), + "special_props": [], }, ), ], @@ -871,7 +873,7 @@ def test_custom_component_wrapper(): from reflex.components.radix.themes.typography.text import Text ccomponent = my_component( - rx.text("child"), width=Var.create(1), color=Var.create("red") + rx.text("child"), width=LiteralVar.create(1), color=LiteralVar.create("red") ) assert isinstance(ccomponent, CustomComponent) assert len(ccomponent.children) == 1 @@ -888,18 +890,105 @@ def test_invalid_event_handler_args(component2, test_state): component2: A test component. test_state: A test state. """ - # Uncontrolled event handlers should not take args. - # This is okay. - component2.create(on_click=test_state.do_something) - # This is not okay. - with pytest.raises(ValueError): + # EventHandler args must match + with pytest.raises(EventHandlerArgMismatch): component2.create(on_click=test_state.do_something_arg) + with pytest.raises(EventHandlerArgMismatch): component2.create(on_open=test_state.do_something) + with pytest.raises(EventHandlerArgMismatch): + component2.create(on_prop_event=test_state.do_something) + + # Multiple EventHandler args: all must match + with pytest.raises(EventHandlerArgMismatch): + component2.create( + on_click=[test_state.do_something_arg, test_state.do_something] + ) + with pytest.raises(EventHandlerArgMismatch): component2.create( on_open=[test_state.do_something_arg, test_state.do_something] ) - # However lambdas are okay. + with pytest.raises(EventHandlerArgMismatch): + component2.create( + on_prop_event=[test_state.do_something_arg, test_state.do_something] + ) + + # lambda cannot return weird values. + with pytest.raises(ValueError): + component2.create(on_click=lambda: 1) + with pytest.raises(ValueError): + component2.create(on_click=lambda: [1]) + with pytest.raises(ValueError): + component2.create( + on_click=lambda: (test_state.do_something_arg(1), test_state.do_something) + ) + + # lambda signature must match event trigger. + with pytest.raises(EventFnArgMismatch): + component2.create(on_click=lambda _: test_state.do_something_arg(1)) + with pytest.raises(EventFnArgMismatch): + component2.create(on_open=lambda: test_state.do_something) + with pytest.raises(EventFnArgMismatch): + component2.create(on_prop_event=lambda: test_state.do_something) + + # lambda returning EventHandler must match spec + with pytest.raises(EventHandlerArgMismatch): + component2.create(on_click=lambda: test_state.do_something_arg) + with pytest.raises(EventHandlerArgMismatch): + component2.create(on_open=lambda _: test_state.do_something) + with pytest.raises(EventHandlerArgMismatch): + component2.create(on_prop_event=lambda _: test_state.do_something) + + # Mixed EventSpec and EventHandler must match spec. + with pytest.raises(EventHandlerArgMismatch): + component2.create( + on_click=lambda: [ + test_state.do_something_arg(1), + test_state.do_something_arg, + ] + ) + with pytest.raises(EventHandlerArgMismatch): + component2.create( + on_open=lambda _: [test_state.do_something_arg(1), test_state.do_something] + ) + with pytest.raises(EventHandlerArgMismatch): + component2.create( + on_prop_event=lambda _: [ + test_state.do_something_arg(1), + test_state.do_something, + ] + ) + + +def test_valid_event_handler_args(component2, test_state): + """Test that an valid event handler args do not raise exception. + + Args: + component2: A test component. + test_state: A test state. + """ + # Uncontrolled event handlers should not take args. + component2.create(on_click=test_state.do_something) + component2.create(on_click=test_state.do_something_arg(1)) + + # Controlled event handlers should take args. + component2.create(on_open=test_state.do_something_arg) + component2.create(on_prop_event=test_state.do_something_arg) + + # Using a partial event spec bypasses arg validation (ignoring the args). + component2.create(on_open=test_state.do_something()) + component2.create(on_prop_event=test_state.do_something()) + + # lambda returning EventHandler is okay if the spec matches. + component2.create(on_click=lambda: test_state.do_something) + component2.create(on_open=lambda _: test_state.do_something_arg) + component2.create(on_prop_event=lambda _: test_state.do_something_arg) + + # lambda can always return an EventSpec. component2.create(on_click=lambda: test_state.do_something_arg(1)) + component2.create(on_open=lambda _: test_state.do_something_arg(1)) + component2.create(on_prop_event=lambda _: test_state.do_something_arg(1)) + + # Return EventSpec and EventHandler (no arg). component2.create( on_click=lambda: [test_state.do_something_arg(1), test_state.do_something] ) @@ -907,9 +996,24 @@ def test_invalid_event_handler_args(component2, test_state): on_click=lambda: [test_state.do_something_arg(1), test_state.do_something()] ) - # Controlled event handlers should take args. - # This is okay. - component2.create(on_open=test_state.do_something_arg) + # Return 2 EventSpec. + component2.create( + on_open=lambda _: [test_state.do_something_arg(1), test_state.do_something()] + ) + component2.create( + on_prop_event=lambda _: [ + test_state.do_something_arg(1), + test_state.do_something(), + ] + ) + + # Return EventHandler (1 arg) and EventSpec. + component2.create( + on_open=lambda _: [test_state.do_something_arg, test_state.do_something()] + ) + component2.create( + on_prop_event=lambda _: [test_state.do_something_arg, test_state.do_something()] + ) def test_get_hooks_nested(component1, component2, component3): @@ -1009,8 +1113,8 @@ def test_component_with_only_valid_children(fixture, request): [ (rx.text("hi"), '\n {"hi"}\n'), ( - rx.box(rc.heading("test", size="md")), - '\n \n {"test"}\n\n', + rx.box(rx.heading("test", size="3")), + '\n \n {"test"}\n\n', ), ], ) @@ -1070,13 +1174,12 @@ TEST_VAR = LiteralVar.create("test")._replace( hooks={"useTest": None}, imports={"test": [ImportVar(tag="test")]}, state="Test", - interpolations=[], ) ) FORMATTED_TEST_VAR = LiteralVar.create(f"foo{TEST_VAR}bar") -STYLE_VAR = TEST_VAR._replace(_var_name="style") +STYLE_VAR = TEST_VAR._replace(_js_expr="style") EVENT_CHAIN_VAR = TEST_VAR._replace(_var_type=EventChain) -ARG_VAR = Var.create("arg") +ARG_VAR = Var(_js_expr="arg") TEST_VAR_DICT_OF_DICT = LiteralVar.create({"a": {"b": "test"}})._replace( merge_var_data=TEST_VAR._var_data @@ -1186,12 +1289,12 @@ class EventState(rx.State): id="fstring-class_name", ), pytest.param( - rx.fragment(special_props={TEST_VAR}), + rx.fragment(special_props=[TEST_VAR]), [TEST_VAR], id="direct-special_props", ), pytest.param( - rx.fragment(special_props={LiteralVar.create(f"foo{TEST_VAR}bar")}), + rx.fragment(special_props=[LiteralVar.create(f"foo{TEST_VAR}bar")]), [FORMATTED_TEST_VAR], id="fstring-special_props", ), @@ -1294,11 +1397,13 @@ class EventState(rx.State): ), ) def test_get_vars(component, exp_vars): - comp_vars = sorted(component._get_vars(), key=lambda v: v._var_name) + comp_vars = sorted(component._get_vars(), key=lambda v: v._js_expr) assert len(comp_vars) == len(exp_vars) + print(comp_vars, exp_vars) for comp_var, exp_var in zip( comp_vars, - sorted(exp_vars, key=lambda v: v._var_name), + sorted(exp_vars, key=lambda v: v._js_expr), + strict=False, ): # print(str(comp_var), str(exp_var)) # print(comp_var._get_all_var_data(), exp_var._get_all_var_data()) @@ -1413,7 +1518,7 @@ def test_validate_valid_children(): True, rx.fragment(valid_component2()), rx.fragment( - rx.foreach(Var.create([1, 2, 3]), lambda x: valid_component2(x)) # type: ignore + rx.foreach(LiteralVar.create([1, 2, 3]), lambda x: valid_component2(x)) # type: ignore ), ) ) @@ -1473,7 +1578,7 @@ def test_validate_valid_parents(): rx.fragment(valid_component3()), rx.fragment( rx.foreach( - Var.create([1, 2, 3]), # type: ignore + LiteralVar.create([1, 2, 3]), # type: ignore lambda x: valid_component2(valid_component3(x)), ) ), @@ -1540,7 +1645,9 @@ def test_validate_invalid_children(): True, rx.fragment(invalid_component()), rx.fragment( - rx.foreach(Var.create([1, 2, 3]), lambda x: invalid_component(x)) # type: ignore + rx.foreach( + LiteralVar.create([1, 2, 3]), lambda x: invalid_component(x) + ) # type: ignore ), ) ) @@ -1613,62 +1720,6 @@ def test_rename_props(): assert 'renamed_prop3={"prop3_2"}' in rendered_c2["props"] -def test_deprecated_props(capsys): - """Assert that deprecated underscore suffix props are translated. - - Args: - capsys: Pytest fixture for capturing stdout and stderr. - """ - - class C1(Component): - tag = "C1" - - type: Var[str] - min: Var[str] - max: Var[str] - - # No warnings are emitted when using the new prop names. - c1_1 = C1.create(type="type1", min="min1", max="max1") - out_err = capsys.readouterr() - assert not out_err.err - assert not out_err.out - - c1_1_render = c1_1.render() - assert 'type={"type1"}' in c1_1_render["props"] - assert 'min={"min1"}' in c1_1_render["props"] - assert 'max={"max1"}' in c1_1_render["props"] - - # Deprecation warning is emitted with underscore suffix, - # but the component still works. - c1_2 = C1.create(type_="type2", min_="min2", max_="max2") - out_err = capsys.readouterr() - assert out_err.out.count("DeprecationWarning:") == 3 - assert not out_err.err - - c1_2_render = c1_2.render() - assert 'type={"type2"}' in c1_2_render["props"] - assert 'min={"min2"}' in c1_2_render["props"] - assert 'max={"max2"}' in c1_2_render["props"] - - class C2(Component): - tag = "C2" - - type_: Var[str] - min_: Var[str] - max_: Var[str] - - # No warnings are emitted if the actual prop has an underscore suffix - c2_1 = C2.create(type_="type1", min_="min1", max_="max1") - out_err = capsys.readouterr() - assert not out_err.err - assert not out_err.out - - c2_1_render = c2_1.render() - assert 'type={"type1"}' in c2_1_render["props"] - assert 'min={"min1"}' in c2_1_render["props"] - assert 'max={"max1"}' in c2_1_render["props"] - - def test_custom_component_get_imports(): class Inner(Component): tag = "Inner" @@ -1742,6 +1793,7 @@ def test_custom_component_declare_event_handlers_in_fields(): for v1, v2 in zip( parse_args_spec(test_triggers[trigger_name]), parse_args_spec(custom_triggers[trigger_name]), + strict=False, ): assert v1.equals(v2) @@ -1978,8 +2030,8 @@ def test_component_add_hooks_var(): return [ "const hook3 = useRef(null)", "const hook1 = 42", - Var.create( - "useEffect(() => () => {}, [])", + Var( + _js_expr="useEffect(() => () => {}, [])", _var_data=VarData( hooks={ "const hook2 = 43": None, @@ -1988,11 +2040,9 @@ def test_component_add_hooks_var(): imports={"react": [ImportVar(tag="useEffect")]}, ), ), - Var.create( - "const hook3 = useRef(null)", - _var_data=VarData( - imports={"react": [ImportVar(tag="useRef")]}, - ), + Var( + _js_expr="const hook3 = useRef(null)", + _var_data=VarData(imports={"react": [ImportVar(tag="useRef")]}), ), ] @@ -2101,7 +2151,7 @@ class TriggerState(rx.State): rx.text("random text", on_click=TriggerState.do_something), rx.text( "random text", - on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain), + on_click=Var(_js_expr="toggleColorMode", _var_type=EventChain), ), ), True, @@ -2111,7 +2161,7 @@ class TriggerState(rx.State): rx.text("random text", on_click=rx.console_log("log")), rx.text( "random text", - on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain), + on_click=Var(_js_expr="toggleColorMode", _var_type=EventChain), ), ), False, diff --git a/tests/components/test_tag.py b/tests/components/test_tag.py index d43f73842..c41246e3f 100644 --- a/tests/components/test_tag.py +++ b/tests/components/test_tag.py @@ -3,8 +3,7 @@ from typing import Dict, List import pytest from reflex.components.tags import CondTag, Tag, tagless -from reflex.ivars.base import LiteralVar -from reflex.vars import BaseVar, Var +from reflex.vars.base import LiteralVar, Var @pytest.mark.parametrize( @@ -111,7 +110,7 @@ def test_format_cond_tag(): tag = CondTag( true_value=dict(Tag(name="h1", contents="True content")), false_value=dict(Tag(name="h2", contents="False content")), - cond=BaseVar(_var_name="logged_in", _var_type=bool), + cond=Var(_js_expr="logged_in", _var_type=bool), ) tag_dict = dict(tag) cond, true_value, false_value = ( @@ -119,7 +118,7 @@ def test_format_cond_tag(): tag_dict["true_value"], tag_dict["false_value"], ) - assert cond._var_name == "logged_in" + assert cond._js_expr == "logged_in" assert cond._var_type == bool assert true_value["name"] == "h1" diff --git a/tests/components/typography/test_markdown.py b/tests/components/typography/test_markdown.py index 2ef6fbce4..5e9abbb1f 100644 --- a/tests/components/typography/test_markdown.py +++ b/tests/components/typography/test_markdown.py @@ -1,5 +1,4 @@ import pytest -import reflex_chakra as rc import reflex as rx from reflex.components.markdown import Markdown @@ -37,9 +36,7 @@ def test_get_component(tag, expected): def test_set_component_map(): """Test setting the component map.""" component_map = { - "h1": lambda value: rx.box( - rc.heading(value, as_="h1", size="2xl"), padding="1em" - ), + "h1": lambda value: rx.box(rx.heading(value, as_="h1"), padding="1em"), "p": lambda value: rx.box(rx.text(value), padding="1em"), } md = Markdown.create("# Hello", component_map=component_map) diff --git a/tests/test_app.py b/tests/test_app.py index 6c5a63dd4..0e9474ef6 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,5 +1,6 @@ from __future__ import annotations +import dataclasses import functools import io import json @@ -13,7 +14,6 @@ from typing import Generator, List, Tuple, Type from unittest.mock import AsyncMock import pytest -import reflex_chakra as rc import sqlmodel from fastapi import FastAPI, UploadFile from starlette_admin.auth import AuthProvider @@ -42,6 +42,7 @@ from reflex.state import ( OnLoadInternalState, RouterData, State, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateUpdate, @@ -49,7 +50,7 @@ from reflex.state import ( ) from reflex.style import Style from reflex.utils import exceptions, format -from reflex.vars import computed_var +from reflex.vars.base import computed_var from .conftest import chdir from .states import ( @@ -68,7 +69,7 @@ class EmptyState(BaseState): @pytest.fixture -def index_page(): +def index_page() -> ComponentCallable: """An index page. Returns: @@ -82,7 +83,7 @@ def index_page(): @pytest.fixture -def about_page(): +def about_page() -> ComponentCallable: """An about page. Returns: @@ -271,8 +272,6 @@ def test_add_page_set_route_dynamic(index_page, windows_platform: bool): app = App(state=EmptyState) assert app.state is not None route = "/test/[dynamic]" - if windows_platform: - route.lstrip("/").replace("/", "\\") assert app.unevaluated_pages == {} app.add_page(index_page, route=route) app._compile_page("test/[dynamic]") @@ -910,7 +909,7 @@ class DynamicState(BaseState): """Increment the counter var.""" self.counter = self.counter + 1 - @computed_var + @computed_var(cache=True) def comp_dynamic(self) -> str: """A computed var that depends on the dynamic var. @@ -923,9 +922,57 @@ class DynamicState(BaseState): on_load_internal = OnLoadInternalState.on_load_internal.fn +def test_dynamic_arg_shadow( + index_page: ComponentCallable, + windows_platform: bool, + token: str, + app_module_mock: unittest.mock.Mock, + mocker, +): + """Create app with dynamic route var and try to add a page with a dynamic arg that shadows a state var. + + Args: + index_page: The index page. + windows_platform: Whether the system is windows. + token: a Token. + app_module_mock: Mocked app module. + mocker: pytest mocker object. + """ + arg_name = "counter" + route = f"/test/[{arg_name}]" + app = app_module_mock.app = App(state=DynamicState) + assert app.state is not None + with pytest.raises(NameError): + app.add_page(index_page, route=route, on_load=DynamicState.on_load) # type: ignore + + +def test_multiple_dynamic_args( + index_page: ComponentCallable, + windows_platform: bool, + token: str, + app_module_mock: unittest.mock.Mock, + mocker, +): + """Create app with multiple dynamic route vars with the same name. + + Args: + index_page: The index page. + windows_platform: Whether the system is windows. + token: a Token. + app_module_mock: Mocked app module. + mocker: pytest mocker object. + """ + arg_name = "my_arg" + route = f"/test/[{arg_name}]" + route2 = f"/test2/[{arg_name}]" + app = app_module_mock.app = App(state=EmptyState) + app.add_page(index_page, route=route) + app.add_page(index_page, route=route2) + + @pytest.mark.asyncio async def test_dynamic_route_var_route_change_completed_on_load( - index_page, + index_page: ComponentCallable, windows_platform: bool, token: str, app_module_mock: unittest.mock.Mock, @@ -945,8 +992,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( """ arg_name = "dynamic" route = f"/test/[{arg_name}]" - if windows_platform: - route.lstrip("/").replace("/", "\\") app = app_module_mock.app = App(state=DynamicState) assert app.state is not None assert arg_name not in app.state.vars @@ -1013,7 +1058,7 @@ async def test_dynamic_route_var_route_change_completed_on_load( f"comp_{arg_name}": exp_val, constants.CompileVars.IS_HYDRATED: False, # "side_effect_counter": exp_index, - "router": exp_router, + "router": dataclasses.asdict(exp_router), } }, events=[ @@ -1053,9 +1098,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( assert on_load_update == StateUpdate( delta={ state.get_name(): { - # These computed vars _shouldn't_ be here, because they didn't change - arg_name: exp_val, - f"comp_{arg_name}": exp_val, "loaded": exp_index + 1, }, }, @@ -1077,9 +1119,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( assert on_set_is_hydrated_update == StateUpdate( delta={ state.get_name(): { - # These computed vars _shouldn't_ be here, because they didn't change - arg_name: exp_val, - f"comp_{arg_name}": exp_val, "is_hydrated": True, }, }, @@ -1101,9 +1140,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( assert update == StateUpdate( delta={ state.get_name(): { - # These computed vars _shouldn't_ be here, because they didn't change - f"comp_{arg_name}": exp_val, - arg_name: exp_val, "counter": exp_index + 1, } }, @@ -1281,13 +1317,13 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]): tag = "Fragment1" def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: - return {(99, "Box"): rc.box()} + return {(99, "Box"): rx.box()} class Fragment2(Component): tag = "Fragment2" def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: - return {(50, "Text"): rc.text()} + return {(50, "Text"): rx.text()} class Fragment3(Component): tag = "Fragment3" @@ -1307,19 +1343,17 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]): assert ( "function AppWrap({children}) {" "return (" - "" - "" - "" - "" + "" + '' + "" "" "" "{children}" "" "" - "" - "" - "" - "" + "" + "" + "" ")" "}" ) in "".join(app_js_lines) @@ -1405,7 +1439,9 @@ def test_app_state_manager(): app.state_manager app._enable_state() assert app.state_manager is not None - assert isinstance(app.state_manager, (StateManagerMemory, StateManagerRedis)) + assert isinstance( + app.state_manager, (StateManagerMemory, StateManagerDisk, StateManagerRedis) + ) def test_generate_component(): diff --git a/tests/test_attribute_access_type.py b/tests/test_attribute_access_type.py index 0813a5e62..0d490ec1e 100644 --- a/tests/test_attribute_access_type.py +++ b/tests/test_attribute_access_type.py @@ -94,6 +94,15 @@ class SQLAClass(SQLABase): """ return self.name + @hybrid_property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + class ModelClass(rx.Model): """Test reflex model.""" @@ -125,6 +134,15 @@ class ModelClass(rx.Model): """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + class BaseClass(rx.Base): """Test rx.Base class.""" @@ -156,6 +174,15 @@ class BaseClass(rx.Base): """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + class BareClass: """Bare python class.""" @@ -187,6 +214,15 @@ class BareClass: """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + @attrs.define class AttrClass: @@ -219,6 +255,15 @@ class AttrClass: """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + @pytest.fixture( params=[ @@ -254,6 +299,7 @@ def cls(request: pytest.FixtureRequest) -> type: pytest.param("dict_str_str", Dict[str, str], id="Dict[str, str]"), pytest.param("str_property", str, id="str_property"), pytest.param("str_or_int_property", Union[str, int], id="str_or_int_property"), + pytest.param("first_label", Optional[SQLALabel], id="first_label"), ], ) def test_get_attribute_access_type(cls: type, attr: str, expected: GenericType) -> None: diff --git a/tests/test_event.py b/tests/test_event.py index a484e0a3c..a152c3749 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -4,10 +4,9 @@ import pytest from reflex import event from reflex.event import Event, EventHandler, EventSpec, call_event_handler, fix_events -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.state import BaseState from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var def make_var(value) -> Var: @@ -19,9 +18,7 @@ def make_var(value) -> Var: Returns: The var. """ - var = Var.create(value) - assert var is not None - return var + return Var(_js_expr=value) def test_create_event(): @@ -57,10 +54,10 @@ def test_call_event_handler(): # Test passing vars as args. assert event_spec.handler == handler - assert event_spec.args[0][0].equals(Var.create_safe("arg1")) - assert event_spec.args[0][1].equals(Var.create_safe("first")) - assert event_spec.args[1][0].equals(Var.create_safe("arg2")) - assert event_spec.args[1][1].equals(Var.create_safe("second")) + assert event_spec.args[0][0].equals(Var(_js_expr="arg1")) + assert event_spec.args[0][1].equals(Var(_js_expr="first")) + assert event_spec.args[1][0].equals(Var(_js_expr="arg2")) + assert event_spec.args[1][1].equals(Var(_js_expr="second")) assert ( format.format_event(event_spec) == 'Event("test_fn_with_args", {arg1:first,arg2:second})' @@ -82,9 +79,9 @@ def test_call_event_handler(): ) assert event_spec.handler == handler - assert event_spec.args[0][0].equals(Var.create_safe("arg1")) - assert event_spec.args[0][1].equals(Var.create_safe(first)) - assert event_spec.args[1][0].equals(Var.create_safe("arg2")) + assert event_spec.args[0][0].equals(Var(_js_expr="arg1")) + assert event_spec.args[0][1].equals(LiteralVar.create(first)) + assert event_spec.args[1][0].equals(Var(_js_expr="arg2")) assert event_spec.args[1][1].equals(LiteralVar.create(second)) handler = EventHandler(fn=test_fn_with_args) @@ -109,17 +106,17 @@ def test_call_event_handler_partial(): assert event_spec.handler == handler assert len(event_spec.args) == 1 - assert event_spec.args[0][0].equals(Var.create_safe("arg1")) - assert event_spec.args[0][1].equals(Var.create_safe("first")) + assert event_spec.args[0][0].equals(Var(_js_expr="arg1")) + assert event_spec.args[0][1].equals(Var(_js_expr="first")) assert format.format_event(event_spec) == 'Event("test_fn_with_args", {arg1:first})' assert event_spec2 is not event_spec assert event_spec2.handler == handler assert len(event_spec2.args) == 2 - assert event_spec2.args[0][0].equals(Var.create_safe("arg1")) - assert event_spec2.args[0][1].equals(Var.create_safe("first")) - assert event_spec2.args[1][0].equals(Var.create_safe("arg2")) - assert event_spec2.args[1][1].equals(Var.create_safe("_a2")) + assert event_spec2.args[0][0].equals(Var(_js_expr="arg1")) + assert event_spec2.args[0][1].equals(Var(_js_expr="first")) + assert event_spec2.args[1][0].equals(Var(_js_expr="arg2")) + assert event_spec2.args[1][1].equals(Var(_js_expr="_a2", _var_type=str)) assert ( format.format_event(event_spec2) == 'Event("test_fn_with_args", {arg1:first,arg2:_a2})' @@ -171,7 +168,7 @@ def test_fix_events(arg1, arg2): 'Event("_redirect", {path:"/path",external:false,replace:false})', ), ( - (Var.create_safe("path"), None, None), + (Var(_js_expr="path"), None, None), 'Event("_redirect", {path:path,external:false,replace:false})', ), ( @@ -202,8 +199,8 @@ def test_event_redirect(input, output): assert spec.handler.fn.__qualname__ == "_redirect" # this asserts need comment about what it's testing (they fail with Var as input) - # assert spec.args[0][0].equals(Var.create_safe("path")) - # assert spec.args[0][1].equals(Var.create_safe("/path")) + # assert spec.args[0][0].equals(Var(_js_expr="path")) + # assert spec.args[0][1].equals(Var(_js_expr="/path")) assert format.format_event(spec) == output @@ -213,10 +210,10 @@ def test_event_console_log(): spec = event.console_log("message") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_console" - assert spec.args[0][0].equals(ImmutableVar(_var_name="message", _var_type=str)) + assert spec.args[0][0].equals(Var(_js_expr="message")) assert spec.args[0][1].equals(LiteralVar.create("message")) assert format.format_event(spec) == 'Event("_console", {message:"message"})' - spec = event.console_log(ImmutableVar.create_safe("message")) + spec = event.console_log(Var(_js_expr="message")) assert format.format_event(spec) == 'Event("_console", {message:message})' @@ -225,10 +222,10 @@ def test_event_window_alert(): spec = event.window_alert("message") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_alert" - assert spec.args[0][0].equals(ImmutableVar(_var_name="message", _var_type=str)) + assert spec.args[0][0].equals(Var(_js_expr="message")) assert spec.args[0][1].equals(LiteralVar.create("message")) assert format.format_event(spec) == 'Event("_alert", {message:"message"})' - spec = event.window_alert(ImmutableVar.create_safe("message")) + spec = event.window_alert(Var(_js_expr="message")) assert format.format_event(spec) == 'Event("_alert", {message:message})' @@ -237,7 +234,7 @@ def test_set_focus(): spec = event.set_focus("input1") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_set_focus" - assert spec.args[0][0].equals(Var.create_safe("ref")) + assert spec.args[0][0].equals(Var(_js_expr="ref")) assert spec.args[0][1].equals(LiteralVar.create("ref_input1")) assert format.format_event(spec) == 'Event("_set_focus", {ref:"ref_input1"})' spec = event.set_focus("input1") @@ -249,14 +246,14 @@ def test_set_value(): spec = event.set_value("input1", "") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_set_value" - assert spec.args[0][0].equals(Var.create_safe("ref")) + assert spec.args[0][0].equals(Var(_js_expr="ref")) assert spec.args[0][1].equals(LiteralVar.create("ref_input1")) - assert spec.args[1][0].equals(Var.create_safe("value")) + assert spec.args[1][0].equals(Var(_js_expr="value")) assert spec.args[1][1].equals(LiteralVar.create("")) assert ( format.format_event(spec) == 'Event("_set_value", {ref:"ref_input1",value:""})' ) - spec = event.set_value("input1", ImmutableVar.create_safe("message")) + spec = event.set_value("input1", Var(_js_expr="message")) assert ( format.format_event(spec) == 'Event("_set_value", {ref:"ref_input1",value:message})' @@ -268,9 +265,9 @@ def test_remove_cookie(): spec = event.remove_cookie("testkey") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_remove_cookie" - assert spec.args[0][0].equals(Var.create_safe("key")) + assert spec.args[0][0].equals(Var(_js_expr="key")) assert spec.args[0][1].equals(LiteralVar.create("testkey")) - assert spec.args[1][0].equals(Var.create_safe("options")) + assert spec.args[1][0].equals(Var(_js_expr="options")) assert spec.args[1][1].equals(LiteralVar.create({"path": "/"})) assert ( format.format_event(spec) @@ -289,9 +286,9 @@ def test_remove_cookie_with_options(): spec = event.remove_cookie("testkey", options) assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_remove_cookie" - assert spec.args[0][0].equals(Var.create_safe("key")) + assert spec.args[0][0].equals(Var(_js_expr="key")) assert spec.args[0][1].equals(LiteralVar.create("testkey")) - assert spec.args[1][0].equals(Var.create_safe("options")) + assert spec.args[1][0].equals(Var(_js_expr="options")) assert spec.args[1][1].equals(LiteralVar.create(options)) assert ( format.format_event(spec) @@ -313,7 +310,7 @@ def test_remove_local_storage(): spec = event.remove_local_storage("testkey") assert isinstance(spec, EventSpec) assert spec.handler.fn.__qualname__ == "_remove_local_storage" - assert spec.args[0][0].equals(Var.create_safe("key")) + assert spec.args[0][0].equals(Var(_js_expr="key")) assert spec.args[0][1].equals(LiteralVar.create("testkey")) assert ( format.format_event(spec) == 'Event("_remove_local_storage", {key:"testkey"})' diff --git a/tests/test_health_endpoint.py b/tests/test_health_endpoint.py new file mode 100644 index 000000000..fe350266f --- /dev/null +++ b/tests/test_health_endpoint.py @@ -0,0 +1,106 @@ +import json +from unittest.mock import MagicMock, Mock + +import pytest +import sqlalchemy +from redis.exceptions import RedisError + +from reflex.app import health +from reflex.model import get_db_status +from reflex.utils.prerequisites import get_redis_status + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "mock_redis_client, expected_status", + [ + # Case 1: Redis client is available and responds to ping + (Mock(ping=lambda: None), True), + # Case 2: Redis client raises RedisError + (Mock(ping=lambda: (_ for _ in ()).throw(RedisError)), False), + # Case 3: Redis client is not used + (None, None), + ], +) +async def test_get_redis_status(mock_redis_client, expected_status, mocker): + # Mock the `get_redis_sync` function to return the mock Redis client + mock_get_redis_sync = mocker.patch( + "reflex.utils.prerequisites.get_redis_sync", return_value=mock_redis_client + ) + + # Call the function + status = await get_redis_status() + + # Verify the result + assert status == expected_status + mock_get_redis_sync.assert_called_once() + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "mock_engine, execute_side_effect, expected_status", + [ + # Case 1: Database is accessible + (MagicMock(), None, True), + # Case 2: Database connection error (OperationalError) + ( + MagicMock(), + sqlalchemy.exc.OperationalError("error", "error", "error"), + False, + ), + ], +) +async def test_get_db_status(mock_engine, execute_side_effect, expected_status, mocker): + # Mock get_engine to return the mock_engine + mock_get_engine = mocker.patch("reflex.model.get_engine", return_value=mock_engine) + + # Mock the connection and its execute method + if mock_engine: + mock_connection = mock_engine.connect.return_value.__enter__.return_value + if execute_side_effect: + # Simulate execute method raising an exception + mock_connection.execute.side_effect = execute_side_effect + else: + # Simulate successful execute call + mock_connection.execute.return_value = None + + # Call the function + status = await get_db_status() + + # Verify the result + assert status == expected_status + mock_get_engine.assert_called_once() + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "db_status, redis_status, expected_status, expected_code", + [ + # Case 1: Both services are connected + (True, True, {"status": True, "db": True, "redis": True}, 200), + # Case 2: Database not connected, Redis connected + (False, True, {"status": False, "db": False, "redis": True}, 503), + # Case 3: Database connected, Redis not connected + (True, False, {"status": False, "db": True, "redis": False}, 503), + # Case 4: Both services not connected + (False, False, {"status": False, "db": False, "redis": False}, 503), + # Case 5: Database Connected, Redis not used + (True, None, {"status": True, "db": True, "redis": False}, 200), + ], +) +async def test_health(db_status, redis_status, expected_status, expected_code, mocker): + # Mock get_db_status and get_redis_status + mocker.patch("reflex.app.get_db_status", return_value=db_status) + mocker.patch( + "reflex.utils.prerequisites.get_redis_status", return_value=redis_status + ) + + # Call the async health function + response = await health() + + print(json.loads(response.body)) + print(expected_status) + + # Verify the response content and status code + assert response.status_code == expected_code + assert json.loads(response.body) == expected_status diff --git a/tests/test_page.py b/tests/test_page.py new file mode 100644 index 000000000..9cbd2886d --- /dev/null +++ b/tests/test_page.py @@ -0,0 +1,50 @@ +from reflex import text +from reflex.config import get_config +from reflex.page import DECORATED_PAGES, page + + +def test_page_decorator(): + def foo_(): + return text("foo") + + assert len(DECORATED_PAGES) == 0 + decorated_foo_ = page()(foo_) + assert decorated_foo_ == foo_ + assert len(DECORATED_PAGES) == 1 + page_data = DECORATED_PAGES.get(get_config().app_name, [])[0][1] + assert page_data == {} + DECORATED_PAGES.clear() + + +def test_page_decorator_with_kwargs(): + def foo_(): + return text("foo") + + def load_foo(): + return [] + + DECORATED_PAGES.clear() + assert len(DECORATED_PAGES) == 0 + decorated_foo_ = page( + route="foo", + title="Foo", + image="foo.png", + description="Foo description", + meta=["foo-meta"], + script_tags=["foo-script"], + on_load=load_foo, + )(foo_) + assert decorated_foo_ == foo_ + assert len(DECORATED_PAGES) == 1 + page_data = DECORATED_PAGES.get(get_config().app_name, [])[0][1] + assert page_data == { + "description": "Foo description", + "image": "foo.png", + "meta": ["foo-meta"], + "on_load": load_foo, + "route": "foo", + "script_tags": ["foo-script"], + "title": "Foo", + } + + DECORATED_PAGES.clear() diff --git a/tests/test_state.py b/tests/test_state.py index d34e771cb..21584fff9 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio import copy +import dataclasses import datetime import functools import json @@ -31,6 +32,7 @@ from reflex.state import ( RouterData, State, StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateProxy, @@ -40,7 +42,7 @@ from reflex.state import ( from reflex.testing import chdir from reflex.utils import format, prerequisites, types from reflex.utils.format import json_dumps -from reflex.vars import BaseVar, ComputedVar, Var +from reflex.vars.base import ComputedVar, Var from tests.states.mutation import MutableSQLAModel, MutableTestState from .states import GenState @@ -57,6 +59,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -267,7 +270,7 @@ def test_base_class_vars(test_state): continue prop = getattr(cls, field) assert isinstance(prop, Var) - assert prop._var_name.split(".")[-1] == field + assert prop._js_expr.split(".")[-1] == field assert cls.num1._var_type == int assert cls.num2._var_type == float @@ -281,7 +284,7 @@ def test_computed_class_var(test_state): test_state: A state. """ cls = type(test_state) - vars = [(prop._var_name, prop._var_type) for prop in cls.computed_vars.values()] + vars = [(prop._js_expr, prop._var_type) for prop in cls.computed_vars.values()] assert ("sum", float) in vars assert ("upper", str) in vars @@ -516,11 +519,9 @@ def test_set_class_var(): """Test setting the var of a class.""" with pytest.raises(AttributeError): TestState.num3 # type: ignore - TestState._set_var( - BaseVar(_var_name="num3", _var_type=int)._var_set_state(TestState) - ) + TestState._set_var(Var(_js_expr="num3", _var_type=int)._var_set_state(TestState)) var = TestState.num3 # type: ignore - assert var._var_name == "num3" + assert var._js_expr == TestState.get_full_name() + ".num3" assert var._var_type == int assert var._var_state == TestState.get_full_name() @@ -648,7 +649,12 @@ def test_set_dirty_var(test_state): assert test_state.dirty_vars == set() -def test_set_dirty_substate(test_state, child_state, child_state2, grandchild_state): +def test_set_dirty_substate( + test_state: TestState, + child_state: ChildState, + child_state2: ChildState2, + grandchild_state: GrandchildState, +): """Test changing substate vars marks the value as dirty. Args: @@ -859,8 +865,10 @@ def test_get_headers(test_state, router_data, router_data_headers): router_data: The router data fixture. router_data_headers: The expected headers. """ + print(router_data_headers) test_state.router = RouterData(router_data) - assert test_state.router.headers.dict() == { + print(test_state.router.headers) + assert dataclasses.asdict(test_state.router.headers) == { format.to_snake_case(k): v for k, v in router_data_headers.items() } @@ -1586,7 +1594,7 @@ async def test_state_with_invalid_yield(capsys, mock_app): assert "must only return/yield: None, Events or other EventHandlers" in captured.out -@pytest.fixture(scope="function", params=["in_process", "redis"]) +@pytest.fixture(scope="function", params=["in_process", "disk", "redis"]) def state_manager(request) -> Generator[StateManager, None, None]: """Instance of state manager parametrized for redis and in-process. @@ -1600,8 +1608,11 @@ def state_manager(request) -> Generator[StateManager, None, None]: if request.param == "redis": if not isinstance(state_manager, StateManagerRedis): pytest.skip("Test requires redis") - else: + elif request.param == "disk": # explicitly NOT using redis + state_manager = StateManagerDisk(state=TestState) + assert not state_manager._states_locks + else: state_manager = StateManagerMemory(state=TestState) assert not state_manager._states_locks @@ -1639,7 +1650,7 @@ async def test_state_manager_modify_state( async with state_manager.modify_state(substate_token) as state: if isinstance(state_manager, StateManagerRedis): assert await state_manager.redis.get(f"{token}_lock") - elif isinstance(state_manager, StateManagerMemory): + elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)): assert token in state_manager._states_locks assert state_manager._states_locks[token].locked() # Should be able to write proxy objects inside mutables @@ -1649,11 +1660,11 @@ async def test_state_manager_modify_state( # lock should be dropped after exiting the context if isinstance(state_manager, StateManagerRedis): assert (await state_manager.redis.get(f"{token}_lock")) is None - elif isinstance(state_manager, StateManagerMemory): + elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)): assert not state_manager._states_locks[token].locked() # separate instances should NOT share locks - sm2 = StateManagerMemory(state=TestState) + sm2 = state_manager.__class__(state=TestState) assert sm2._state_manager_lock is state_manager._state_manager_lock assert not sm2._states_locks if state_manager._states_locks: @@ -1691,7 +1702,7 @@ async def test_state_manager_contend( if isinstance(state_manager, StateManagerRedis): assert (await state_manager.redis.get(f"{token}_lock")) is None - elif isinstance(state_manager, StateManagerMemory): + elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)): assert token in state_manager._states_locks assert not state_manager._states_locks[token].locked() @@ -1831,7 +1842,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): assert child_state is not None parent_state = child_state.parent_state assert parent_state is not None - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): mock_app.state_manager.states[parent_state.router.session.client_token] = ( parent_state ) @@ -1874,7 +1885,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): # For in-process store, only one instance of the state exists assert sp.__wrapped__ is grandchild_state else: - # When redis is used, a new+updated instance is assigned to the proxy + # When redis or disk is used, a new+updated instance is assigned to the proxy assert sp.__wrapped__ is not grandchild_state sp.value2 = "42" assert not sp._self_mutable # proxy is not mutable after exiting context @@ -1899,19 +1910,21 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): mock_app.event_namespace.emit.assert_called_once() mcall = mock_app.event_namespace.emit.mock_calls[0] assert mcall.args[0] == str(SocketEvent.EVENT) - assert json.loads(mcall.args[1]) == StateUpdate( - delta={ - parent_state.get_full_name(): { - "upper": "", - "sum": 3.14, - }, - grandchild_state.get_full_name(): { - "value2": "42", - }, - GrandchildState3.get_full_name(): { - "computed": "", - }, - } + assert json.loads(mcall.args[1]) == dataclasses.asdict( + StateUpdate( + delta={ + parent_state.get_full_name(): { + "upper": "", + "sum": 3.14, + }, + grandchild_state.get_full_name(): { + "value2": "42", + }, + GrandchildState3.get_full_name(): { + "computed": "", + }, + } + ) ) assert mcall.kwargs["to"] == grandchild_state.router.session.session_id @@ -2507,7 +2520,7 @@ def test_json_dumps_with_mutables(): items: List[Foo] = [Foo()] dict_val = MutableContainsBase().dict() - assert isinstance(dict_val[MutableContainsBase.get_full_name()]["items"][0], dict) + assert isinstance(dict_val[MutableContainsBase.get_full_name()]["items"][0], Foo) val = json_dumps(dict_val) f_items = '[{"tags": ["123", "456"]}]' f_formatted_router = str(formatted_router).replace("'", '"') @@ -2837,7 +2850,7 @@ async def test_get_state(mock_app: rx.App, token: str): _substate_key(token, ChildState2) ) assert isinstance(test_state, TestState) - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): # All substates are available assert tuple(sorted(test_state.substates)) == ( ChildState.get_name(), @@ -2916,6 +2929,15 @@ async def test_get_state(mock_app: rx.App, token: str): ChildState2.get_name(), ChildState3.get_name(), ) + elif isinstance(mock_app.state_manager, StateManagerDisk): + # On disk, it's a new instance + assert new_test_state is not test_state + # All substates are available + assert tuple(sorted(new_test_state.substates)) == ( + ChildState.get_name(), + ChildState2.get_name(), + ChildState3.get_name(), + ) else: # With redis, we get a whole new instance assert new_test_state is not test_state @@ -3064,6 +3086,51 @@ def test_potentially_dirty_substates(): assert C1._potentially_dirty_substates() == set() +def test_router_var_dep() -> None: + """Test that router var dependencies are correctly tracked.""" + + class RouterVarParentState(State): + """A parent state for testing router var dependency.""" + + pass + + class RouterVarDepState(RouterVarParentState): + """A state with a router var dependency.""" + + @rx.var(cache=True) + def foo(self) -> str: + return self.router.page.params.get("foo", "") + + foo = RouterVarDepState.computed_vars["foo"] + State._init_var_dependency_dicts() + + assert foo._deps(objclass=RouterVarDepState) == {"router"} + assert RouterVarParentState._potentially_dirty_substates() == {RouterVarDepState} + assert RouterVarParentState._substate_var_dependencies == { + "router": {RouterVarDepState.get_name()} + } + assert RouterVarDepState._computed_var_dependencies == { + "router": {"foo"}, + } + + rx_state = State() + parent_state = RouterVarParentState() + state = RouterVarDepState() + + # link states + rx_state.substates = {RouterVarParentState.get_name(): parent_state} + parent_state.parent_state = rx_state + state.parent_state = parent_state + parent_state.substates = {RouterVarDepState.get_name(): state} + + assert state.dirty_vars == set() + + # Reassign router var + state.router = state.router + assert state.dirty_vars == {"foo", "router"} + assert parent_state.dirty_substates == {RouterVarDepState.get_name()} + + @pytest.mark.asyncio async def test_setvar(mock_app: rx.App, token: str): """Test that setvar works correctly. @@ -3148,6 +3215,15 @@ class MixinState(State, mixin=True): num: int = 0 _backend: int = 0 + @rx.var(cache=True) + def computed(self) -> str: + """A computed var on mixin state. + + Returns: + A computed value. + """ + return "" + class UsesMixinState(MixinState, State): """A state that uses the mixin state.""" @@ -3155,8 +3231,26 @@ class UsesMixinState(MixinState, State): pass +class ChildUsesMixinState(UsesMixinState): + """A child state that uses the mixin state.""" + + pass + + def test_mixin_state() -> None: """Test that a mixin state works correctly.""" assert "num" in UsesMixinState.base_vars assert "num" in UsesMixinState.vars assert UsesMixinState.backend_vars == {"_backend": 0} + + assert "computed" in UsesMixinState.computed_vars + assert "computed" in UsesMixinState.vars + + +def test_child_mixin_state() -> None: + """Test that mixin vars are only applied to the highest state in the hierarchy.""" + assert "num" in ChildUsesMixinState.inherited_vars + assert "num" not in ChildUsesMixinState.base_vars + + assert "computed" in ChildUsesMixinState.inherited_vars + assert "computed" not in ChildUsesMixinState.computed_vars diff --git a/tests/test_style.py b/tests/test_style.py index 8fa443cdf..19106df75 100644 --- a/tests/test_style.py +++ b/tests/test_style.py @@ -7,9 +7,9 @@ import pytest import reflex as rx from reflex import style from reflex.components.component import evaluate_style_namespaces -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style -from reflex.vars import ImmutableVarData, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var test_style = [ ({"a": 1}, {"a": 1}), @@ -377,8 +377,8 @@ class StyleState(rx.State): ( {"color": f"dark{StyleState.color}"}, { - "css": ImmutableVar.create_safe( - f'({{ ["color"] : ("dark"+{StyleState.color}) }})' + "css": Var( + _js_expr=f'({{ ["color"] : ("dark"+{StyleState.color}) }})' ).to(Dict[str, str]) }, ), @@ -504,7 +504,7 @@ def test_style_via_component_with_state( comp = rx.el.div(**kwargs) assert ( - ImmutableVarData.merge(comp.style._var_data) + VarData.merge(comp.style._var_data) == expected_get_style["css"]._get_all_var_data() ) # Assert that style values are equal. diff --git a/tests/test_var.py b/tests/test_var.py index cca6cbec4..e9998c456 100644 --- a/tests/test_var.py +++ b/tests/test_var.py @@ -1,50 +1,46 @@ import json import math import typing -from typing import Dict, List, Set, Tuple, Union +from typing import Dict, List, Optional, Set, Tuple, Union, cast import pytest from pandas import DataFrame +import reflex as rx from reflex.base import Base from reflex.constants.base import REFLEX_VAR_CLOSING_TAG, REFLEX_VAR_OPENING_TAG -from reflex.ivars.base import ( - ImmutableVar, +from reflex.state import BaseState +from reflex.utils.exceptions import PrimitiveUnserializableToJSON +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import ( + ComputedVar, LiteralVar, + Var, + computed_var, var_operation, + var_operation_return, ) -from reflex.ivars.function import ArgsFunctionOperation, FunctionStringVar -from reflex.ivars.number import ( +from reflex.vars.function import ArgsFunctionOperation, FunctionStringVar +from reflex.vars.number import ( LiteralBooleanVar, LiteralNumberVar, NumberVar, ) -from reflex.ivars.object import LiteralObjectVar -from reflex.ivars.sequence import ( +from reflex.vars.object import LiteralObjectVar, ObjectVar +from reflex.vars.sequence import ( ArrayVar, ConcatVarOperation, LiteralArrayVar, LiteralStringVar, ) -from reflex.state import BaseState -from reflex.utils.imports import ImportVar -from reflex.vars import ( - BaseVar, - ComputedVar, - ImmutableVarData, - Var, - VarData, - computed_var, -) test_vars = [ - BaseVar(_var_name="prop1", _var_type=int), - BaseVar(_var_name="key", _var_type=str), - BaseVar(_var_name="value", _var_type=str)._var_set_state("state"), - BaseVar(_var_name="local", _var_type=str, _var_is_local=True)._var_set_state( - "state" - ), - BaseVar(_var_name="local2", _var_type=str, _var_is_local=True), + Var(_js_expr="prop1", _var_type=int), + Var(_js_expr="key", _var_type=str), + Var(_js_expr="value", _var_type=str)._var_set_state("state"), + Var(_js_expr="local", _var_type=str)._var_set_state("state"), + Var(_js_expr="local2", _var_type=str), ] @@ -82,6 +78,11 @@ def ChildState(ParentState, TestObj): class ChildState(ParentState): @computed_var def var_without_annotation(self): + """This shadows ParentState.var_without_annotation. + + Returns: + TestObj: Test object. + """ return TestObj return ChildState @@ -92,6 +93,11 @@ def GrandChildState(ChildState, TestObj): class GrandChildState(ChildState): @computed_var def var_without_annotation(self): + """This shadows ChildState.var_without_annotation. + + Returns: + TestObj: Test object. + """ return TestObj return GrandChildState @@ -178,6 +184,7 @@ def ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar): "state.local", "local2", ], + strict=False, ), ) def test_full_name(prop, expected): @@ -187,14 +194,15 @@ def test_full_name(prop, expected): prop: The var to test. expected: The expected full name. """ - assert prop._var_full_name == expected + assert str(prop) == expected @pytest.mark.parametrize( "prop,expected", zip( test_vars, - ["{prop1}", "{key}", "{state.value}", "state.local", "local2"], + ["prop1", "key", "state.value", "state.local", "local2"], + strict=False, ), ) def test_str(prop, expected): @@ -210,14 +218,14 @@ def test_str(prop, expected): @pytest.mark.parametrize( "prop,expected", [ - (BaseVar(_var_name="p", _var_type=int), 0), - (BaseVar(_var_name="p", _var_type=float), 0.0), - (BaseVar(_var_name="p", _var_type=str), ""), - (BaseVar(_var_name="p", _var_type=bool), False), - (BaseVar(_var_name="p", _var_type=list), []), - (BaseVar(_var_name="p", _var_type=dict), {}), - (BaseVar(_var_name="p", _var_type=tuple), ()), - (BaseVar(_var_name="p", _var_type=set), set()), + (Var(_js_expr="p", _var_type=int), 0), + (Var(_js_expr="p", _var_type=float), 0.0), + (Var(_js_expr="p", _var_type=str), ""), + (Var(_js_expr="p", _var_type=bool), False), + (Var(_js_expr="p", _var_type=list), []), + (Var(_js_expr="p", _var_type=dict), {}), + (Var(_js_expr="p", _var_type=tuple), ()), + (Var(_js_expr="p", _var_type=set), set()), ], ) def test_default_value(prop, expected): @@ -241,6 +249,7 @@ def test_default_value(prop, expected): "state.set_local", "set_local2", ], + strict=False, ), ) def test_get_setter(prop, expected): @@ -256,14 +265,14 @@ def test_get_setter(prop, expected): @pytest.mark.parametrize( "value,expected", [ - (None, None), - (1, BaseVar(_var_name="1", _var_type=int, _var_is_local=True)), - ("key", BaseVar(_var_name="key", _var_type=str, _var_is_local=True)), - (3.14, BaseVar(_var_name="3.14", _var_type=float, _var_is_local=True)), - ([1, 2, 3], BaseVar(_var_name="[1, 2, 3]", _var_type=list, _var_is_local=True)), + (None, Var(_js_expr="null", _var_type=None)), + (1, Var(_js_expr="1", _var_type=int)), + ("key", Var(_js_expr='"key"', _var_type=str)), + (3.14, Var(_js_expr="3.14", _var_type=float)), + ([1, 2, 3], Var(_js_expr="[1, 2, 3]", _var_type=List[int])), ( {"a": 1, "b": 2}, - BaseVar(_var_name='{"a": 1, "b": 2}', _var_type=dict, _var_is_local=True), + Var(_js_expr='({ ["a"] : 1, ["b"] : 2 })', _var_type=Dict[str, int]), ), ], ) @@ -274,11 +283,8 @@ def test_create(value, expected): value: The value to create a var from. expected: The expected name of the setter function. """ - prop = Var.create(value) - if value is None: - assert prop == expected - else: - assert prop.equals(expected) # type: ignore + prop = LiteralVar.create(value) + assert prop.equals(expected) # type: ignore def test_create_type_error(): @@ -290,17 +296,11 @@ def test_create_type_error(): value = ErrorType() with pytest.raises(TypeError): - Var.create(value) + LiteralVar.create(value) def v(value) -> Var: - val = ( - Var.create(json.dumps(value), _var_is_string=True, _var_is_local=False) - if isinstance(value, str) - else Var.create(value, _var_is_local=False) - ) - assert val is not None - return val + return LiteralVar.create(value) def test_basic_operations(TestObj): @@ -309,130 +309,65 @@ def test_basic_operations(TestObj): Args: TestObj: The test object. """ - assert str(v(1) == v(2)) == "{((1) === (2))}" - assert str(v(1) != v(2)) == "{((1) !== (2))}" - assert str(v(1) < v(2)) == "{((1) < (2))}" - assert str(v(1) <= v(2)) == "{((1) <= (2))}" - assert str(v(1) > v(2)) == "{((1) > (2))}" - assert str(v(1) >= v(2)) == "{((1) >= (2))}" - assert str(v(1) + v(2)) == "{((1) + (2))}" - assert str(v(1) - v(2)) == "{((1) - (2))}" - assert str(v(1) * v(2)) == "{((1) * (2))}" - assert str(v(1) / v(2)) == "{((1) / (2))}" - assert str(v(1) // v(2)) == "{Math.floor((1) / (2))}" - assert str(v(1) % v(2)) == "{((1) % (2))}" - assert str(v(1) ** v(2)) == "{Math.pow((1) , (2))}" - assert str(v(1) & v(2)) == "{((1) && (2))}" - assert str(v(1) | v(2)) == "{((1) || (2))}" - assert str(v([1, 2, 3])[v(0)]) == "{[1, 2, 3].at(0)}" - assert str(v({"a": 1, "b": 2})["a"]) == '{{"a": 1, "b": 2}["a"]}' - assert str(v("foo") == v("bar")) == '{(("foo") === ("bar"))}' + assert str(v(1) == v(2)) == "(1 === 2)" + assert str(v(1) != v(2)) == "(1 !== 2)" + assert str(LiteralNumberVar.create(1) < 2) == "(1 < 2)" + assert str(LiteralNumberVar.create(1) <= 2) == "(1 <= 2)" + assert str(LiteralNumberVar.create(1) > 2) == "(1 > 2)" + assert str(LiteralNumberVar.create(1) >= 2) == "(1 >= 2)" + assert str(LiteralNumberVar.create(1) + 2) == "(1 + 2)" + assert str(LiteralNumberVar.create(1) - 2) == "(1 - 2)" + assert str(LiteralNumberVar.create(1) * 2) == "(1 * 2)" + assert str(LiteralNumberVar.create(1) / 2) == "(1 / 2)" + assert str(LiteralNumberVar.create(1) // 2) == "Math.floor(1 / 2)" + assert str(LiteralNumberVar.create(1) % 2) == "(1 % 2)" + assert str(LiteralNumberVar.create(1) ** 2) == "(1 ** 2)" + assert str(LiteralNumberVar.create(1) & v(2)) == "(1 && 2)" + assert str(LiteralNumberVar.create(1) | v(2)) == "(1 || 2)" + assert str(LiteralArrayVar.create([1, 2, 3])[0]) == "[1, 2, 3].at(0)" + assert ( + str(LiteralObjectVar.create({"a": 1, "b": 2})["a"]) + == '({ ["a"] : 1, ["b"] : 2 })["a"]' + ) + assert str(v("foo") == v("bar")) == '("foo" === "bar")' + assert str(Var(_js_expr="foo") == Var(_js_expr="bar")) == "(foo === bar)" + assert ( + str(LiteralVar.create("foo") == LiteralVar.create("bar")) == '("foo" === "bar")' + ) + print(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state")) assert ( str( - Var.create("foo", _var_is_local=False) - == Var.create("bar", _var_is_local=False) + Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar + == LiteralVar.create("bar") ) - == "{((foo) === (bar))}" + == '(state.foo["bar"] === "bar")' ) assert ( - str( - BaseVar( - _var_name="foo", _var_type=str, _var_is_string=True, _var_is_local=True - ) - == BaseVar( - _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True - ) - ) - == "((`foo`) === (`bar`))" + str(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar) + == 'state.foo["bar"]' ) + assert str(abs(LiteralNumberVar.create(1))) == "Math.abs(1)" + assert str(LiteralArrayVar.create([1, 2, 3]).length()) == "[1, 2, 3].length" assert ( - str( - BaseVar( - _var_name="foo", - _var_type=TestObj, - _var_is_string=True, - _var_is_local=False, - ) - ._var_set_state("state") - .bar - == BaseVar( - _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True - ) - ) - == "{((state.foo.bar) === (`bar`))}" + str(LiteralArrayVar.create([1, 2]) + LiteralArrayVar.create([3, 4])) + == "[...[1, 2], ...[3, 4]]" ) - assert ( - str(BaseVar(_var_name="foo", _var_type=TestObj)._var_set_state("state").bar) - == "{state.foo.bar}" - ) - assert str(abs(v(1))) == "{Math.abs(1)}" - assert str(v([1, 2, 3]).length()) == "{[1, 2, 3].length}" - assert str(v([1, 2]) + v([3, 4])) == "{spreadArraysOrObjects(([1, 2]) , ([3, 4]))}" # Tests for reverse operation - assert str(v([1, 2, 3]).reverse()) == "{[...[1, 2, 3]].reverse()}" - assert str(v(["1", "2", "3"]).reverse()) == '{[...["1", "2", "3"]].reverse()}' assert ( - str(BaseVar(_var_name="foo", _var_type=list)._var_set_state("state").reverse()) - == "{[...state.foo].reverse()}" + str(LiteralArrayVar.create([1, 2, 3]).reverse()) + == "[1, 2, 3].slice().reverse()" ) assert ( - str(BaseVar(_var_name="foo", _var_type=list).reverse()) - == "{[...foo].reverse()}" - ) - assert str(BaseVar(_var_name="foo", _var_type=str)._type()) == "{typeof foo}" # type: ignore - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore - == "{((typeof foo) === (`string`))}" + str(LiteralArrayVar.create(["1", "2", "3"]).reverse()) + == '["1", "2", "3"].slice().reverse()' ) assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore - == "{((typeof foo) === (`string`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == int) # type: ignore - == "{((typeof foo) === (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == list) # type: ignore - == "{((typeof foo) === (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == float) # type: ignore - == "{((typeof foo) === (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == tuple) # type: ignore - == "{((typeof foo) === (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == dict) # type: ignore - == "{((typeof foo) === (`Object`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != str) # type: ignore - == "{((typeof foo) !== (`string`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != int) # type: ignore - == "{((typeof foo) !== (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != list) # type: ignore - == "{((typeof foo) !== (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != float) # type: ignore - == "{((typeof foo) !== (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != tuple) # type: ignore - == "{((typeof foo) !== (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != dict) # type: ignore - == "{((typeof foo) !== (`Object`))}" + str(Var(_js_expr="foo")._var_set_state("state").to(list).reverse()) + == "state.foo.slice().reverse()" ) + assert str(Var(_js_expr="foo").to(list).reverse()) == "foo.slice().reverse()" + assert str(Var(_js_expr="foo", _var_type=str).js_type()) == "(typeof(foo))" @pytest.mark.parametrize( @@ -441,76 +376,79 @@ def test_basic_operations(TestObj): (v([1, 2, 3]), "[1, 2, 3]"), (v(set([1, 2, 3])), "[1, 2, 3]"), (v(["1", "2", "3"]), '["1", "2", "3"]'), - (BaseVar(_var_name="foo", _var_type=list)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=list), "foo"), + ( + Var(_js_expr="foo")._var_set_state("state").to(list), + "state.foo", + ), + (Var(_js_expr="foo").to(list), "foo"), (v((1, 2, 3)), "[1, 2, 3]"), (v(("1", "2", "3")), '["1", "2", "3"]'), ( - BaseVar(_var_name="foo", _var_type=tuple)._var_set_state("state"), + Var(_js_expr="foo")._var_set_state("state").to(tuple), "state.foo", ), - (BaseVar(_var_name="foo", _var_type=tuple), "foo"), + (Var(_js_expr="foo").to(tuple), "foo"), ], ) def test_list_tuple_contains(var, expected): - assert str(var.contains(1)) == f"{{{expected}.includes(1)}}" - assert str(var.contains("1")) == f'{{{expected}.includes("1")}}' - assert str(var.contains(v(1))) == f"{{{expected}.includes(1)}}" - assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) - assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}" - assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}" + assert str(var.contains(1)) == f"{expected}.includes(1)" + assert str(var.contains("1")) == f'{expected}.includes("1")' + assert str(var.contains(v(1))) == f"{expected}.includes(1)" + assert str(var.contains(v("1"))) == f'{expected}.includes("1")' + other_state_var = Var(_js_expr="other", _var_type=str)._var_set_state("state") + other_var = Var(_js_expr="other", _var_type=str) + assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)" + assert str(var.contains(other_var)) == f"{expected}.includes(other)" @pytest.mark.parametrize( "var, expected", [ (v("123"), json.dumps("123")), - (BaseVar(_var_name="foo", _var_type=str)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=str), "foo"), + (Var(_js_expr="foo")._var_set_state("state").to(str), "state.foo"), + (Var(_js_expr="foo").to(str), "foo"), ], ) def test_str_contains(var, expected): - assert str(var.contains("1")) == f'{{{expected}.includes("1")}}' - assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) - assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}" - assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}" + assert str(var.contains("1")) == f'{expected}.includes("1")' + assert str(var.contains(v("1"))) == f'{expected}.includes("1")' + other_state_var = Var(_js_expr="other")._var_set_state("state").to(str) + other_var = Var(_js_expr="other").to(str) + assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)" + assert str(var.contains(other_var)) == f"{expected}.includes(other)" assert ( - str(var.contains("1", "hello")) == f'{{{expected}.some(e=>e[`hello`]==="1")}}' + str(var.contains("1", "hello")) + == f'{expected}.some(obj => obj["hello"] === "1")' ) @pytest.mark.parametrize( "var, expected", [ - (v({"a": 1, "b": 2}), '{"a": 1, "b": 2}'), - (BaseVar(_var_name="foo", _var_type=dict)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=dict), "foo"), + (v({"a": 1, "b": 2}), '({ ["a"] : 1, ["b"] : 2 })'), + (Var(_js_expr="foo")._var_set_state("state").to(dict), "state.foo"), + (Var(_js_expr="foo").to(dict), "foo"), ], ) def test_dict_contains(var, expected): - assert str(var.contains(1)) == f"{{{expected}.hasOwnProperty(1)}}" - assert str(var.contains("1")) == f'{{{expected}.hasOwnProperty("1")}}' - assert str(var.contains(v(1))) == f"{{{expected}.hasOwnProperty(1)}}" - assert str(var.contains(v("1"))) == f'{{{expected}.hasOwnProperty("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) + assert str(var.contains(1)) == f"{expected}.hasOwnProperty(1)" + assert str(var.contains("1")) == f'{expected}.hasOwnProperty("1")' + assert str(var.contains(v(1))) == f"{expected}.hasOwnProperty(1)" + assert str(var.contains(v("1"))) == f'{expected}.hasOwnProperty("1")' + other_state_var = Var(_js_expr="other")._var_set_state("state").to(str) + other_var = Var(_js_expr="other").to(str) assert ( - str(var.contains(other_state_var)) - == f"{{{expected}.hasOwnProperty(state.other)}}" + str(var.contains(other_state_var)) == f"{expected}.hasOwnProperty(state.other)" ) - assert str(var.contains(other_var)) == f"{{{expected}.hasOwnProperty(other)}}" + assert str(var.contains(other_var)) == f"{expected}.hasOwnProperty(other)" @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="list", _var_type=List[int]), - BaseVar(_var_name="tuple", _var_type=Tuple[int, int]), - BaseVar(_var_name="str", _var_type=str), + Var(_js_expr="list", _var_type=List[int]).guess_type(), + Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), + Var(_js_expr="str", _var_type=str).guess_type(), ], ) def test_var_indexing_lists(var): @@ -520,18 +458,21 @@ def test_var_indexing_lists(var): var : The str, list or tuple base var. """ # Test basic indexing. - assert str(var[0]) == f"{{{var._var_name}.at(0)}}" - assert str(var[1]) == f"{{{var._var_name}.at(1)}}" + assert str(var[0]) == f"{var._js_expr}.at(0)" + assert str(var[1]) == f"{var._js_expr}.at(1)" # Test negative indexing. - assert str(var[-1]) == f"{{{var._var_name}.at(-1)}}" + assert str(var[-1]) == f"{var._js_expr}.at(-1)" @pytest.mark.parametrize( "var, type_", [ - (BaseVar(_var_name="list", _var_type=List[int]), [int, int]), - (BaseVar(_var_name="tuple", _var_type=Tuple[int, str]), [int, str]), + (Var(_js_expr="list", _var_type=List[int]).guess_type(), [int, int]), + ( + Var(_js_expr="tuple", _var_type=Tuple[int, str]).guess_type(), + [int, str], + ), ], ) def test_var_indexing_types(var, type_): @@ -548,31 +489,31 @@ def test_var_indexing_types(var, type_): def test_var_indexing_str(): """Test that we can index into str vars.""" - str_var = BaseVar(_var_name="str", _var_type=str) + str_var = Var(_js_expr="str").to(str) # Test that indexing gives a type of Var[str]. assert isinstance(str_var[0], Var) assert str_var[0]._var_type == str # Test basic indexing. - assert str(str_var[0]) == "{str.at(0)}" - assert str(str_var[1]) == "{str.at(1)}" + assert str(str_var[0]) == "str.at(0)" + assert str(str_var[1]) == "str.at(1)" # Test negative indexing. - assert str(str_var[-1]) == "{str.at(-1)}" + assert str(str_var[-1]) == "str.at(-1)" @pytest.mark.parametrize( "var", [ - (BaseVar(_var_name="foo", _var_type=int)), - (BaseVar(_var_name="bar", _var_type=float)), + (Var(_js_expr="foo", _var_type=int).guess_type()), + (Var(_js_expr="bar", _var_type=float).guess_type()), ], ) def test_var_replace_with_invalid_kwargs(var): with pytest.raises(TypeError) as excinfo: var._replace(_this_should_fail=True) - assert "Unexpected keyword arguments" in str(excinfo.value) + assert "unexpected keyword argument" in str(excinfo.value) def test_computed_var_replace_with_invalid_kwargs(): @@ -582,65 +523,71 @@ def test_computed_var_replace_with_invalid_kwargs(): with pytest.raises(TypeError) as excinfo: test_var._replace(_random_kwarg=True) - assert "Unexpected keyword arguments" in str(excinfo.value) + assert "Unexpected keyword argument" in str(excinfo.value) @pytest.mark.parametrize( "var, index", [ - (BaseVar(_var_name="lst", _var_type=List[int]), [1, 2]), - (BaseVar(_var_name="lst", _var_type=List[int]), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=List[int]), {"set"}), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), [1, 2]), ( - BaseVar(_var_name="lst", _var_type=List[int]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + {"name": "dict"}, + ), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), {"set"}), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), ( 1, 2, ), ), - (BaseVar(_var_name="lst", _var_type=List[int]), 1.5), - (BaseVar(_var_name="lst", _var_type=List[int]), "str"), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), 1.5), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), "str"), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), - (BaseVar(_var_name="str", _var_type=str), [1, 2]), - (BaseVar(_var_name="lst", _var_type=str), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=str), {"set"}), + (Var(_js_expr="str", _var_type=str).guess_type(), [1, 2]), + (Var(_js_expr="lst", _var_type=str).guess_type(), {"name": "dict"}), + (Var(_js_expr="lst", _var_type=str).guess_type(), {"set"}), ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), - (BaseVar(_var_name="str", _var_type=Tuple[str]), [1, 2]), - (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"set"}), + (Var(_js_expr="str", _var_type=Tuple[str]).guess_type(), [1, 2]), ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + {"name": "dict"}, + ), + (Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), {"set"}), + ( + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), ], ) @@ -658,9 +605,8 @@ def test_var_unsupported_indexing_lists(var, index): @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="tuple", _var_type=Tuple[int, int]), - BaseVar(_var_name="str", _var_type=str), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), ], ) def test_var_list_slicing(var): @@ -669,84 +615,105 @@ def test_var_list_slicing(var): Args: var : The str, list or tuple base var. """ - assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}" - assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}" - assert str(var[:]) == f"{{{var._var_name}.slice(0, undefined)}}" + assert str(var[:1]) == f"{var._js_expr}.slice(undefined, 1)" + assert str(var[1:]) == f"{var._js_expr}.slice(1, undefined)" + assert str(var[:]) == f"{var._js_expr}.slice(undefined, undefined)" + + +def test_str_var_slicing(): + """Test that we can slice into str vars.""" + str_var = Var(_js_expr="str").to(str) + + # Test that slicing gives a type of Var[str]. + assert isinstance(str_var[:1], Var) + assert str_var[:1]._var_type == str + + # Test basic slicing. + assert str(str_var[:1]) == 'str.split("").slice(undefined, 1).join("")' + assert str(str_var[1:]) == 'str.split("").slice(1, undefined).join("")' + assert str(str_var[:]) == 'str.split("").slice(undefined, undefined).join("")' + assert str(str_var[1:2]) == 'str.split("").slice(1, 2).join("")' + + # Test negative slicing. + assert str(str_var[:-1]) == 'str.split("").slice(undefined, -1).join("")' + assert str(str_var[-1:]) == 'str.split("").slice(-1, undefined).join("")' + assert str(str_var[:-2]) == 'str.split("").slice(undefined, -2).join("")' + assert str(str_var[-2:]) == 'str.split("").slice(-2, undefined).join("")' def test_dict_indexing(): """Test that we can index into dict vars.""" - dct = BaseVar(_var_name="dct", _var_type=Dict[str, int]) + dct = Var(_js_expr="dct").to(ObjectVar, Dict[str, str]) # Check correct indexing. - assert str(dct["a"]) == '{dct["a"]}' - assert str(dct["asdf"]) == '{dct["asdf"]}' + assert str(dct["a"]) == 'dct["a"]' + assert str(dct["asdf"]) == 'dct["asdf"]' @pytest.mark.parametrize( "var, index", [ ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), [1, 2], ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), {"name": "dict"}, ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), {"set"}, ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), ( 1, 2, ), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), [1, 2], ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), {"name": "dict"}, ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), {"set"}, ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), ( 1, 2, ), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), ], ) @@ -765,8 +732,6 @@ def test_var_unsupported_indexing_dicts(var, index): "fixture", [ "ParentState", - "ChildState", - "GrandChildState", "StateWithAnyVar", ], ) @@ -788,6 +753,26 @@ def test_computed_var_without_annotation_error(request, fixture): ) +@pytest.mark.parametrize( + "fixture", + [ + "ChildState", + "GrandChildState", + ], +) +def test_shadow_computed_var_error(request: pytest.FixtureRequest, fixture: str): + """Test that a name error is thrown when an attribute of a computed var is + shadowed by another attribute. + + Args: + request: Fixture Request. + fixture: The state fixture. + """ + with pytest.raises(NameError): + state = request.getfixturevalue(fixture) + state.var_without_annotation.foo + + @pytest.mark.parametrize( "fixture", [ @@ -898,8 +883,8 @@ def test_function_var(): manual_addition_func = ArgsFunctionOperation.create( ("a", "b"), { - "args": [ImmutableVar.create_safe("a"), ImmutableVar.create_safe("b")], - "result": ImmutableVar.create_safe("a + b"), + "args": [Var(_js_expr="a"), Var(_js_expr="b")], + "result": Var(_js_expr="a + b"), }, ) assert ( @@ -914,7 +899,7 @@ def test_function_var(): ) create_hello_statement = ArgsFunctionOperation.create( - ("name",), f"Hello, {ImmutableVar.create_safe('name')}!" + ("name",), f"Hello, {Var(_js_expr='name')}!" ) first_name = LiteralStringVar.create("Steven") last_name = LiteralStringVar.create("Universe") @@ -925,9 +910,9 @@ def test_function_var(): def test_var_operation(): - @var_operation(output=NumberVar) - def add(a: Union[NumberVar, int], b: Union[NumberVar, int]) -> str: - return f"({a} + {b})" + @var_operation + def add(a: Union[NumberVar, int], b: Union[NumberVar, int]): + return var_operation_return(js_expression=f"({a} + {b})", var_type=int) assert str(add(1, 2)) == "(1 + 2)" assert str(add(a=4, b=-9)) == "(4 + -9)" @@ -967,17 +952,32 @@ def test_all_number_operations(): assert ( str(even_more_complicated_number) - == "!(Boolean((Math.abs(Math.floor(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))) || (2 && Math.round(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))))))" + == "!(((Math.abs(Math.floor(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))) || (2 && Math.round(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2)))) !== 0))" ) assert str(LiteralNumberVar.create(5) > False) == "(5 > 0)" - assert str(LiteralBooleanVar.create(False) < 5) == "((false ? 1 : 0) < 5)" + assert str(LiteralBooleanVar.create(False) < 5) == "(Number(false) < 5)" assert ( str(LiteralBooleanVar.create(False) < LiteralBooleanVar.create(True)) - == "((false ? 1 : 0) < (true ? 1 : 0))" + == "(Number(false) < Number(true))" ) +@pytest.mark.parametrize( + ("var", "expected"), + [ + (Var.create(False), "false"), + (Var.create(True), "true"), + (Var.create("false"), '("false".split("").length !== 0)'), + (Var.create([1, 2, 3]), "isTrue([1, 2, 3])"), + (Var.create({"a": 1, "b": 2}), 'isTrue(({ ["a"] : 1, ["b"] : 2 }))'), + (Var("mysterious_var"), "isTrue(mysterious_var)"), + ], +) +def test_boolify_operations(var, expected): + assert str(var.bool()) == expected + + def test_index_operation(): array_var = LiteralArrayVar.create([1, 2, 3, 4, 5]) assert str(array_var[0]) == "[1, 2, 3, 4, 5].at(0)" @@ -994,6 +994,22 @@ def test_index_operation(): assert str(array_var[0].to(NumberVar) + 9) == "([1, 2, 3, 4, 5].at(0) + 9)" +@pytest.mark.parametrize( + "var, expected_js", + [ + (Var.create(float("inf")), "Infinity"), + (Var.create(-float("inf")), "-Infinity"), + (Var.create(float("nan")), "NaN"), + ], +) +def test_inf_and_nan(var, expected_js): + assert str(var) == expected_js + assert isinstance(var, NumberVar) + assert isinstance(var, LiteralVar) + with pytest.raises(PrimitiveUnserializableToJSON): + var.json() + + def test_array_operations(): array_var = LiteralArrayVar.create([1, 2, 3, 4, 5]) @@ -1040,6 +1056,29 @@ def test_object_operations(): ) +def test_var_component(): + class ComponentVarState(rx.State): + field_var: rx.Component = rx.text("I am a field var") + + @rx.var + def computed_var(self) -> rx.Component: + return rx.text("I am a computed var") + + def has_eval_react_component(var: Var): + var_data = var._get_all_var_data() + assert var_data is not None + assert any( + any( + imported_object.name == "evalReactComponent" + for imported_object in imported_objects + ) + for _, imported_objects in var_data.imports + ) + + has_eval_react_component(ComponentVarState.field_var) # type: ignore + has_eval_react_component(ComponentVarState.computed_var) + + def test_type_chains(): object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3}) assert (object_var._key_type(), object_var._value_type()) == (str, int) @@ -1078,7 +1117,9 @@ def nested_base(): bar: Boo baz: int - parent_obj = LiteralVar.create(Foo(bar=Boo(foo="bar", bar=5), baz=5)) + parent_obj = LiteralObjectVar.create( + Foo(bar=Boo(foo="bar", bar=5), baz=5).dict(), Foo + ) assert ( str(parent_obj.bar.foo) @@ -1087,7 +1128,7 @@ def nested_base(): def test_retrival(): - var_without_data = ImmutableVar.create("test") + var_without_data = Var(_js_expr="test") assert var_without_data is not None original_var_data = VarData( @@ -1103,8 +1144,8 @@ def test_retrival(): assert REFLEX_VAR_OPENING_TAG in f_string assert REFLEX_VAR_CLOSING_TAG in f_string - result_var_data = Var.create_safe(f_string)._var_data - result_immutable_var_data = ImmutableVar.create_safe(f_string)._var_data + result_var_data = LiteralVar.create(f_string)._get_all_var_data() + result_immutable_var_data = Var(_js_expr=f_string)._var_data assert result_var_data is not None and result_immutable_var_data is not None assert ( result_var_data.state @@ -1113,35 +1154,23 @@ def test_retrival(): ) assert ( result_var_data.imports - == ( - result_immutable_var_data.imports - if isinstance(result_immutable_var_data.imports, dict) - else { - k: list(v) - for k, v in result_immutable_var_data.imports - if k in original_var_data.imports - } - ) + == result_immutable_var_data.imports == original_var_data.imports ) assert ( - list(result_var_data.hooks.keys()) - == ( - list(result_immutable_var_data.hooks.keys()) - if isinstance(result_immutable_var_data.hooks, dict) - else list(result_immutable_var_data.hooks) - ) - == list(original_var_data.hooks.keys()) + tuple(result_var_data.hooks) + == tuple(result_immutable_var_data.hooks) + == tuple(original_var_data.hooks) ) def test_fstring_concat(): - original_var_with_data = Var.create_safe( + original_var_with_data = LiteralVar.create( "imagination", _var_data=VarData(state="fear") ) - immutable_var_with_data = ImmutableVar.create_safe( - "consequences", + immutable_var_with_data = Var( + _js_expr="consequences", _var_data=VarData( imports={ "react": [ImportVar(tag="useRef")], @@ -1159,9 +1188,9 @@ def test_fstring_concat(): ), ) - assert str(string_concat) == '("foo"+imagination+"bar"+consequences+"baz")' + assert str(string_concat) == '("fooimaginationbar"+consequences+"baz")' assert isinstance(string_concat, ConcatVarOperation) - assert string_concat._get_all_var_data() == ImmutableVarData( + assert string_concat._get_all_var_data() == VarData( state="fear", imports={ "react": [ImportVar(tag="useRef")], @@ -1171,17 +1200,22 @@ def test_fstring_concat(): ) +var = Var(_js_expr="var", _var_type=str) +myvar = Var(_js_expr="myvar", _var_type=int)._var_set_state("state") +x = Var(_js_expr="x", _var_type=str) + + @pytest.mark.parametrize( "out, expected", [ - (f"{BaseVar(_var_name='var', _var_type=str)}", "${var}"), + (f"{var}", f"{hash(var)}var"), ( - f"testing f-string with {BaseVar(_var_name='myvar', _var_type=int)._var_set_state('state')}", - 'testing f-string with ${"state": "state", "interpolations": [], "imports": {"/utils/context": [{"tag": "StateContexts", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}], "react": [{"tag": "useContext", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}]}, "hooks": {"const state = useContext(StateContexts.state)": null}, "string_length": 13}{state.myvar}', + f"testing f-string with {myvar}", + f"testing f-string with {hash(myvar)}state.myvar", ), ( - f"testing local f-string {BaseVar(_var_name='x', _var_is_local=True, _var_type=str)}", - "testing local f-string x", + f"testing local f-string {x}", + f"testing local f-string {hash(x)}x", ), ], ) @@ -1194,8 +1228,8 @@ def test_fstrings(out, expected): [ ([1], ""), ({"a": 1}, ""), - ([Var.create_safe(1)._var_set_state("foo")], "foo"), - ({"a": Var.create_safe(1)._var_set_state("foo")}, "foo"), + ([LiteralVar.create(1)._var_set_state("foo")], "foo"), + ({"a": LiteralVar.create(1)._var_set_state("foo")}, "foo"), ], ) def test_extract_state_from_container(value, expect_state): @@ -1205,7 +1239,9 @@ def test_extract_state_from_container(value, expect_state): value: The value to create a var from. expect_state: The expected state. """ - assert Var.create_safe(value)._var_state == expect_state + var_data = LiteralVar.create(value)._get_all_var_data() + var_state = var_data.state if var_data else "" + assert var_state == expect_state @pytest.mark.parametrize( @@ -1221,25 +1257,21 @@ def test_fstring_roundtrip(value): Args: value: The value to create a Var from. """ - var = BaseVar.create_safe(value)._var_set_state("state") - rt_var = Var.create_safe(f"{var}") + var = Var(_js_expr=value)._var_set_state("state") + rt_var = LiteralVar.create(f"{var}") assert var._var_state == rt_var._var_state - assert var._var_full_name_needs_state_prefix - assert not rt_var._var_full_name_needs_state_prefix - assert rt_var._var_name == var._var_full_name + assert str(rt_var) == str(var) @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="var", _var_type=int), - BaseVar(_var_name="var", _var_type=float), - BaseVar(_var_name="var", _var_type=str), - BaseVar(_var_name="var", _var_type=bool), - BaseVar(_var_name="var", _var_type=dict), - BaseVar(_var_name="var", _var_type=tuple), - BaseVar(_var_name="var", _var_type=set), - BaseVar(_var_name="var", _var_type=None), + Var(_js_expr="var", _var_type=int).guess_type(), + Var(_js_expr="var", _var_type=float).guess_type(), + Var(_js_expr="var", _var_type=str).guess_type(), + Var(_js_expr="var", _var_type=bool).guess_type(), + Var(_js_expr="var", _var_type=dict).guess_type(), + Var(_js_expr="var", _var_type=None).guess_type(), ], ) def test_unsupported_types_for_reverse(var): @@ -1250,16 +1282,16 @@ def test_unsupported_types_for_reverse(var): """ with pytest.raises(TypeError) as err: var.reverse() - assert err.value.args[0] == f"Cannot reverse non-list var var." + assert err.value.args[0] == f"Cannot reverse non-list var." @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="var", _var_type=int), - BaseVar(_var_name="var", _var_type=float), - BaseVar(_var_name="var", _var_type=bool), - BaseVar(_var_name="var", _var_type=None), + Var(_js_expr="var", _var_type=int).guess_type(), + Var(_js_expr="var", _var_type=float).guess_type(), + Var(_js_expr="var", _var_type=bool).guess_type(), + Var(_js_expr="var", _var_type=None).guess_type(), ], ) def test_unsupported_types_for_contains(var): @@ -1272,34 +1304,34 @@ def test_unsupported_types_for_contains(var): assert var.contains(1) assert ( err.value.args[0] - == f"Var var of type {var._var_type} does not support contains check." + == f"Var of type {var._var_type} does not support contains check." ) @pytest.mark.parametrize( "other", [ - BaseVar(_var_name="other", _var_type=int), - BaseVar(_var_name="other", _var_type=float), - BaseVar(_var_name="other", _var_type=bool), - BaseVar(_var_name="other", _var_type=list), - BaseVar(_var_name="other", _var_type=dict), - BaseVar(_var_name="other", _var_type=tuple), - BaseVar(_var_name="other", _var_type=set), + Var(_js_expr="other", _var_type=int).guess_type(), + Var(_js_expr="other", _var_type=float).guess_type(), + Var(_js_expr="other", _var_type=bool).guess_type(), + Var(_js_expr="other", _var_type=list).guess_type(), + Var(_js_expr="other", _var_type=dict).guess_type(), + Var(_js_expr="other", _var_type=tuple).guess_type(), + Var(_js_expr="other", _var_type=set).guess_type(), ], ) def test_unsupported_types_for_string_contains(other): with pytest.raises(TypeError) as err: - assert BaseVar(_var_name="var", _var_type=str).contains(other) + assert Var(_js_expr="var").to(str).contains(other) assert ( err.value.args[0] - == f"'in ' requires string as left operand, not {other._var_type}" + == f"Unsupported Operand type(s) for contains: ToStringOperation, {type(other).__name__}" ) def test_unsupported_default_contains(): with pytest.raises(TypeError) as err: - assert 1 in BaseVar(_var_name="var", _var_type=str) + assert 1 in Var(_js_expr="var", _var_type=str).guess_type() assert ( err.value.args[0] == "'in' operator not supported for Var types, use Var.contains() instead." @@ -1310,8 +1342,8 @@ def test_unsupported_default_contains(): "operand1_var,operand2_var,operators", [ ( - Var.create(10), - Var.create(5), + LiteralVar.create(10), + LiteralVar.create(5), [ "+", "-", @@ -1329,13 +1361,13 @@ def test_unsupported_default_contains(): ], ), ( - Var.create(10.5), - Var.create(5), + LiteralVar.create(10.5), + LiteralVar.create(5), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), ( - Var.create(5), - Var.create(True), + LiteralVar.create(5), + LiteralVar.create(True), [ "+", "-", @@ -1353,22 +1385,26 @@ def test_unsupported_default_contains(): ], ), ( - Var.create(10.5), - Var.create(5.5), + LiteralVar.create(10.5), + LiteralVar.create(5.5), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), ( - Var.create(10.5), - Var.create(True), + LiteralVar.create(10.5), + LiteralVar.create(True), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), - (Var.create("10"), Var.create("5"), ["+", ">", "<", "<=", ">="]), - (Var.create([10, 20]), Var.create([5, 6]), ["+", ">", "<", "<=", ">="]), - (Var.create([10, 20]), Var.create(5), ["*"]), - (Var.create([10, 20]), Var.create(True), ["*"]), + (LiteralVar.create("10"), LiteralVar.create("5"), ["+", ">", "<", "<=", ">="]), ( - Var.create(True), - Var.create(True), + LiteralVar.create([10, 20]), + LiteralVar.create([5, 6]), + ["+", ">", "<", "<=", ">="], + ), + (LiteralVar.create([10, 20]), LiteralVar.create(5), ["*"]), + (LiteralVar.create([10, 20]), LiteralVar.create(True), ["*"]), + ( + LiteralVar.create(True), + LiteralVar.create(True), [ "+", "-", @@ -1396,16 +1432,28 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s operators: list of supported operators. """ for operator in operators: - operand1_var.operation(op=operator, other=operand2_var) - operand1_var.operation(op=operator, other=operand2_var, flip=True) + print( + "testing", + operator, + "on", + operand1_var, + operand2_var, + " of types", + type(operand1_var), + type(operand2_var), + ) + eval(f"operand1_var {operator} operand2_var") + eval(f"operand2_var {operator} operand1_var") + # operand1_var.operation(op=operator, other=operand2_var) + # operand1_var.operation(op=operator, other=operand2_var, flip=True) @pytest.mark.parametrize( "operand1_var,operand2_var,operators", [ ( - Var.create(10), - Var.create(5), + LiteralVar.create(10), + LiteralVar.create(5), [ "^", "<<", @@ -1413,41 +1461,35 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s ], ), ( - Var.create(10.5), - Var.create(5), + LiteralVar.create(10.5), + LiteralVar.create(5), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create(10.5), - Var.create(True), + LiteralVar.create(10.5), + LiteralVar.create(True), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create(10.5), - Var.create(5.5), + LiteralVar.create(10.5), + LiteralVar.create(5.5), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create("10"), - Var.create("5"), + LiteralVar.create("10"), + LiteralVar.create("5"), [ "-", "/", @@ -1455,16 +1497,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "*", "%", "**", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create([5, 6]), + LiteralVar.create([10, 20]), + LiteralVar.create([5, 6]), [ "-", "/", @@ -1472,16 +1512,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "*", "%", "**", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(5), + LiteralVar.create([10, 20]), + LiteralVar.create(5), [ "+", "-", @@ -1493,16 +1531,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(True), + LiteralVar.create([10, 20]), + LiteralVar.create(True), [ "+", "-", @@ -1514,16 +1550,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create("5"), + LiteralVar.create([10, 20]), + LiteralVar.create("5"), [ "+", "-", @@ -1536,16 +1570,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create({"key": "value"}), + LiteralVar.create([10, 20]), + LiteralVar.create({"key": "value"}), [ "+", "-", @@ -1558,16 +1590,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(5.5), + LiteralVar.create([10, 20]), + LiteralVar.create(5.5), [ "+", "-", @@ -1580,16 +1610,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create({"another_key": "another_value"}), + LiteralVar.create({"key": "value"}), + LiteralVar.create({"another_key": "another_value"}), [ "+", "-", @@ -1602,16 +1630,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(5), + LiteralVar.create({"key": "value"}), + LiteralVar.create(5), [ "+", "-", @@ -1624,16 +1650,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(True), + LiteralVar.create({"key": "value"}), + LiteralVar.create(True), [ "+", "-", @@ -1646,16 +1670,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(5.5), + LiteralVar.create({"key": "value"}), + LiteralVar.create(5.5), [ "+", "-", @@ -1668,16 +1690,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create("5"), + LiteralVar.create({"key": "value"}), + LiteralVar.create("5"), [ "+", "-", @@ -1690,44 +1710,48 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ], ) def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): for operator in operators: + print(f"testing {operator} on {str(operand1_var)} and {str(operand2_var)}") with pytest.raises(TypeError): - operand1_var.operation(op=operator, other=operand2_var) + print(eval(f"operand1_var {operator} operand2_var")) + # operand1_var.operation(op=operator, other=operand2_var) with pytest.raises(TypeError): - operand1_var.operation(op=operator, other=operand2_var, flip=True) + print(eval(f"operand2_var {operator} operand1_var")) + # operand1_var.operation(op=operator, other=operand2_var, flip=True) @pytest.mark.parametrize( "var, expected", [ - (Var.create("string_value", _var_is_string=True), "`string_value`"), - (Var.create(1), "1"), - (Var.create([1, 2, 3]), "[1, 2, 3]"), - (Var.create({"foo": "bar"}), '{"foo": "bar"}'), + (LiteralVar.create("string_value"), '"string_value"'), + (LiteralVar.create(1), "1"), + (LiteralVar.create([1, 2, 3]), "[1, 2, 3]"), + (LiteralVar.create({"foo": "bar"}), '({ ["foo"] : "bar" })'), ( - Var.create(ATestState.value, _var_is_string=True), + LiteralVar.create(ATestState.value), f"{ATestState.get_full_name()}.value", ), ( LiteralVar.create(f"{ATestState.value} string"), f'({ATestState.get_full_name()}.value+" string")', ), - (Var.create(ATestState.dict_val), f"{ATestState.get_full_name()}.dict_val"), + ( + LiteralVar.create(ATestState.dict_val), + f"{ATestState.get_full_name()}.dict_val", + ), ], ) def test_var_name_unwrapped(var, expected): - assert var._var_name_unwrapped == expected + assert str(var) == expected def cv_fget(state: BaseState) -> int: @@ -1770,3 +1794,21 @@ def test_invalid_computed_var_deps(deps: List): ) def test_var(state) -> int: return 1 + + +def test_to_string_operation(): + class Email(str): ... + + class TestState(BaseState): + optional_email: Optional[Email] = None + email: Email = Email("test@reflex.dev") + + assert ( + str(TestState.optional_email) == f"{TestState.get_full_name()}.optional_email" + ) + my_state = TestState() + assert my_state.optional_email is None + assert my_state.email == "test@reflex.dev" + + assert cast(Var, TestState.email)._var_type == Email + assert cast(Var, TestState.optional_email)._var_type == Optional[Email] diff --git a/tests/utils/test_format.py b/tests/utils/test_format.py index 4623f0fb2..b108f9dc2 100644 --- a/tests/utils/test_format.py +++ b/tests/utils/test_format.py @@ -8,11 +8,11 @@ import pytest from reflex.components.tags.tag import Tag from reflex.event import EventChain, EventHandler, EventSpec, FrontendEvent -from reflex.ivars.base import ImmutableVar, LiteralVar from reflex.style import Style from reflex.utils import format from reflex.utils.serializers import serialize_figure -from reflex.vars import BaseVar, Var +from reflex.vars.base import LiteralVar, Var +from reflex.vars.object import ObjectVar from tests.test_state import ( ChildState, ChildState2, @@ -273,16 +273,12 @@ def test_format_string(input: str, output: str): @pytest.mark.parametrize( "input,output", [ - (Var.create(value="test"), "{`test`}"), - (Var.create(value="test", _var_is_local=True), "{`test`}"), - (Var.create(value="test", _var_is_local=False), "{test}"), - (Var.create(value="test", _var_is_string=True), "{`test`}"), - (Var.create(value="test", _var_is_string=False), "{`test`}"), - (Var.create(value="test", _var_is_local=False, _var_is_string=False), "{test}"), + (LiteralVar.create(value="test"), '"test"'), + (Var(_js_expr="test"), "test"), ], ) def test_format_var(input: Var, output: str): - assert format.format_var(input) == output + assert str(input) == output @pytest.mark.parametrize( @@ -313,110 +309,6 @@ def test_format_route(route: str, format_case: bool, expected: bool): assert format.format_route(route, format_case=format_case) == expected -@pytest.mark.parametrize( - "condition,true_value,false_value,is_prop,expected", - [ - ("cond", "", '""', False, '{isTrue(cond) ? : ""}'), - ("cond", "", "", False, "{isTrue(cond) ? : }"), - ( - "cond", - Var.create_safe(""), - "", - False, - "{isTrue(cond) ? : }", - ), - ( - "cond", - Var.create_safe(""), - Var.create_safe(""), - False, - "{isTrue(cond) ? : }", - ), - ( - "cond", - Var.create_safe("", _var_is_local=False), - Var.create_safe(""), - False, - "{isTrue(cond) ? ${} : }", - ), - ( - "cond", - Var.create_safe("", _var_is_string=True), - Var.create_safe(""), - False, - "{isTrue(cond) ? {``} : }", - ), - ("cond", "", '""', True, 'isTrue(cond) ? `` : `""`'), - ("cond", "", "", True, "isTrue(cond) ? `` : ``"), - ( - "cond", - Var.create_safe(""), - "", - True, - "isTrue(cond) ? : ``", - ), - ( - "cond", - Var.create_safe(""), - Var.create_safe(""), - True, - "isTrue(cond) ? : ", - ), - ( - "cond", - Var.create_safe("", _var_is_local=False), - Var.create_safe(""), - True, - "isTrue(cond) ? : ", - ), - ( - "cond", - Var.create_safe(""), - Var.create_safe("", _var_is_local=False), - True, - "isTrue(cond) ? : ", - ), - ( - "cond", - Var.create_safe("", _var_is_string=True), - Var.create_safe(""), - True, - "isTrue(cond) ? `` : ", - ), - ], -) -def test_format_cond( - condition: str, - true_value: str | Var, - false_value: str | Var, - is_prop: bool, - expected: str, -): - """Test formatting a cond. - - Args: - condition: The condition to check. - true_value: The value to return if the condition is true. - false_value: The value to return if the condition is false. - is_prop: Whether the values are rendered as props or not. - expected: The expected output string. - """ - orig_true_value = ( - true_value._replace() if isinstance(true_value, Var) else Var.create_safe("") - ) - orig_false_value = ( - false_value._replace() if isinstance(false_value, Var) else Var.create_safe("") - ) - - assert format.format_cond(condition, true_value, false_value, is_prop) == expected - - # Ensure the formatting operation didn't change the original Var - if isinstance(true_value, Var): - assert true_value.equals(orig_true_value) - if isinstance(false_value, Var): - assert false_value.equals(orig_false_value) - - @pytest.mark.parametrize( "condition, match_cases, default,expected", [ @@ -440,7 +332,10 @@ def test_format_cond( ], ) def test_format_match( - condition: str, match_cases: List[BaseVar], default: BaseVar, expected: str + condition: str, + match_cases: List[List[Var]], + default: Var, + expected: str, ): """Test formatting a match statement. @@ -457,28 +352,28 @@ def test_format_match( "prop,formatted", [ ("string", '"string"'), - ("{wrapped_string}", "{wrapped_string}"), - (True, "{true}"), - (False, "{false}"), - (123, "{123}"), - (3.14, "{3.14}"), - ([1, 2, 3], "{[1, 2, 3]}"), - (["a", "b", "c"], '{["a", "b", "c"]}'), - ({"a": 1, "b": 2, "c": 3}, '{{"a": 1, "b": 2, "c": 3}}'), - ({"a": 'foo "bar" baz'}, r'{{"a": "foo \"bar\" baz"}}'), + ("{wrapped_string}", '"{wrapped_string}"'), + (True, "true"), + (False, "false"), + (123, "123"), + (3.14, "3.14"), + ([1, 2, 3], "[1, 2, 3]"), + (["a", "b", "c"], '["a", "b", "c"]'), + ({"a": 1, "b": 2, "c": 3}, '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })'), + ({"a": 'foo "bar" baz'}, r'({ ["a"] : "foo \"bar\" baz" })'), ( { "a": 'foo "{ "bar" }" baz', - "b": BaseVar(_var_name="val", _var_type="str"), + "b": Var(_js_expr="val", _var_type=str).guess_type(), }, - r'{{"a": "foo \"{ \"bar\" }\" baz", "b": val}}', + r'({ ["a"] : "foo \"{ \"bar\" }\" baz", ["b"] : val })', ), ( EventChain( events=[EventSpec(handler=EventHandler(fn=mock_event))], args_spec=lambda: [], ), - '{(...args) => addEvents([Event("mock_event", {})], args, {})}', + '((...args) => ((addEvents([(Event("mock_event", ({ })))], args, ({ })))))', ), ( EventChain( @@ -487,18 +382,19 @@ def test_format_match( handler=EventHandler(fn=mock_event), args=( ( - Var.create_safe("arg"), - BaseVar( - _var_name="_e", - _var_type=FrontendEvent, - ).target.value, + Var(_js_expr="arg"), + Var( + _js_expr="_e", + ) + .to(ObjectVar, FrontendEvent) + .target.value, ), ), ) ], args_spec=lambda e: [e.target.value], ), - '{(_e) => addEvents([Event("mock_event", {arg:_e.target.value})], [_e], {})}', + '((_e) => ((addEvents([(Event("mock_event", ({ ["arg"] : _e["target"]["value"] })))], [_e], ({ })))))', ), ( EventChain( @@ -506,7 +402,7 @@ def test_format_match( args_spec=lambda: [], event_actions={"stopPropagation": True}, ), - '{(...args) => addEvents([Event("mock_event", {})], args, {"stopPropagation": true})}', + '((...args) => ((addEvents([(Event("mock_event", ({ })))], args, ({ ["stopPropagation"] : true })))))', ), ( EventChain( @@ -514,35 +410,41 @@ def test_format_match( args_spec=lambda: [], event_actions={"preventDefault": True}, ), - '{(...args) => addEvents([Event("mock_event", {})], args, {"preventDefault": true})}', + '((...args) => ((addEvents([(Event("mock_event", ({ })))], args, ({ ["preventDefault"] : true })))))', ), - ({"a": "red", "b": "blue"}, '{{"a": "red", "b": "blue"}}'), - (BaseVar(_var_name="var", _var_type="int"), "{var}"), + ({"a": "red", "b": "blue"}, '({ ["a"] : "red", ["b"] : "blue" })'), + (Var(_js_expr="var", _var_type=int).guess_type(), "var"), ( - BaseVar( - _var_name="_", + Var( + _js_expr="_", _var_type=Any, - _var_is_local=True, - _var_is_string=False, ), - "{_}", + "_", ), ( - BaseVar(_var_name='state.colors["a"]', _var_type="str"), - '{state.colors["a"]}', + Var(_js_expr='state.colors["a"]', _var_type=str).guess_type(), + 'state.colors["a"]', ), - ({"a": BaseVar(_var_name="val", _var_type="str")}, '{{"a": val}}'), - ({"a": BaseVar(_var_name='"val"', _var_type="str")}, '{{"a": "val"}}'), ( - {"a": BaseVar(_var_name='state.colors["val"]', _var_type="str")}, - '{{"a": state.colors["val"]}}', + {"a": Var(_js_expr="val", _var_type=str).guess_type()}, + '({ ["a"] : val })', + ), + ( + {"a": Var(_js_expr='"val"', _var_type=str).guess_type()}, + '({ ["a"] : "val" })', + ), + ( + {"a": Var(_js_expr='state.colors["val"]', _var_type=str).guess_type()}, + '({ ["a"] : state.colors["val"] })', ), # tricky real-world case from markdown component ( { - "h1": f"{{({{node, ...props}}) => }}" + "h1": Var( + _js_expr=f"(({{node, ...props}}) => )" + ), }, - '{{"h1": ({node, ...props}) => }}', + '({ ["h1"] : (({node, ...props}) => ) })', ), ], ) @@ -553,14 +455,14 @@ def test_format_prop(prop: Var, formatted: str): prop: The prop to test. formatted: The expected formatted value. """ - assert format.format_prop(prop) == formatted + assert format.format_prop(LiteralVar.create(prop)) == formatted @pytest.mark.parametrize( "single_props,key_value_props,output", [ ( - [ImmutableVar.create_safe("...props")], + [Var(_js_expr="{...props}")], {"key": 42}, ["key={42}", "{...props}"], ), @@ -614,40 +516,14 @@ def test_format_event_handler(input, output): @pytest.mark.parametrize( "input,output", [ - (EventSpec(handler=EventHandler(fn=mock_event)), 'Event("mock_event", {})'), + ( + EventSpec(handler=EventHandler(fn=mock_event)), + '(Event("mock_event", ({ })))', + ), ], ) def test_format_event(input, output): - assert format.format_event(input) == output - - -@pytest.mark.parametrize( - "input,output", - [ - ( - EventChain( - events=[ - EventSpec(handler=EventHandler(fn=mock_event)), - EventSpec(handler=EventHandler(fn=mock_event)), - ], - args_spec=None, - ), - 'addEvents([Event("mock_event", {}),Event("mock_event", {})])', - ), - ( - EventChain( - events=[ - EventSpec(handler=EventHandler(fn=mock_event)), - EventSpec(handler=EventHandler(fn=mock_event)), - ], - args_spec=lambda e0: [e0], - ), - 'addEvents([Event("mock_event", {}),Event("mock_event", {})])', - ), - ], -) -def test_format_event_chain(input, output): - assert format.format_event_chain(input) == output + assert str(LiteralVar.create(input)) == output @pytest.mark.parametrize( @@ -668,6 +544,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -771,29 +648,14 @@ def test_format_ref(input, output): "input,output", [ (("my_array", None), "refs_my_array"), - (("my_array", Var.create(0)), "refs_my_array[0]"), - (("my_array", Var.create(1)), "refs_my_array[1]"), + (("my_array", LiteralVar.create(0)), "refs_my_array[0]"), + (("my_array", LiteralVar.create(1)), "refs_my_array[1]"), ], ) def test_format_array_ref(input, output): assert format.format_array_ref(input[0], input[1]) == output -@pytest.mark.parametrize( - "input,output", - [ - ("/foo", [("foo", "/foo")]), - ("/foo/bar", [("foo", "/foo"), ("bar", "/foo/bar")]), - ( - "/foo/bar/baz", - [("foo", "/foo"), ("bar", "/foo/bar"), ("baz", "/foo/bar/baz")], - ), - ], -) -def test_format_breadcrumbs(input, output): - assert format.format_breadcrumbs(input) == output - - @pytest.mark.parametrize( "input, output", [ diff --git a/tests/utils/test_imports.py b/tests/utils/test_imports.py index e9be5c1be..c30d1d85c 100644 --- a/tests/utils/test_imports.py +++ b/tests/utils/test_imports.py @@ -54,17 +54,21 @@ def test_import_var(import_var, expected_name): ( {"react": {"Component"}}, {"react": {"Component"}, "react-dom": {"render"}}, - {"react": {"Component"}, "react-dom": {"render"}}, + {"react": {ImportVar("Component")}, "react-dom": {ImportVar("render")}}, ), ( {"react": {"Component"}, "next/image": {"Image"}}, {"react": {"Component"}, "react-dom": {"render"}}, - {"react": {"Component"}, "react-dom": {"render"}, "next/image": {"Image"}}, + { + "react": {ImportVar("Component")}, + "react-dom": {ImportVar("render")}, + "next/image": {ImportVar("Image")}, + }, ), ( {"react": {"Component"}}, {"": {"some/custom.css"}}, - {"react": {"Component"}, "": {"some/custom.css"}}, + {"react": {ImportVar("Component")}, "": {ImportVar("some/custom.css")}}, ), ], ) diff --git a/tests/utils/test_serializers.py b/tests/utils/test_serializers.py index b516f5eb3..97da98792 100644 --- a/tests/utils/test_serializers.py +++ b/tests/utils/test_serializers.py @@ -1,14 +1,14 @@ import datetime from enum import Enum from pathlib import Path -from typing import Any, Dict, List, Type +from typing import Any, Dict, Type import pytest from reflex.base import Base from reflex.components.core.colors import Color from reflex.utils import serializers -from reflex.vars import Var +from reflex.vars.base import LiteralVar @pytest.mark.parametrize( @@ -29,20 +29,10 @@ def test_has_serializer(type_: Type, expected: bool): @pytest.mark.parametrize( "type_,expected", [ - (str, serializers.serialize_str), - (list, serializers.serialize_list), - (tuple, serializers.serialize_list), - (set, serializers.serialize_list), - (dict, serializers.serialize_dict), - (List[str], serializers.serialize_list), - (Dict[int, int], serializers.serialize_dict), (datetime.datetime, serializers.serialize_datetime), (datetime.date, serializers.serialize_datetime), (datetime.time, serializers.serialize_datetime), (datetime.timedelta, serializers.serialize_datetime), - (int, serializers.serialize_primitive), - (float, serializers.serialize_primitive), - (bool, serializers.serialize_primitive), (Enum, serializers.serialize_enum), ], ) @@ -133,48 +123,59 @@ class BaseSubclass(Base): "value,expected", [ ("test", "test"), - (1, "1"), - (1.0, "1.0"), - (True, "true"), - (False, "false"), - (None, "null"), - ([1, 2, 3], "[1, 2, 3]"), - ([1, "2", 3.0], '[1, "2", 3.0]'), - ([{"key": 1}, {"key": 2}], '[{"key": 1}, {"key": 2}]'), + (1, 1), + (1.0, 1.0), + (True, True), + (False, False), + (None, None), + ([1, 2, 3], [1, 2, 3]), + ([1, "2", 3.0], [1, "2", 3.0]), + ([{"key": 1}, {"key": 2}], [{"key": 1}, {"key": 2}]), (StrEnum.FOO, "foo"), - ([StrEnum.FOO, StrEnum.BAR], '["foo", "bar"]'), + ([StrEnum.FOO, StrEnum.BAR], ["foo", "bar"]), ( {"key1": [1, 2, 3], "key2": [StrEnum.FOO, StrEnum.BAR]}, - '{"key1": [1, 2, 3], "key2": ["foo", "bar"]}', + { + "key1": [1, 2, 3], + "key2": ["foo", "bar"], + }, ), (EnumWithPrefix.FOO, "prefix_foo"), - ([EnumWithPrefix.FOO, EnumWithPrefix.BAR], '["prefix_foo", "prefix_bar"]'), + ([EnumWithPrefix.FOO, EnumWithPrefix.BAR], ["prefix_foo", "prefix_bar"]), ( {"key1": EnumWithPrefix.FOO, "key2": EnumWithPrefix.BAR}, - '{"key1": "prefix_foo", "key2": "prefix_bar"}', + { + "key1": "prefix_foo", + "key2": "prefix_bar", + }, ), (TestEnum.FOO, "foo"), - ([TestEnum.FOO, TestEnum.BAR], '["foo", "bar"]'), + ([TestEnum.FOO, TestEnum.BAR], ["foo", "bar"]), ( {"key1": TestEnum.FOO, "key2": TestEnum.BAR}, - '{"key1": "foo", "key2": "bar"}', + { + "key1": "foo", + "key2": "bar", + }, ), ( BaseSubclass(ts=datetime.timedelta(1, 1, 1)), - '{"ts": "1 day, 0:00:01.000001"}', + { + "ts": "1 day, 0:00:01.000001", + }, ), ( - [1, Var.create_safe("hi"), Var.create_safe("bye", _var_is_local=False)], - '[1, "hi", bye]', + [1, LiteralVar.create("hi")], + [1, "hi"], ), ( - (1, Var.create_safe("hi"), Var.create_safe("bye", _var_is_local=False)), - '[1, "hi", bye]', + (1, LiteralVar.create("hi")), + [1, "hi"], ), - ({1: 2, 3: 4}, '{"1": 2, "3": 4}'), + ({1: 2, 3: 4}, {1: 2, 3: 4}), ( - {1: Var.create_safe("hi"), 3: Var.create_safe("bye", _var_is_local=False)}, - '{"1": "hi", "3": bye}', + {1: LiteralVar.create("hi")}, + {1: "hi"}, ), (datetime.datetime(2021, 1, 1, 1, 1, 1, 1), "2021-01-01 01:01:01.000001"), (datetime.date(2021, 1, 1), "2021-01-01"), @@ -182,7 +183,7 @@ class BaseSubclass(Base): (datetime.timedelta(1, 1, 1), "1 day, 0:00:01.000001"), ( [datetime.timedelta(1, 1, 1), datetime.timedelta(1, 1, 2)], - '["1 day, 0:00:01.000001", "1 day, 0:00:01.000002"]', + ["1 day, 0:00:01.000001", "1 day, 0:00:01.000002"], ), (Color(color="slate", shade=1), "var(--slate-1)"), (Color(color="orange", shade=1, alpha=True), "var(--orange-a1)"), @@ -203,24 +204,28 @@ def test_serialize(value: Any, expected: str): @pytest.mark.parametrize( "value,expected,exp_var_is_string", [ - ("test", "test", False), + ("test", '"test"', False), (1, "1", False), (1.0, "1.0", False), (True, "true", False), (False, "false", False), ([1, 2, 3], "[1, 2, 3]", False), - ([{"key": 1}, {"key": 2}], '[{"key": 1}, {"key": 2}]', False), - (StrEnum.FOO, "foo", False), + ([{"key": 1}, {"key": 2}], '[({ ["key"] : 1 }), ({ ["key"] : 2 })]', False), + (StrEnum.FOO, '"foo"', False), ([StrEnum.FOO, StrEnum.BAR], '["foo", "bar"]', False), ( BaseSubclass(ts=datetime.timedelta(1, 1, 1)), - '{"ts": "1 day, 0:00:01.000001"}', + '({ ["ts"] : "1 day, 0:00:01.000001" })', False, ), - (datetime.datetime(2021, 1, 1, 1, 1, 1, 1), "2021-01-01 01:01:01.000001", True), - (Color(color="slate", shade=1), "var(--slate-1)", True), - (BaseSubclass, "BaseSubclass", True), - (Path("."), ".", True), + ( + datetime.datetime(2021, 1, 1, 1, 1, 1, 1), + '"2021-01-01 01:01:01.000001"', + True, + ), + (Color(color="slate", shade=1), '"var(--slate-1)"', True), + (BaseSubclass, '"BaseSubclass"', True), + (Path("."), '"."', True), ], ) def test_serialize_var_to_str(value: Any, expected: str, exp_var_is_string: bool): @@ -231,6 +236,5 @@ def test_serialize_var_to_str(value: Any, expected: str, exp_var_is_string: bool expected: The expected result. exp_var_is_string: The expected value of _var_is_string. """ - v = Var.create_safe(value) - assert v._var_full_name == expected - assert v._var_is_string == exp_var_is_string + v = LiteralVar.create(value) + assert str(v) == expected diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index e905ff587..5cdd846fe 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -18,8 +18,8 @@ from reflex.utils import ( types, ) from reflex.utils import exec as utils_exec -from reflex.utils.serializers import serialize -from reflex.vars import Var +from reflex.utils.exceptions import ReflexError +from reflex.vars.base import Var def mock_event(arg): @@ -538,11 +538,15 @@ def test_style_prop_with_event_handler_value(callable): callable: The callable function or event handler. """ + import reflex as rx + style = { "color": ( EventHandler(fn=callable) if type(callable) != EventHandler else callable ) } - with pytest.raises(TypeError): - serialize(style) # type: ignore + with pytest.raises(ReflexError): + rx.box( + style=style, # type: ignore + ) diff --git a/tests/vars/test_base.py b/tests/vars/test_base.py new file mode 100644 index 000000000..f83d79373 --- /dev/null +++ b/tests/vars/test_base.py @@ -0,0 +1,21 @@ +from typing import Dict, List, Union + +import pytest + +from reflex.vars.base import figure_out_type + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1, int), + (1.0, float), + ("a", str), + ([1, 2, 3], List[int]), + ([1, 2.0, "a"], List[Union[int, float, str]]), + ({"a": 1, "b": 2}, Dict[str, int]), + ({"a": 1, 2: "b"}, Dict[Union[int, str], Union[str, int]]), + ], +) +def test_figure_out_type(value, expected): + assert figure_out_type(value) == expected