diff --git a/.github/actions/setup_build_env/action.yml b/.github/actions/setup_build_env/action.yml index 425f2d233..a25f0ae44 100644 --- a/.github/actions/setup_build_env/action.yml +++ b/.github/actions/setup_build_env/action.yml @@ -18,7 +18,7 @@ inputs: poetry-version: description: 'Poetry version to install' required: false - default: '1.3.1' + default: '1.8.3' run-poetry-install: description: 'Whether to run poetry install on current dir' required: false @@ -106,3 +106,8 @@ runs: run: | source ${{ inputs.create-venv-at-path }}/*/activate poetry install --only-root --no-interaction + + - name: Install uv + shell: bash + run: | + poetry run pip install uv diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 5de54a528..aac67f7a6 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -17,20 +17,19 @@ defaults: env: PYTHONIOENCODING: 'utf8' TELEMETRY_ENABLED: false - NODE_OPTIONS: '--max_old_space_size=4096' - DATABASE_URL: ${{ secrets.DATABASE_URL }} + NODE_OPTIONS: '--max_old_space_size=8192' PR_TITLE: ${{ github.event.pull_request.title }} jobs: reflex-web: - if: github.event.pull_request.merged == true +# if: github.event.pull_request.merged == true strategy: fail-fast: false matrix: # Show OS combos first in GUI os: [ubuntu-latest] python-version: ['3.11.4'] - node-version: ['16.x'] + node-version: ['18.x'] runs-on: ${{ matrix.os }} steps: @@ -49,12 +48,12 @@ jobs: uses: actions/checkout@v4 with: repository: reflex-dev/reflex-web - ref: reflex-ci + ref: main path: reflex-web - name: Install Requirements for reflex-web working-directory: ./reflex-web - run: poetry run pip install -r requirements.txt + run: poetry run uv pip install -r requirements.txt - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init @@ -62,17 +61,16 @@ jobs: run: | # Check that npm is home npm -v - poetry run bash scripts/benchmarks/benchmarks.sh ./reflex-web prod + poetry run bash benchmarks/lighthouse.sh ./reflex-web prod env: LHCI_GITHUB_APP_TOKEN: $ - name: Run Benchmarks # Only run if the database creds are available in this context. - if: ${{ env.DATABASE_URL }} - run: poetry run python scripts/benchmarks/lighthouse_score_upload.py "$GITHUB_SHA" ./integration/benchmarks/.lighthouseci + run: poetry run python benchmarks/benchmark_lighthouse.py "$GITHUB_SHA" ./integration/benchmarks/.lighthouseci env: GITHUB_SHA: ${{ github.sha }} - simple-apps-benchmarks: + simple-apps-benchmarks: # This app tests the compile times of various compoonents and pages if: github.event.pull_request.merged == true env: OUTPUT_FILE: benchmarks.json @@ -83,17 +81,13 @@ 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.9.18', '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 @@ -105,8 +99,6 @@ jobs: 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: @@ -116,8 +108,6 @@ jobs: python-version: ${{ matrix.python-version }} run-poetry-install: true create-venv-at-path: .venv - - name: Install additional dependencies for DB access - run: poetry run pip install psycopg2-binary - name: Run benchmark tests env: APP_HARNESS_HEADLESS: 1 @@ -126,16 +116,14 @@ jobs: poetry run pytest -v benchmarks/ --benchmark-json=${{ env.OUTPUT_FILE }} -s - name: Upload benchmark results # Only run if the database creds are available in this context. - if: ${{ env.DATABASE_URL }} run: - poetry run python scripts/benchmarks/simple_app_benchmark_upload.py --os "${{ matrix.os }}" + poetry run python benchmarks/benchmark_compile_times.py --os "${{ matrix.os }}" --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" - --benchmark-json "${{ env.OUTPUT_FILE }}" - --db-url "${{ env.DATABASE_URL }}" --branch-name "${{ github.head_ref || github.ref_name }}" - --event-type "${{ github.event_name }}" --actor "${{ github.actor }}" --pr-id "${{ github.event.pull_request.id }}" + --benchmark-json "${{ env.OUTPUT_FILE }}" --branch-name "${{ github.head_ref || github.ref_name }}" + --event-type "${{ github.event_name }}" --pr-id "${{ github.event.pull_request.id }}" - reflex-build-size: - if: github.event.pull_request.merged == true + reflex-dist-size: # This job is used to calculate the size of the Reflex distribution (wheel file) + if: github.event.pull_request.merged == true timeout-minutes: 30 strategy: # Prioritize getting more information out of the workflow (even if something fails) @@ -148,22 +136,19 @@ jobs: python-version: 3.11.5 run-poetry-install: true create-venv-at-path: .venv - - name: Install additional dependencies for DB access - run: poetry run pip install psycopg2-binary - name: Build reflex run: | poetry build - name: Upload benchmark results # Only run if the database creds are available in this context. - if: ${{ env.DATABASE_URL }} run: - poetry run python scripts/benchmarks/benchmark_reflex_size.py --os ubuntu-latest + poetry run python benchmarks/benchmark_package_size.py --os ubuntu-latest --python-version 3.11.5 --commit-sha "${{ github.sha }}" --pr-id "${{ github.event.pull_request.id }}" - --db-url "${{ env.DATABASE_URL }}" --branch-name "${{ github.head_ref || github.ref_name }}" - --measurement-type "reflex-build" --path ./dist + --branch-name "${{ github.head_ref || github.ref_name }}" + --path ./dist - reflex-plus-dependency-size: - if: github.event.pull_request.merged == true + reflex-venv-size: # This job calculates the total size of Reflex and its dependencies + if: github.event.pull_request.merged == true timeout-minutes: 30 strategy: # Prioritize getting more information out of the workflow (even if something fails) @@ -192,14 +177,15 @@ jobs: source .venv/*/activate poetry install --without dev --no-interaction --no-root - - name: Install additional dependencies for DB access - run: poetry run pip install psycopg2-binary + - name: Install uv + shell: bash + run: | + poetry run pip install uv - - if: ${{ env.DATABASE_URL }} - name: calculate and upload size + - name: calculate and upload size run: - poetry run python scripts/benchmarks/benchmark_reflex_size.py --os "${{ matrix.os }}" + poetry run python benchmarks/benchmark_package_size.py --os "${{ matrix.os }}" --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" - --pr-id "${{ github.event.pull_request.id }}" --db-url "${{ env.DATABASE_URL }}" + --pr-id "${{ github.event.pull_request.id }}" --branch-name "${{ github.head_ref || github.ref_name }}" - --measurement-type "reflex-package" --path ./.venv + --path ./.venv \ No newline at end of file diff --git a/.github/workflows/check_node_latest.yml b/.github/workflows/check_node_latest.yml new file mode 100644 index 000000000..5910fa9ed --- /dev/null +++ b/.github/workflows/check_node_latest.yml @@ -0,0 +1,40 @@ +name: integration-node-latest + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + TELEMETRY_ENABLED: false + REFLEX_USE_SYSTEM_NODE: true + +jobs: + check_latest_node: + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ['3.12'] + node-version: ['node'] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup_build_env + with: + python-version: ${{ matrix.python-version }} + run-poetry-install: true + create-venv-at-path: .venv + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: | + poetry run uv pip install pyvirtualdisplay pillow + poetry run playwright install --with-deps + - run: | + poetry run pytest tests/test_node_version.py + poetry run pytest tests/integration + + + diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml new file mode 100644 index 000000000..fe8c42608 --- /dev/null +++ b/.github/workflows/check_outdated_dependencies.yml @@ -0,0 +1,88 @@ +name: check-outdated-dependencies + +on: + push: # This will trigger the action when a pull request is opened or updated. + branches: + - 'release/**' # This will trigger the action when any branch starting with "release/" is created. + workflow_dispatch: # Allow manual triggering if needed. + +jobs: + backend: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - uses: ./.github/actions/setup_build_env + with: + python-version: '3.9' + run-poetry-install: true + create-venv-at-path: .venv + + - name: Check outdated backend dependencies + run: | + outdated=$(poetry show -oT) + echo "Outdated:" + echo "$outdated" + + filtered_outdated=$(echo "$outdated" | grep -vE 'pyright|ruff' || true) + + if [ ! -z "$filtered_outdated" ]; then + echo "Outdated dependencies found:" + echo "$filtered_outdated" + exit 1 + else + echo "All dependencies are up to date. (pyright and ruff are ignored)" + fi + + + frontend: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + - uses: ./.github/actions/setup_build_env + with: + python-version: '3.10.11' + run-poetry-install: true + create-venv-at-path: .venv + - name: Clone Reflex Website Repo + uses: actions/checkout@v4 + with: + repository: reflex-dev/reflex-web + ref: main + path: reflex-web + - name: Install Requirements for reflex-web + working-directory: ./reflex-web + run: poetry run uv pip install -r requirements.txt + - name: Install additional dependencies for DB access + run: poetry run uv pip install psycopg2-binary + - name: Init Website for reflex-web + working-directory: ./reflex-web + run: poetry run reflex init + - name: Run Website and Check for errors + run: | + poetry run bash scripts/integration.sh ./reflex-web dev + - name: Check outdated frontend dependencies + working-directory: ./reflex-web/.web + run: | + raw_outdated=$(/home/runner/.local/share/reflex/bun/bin/bun outdated) + outdated=$(echo "$raw_outdated" | grep -vE '\|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\|' || true) + echo "Outdated:" + echo "$outdated" + + # Ignore 3rd party dependencies that are not updated. + filtered_outdated=$(echo "$outdated" | grep -vE 'Package|@chakra-ui|lucide-react|@splinetool/runtime|ag-grid-react|framer-motion|react-markdown|remark-math|remark-gfm|rehype-katex|rehype-raw|remark-unwrap-images' || true) + no_extra=$(echo "$filtered_outdated" | grep -vE '\|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-' || true) + + + if [ ! -z "$no_extra" ]; then + echo "Outdated dependencies found:" + echo "$filtered_outdated" + exit 1 + else + echo "All dependencies are up to date. (3rd party packages are ignored)" + fi + diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000..3a2403a48 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,17 @@ +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v4 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v4 + with: + allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, HPND, ISC, MIT, MPL-2.0, Unlicense, Python-2.0, Python-2.0.1, Apache-2.0 AND MIT, BSD-2-Clause AND BSD-3-Clause, Apache-2.0 AND BSD-3-Clause + allow-dependencies-licenses: 'pkg:pypi/lazy-loader' \ No newline at end of file diff --git a/.github/workflows/integration_app_harness.yml b/.github/workflows/integration_app_harness.yml index 6b113cd79..c86893556 100644 --- a/.github/workflows/integration_app_harness.yml +++ b/.github/workflows/integration_app_harness.yml @@ -23,8 +23,8 @@ jobs: strategy: matrix: state_manager: ['redis', 'memory'] - python-version: ['3.8.18', '3.11.5', '3.12.0'] - runs-on: ubuntu-latest + python-version: ['3.11.5', '3.12.0'] + runs-on: ubuntu-22.04 services: # Label used to access the service container redis: @@ -45,13 +45,14 @@ jobs: python-version: ${{ matrix.python-version }} run-poetry-install: true create-venv-at-path: .venv - - run: poetry run pip install pyvirtualdisplay pillow + - run: poetry run uv pip install pyvirtualdisplay pillow - name: Run app harness tests env: SCREENSHOT_DIR: /tmp/screenshots REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }} run: | - poetry run pytest integration + poetry run playwright install --with-deps + poetry run pytest tests/integration - uses: actions/upload-artifact@v4 name: Upload failed test screenshots if: always() diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index b1b622cb2..7717ef265 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -29,34 +29,31 @@ env: # - Best effort print lines that contain illegal chars (map to some default char, etc.) PYTHONIOENCODING: 'utf8' TELEMETRY_ENABLED: false - NODE_OPTIONS: '--max_old_space_size=4096' - DATABASE_URL: ${{ secrets.DATABASE_URL }} + NODE_OPTIONS: '--max_old_space_size=8192' PR_TITLE: ${{ github.event.pull_request.title }} jobs: example-counter: + env: + OUTPUT_FILE: import_benchmark.json timeout-minutes: 30 strategy: # Prioritize getting more information out of the workflow (even if something fails) fail-fast: false 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'] + os: [ubuntu-latest, windows-latest] + python-version: ['3.9.18', '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: @@ -74,9 +71,9 @@ jobs: - name: Install requirements for counter example working-directory: ./reflex-examples/counter run: | - poetry run pip install -r requirements.txt + poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run pip install psycopg2-binary + run: poetry run uv pip install psycopg2-binary - name: Check export --backend-only before init for counter example working-directory: ./reflex-examples/counter run: | @@ -98,20 +95,34 @@ jobs: npm -v poetry run bash scripts/integration.sh ./reflex-examples/counter dev - name: Measure and upload .web size - if: ${{ env.DATABASE_URL }} run: - poetry run python scripts/benchmarks/benchmark_reflex_size.py --os "${{ matrix.os }}" + poetry run python benchmarks/benchmark_web_size.py --os "${{ matrix.os }}" --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" - --pr-id "${{ github.event.pull_request.id }}" --db-url "${{ env.DATABASE_URL }}" + --pr-id "${{ github.event.pull_request.id }}" --branch-name "${{ github.head_ref || github.ref_name }}" - --measurement-type "counter-app-dot-web" --path ./reflex-examples/counter/.web + --path ./reflex-examples/counter/.web + --app-name "counter" + - name: Install hyperfine + run: cargo install hyperfine + - name: Benchmark imports + working-directory: ./reflex-examples/counter + run: hyperfine --warmup 3 "export POETRY_VIRTUALENVS_PATH=../../.venv; poetry run python counter/counter.py" --show-output --export-json "${{ env.OUTPUT_FILE }}" --shell bash + - name: Upload Benchmarks + run: + poetry run python benchmarks/benchmark_imports.py --os "${{ matrix.os }}" + --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" + --benchmark-json "./reflex-examples/counter/${{ env.OUTPUT_FILE }}" + --branch-name "${{ github.head_ref || github.ref_name }}" --pr-id "${{ github.event.pull_request.id }}" + --app-name "counter" + + reflex-web: strategy: fail-fast: false matrix: # Show OS combos first in GUI - os: [ubuntu-latest, windows-latest, macos-12] + os: [ubuntu-latest] python-version: ['3.10.11', '3.11.4'] env: @@ -134,9 +145,9 @@ jobs: - name: Install Requirements for reflex-web working-directory: ./reflex-web - run: poetry run pip install -r requirements.txt + run: poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run pip install psycopg2-binary + run: poetry run uv pip install psycopg2-binary - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init @@ -146,10 +157,49 @@ jobs: npm -v poetry run bash scripts/integration.sh ./reflex-web prod - name: Measure and upload .web size - if: ${{ env.DATABASE_URL }} run: - poetry run python scripts/benchmarks/benchmark_reflex_size.py --os "${{ matrix.os }}" + poetry run python benchmarks/benchmark_web_size.py --os "${{ matrix.os }}" --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" - --pr-id "${{ github.event.pull_request.id }}" - --db-url "${{ env.DATABASE_URL }}" --branch-name "${{ github.head_ref || github.ref_name }}" - --measurement-type "reflex-web-dot-web" --path ./reflex-web/.web + --pr-id "${{ github.event.pull_request.id }}" --branch-name "${{ github.head_ref || github.ref_name }}" + --app-name "reflex-web" --path ./reflex-web/.web + + reflex-web-macos: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + strategy: + fail-fast: false + matrix: + python-version: ['3.11.5', '3.12.0'] + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup_build_env + with: + python-version: ${{ matrix.python-version }} + run-poetry-install: true + create-venv-at-path: .venv + - name: Clone Reflex Website Repo + uses: actions/checkout@v4 + with: + repository: reflex-dev/reflex-web + ref: main + path: reflex-web + - name: Install Requirements for reflex-web + working-directory: ./reflex-web + run: poetry run uv pip install -r requirements.txt + - name: Install additional dependencies for DB access + run: poetry run uv pip install psycopg2-binary + - name: Init Website for reflex-web + working-directory: ./reflex-web + run: poetry run reflex init + - name: Run Website and Check for errors + run: | + # Check that npm is home + npm -v + poetry run bash scripts/integration.sh ./reflex-web prod + - name: Measure and upload .web size + run: + poetry run python benchmarks/benchmark_web_size.py --os "${{ matrix.os }}" + --python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}" + --pr-id "${{ github.event.pull_request.id }}" --branch-name "${{ github.head_ref || github.ref_name }}" + --app-name "reflex-web" --path ./reflex-web/.web + \ No newline at end of file diff --git a/.github/workflows/integration_tests_wsl.yml b/.github/workflows/integration_tests_wsl.yml index 87f611898..7a743252b 100644 --- a/.github/workflows/integration_tests_wsl.yml +++ b/.github/workflows/integration_tests_wsl.yml @@ -37,6 +37,8 @@ jobs: path: reflex-examples - uses: Vampire/setup-wsl@v3 + with: + distribution: Ubuntu-24.04 - name: Install Python shell: wsl-bash {0} @@ -56,11 +58,16 @@ jobs: run: | poetry install + - name: Install uv + shell: wsl-bash {0} + run: | + poetry run pip install uv + - name: Install requirements for counter example working-directory: ./reflex-examples/counter shell: wsl-bash {0} run: | - poetry run pip install -r requirements.txt + poetry run uv pip install -r requirements.txt - name: Check export --backend-only before init for counter example working-directory: ./reflex-examples/counter shell: wsl-bash {0} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 452399c45..9e6e42a38 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -28,7 +28,7 @@ jobs: create-venv-at-path: .venv # TODO pre-commit related stuff can be cached too (not a bottleneck yet) - run: | - poetry run pip install pre-commit + poetry run uv pip install pre-commit poetry run pre-commit run --all-files env: SKIP: update-pyi-files diff --git a/.github/workflows/reflex_init_in_docker_test.yml b/.github/workflows/reflex_init_in_docker_test.yml index b34efd2f6..ce56a1310 100644 --- a/.github/workflows/reflex_init_in_docker_test.yml +++ b/.github/workflows/reflex_init_in_docker_test.yml @@ -28,5 +28,5 @@ jobs: # Run reflex init in a docker container # cwd is repo root - docker build -f integration/init-test/Dockerfile -t reflex-init-test integration/init-test - docker run --rm -v $(pwd):/reflex-repo/ reflex-init-test /reflex-repo/integration/init-test/in_docker_test_script.sh + docker build -f tests/integration/init-test/Dockerfile -t reflex-init-test tests/integration/init-test + docker run --rm -v $(pwd):/reflex-repo/ reflex-init-test /reflex-repo/tests/integration/init-test/in_docker_test_script.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 178859d29..c76918583 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -27,24 +27,21 @@ jobs: strategy: 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'] + os: [ubuntu-latest, windows-latest] + python-version: ['3.9.18', '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: # Label used to access the service container @@ -69,17 +66,43 @@ jobs: - name: Run unit tests run: | export PYTHONUNBUFFERED=1 - poetry run pytest tests --cov --no-cov-on-fail --cov-report= + poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= - name: Run unit tests w/ redis if: ${{ matrix.os == 'ubuntu-latest' }} run: | export PYTHONUNBUFFERED=1 export REDIS_URL=redis://localhost:6379 - poetry run pytest tests --cov --no-cov-on-fail --cov-report= + poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= # Change to explicitly install v1 when reflex-hosting-cli is compatible with v2 - name: Run unit tests w/ pydantic v1 run: | export PYTHONUNBUFFERED=1 - poetry run pip install "pydantic~=1.10" - poetry run pytest tests --cov --no-cov-on-fail --cov-report= - - run: poetry run coverage html + poetry run uv pip install "pydantic~=1.10" + poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= + - name: Generate coverage report + run: poetry run coverage html + + unit-tests-macos: + timeout-minutes: 30 + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + strategy: + fail-fast: false + matrix: + python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0'] + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup_build_env + with: + python-version: ${{ matrix.python-version }} + run-poetry-install: true + create-venv-at-path: .venv + - name: Run unit tests + run: | + export PYTHONUNBUFFERED=1 + poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= + - name: Run unit tests w/ pydantic v1 + run: | + export PYTHONUNBUFFERED=1 + poetry run uv pip install "pydantic~=1.10" + poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= \ No newline at end of file diff --git a/.gitignore b/.gitignore index c6acfc099..0f7d9e5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ **/.DS_Store **/*.pyc +assets/external/* dist/* examples/ +.web .idea .vscode .coverage @@ -11,3 +13,4 @@ venv requirements.txt .pyi_generator_last_run .pyi_generator_diff +reflex.db diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e36cbdfe6..60cbec00f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,19 +3,29 @@ fail_fast: true repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.0 + rev: v0.7.1 hooks: - id: ruff-format - args: [integration, reflex, tests] + args: [reflex, tests] - id: ruff args: ["--fix", "--exit-non-zero-on-fix"] exclude: '^integration/benchmarks/' + # Run pyi check before pyright because pyright can fail if pyi files are wrong. + - repo: local + hooks: + - id: update-pyi-files + name: update-pyi-files + always_run: true + language: system + description: 'Update pyi files as needed' + entry: python3 scripts/make_pyi.py + - repo: https://github.com/RobertCraigie/pyright-python rev: v1.1.313 hooks: - id: pyright - args: [integration, reflex, tests] + args: [reflex, tests] language: system - repo: https://github.com/terrencepreilly/darglint @@ -24,11 +34,3 @@ repos: - id: darglint exclude: '^reflex/reflex.py' - - repo: local - hooks: - - id: update-pyi-files - name: update-pyi-files - always_run: true - language: system - description: 'Update pyi files as needed' - entry: python scripts/make_pyi.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff669c625..fc8398013 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.9 - 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:** @@ -69,7 +69,7 @@ In your `reflex` directory run make sure all the unit tests are still passing us This will fail if code coverage is below 70%. ``` bash -poetry run pytest tests --cov --no-cov-on-fail --cov-report= +poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= ``` Next make sure all the following tests pass. This ensures that every new change has proper documentation and type checking. @@ -80,14 +80,14 @@ poetry run pyright reflex tests find reflex tests -name "*.py" -not -path reflex/reflex.py | xargs poetry run darglint ``` -Finally, run `black` to format your code. +Finally, run `ruff` to format your code. ``` bash -poetry run black reflex tests +poetry run ruff format . ``` -Consider installing git pre-commit hooks so Ruff, Pyright, Darglint and Black will run automatically before each commit. -Note that pre-commit will only be installed when you use a Python version >= 3.8. +Consider installing git pre-commit hooks so Ruff, Pyright, Darglint and `make_pyi` will run automatically before each commit. +Note that pre-commit will only be installed when you use a Python version >= 3.9. ``` bash pre-commit install diff --git a/README.md b/README.md index 675f29cc3..527cca980 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) @@ -18,7 +17,7 @@ --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) | [Tiếng Việt](https://github.com/reflex-dev/reflex/blob/main/docs/vi/README.md) --- @@ -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.9+): ```bash pip install reflex @@ -120,14 +119,15 @@ def index(): on_blur=State.set_prompt, width="25em", ), - rx.button("Generate Image", on_click=State.get_image, width="25em"), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), rx.cond( - State.processing, - rx.chakra.circular_progress(is_indeterminate=True), - rx.cond( - State.complete, - rx.image(src=State.image_url, width="20em"), - ), + State.complete, + rx.image(src=State.image_url, width="20em"), ), align="center", ), @@ -185,7 +185,7 @@ class State(rx.State): The state defines all the variables (called vars) in an app that can change and the functions that change them. -Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to show the circular progress and image. +Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to disable the button (during image generation) and when to show the resulting image. ### **Event Handlers** @@ -228,7 +228,7 @@ You can create a multi-page app by adding more pages.
-📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)   +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Templates](https://reflex.dev/templates/)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)  
diff --git a/scripts/benchmarks/simple_app_benchmark_upload.py b/benchmarks/benchmark_compile_times.py similarity index 71% rename from scripts/benchmarks/simple_app_benchmark_upload.py rename to benchmarks/benchmark_compile_times.py index 7edb73fab..2273bd5c8 100644 --- a/scripts/benchmarks/simple_app_benchmark_upload.py +++ b/benchmarks/benchmark_compile_times.py @@ -1,13 +1,12 @@ -"""Runs the benchmarks and inserts the results into the database.""" +"""Extracts the compile times from the JSON files in the specified directory and inserts them into the database.""" from __future__ import annotations import argparse import json import os -from datetime import datetime -import psycopg2 +from utils import send_data_to_posthog def extract_stats_from_json(json_file: str) -> list[dict]: @@ -51,7 +50,6 @@ def extract_stats_from_json(json_file: str) -> list[dict]: def insert_benchmarking_data( - db_connection_url: str, os_type_version: str, python_version: str, performance_data: list[dict], @@ -59,52 +57,33 @@ def insert_benchmarking_data( pr_title: str, branch_name: str, event_type: str, - actor: str, pr_id: str, ): """Insert the benchmarking data into the database. Args: - db_connection_url: The URL to connect to the database. os_type_version: The OS type and version to insert. python_version: The Python version to insert. performance_data: The performance data of reflex web to insert. commit_sha: The commit SHA to insert. pr_title: The PR title to insert. branch_name: The name of the branch. - event_type: Type of github event(push, pull request, etc) - actor: Username of the user that triggered the run. + event_type: Type of github event(push, pull request, etc). pr_id: Id of the PR. """ - # Serialize the JSON data - simple_app_performance_json = json.dumps(performance_data) + # Prepare the event data + properties = { + "os": os_type_version, + "python_version": python_version, + "distinct_id": commit_sha, + "pr_title": pr_title, + "branch_name": branch_name, + "event_type": event_type, + "performance": performance_data, + "pr_id": pr_id, + } - # Get the current timestamp - current_timestamp = datetime.now() - - # Connect to the database and insert the data - with psycopg2.connect(db_connection_url) as conn, conn.cursor() as cursor: - insert_query = """ - INSERT INTO simple_app_benchmarks (os, python_version, commit_sha, time, pr_title, branch_name, event_type, actor, performance, pr_id) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s); - """ - cursor.execute( - insert_query, - ( - os_type_version, - python_version, - commit_sha, - current_timestamp, - pr_title, - branch_name, - event_type, - actor, - simple_app_performance_json, - pr_id, - ), - ) - # Commit the transaction - conn.commit() + send_data_to_posthog("simple_app_benchmark", properties) def main(): @@ -124,11 +103,6 @@ def main(): "--benchmark-json", help="The JSON file containing the benchmark results.", ) - parser.add_argument( - "--db-url", - help="The URL to connect to the database.", - required=True, - ) parser.add_argument( "--pr-title", help="The PR title to insert into the database.", @@ -143,11 +117,6 @@ def main(): help="The github event type", required=True, ) - parser.add_argument( - "--actor", - help="Username of the user that triggered the run.", - required=True, - ) parser.add_argument( "--pr-id", help="ID of the PR.", @@ -162,7 +131,6 @@ def main(): cleaned_benchmark_results = extract_stats_from_json(args.benchmark_json) # Insert the data into the database insert_benchmarking_data( - db_connection_url=args.db_url, os_type_version=args.os, python_version=args.python_version, performance_data=cleaned_benchmark_results, @@ -170,7 +138,6 @@ def main(): pr_title=pr_title, branch_name=args.branch_name, event_type=args.event_type, - actor=args.actor, pr_id=args.pr_id, ) diff --git a/benchmarks/benchmark_imports.py b/benchmarks/benchmark_imports.py new file mode 100644 index 000000000..4706c0cf6 --- /dev/null +++ b/benchmarks/benchmark_imports.py @@ -0,0 +1,127 @@ +"""Extract and upload benchmarking data to PostHog.""" + +from __future__ import annotations + +import argparse +import json +import os + +from utils import send_data_to_posthog + + +def extract_stats_from_json(json_file: str) -> dict: + """Extracts the stats from the JSON data and returns them as dictionaries. + + Args: + json_file: The JSON file to extract the stats data from. + + Returns: + dict: The stats for each test. + """ + with open(json_file, "r") as file: + json_data = json.load(file) + + # Load the JSON data if it is a string, otherwise assume it's already a dictionary + data = json.loads(json_data) if isinstance(json_data, str) else json_data + + result = data.get("results", [{}])[0] + return { + k: v + for k, v in result.items() + if k in ("mean", "stddev", "median", "min", "max") + } + + +def insert_benchmarking_data( + os_type_version: str, + python_version: str, + performance_data: dict, + commit_sha: str, + pr_title: str, + branch_name: str, + pr_id: str, + app_name: str, +): + """Insert the benchmarking data into the database. + + Args: + os_type_version: The OS type and version to insert. + python_version: The Python version to insert. + performance_data: The imports performance data to insert. + commit_sha: The commit SHA to insert. + pr_title: The PR title to insert. + branch_name: The name of the branch. + pr_id: Id of the PR. + app_name: The name of the app being measured. + """ + properties = { + "os": os_type_version, + "python_version": python_version, + "distinct_id": commit_sha, + "pr_title": pr_title, + "branch_name": branch_name, + "pr_id": pr_id, + "performance": performance_data, + "app_name": app_name, + } + + send_data_to_posthog("import_benchmark", properties) + + +def main(): + """Runs the benchmarks and inserts the results.""" + # Get the commit SHA and JSON directory from the command line arguments + parser = argparse.ArgumentParser(description="Run benchmarks and process results.") + parser.add_argument( + "--os", help="The OS type and version to insert into the database." + ) + parser.add_argument( + "--python-version", help="The Python version to insert into the database." + ) + parser.add_argument( + "--commit-sha", help="The commit SHA to insert into the database." + ) + parser.add_argument( + "--benchmark-json", + help="The JSON file containing the benchmark results.", + ) + parser.add_argument( + "--pr-title", + help="The PR title to insert into the database.", + ) + parser.add_argument( + "--branch-name", + help="The current branch", + required=True, + ) + parser.add_argument( + "--app-name", + help="The name of the app measured.", + required=True, + ) + parser.add_argument( + "--pr-id", + help="ID of the PR.", + required=True, + ) + args = parser.parse_args() + + # Get the PR title from env or the args. For the PR merge or push event, there is no PR title, leaving it empty. + pr_title = args.pr_title or os.getenv("PR_TITLE", "") + + cleaned_benchmark_results = extract_stats_from_json(args.benchmark_json) + # Insert the data into the database + insert_benchmarking_data( + os_type_version=args.os, + python_version=args.python_version, + performance_data=cleaned_benchmark_results, + commit_sha=args.commit_sha, + pr_title=pr_title, + branch_name=args.branch_name, + app_name=args.app_name, + pr_id=args.pr_id, + ) + + +if __name__ == "__main__": + main() diff --git a/benchmarks/benchmark_lighthouse.py b/benchmarks/benchmark_lighthouse.py new file mode 100644 index 000000000..d428c16e6 --- /dev/null +++ b/benchmarks/benchmark_lighthouse.py @@ -0,0 +1,75 @@ +"""Extracts the Lighthouse scores from the JSON files in the specified directory and inserts them into the database.""" + +from __future__ import annotations + +import json +import sys +from pathlib import Path + +from utils import send_data_to_posthog + + +def insert_benchmarking_data( + lighthouse_data: dict, + commit_sha: str, +): + """Insert the benchmarking data into the database. + + Args: + lighthouse_data: The Lighthouse data to insert. + commit_sha: The commit SHA to insert. + """ + properties = { + "distinct_id": commit_sha, + "lighthouse_data": lighthouse_data, + } + + # Send the data to PostHog + send_data_to_posthog("lighthouse_benchmark", properties) + + +def get_lighthouse_scores(directory_path: str | Path) -> dict: + """Extracts the Lighthouse scores from the JSON files in the specified directory. + + Args: + directory_path (str): The path to the directory containing the JSON files. + + Returns: + dict: The Lighthouse scores. + """ + scores = {} + directory_path = Path(directory_path) + try: + for filename in directory_path.iterdir(): + if filename.suffix == ".json" and filename.stem != "manifest": + data = json.loads(filename.read_text()) + # Extract scores and add them to the dictionary with the filename as key + scores[data["finalUrl"].replace("http://localhost:3000/", "/")] = { + "performance_score": data["categories"]["performance"]["score"], + "accessibility_score": data["categories"]["accessibility"]["score"], + "best_practices_score": data["categories"]["best-practices"][ + "score" + ], + "seo_score": data["categories"]["seo"]["score"], + } + except Exception as e: + return {"error": e} + + return scores + + +def main(): + """Runs the benchmarks and inserts the results into the database.""" + # Get the commit SHA and JSON directory from the command line arguments + commit_sha = sys.argv[1] + json_dir = sys.argv[2] + + # Get the Lighthouse scores + lighthouse_scores = get_lighthouse_scores(json_dir) + + # Insert the data into the database + insert_benchmarking_data(lighthouse_scores, commit_sha) + + +if __name__ == "__main__": + main() diff --git a/benchmarks/benchmark_package_size.py b/benchmarks/benchmark_package_size.py new file mode 100644 index 000000000..778b52769 --- /dev/null +++ b/benchmarks/benchmark_package_size.py @@ -0,0 +1,135 @@ +"""Checks the size of a specific directory and uploads result to Posthog.""" + +import argparse +import os +from pathlib import Path + +from utils import get_directory_size, get_python_version, send_data_to_posthog + + +def get_package_size(venv_path: Path, os_name): + """Get the size of a specified package. + + Args: + venv_path: The path to the venv. + os_name: Name of os. + + Returns: + The total size of the package in bytes. + + Raises: + ValueError: when venv does not exist or python version is None. + """ + python_version = get_python_version(venv_path, os_name) + print("Python version:", python_version) + if python_version is None: + raise ValueError("Error: Failed to determine Python version.") + + is_windows = "windows" in os_name + + package_dir: Path = ( + venv_path / "lib" / f"python{python_version}" / "site-packages" + if not is_windows + else venv_path / "Lib" / "site-packages" + ) + if not package_dir.exists(): + raise ValueError( + "Error: Virtual environment does not exist or is not activated." + ) + + total_size = get_directory_size(package_dir) + return total_size + + +def insert_benchmarking_data( + os_type_version: str, + python_version: str, + commit_sha: str, + pr_title: str, + branch_name: str, + pr_id: str, + path: str, +): + """Insert the benchmarking data into PostHog. + + Args: + os_type_version: The OS type and version to insert. + python_version: The Python version to insert. + commit_sha: The commit SHA to insert. + pr_title: The PR title to insert. + branch_name: The name of the branch. + pr_id: The id of the PR. + path: The path to the dir or file to check size. + """ + if "./dist" in path: + size = get_directory_size(Path(path)) + else: + size = get_package_size(Path(path), os_type_version) + + # Prepare the event data + properties = { + "path": path, + "os": os_type_version, + "python_version": python_version, + "distinct_id": commit_sha, + "pr_title": pr_title, + "branch_name": branch_name, + "pr_id": pr_id, + "size_mb": round( + size / (1024 * 1024), 3 + ), # save size in MB and round to 3 places + } + + send_data_to_posthog("package_size", properties) + + +def main(): + """Runs the benchmarks and inserts the results.""" + parser = argparse.ArgumentParser(description="Run benchmarks and process results.") + parser.add_argument( + "--os", help="The OS type and version to insert into the database." + ) + parser.add_argument( + "--python-version", help="The Python version to insert into the database." + ) + parser.add_argument( + "--commit-sha", help="The commit SHA to insert into the database." + ) + parser.add_argument( + "--pr-title", + help="The PR title to insert into the database.", + ) + parser.add_argument( + "--branch-name", + help="The current branch", + required=True, + ) + parser.add_argument( + "--pr-id", + help="The pr id", + required=True, + ) + parser.add_argument( + "--path", + help="The path to the vnenv.", + required=True, + ) + args = parser.parse_args() + + # Get the PR title from env or the args. For the PR merge or push event, there is no PR title, leaving it empty. + pr_title = args.pr_title or os.getenv("PR_TITLE", "") + + # Insert the data into the database + insert_benchmarking_data( + os_type_version=args.os, + python_version=args.python_version, + commit_sha=args.commit_sha, + pr_title=pr_title, + branch_name=args.branch_name, + pr_id=args.pr_id, + path=args.path, + ) + + +if __name__ == "__main__": + main() diff --git a/benchmarks/benchmark_web_size.py b/benchmarks/benchmark_web_size.py new file mode 100644 index 000000000..3ceccecf8 --- /dev/null +++ b/benchmarks/benchmark_web_size.py @@ -0,0 +1,106 @@ +"""Checks the size of a specific directory and uploads result to Posthog.""" + +import argparse +import os +from pathlib import Path + +from utils import get_directory_size, send_data_to_posthog + + +def insert_benchmarking_data( + os_type_version: str, + python_version: str, + app_name: str, + commit_sha: str, + pr_title: str, + branch_name: str, + pr_id: str, + path: str, +): + """Insert the benchmarking data into PostHog. + + Args: + app_name: The name of the app being measured. + os_type_version: The OS type and version to insert. + python_version: The Python version to insert. + commit_sha: The commit SHA to insert. + pr_title: The PR title to insert. + branch_name: The name of the branch. + pr_id: The id of the PR. + path: The path to the dir or file to check size. + """ + size = get_directory_size(Path(path)) + + # Prepare the event data + properties = { + "app_name": app_name, + "os": os_type_version, + "python_version": python_version, + "distinct_id": commit_sha, + "pr_title": pr_title, + "branch_name": branch_name, + "pr_id": pr_id, + "size_mb": round( + size / (1024 * 1024), 3 + ), # save size in MB and round to 3 places + } + + send_data_to_posthog("web-size", properties) + + +def main(): + """Runs the benchmarks and inserts the results.""" + parser = argparse.ArgumentParser(description="Run benchmarks and process results.") + parser.add_argument( + "--os", help="The OS type and version to insert into the database." + ) + parser.add_argument( + "--python-version", help="The Python version to insert into the database." + ) + parser.add_argument( + "--commit-sha", help="The commit SHA to insert into the database." + ) + parser.add_argument( + "--pr-title", + help="The PR title to insert into the database.", + ) + parser.add_argument( + "--branch-name", + help="The current branch", + required=True, + ) + parser.add_argument( + "--app-name", + help="The name of the app measured.", + required=True, + ) + parser.add_argument( + "--pr-id", + help="The pr id", + required=True, + ) + parser.add_argument( + "--path", + help="The current path to app to check.", + required=True, + ) + args = parser.parse_args() + + # Get the PR title from env or the args. For the PR merge or push event, there is no PR title, leaving it empty. + pr_title = args.pr_title or os.getenv("PR_TITLE", "") + + # Insert the data into the database + insert_benchmarking_data( + app_name=args.app_name, + os_type_version=args.os, + python_version=args.python_version, + commit_sha=args.commit_sha, + pr_title=pr_title, + branch_name=args.branch_name, + pr_id=args.pr_id, + path=args.path, + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/benchmarks/benchmarks.sh b/benchmarks/lighthouse.sh similarity index 100% rename from scripts/benchmarks/benchmarks.sh rename to benchmarks/lighthouse.sh diff --git a/benchmarks/test_benchmark_compile_components.py b/benchmarks/test_benchmark_compile_components.py index 14d5d4d89..81d0c2e89 100644 --- a/benchmarks/test_benchmark_compile_components.py +++ b/benchmarks/test_benchmark_compile_components.py @@ -13,6 +13,9 @@ from reflex import constants from reflex.compiler import utils from reflex.testing import AppHarness, chdir from reflex.utils import build +from reflex.utils.prerequisites import get_web_dir + +web_pages = get_web_dir() / constants.Dirs.PAGES def render_component(num: int): @@ -231,7 +234,7 @@ def test_app_10_compile_time_cold(benchmark, app_with_10_components): def setup(): with chdir(app_with_10_components.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, ["_app.js"]) app_with_10_components._initialize_app() build.setup_frontend(app_with_10_components.app_path) @@ -284,7 +287,7 @@ def test_app_100_compile_time_cold(benchmark, app_with_100_components): def setup(): with chdir(app_with_100_components.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, ["_app.js"]) app_with_100_components._initialize_app() build.setup_frontend(app_with_100_components.app_path) @@ -337,7 +340,7 @@ def test_app_1000_compile_time_cold(benchmark, app_with_1000_components): def setup(): with chdir(app_with_1000_components.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_1000_components._initialize_app() build.setup_frontend(app_with_1000_components.app_path) diff --git a/benchmarks/test_benchmark_compile_pages.py b/benchmarks/test_benchmark_compile_pages.py index 97e1bb68e..4448bca45 100644 --- a/benchmarks/test_benchmark_compile_pages.py +++ b/benchmarks/test_benchmark_compile_pages.py @@ -13,6 +13,9 @@ from reflex import constants from reflex.compiler import utils from reflex.testing import AppHarness, chdir from reflex.utils import build +from reflex.utils.prerequisites import get_web_dir + +web_pages = get_web_dir() / constants.Dirs.PAGES def render_multiple_pages(app, num: int): @@ -141,7 +144,7 @@ def AppWithOnePage(): def index() -> rx.Component: return rx.center( - rx.chakra.input( + rx.input( id="token", value=State.router.session.client_token, is_read_only=True ), rx.vstack( @@ -320,7 +323,7 @@ def test_app_1_compile_time_cold(benchmark, app_with_one_page): def setup(): with chdir(app_with_one_page.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_one_page._initialize_app() build.setup_frontend(app_with_one_page.app_path) @@ -375,7 +378,7 @@ def test_app_10_compile_time_cold(benchmark, app_with_ten_pages): def setup(): with chdir(app_with_ten_pages.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_ten_pages._initialize_app() build.setup_frontend(app_with_ten_pages.app_path) @@ -430,7 +433,7 @@ def test_app_100_compile_time_cold(benchmark, app_with_hundred_pages): def setup(): with chdir(app_with_hundred_pages.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_hundred_pages._initialize_app() build.setup_frontend(app_with_hundred_pages.app_path) @@ -485,7 +488,7 @@ def test_app_1000_compile_time_cold(benchmark, app_with_thousand_pages): def setup(): with chdir(app_with_thousand_pages.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_thousand_pages._initialize_app() build.setup_frontend(app_with_thousand_pages.app_path) @@ -540,7 +543,7 @@ def test_app_10000_compile_time_cold(benchmark, app_with_ten_thousand_pages): def setup(): with chdir(app_with_ten_thousand_pages.app_path): - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(web_pages, keep_files=["_app.js"]) app_with_ten_thousand_pages._initialize_app() build.setup_frontend(app_with_ten_thousand_pages.app_path) diff --git a/benchmarks/utils.py b/benchmarks/utils.py new file mode 100644 index 000000000..bfadf5b4e --- /dev/null +++ b/benchmarks/utils.py @@ -0,0 +1,74 @@ +"""Utility functions for the benchmarks.""" + +import os +import subprocess +from pathlib import Path + +import httpx +from httpx import HTTPError + + +def get_python_version(venv_path: Path, os_name): + """Get the python version of python in a virtual env. + + Args: + venv_path: Path to virtual environment. + os_name: Name of os. + + Returns: + The python version. + """ + python_executable = ( + venv_path / "bin" / "python" + if "windows" not in os_name + else venv_path / "Scripts" / "python.exe" + ) + try: + output = subprocess.check_output( + [str(python_executable), "--version"], stderr=subprocess.STDOUT + ) + python_version = output.decode("utf-8").strip().split()[1] + return ".".join(python_version.split(".")[:-1]) + except subprocess.CalledProcessError: + return None + + +def get_directory_size(directory: Path): + """Get the size of a directory in bytes. + + Args: + directory: The directory to check. + + Returns: + The size of the dir in bytes. + """ + total_size = 0 + for dirpath, _, filenames in os.walk(directory): + for f in filenames: + fp = Path(dirpath) / f + total_size += fp.stat().st_size + return total_size + + +def send_data_to_posthog(event, properties): + """Send data to PostHog. + + Args: + event: The event to send. + properties: The properties to send. + + Raises: + HTTPError: When there is an error sending data to PostHog. + """ + event_data = { + "api_key": "phc_JoMo0fOyi0GQAooY3UyO9k0hebGkMyFJrrCw1Gt5SGb", + "event": event, + "properties": properties, + } + + with httpx.Client() as client: + response = client.post("https://app.posthog.com/capture/", json=event_data) + if response.status_code != 200: + raise HTTPError( + f"Error sending data to PostHog: {response.status_code} - {response.text}" + ) 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 < +Reflex Logo +Reflex Logo + +
+ +### **✨ Performante, anpassbare Web-Apps in purem Python. Bereitstellung in Sekunden. ✨** +[![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex) +![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) + + +--- + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) + +--- + +# Reflex + +Reflex ist eine Bibliothek, mit der man Full-Stack-Web-Applikationen in purem Python erstellen kann. + +Wesentliche Merkmale: +* **Pures Python** - Schreibe dein Front- und Backend in Python, es gibt also keinen Grund, JavaScript zu lernen. +* **Volle Flexibilität** - Reflex ist einfach zu handhaben, kann aber auch für komplexe Anwendungen skaliert werden. +* **Sofortige Bereitstellung** - Nach dem Erstellen kannst du deine App mit einem [einzigen Befehl](https://reflex.dev/docs/hosting/deploy-quick-start/) bereitstellen oder auf deinem eigenen Server hosten. + +Auf unserer [Architektur-Seite](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) erfahren Sie, wie Reflex unter der Haube funktioniert. + +## ⚙️ Installation + +Öffne ein Terminal und führe den folgenden Befehl aus (benötigt Python 3.9+): + +```bash +pip install reflex +``` + +## 🥳 Erstelle deine erste App + +Die Installation von `reflex` installiert auch das `reflex`-Kommandozeilen-Tool. + +Teste, ob die Installation erfolgreich war, indem du ein neues Projekt erstellst. (Ersetze `my_app_name` durch deinen Projektnamen): + +```bash +mkdir my_app_name +cd my_app_name +reflex init +``` + +Dieser Befehl initialisiert eine Vorlage in deinem neuen Verzeichnis. + +Du kannst diese App im Entwicklungsmodus ausführen: + +```bash +reflex run +``` + +Du solltest deine App unter http://localhost:3000 laufen sehen. + +Nun kannst du den Quellcode in `my_app_name/my_app_name.py` ändern. Reflex hat schnelle Aktualisierungen, sodass du deine Änderungen sofort siehst, wenn du deinen Code speicherst. + + +## 🫧 Beispiel-App + +Lass uns ein Beispiel durchgehen: die Erstellung einer Benutzeroberfläche für die Bildgenerierung mit [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node). Zur Vereinfachung rufen wir einfach die [OpenAI-API](https://platform.openai.com/docs/api-reference/authentication) auf, aber du könntest dies auch durch ein lokal ausgeführtes ML-Modell ersetzen. + +  + +
+Eine Benutzeroberfläche für DALL·E, die im Prozess der Bildgenerierung gezeigt wird. +
+ +  + +Hier ist der komplette Code, um dies zu erstellen. Das alles wird in einer Python-Datei gemacht! + + + +```python +import reflex as rx +import openai + +openai_client = openai.OpenAI() + + +class State(rx.State): + """Der Zustand der App.""" + + prompt = "" + image_url = "" + processing = False + complete = False + + def get_image(self): + """Hole das Bild aus dem Prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True + + +def index(): + return rx.center( + rx.vstack( + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), + rx.cond( + State.complete, + rx.image(src=State.image_url, width="20em"), + ), + align="center", + ), + width="100%", + height="100vh", + ) + +# Füge Zustand und Seite zur App hinzu. +app = rx.App() +app.add_page(index, title="Reflex:DALL-E") +``` + + + + + +## Schauen wir uns das mal genauer an. + +
+Erläuterung der Unterschiede zwischen Backend- und Frontend-Teilen der DALL-E-App. +
+ + +### **Reflex-UI** + +Fangen wir mit der Benutzeroberfläche an. + +```python +def index(): + return rx.center( + ... + ) +``` + +Diese `index`-Funktion definiert das Frontend der App. + +Wir verwenden verschiedene Komponenten wie `center`, `vstack`, `input` und `button`, um das Frontend zu erstellen. Komponenten können ineinander verschachtelt werden, um komplexe Layouts zu erstellen. Und du kannst Schlüsselwortargumente verwenden, um sie mit der vollen Kraft von CSS zu stylen. + +Reflex wird mit [über 60 eingebauten Komponenten](https://reflex.dev/docs/library) geliefert, die dir den Einstieg erleichtern. Wir fügen aktiv weitere Komponenten hinzu, und es ist einfach, [eigene Komponenten zu erstellen](https://reflex.dev/docs/wrapping-react/overview/). + +### **State** + +Reflex stellt deine Benutzeroberfläche als Funktion deines Zustands dar. + +```python +class State(rx.State): + """Der Zustand der App.""" + prompt = "" + image_url = "" + processing = False + complete = False + +``` + +Der Zustand definiert alle Variablen (genannt Vars) in einer App, die sich ändern können, und die Funktionen, die sie ändern. + +Hier besteht der Zustand aus einem `prompt` und einer `image_url`. Es gibt auch die Booleans `processing` und `complete`, um anzuzeigen, wann der Button deaktiviert werden soll (während der Bildgenerierung) und wann das resultierende Bild angezeigt werden soll. + +### **Event-Handler** + +```python +def get_image(self): + """Hole das Bild aus dem Prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True +``` + +Innerhalb des Zustands definieren wir Funktionen, die als Event-Handler bezeichnet werden und die Zustand-Variablen ändern. Event-Handler sind die Art und Weise, wie wir den Zustand in Reflex ändern können. Sie können als Reaktion auf Benutzeraktionen aufgerufen werden, z.B. beim Klicken auf eine Schaltfläche oder bei der Eingabe in ein Textfeld. Diese Aktionen werden als Ereignisse bezeichnet. + +Unsere DALL-E.-App hat einen Event-Handler, `get_image`, der dieses Bild von der OpenAI-API abruft. Die Verwendung von `yield` in der Mitte eines Event-Handlers führt zu einer Aktualisierung der Benutzeroberfläche. Andernfalls wird die Benutzeroberfläche am Ende des Ereignishandlers aktualisiert. + +### **Routing** + +Schließlich definieren wir unsere App. + +```python +app = rx.App() +``` + +Wir fügen der Indexkomponente eine Seite aus dem Stammverzeichnis der Anwendung hinzu. Wir fügen auch einen Titel hinzu, der in der Seitenvorschau/Browser-Registerkarte angezeigt wird. + +```python +app.add_page(index, title="DALL-E") +``` + +Du kannst eine mehrseitige App erstellen, indem du weitere Seiten hinzufügst. + +## 📑 Ressourcen + +
+ +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Komponentenbibliothek](https://reflex.dev/docs/library)   |   🖼️ [Galerie](https://reflex.dev/docs/gallery)   |   🛸 [Bereitstellung](https://reflex.dev/docs/hosting/deploy-quick-start)   + +
+ + +## ✅ Status + +Reflex wurde im Dezember 2022 unter dem Namen Pynecone gestartet. + +Ab Februar 2024 befindet sich unser Hosting-Service in der Alpha-Phase! In dieser Zeit kann jeder seine Apps kostenlos bereitstellen. Siehe unsere [Roadmap](https://github.com/reflex-dev/reflex/issues/2727), um zu sehen, was geplant ist. + +Reflex hat wöchentliche Veröffentlichungen und neue Features! Stelle sicher, dass du dieses Repository mit einem :star: Stern markierst und :eyes: beobachtest, um auf dem Laufenden zu bleiben. + +## Beitragende + +Wir begrüßen Beiträge jeder Größe! Hier sind einige gute Möglichkeiten, um in der Reflex-Community zu starten. + +- **Tritt unserem Discord bei**: Unser [Discord](https://discord.gg/T5WSbC2YtQ) ist der beste Ort, um Hilfe für dein Reflex-Projekt zu bekommen und zu besprechen, wie du beitragen kannst. +- **GitHub-Diskussionen**: Eine großartige Möglichkeit, über Funktionen zu sprechen, die du hinzugefügt haben möchtest oder Dinge, die verwirrend sind/geklärt werden müssen. +- **GitHub-Issues**: [Issues](https://github.com/reflex-dev/reflex/issues) sind eine ausgezeichnete Möglichkeit, Bugs zu melden. Außerdem kannst du versuchen, ein bestehendes Problem zu lösen und eine PR einzureichen. + +Wir suchen aktiv nach Mitwirkenden, unabhängig von deinem Erfahrungslevel oder deiner Erfahrung. Um beizutragen, sieh dir [CONTRIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) an. + + +## Vielen Dank an unsere Mitwirkenden: + + + + +## Lizenz + +Reflex ist Open-Source und lizenziert unter der [Apache License 2.0](LICENSE). diff --git a/docs/es/README.md b/docs/es/README.md index 40b3313ec..15ce63335 100644 --- a/docs/es/README.md +++ b/docs/es/README.md @@ -1,5 +1,5 @@ ```diff -+ ¿Buscando Pynecone? Estas en el repositorio correcto. Pynecone ha sido renomabrado a Reflex. + ++ ¿Buscando Pynecone? Estás en el repositorio correcto. Pynecone ha sido renombrado a Reflex. + ```
@@ -8,28 +8,42 @@
-### **✨ Aplicaciones web personalizables y eficaces en Python puro. Despliega tú aplicación en segundos. ✨** +### **✨ Aplicaciones web personalizables y eficaces en Python puro. Despliega tu aplicación en segundos. ✨** [![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) -[![Documentaiton](https://img.shields.io/badge/Documentation%20-Introduction%20-%20%23007ec6)](https://reflex.dev/docs/getting-started/introduction) +![Pruebas](https://github.com/pynecone-io/pynecone/actions/workflows/integration.yml/badge.svg) +![Versiones](https://img.shields.io/pypi/pyversions/reflex.svg) +[![Documentación](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)
--- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) + --- + +# Reflex + +Reflex es una biblioteca para construir aplicaciones web full-stack en Python puro. + +Características clave: +* **Python puro** - Escribe el frontend y backend de tu aplicación en Python, sin necesidad de aprender JavaScript. +* **Flexibilidad total** - Reflex es fácil para empezar, pero también puede escalar a aplicaciones complejas. +* **Despliegue instantáneo** - Después de construir, despliega tu aplicación con un [solo comando](https://reflex.dev/docs/hosting/deploy-quick-start/) u hospédala en tu propio servidor. + +Consulta nuestra [página de arquitectura](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) para aprender cómo funciona Reflex en detalle. + ## ⚙️ Instalación -Abra un terminal y ejecute (Requiere Python 3.7+): +Abra un terminal y ejecute (Requiere Python 3.9+): ```bash pip install reflex ``` -## 🥳 Crea tú primera aplicación +## 🥳 Crea tu primera aplicación -Al instalar `reflex` tambien se instala la herramienta de línea de comandos `reflex`. +Al instalar `reflex` también se instala la herramienta de línea de comandos `reflex`. Compruebe que la instalación se ha realizado correctamente creando un nuevo proyecto. (Sustituye `my_app_name` por el nombre de tu proyecto): @@ -39,7 +53,7 @@ cd my_app_name reflex init ``` -Este comando inicializa una aplicación de ejemplo (plantilla) en tu nuevo directorio. +Este comando inicializa una plantilla en tu nuevo directorio. Puedes iniciar esta aplicación en modo de desarrollo: @@ -54,12 +68,12 @@ Ahora puede modificar el código fuente en `my_app_name/my_app_name.py`. Reflex ## 🫧 Ejemplo de una Aplicación -Veamos un ejemplo: crearemos una UI de generación de imágenes en torno a DALL-E. Para simplificar, solo llamamos a la API de OpenAI, pero podrías reeemplazar esto con un modelo ML ejecutado localmente. +Veamos un ejemplo: crearemos una UI de generación de imágenes en torno a [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node). Para simplificar, solo llamamos a la [API de OpenAI](https://platform.openai.com/docs/api-reference/authentication), pero podrías reemplazar esto con un modelo ML ejecutado localmente.  
-A frontend wrapper for DALL·E, shown in the process of generating an image. +Un envoltorio frontend para DALL·E, mostrado en el proceso de generar una imagen.
  @@ -70,61 +84,65 @@ Aquí está el código completo para crear esto. ¡Todo esto se hace en un archi import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() class State(rx.State): - """The app state.""" + """El estado de la aplicación""" prompt = "" image_url = "" processing = False complete = False def get_image(self): - """Get the image from the prompt.""" + """Obtiene la imagen desde la consulta.""" if self.prompt == "": return rx.window_alert("Prompt Empty") self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( - "Generate Image", + "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", ) -# Add state and page to the app. +# Agrega el estado y la pagina a la aplicación app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` ## Vamos a analizarlo. +
+Explicando las diferencias entre las partes del backend y frontend de la aplicación DALL-E. +
+ ### **Reflex UI** Empezemos por la interfaz de usuario (UI). @@ -138,17 +156,17 @@ def index(): Esta función `index` define el frontend de la aplicación. -Utilizamos diferentes componentes como `center`, `vstack`, `input`, y `button` para construir el frontend. Los componentes pueden anidarse unos dentro de otros para crear diseños complejos. Además, puedes usar argumentos (keyword args) para darles estilo con toda la potencia de CSS. +Utilizamos diferentes componentes como `center`, `vstack`, `input`, y `button` para construir el frontend. Los componentes pueden anidarse unos dentro de otros para crear diseños complejos. Además, puedes usar argumentos de tipo keyword para darles estilo con toda la potencia de CSS. -Reflex viene con [mas de 60+ componentes incorporados](https://reflex.dev/docs/library) para ayudarle a empezar. Estamos añadiendo activamente más componentes y es fácil [crear sus propios componentes](https://reflex.dev/docs/advanced-guide/wrapping-react). +Reflex viene con [mas de 60 componentes incorporados](https://reflex.dev/docs/library) para ayudarle a empezar. Estamos añadiendo activamente más componentes y es fácil [crear sus propios componentes](https://reflex.dev/docs/wrapping-react/overview/). -### **State** +### **Estado** -Reflex representa su UI en función de su estado (State). +Reflex representa su UI como una función de su estado (State). ```python class State(rx.State): - """The app state.""" + """El estado de la aplicación""" prompt = "" image_url = "" processing = False @@ -157,28 +175,30 @@ class State(rx.State): El estado (State) define todas las variables (llamadas vars) de una aplicación que pueden cambiar y las funciones que las modifican. -Aquí el estado (State) se compone de `prompt` e `image_url`. También están los booleanos `processing` y `complete` para poder indicar cuándo mostrar el progreso circular y la imagen. +Aquí el estado se compone de `prompt` e `image_url`. También están los booleanos `processing` y `complete` para indicar cuando se deshabilite el botón (durante la generación de la imagen) y cuando se muestre la imagen resultante. -### **Event Handlers** +### **Manejadores de Evento** ```python def get_image(self): - """Get the image from the prompt.""" + """Obtiene la imagen desde la consulta.""" if self.prompt == "": return rx.window_alert("Prompt Empty") self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True ``` -Dentro del estado (State), definimos funciones llamadas "event handlers" que cambian los 'state vars'. Event handlers, son la manera que podemos modificar el 'state' en Reflex. Pueden ser activados en respuesta a las acciones del usuario, como hacer clic en un botón o escribir en un cuadro de texto. Estas acciones se llaman eventos 'events'. +Dentro del estado, definimos funciones llamadas manejadores de eventos que cambian las variables de estado. Los Manejadores de Evento son la manera que podemos modificar el estado en Reflex. Pueden ser activados en respuesta a las acciones del usuario, como hacer clic en un botón o escribir en un cuadro de texto. Estas acciones se llaman eventos. -Nuestra aplicación DALL·E. tiene un controlador de eventos "event handler", `get_image` que recibe esta imagen del OpenAI API. El uso de `yield` en medio de un controlador de eventos "event handler" hará que la UI se actualice. De lo contrario, la interfaz se actualizará al final del controlador de eventos "event handler". +Nuestra aplicación DALL·E tiene un manipulador de eventos, `get_image` que recibe esta imagen del OpenAI API. El uso de `yield` en medio de un manipulador de eventos hará que la UI se actualice. De lo contrario, la interfaz se actualizará al final del manejador de eventos. -### **Routing** +### **Enrutamiento** Por último, definimos nuestra app. @@ -198,36 +218,28 @@ Puedes crear una aplicación multipágina añadiendo más páginas.
-📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Biblioteca de Componentes](https://reflex.dev/docs/library)   |   🖼️ [Galería](https://reflex.dev/docs/gallery)   |   🛸 [Hospedaje](https://reflex.dev/docs/hosting/deploy)   +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Librería de componentes](https://reflex.dev/docs/library)   |   🖼️ [Galería](https://reflex.dev/docs/gallery)   |   🛸 [Despliegue](https://reflex.dev/docs/hosting/deploy-quick-start)  
+## ✅ Estado +Reflex se lanzó en diciembre de 2022 con el nombre de Pynecone. +¡Desde febrero de 2024, nuestro servicio de alojamiento está en fase alfa! Durante este tiempo, cualquiera puede implementar sus aplicaciones de forma gratuita. Consulta nuestra [hoja de ruta](https://github.com/reflex-dev/reflex/issues/2727) para ver qué está planeado. -## ✅ Estatus +¡Reflex tiene nuevas versiones y características cada semana! Asegúrate de :star: marcar como favorito y :eyes: seguir este repositorio para mantenerte actualizado. -Reflex se lanzó en Diciembre de 2022 con el nombre Pynecone. - -A partir de julio de 2023, nos encontramos en la etapa de **Beta Pública**. - -- :white_check_mark: **Alpha Pública**: Cualquier persona puede instalar y usar Reflex. Puede haber problemas, pero estamos trabajando activamente para resolverlos. -- :large_orange_diamond: **Beta Pública**: Suficientemente estable para casos de uso no empresariales. -- **Beta de Hospedaje Público**: ¡_Opcionalmente_, despliega y hospeda tus aplicaciónes en Reflex! -- **Público**: Reflex está listo para producción. - -¡Reflex tiene nuevas versiones y características que se lanzan cada semana! Aseguraté de darnos una :star: estrella y :eyes: revisa este repositorio para mantenerte actualizado. - -## Contribuyendo +## Contribuciones ¡Aceptamos contribuciones de cualquier tamaño! A continuación encontrará algunas buenas formas de iniciarse en la comunidad Reflex. - **Únete a nuestro Discord**: Nuestro [Discord](https://discord.gg/T5WSbC2YtQ) es el mejor lugar para obtener ayuda en su proyecto Reflex y discutir cómo puedes contribuir. -- **Discusiones de GitHub**: Una excelente manera de hablar sobre las características que deseas agregar o las cosas que te resusltan confusas o necesitan aclaración. -- **GitHub Issues**: Las incidencias son una forma excelente de informar de errores. Además, puedes intentar resolver un problema exixtente y enviar un PR. +- **Discusiones de GitHub**: Una excelente manera de hablar sobre las características que deseas agregar o las cosas que te resultan confusas o necesitan aclaración. +- **GitHub Issues**: Las incidencias son una forma excelente de informar de errores. Además, puedes intentar resolver un problema existente y enviar un PR. -Buscamos colaboradores, sin importar su nivel o experiencia. +Buscamos colaboradores, sin importar su nivel o experiencia. Para contribuir consulta [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) ## Licencia diff --git a/docs/images/dalle_colored_code_example.png b/docs/images/dalle_colored_code_example.png index c6f768974..18c8307c5 100644 Binary files a/docs/images/dalle_colored_code_example.png and b/docs/images/dalle_colored_code_example.png differ diff --git a/docs/in/README.md b/docs/in/README.md index 378cfaaec..ebc4155f4 100644 --- a/docs/in/README.md +++ b/docs/in/README.md @@ -1,37 +1,51 @@ ```diff Pynecone की तलाश हैं? आप सही रेपो में हैं। Pynecone का नाम Reflex में बदल दिया गया है। + + ``` +
-Reflex Logo -Reflex Logo +Reflex लोगो +Reflex लोगो
-### **✨ Python (पायथन) में परफॉर्मेंट, अनुकूलनयोग्य वेब ऐप्स। कुछ सेकंड्स में ही डिप्लॉय करें ✨** +### **✨ प्रदर्शनकारी, अनुकूलित वेब ऐप्स, शुद्ध Python में। सेकंडों में तैनात करें। ✨** + [![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) [![Documentaiton](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) +
---- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) --- -## ⚙️ इंस्टॉलेशन +## [English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) -एक टर्मिनल खोलें और चलाएं (Python 3.8+ की आवश्यकता है): +# Reflex + +Reflex शुद्ध पायथन में पूर्ण-स्टैक वेब ऐप्स बनाने के लिए एक लाइब्रेरी है। + +मुख्य विशेषताएँ: + +- **शुद्ध पायथन** - अपने ऐप के फ्रंटएंड और बैकएंड को पायथन में लिखें, जावास्क्रिप्ट सीखने की जरूरत नहीं है। +- **पूर्ण लचीलापन** - Reflex के साथ शुरुआत करना आसान है, लेकिन यह जटिल ऐप्स के लिए भी स्केल कर सकता है। +- **तुरंत तैनाती** - बिल्डिंग के बाद, अपने ऐप को [एकल कमांड](https://reflex.dev/docs/hosting/deploy-quick-start/) के साथ तैनात करें या इसे अपने सर्वर पर होस्ट करें। + +Reflex के अंदर के कामकाज को जानने के लिए हमारे [आर्किटेक्चर पेज](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) को देखें। + +## ⚙️ इंस्टॉलेशन (Installation) + +एक टर्मिनल खोलें और चलाएं (Python 3.9+ की आवश्यकता है): ```bash pip install reflex ``` -## 🥳 अपना पहला ऐप बनाएं +## 🥳 अपना पहला ऐप बनाएं (Create your first App) reflex को इंस्टॉल करने से ही reflex कमांड लाइन टूल भी इंस्टॉल हो जाता है। -सुनिश्चित करें कि इंस्टॉलेशन सफल थी, एक नया प्रोजेक्ट बनाकर इसे टेस्ट करें। ('my_app_name' की जगह अपने प्रोजेक्ट का नाम रखें): +सुनिश्चित करें कि इंस्टॉलेशन सफल थी, एक नया प्रोजेक्ट बनाकर इसे टेस्ट करें। ('my_app_name' की जगह अपने प्रोजेक्ट का नाम रखें): ```bash mkdir my_app_name @@ -51,14 +65,14 @@ reflex run अब आप my_app_name/my_app_name.py में source कोड को संशोधित कर सकते हैं। Reflex में तेज रिफ्रेश की सुविधा है, इसलिए जब आप अपनी कोड को सहेजते हैं, तो आप अपने बदलावों को तुरंत देख सकते हैं। -## 🫧 उदाहरण ऐप +## 🫧 उदाहरण ऐप (Example App) एक उदाहरण पर चलते हैं: DALL·E से एक इमेज उत्पन्न करने के लिए UI। सरलता के लिए, हम सिर्फ OpenAI API को बुलाते हैं, लेकिन आप इसे ML मॉडल से बदल सकते हैं locally।  
-A frontend wrapper for DALL·E, shown in the process of generating an image. +DALL·E के लिए एक फ्रंटएंड रैपर, छवि उत्पन्न करने की प्रक्रिया में दिखाया गया।
  @@ -69,10 +83,12 @@ reflex run import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() + class State(rx.State): """The app state.""" + prompt = "" image_url = "" processing = False @@ -85,33 +101,33 @@ class State(rx.State): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True - + def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", @@ -119,10 +135,14 @@ def index(): # Add state and page to the app. app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` -## चलो इसे विस्तार से देखते हैं। +## इसे समझते हैं। + +
+DALL-E ऐप के बैकएंड और फ्रंटएंड भागों के बीच के अंतर की व्याख्या करता है। +
### **Reflex UI** @@ -156,7 +176,7 @@ class State(rx.State): स्टेट (state) ऐप में उन सभी वेरिएबल्स (vars) को परिभाषित करती है जो बदल सकती हैं और उन फ़ंक्शनों को जो उन्हें बदलते हैं। -यहां स्टेट (state) में `prompt` और `image_url` शामिल हैं। प्रगति और छवि दिखाने के लिए `processing` और `complete` बूलियन भी हैं। +यहां स्टेट (state) में `prompt` और `image_url` शामिल हैं। प्रगति और छवि दिखाने के लिए `processing` और `complete` बूलियन भी हैं। ### **इवेंट हैंडलर (Event Handlers)** @@ -168,8 +188,10 @@ def get_image(self): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True ``` @@ -197,33 +219,34 @@ app.add_page(index, title="DALL-E")
-📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy)   +📑 [दस्तावेज़](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [ब्लॉग](https://reflex.dev/blog)   |   📱 [कॉम्पोनेंट लाइब्रेरी](https://reflex.dev/docs/library)   |   🖼️ [गैलरी](https://reflex.dev/docs/gallery)   |   🛸 [तैनाती](https://reflex.dev/docs/hosting/deploy)  
## ✅ स्टेटस (Status) -रिफ्लेक्स को दिसंबर 2022 में पाइनकोन नाम से लॉन्च किया गया। +Reflex दिसंबर 2022 में Pynecone नाम से शुरू हुआ। -जुलाई 2023 तक, हम **Public Beta** (सार्वजनिक बीटा) चरण में हैं। +फरवरी 2024 तक, हमारी होस्टिंग सेवा अल्फा में है! इस समय कोई भी अपने ऐप्स को मुफ्त में तैनात कर सकता है। देखें हमारी [रोडमैप](https://github.com/reflex-dev/reflex/issues/2727) योजनाबद्ध चीज़ों को जानने के लिए। -- :white_check_mark: **Public Alpha** (सार्वजनिक अल्फा): कोई भी रिफ्लेक्स इंस्टॉल और उपयोग कर सकता है। कुछ इशू हो सकते हैं, लेकिन हम उन्हें सुलझाने के लिए सक्रिय रूप से काम कर रहे हैं। -- :large_orange_diamond: **Public Beta** (सार्वजनिक बीटा): गैर-उद्यम उपयोग-मामलों के लिए स्थिर। -- **Public Hosting Beta** (सार्वजनिक होस्टिंग बीटा): _Optionally_, अपने ऐप्स को रिफ्लेक्स पर डिप्लॉइ और होस्ट करें! -- **Public** (सार्वजनिक): रिफ्लेक्स उत्पादन के लिए तैयार है। - -रिफ्लेक्स में हर सप्ताह नई रिलीज़ और सुविधाएँ आ रही हैं! अपडेट रहने के लिए इस रिपॉजिटरी को :star: स्टार करें और समय-समय पर अवश्य देखें :eyes:। +Reflex में हर सप्ताह नए रिलीज़ और फीचर्स आ रहे हैं! सुनिश्चित करें कि ⭐ स्टार और 👀 वॉच इस रेपोजिटरी को अपडेट रहने के लिए। ## (योगदान) Contributing हम हर तरह के योगदान का स्वागत करते हैं! रिफ्लेक्स कम्यूनिटी में शुरुआत करने के कुछ अच्छे तरीके नीचे दिए गए हैं। -- **Join Our Discord** (डिस्कॉर्ड सर्वर से जुड़ें): Our [Discord](https://discord.gg/T5WSbC2YtQ) हमारा डिस्कॉर्ड रिफ्लेक्स प्रोजेक्ट पर सहायता प्राप्त करने और आप कैसे योगदान दे सकते हैं, इस पर चर्चा करने के लिए सबसे अच्छी जगह है। -- **GitHub Discussions** (गिटहब चर्चाएँ): उन सुविधाओं के बारे में बात करने का एक शानदार तरीका जिन्हें आप जोड़ना चाहते हैं या ऐसी चीज़ें जो भ्रमित करने वाली हैं/स्पष्टीकरण की आवश्यकता है। -- **GitHub Issues** (गिटहब समस्याएं): ये बग की रिपोर्ट करने का एक शानदार तरीका है। इसके अतिरिक्त, आप किसी मौजूदा समस्या को हल करने का प्रयास कर सकते हैं और एक पीआर सबमिट कर सकते हैं। +- **Join Our Discord** (डिस्कॉर्ड सर्वर से जुड़ें): Our [Discord](https://discord.gg/T5WSbC2YtQ) हमारा डिस्कॉर्ड रिफ्लेक्स प्रोजेक्ट पर सहायता प्राप्त करने और आप कैसे योगदान दे सकते हैं, इस पर चर्चा करने के लिए सबसे अच्छी जगह है। +- **GitHub Discussions** (गिटहब चर्चाएँ): उन सुविधाओं के बारे में बात करने का एक शानदार तरीका जिन्हें आप जोड़ना चाहते हैं या ऐसी चीज़ें जो भ्रमित करने वाली हैं/स्पष्टीकरण की आवश्यकता है। +- **GitHub Issues** (गिटहब समस्याएं): ये [बग](https://github.com/reflex-dev/reflex/issues) की रिपोर्ट करने का एक शानदार तरीका है। इसके अतिरिक्त, आप किसी मौजूदा समस्या को हल करने का प्रयास कर सकते हैं और एक पीआर सबमिट कर सकते हैं। -हम सक्रिय रूप से योगदानकर्ताओं की तलाश कर रहे हैं, चाहे आपका कौशल स्तर या अनुभव कुछ भी हो। +हम सक्रिय रूप से योगदानकर्ताओं की तलाश कर रहे हैं, चाहे आपका कौशल स्तर या अनुभव कुछ भी हो।योगदान करने के लिए [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) देखें। + +## हमारे सभी योगदानकर्ताओं का धन्यवाद: + + + + ## लाइसेंस (License) -रिफ्लेक्स ओपन-सोर्स है और [अपाचे लाइसेंस 2.0] (लाइसेंस) के तहत लाइसेंस प्राप्त है। +रिफ्लेक्स ओपन-सोर्स है और [अपाचे लाइसेंस 2.0](https://github.com/reflex-dev/reflex/blob/main/LICENSE) के तहत लाइसेंस प्राप्त है। diff --git a/docs/it/README.md b/docs/it/README.md index f4da25d01..92438f696 100644 --- a/docs/it/README.md +++ b/docs/it/README.md @@ -10,7 +10,6 @@ ### **✨ App web performanti e personalizzabili in puro Python. Distribuisci in pochi secondi. ✨** [![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) [![Documentaiton](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) @@ -18,12 +17,12 @@ --- [English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | -[Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) --- ## ⚙️ Installazione -Apri un terminale ed esegui (Richiede Python 3.8+): +Apri un terminale ed esegui (Richiede Python 3.9+): ```bash pip install reflex diff --git a/docs/ja/README.md b/docs/ja/README.md index 2bd97cfb4..0a7ab0d53 100644 --- a/docs/ja/README.md +++ b/docs/ja/README.md @@ -8,34 +8,36 @@
-### **✨ 即時デプロイが可能な、Pure Pythonで作ったパフォーマンスと汎用性が高いWebアプリケーション✨** +### **✨ 即時デプロイが可能な、Pure Python で作ったパフォーマンスと汎用性が高い Web アプリケーション ✨** + [![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) + --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) --- # Reflex -ReflexはPythonのみでフルスタックWebアプリケーションを作成できるライブラリです。 +Reflex は Python のみでフルスタック Web アプリケーションを作成できるライブラリです。 主な特徴: -* **Pure Python** - WebアプリケーションのフロントエンドとバックエンドをPythonのみで実装できるため、Javascriptを学ぶ必要がありません。 -* **高い柔軟性** - Reflexは簡単に始められて、複雑なアプリケーションまで作成できます。 -* **即時デプロイ** - ビルド後、すぐにデプロイが可能です。[単純なCLIコマンド](https://reflex.dev/docs/hosting/deploy-quick-start/)を使ったアプリケーションのデプロイや、自身のサーバーへのホストができます。 -Reflexがどのように動作しているかを知るには、[アーキテクチャページ](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)をご覧ください。 +- **Pure Python** - Web アプリケーションのフロントエンドとバックエンドを Python のみで実装できるため、Javascript を学ぶ必要がありません。 +- **高い柔軟性** - Reflex は簡単に始められて、複雑なアプリケーションまで作成できます。 +- **即時デプロイ** - ビルド後、すぐにデプロイが可能です。[単純な CLI コマンド](https://reflex.dev/docs/hosting/deploy-quick-start/)を使ったアプリケーションのデプロイや、自身のサーバーへのホストができます。 + +Reflex がどのように動作しているかを知るには、[アーキテクチャページ](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)をご覧ください。 ## ⚙️ インストール -ターミナルを開いて以下のコマンドを実行してください。(Python 3.8以上が必要です。): +ターミナルを開いて以下のコマンドを実行してください。(Python 3.9 以上が必要です。): ```bash pip install reflex @@ -43,7 +45,7 @@ pip install reflex ## 🥳 最初のアプリケーションを作ろう -`reflex`をインストールすると、`reflex`のCLIツールが自動でインストールされます。 +`reflex`をインストールすると、`reflex`の CLI ツールが自動でインストールされます。 新しいプロジェクトを作成して、インストールが成功しているかを確認しましょう。(`my_app_name`を自身のプロジェクト名に書き換えて実行ください。): @@ -63,11 +65,11 @@ reflex run http://localhost:3000 にアクセスしてアプリの動作を見ることができます。 -`my_app_name/my_app_name.py`のソースコードを編集してみましょう!Reflexはfast refreshなので、ソースを保存した直後に変更がWebページに反映されます。 +`my_app_name/my_app_name.py`のソースコードを編集してみましょう!Reflex は fast refresh なので、ソースを保存した直後に変更が Web ページに反映されます。 ## 🫧 実装例 -実装例を見てみましょう: [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node)を中心とした画像生成UIを作成しました。説明を簡単にするためにここでは[OpenAI API](https://platform.openai.com/docs/api-reference/authentication)を呼んでいますが、ローカルで動作している機械学習モデルに置き換えることも可能です。 +実装例を見てみましょう: [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node)を中心とした画像生成 UI を作成しました。説明を簡単にするためにここでは[OpenAI API](https://platform.openai.com/docs/api-reference/authentication)を呼んでいますが、ローカルで動作している機械学習モデルに置き換えることも可能です。   @@ -77,7 +79,7 @@ http://localhost:3000 にアクセスしてアプリの動作を見ることが   -画像生成UIのソースコードの全貌を見てみましょう。下記のように、単一のPythonファイルで作れます! +画像生成 UI のソースコードの全貌を見てみましょう。下記のように、単一の Python ファイルで作れます! ```python import reflex as rx @@ -117,14 +119,15 @@ def index(): on_blur=State.set_prompt, width="25em", ), - rx.button("Generate Image", on_click=State.get_image, width="25em"), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), rx.cond( - State.processing, - rx.chakra.circular_progress(is_indeterminate=True), - rx.cond( - State.complete, - rx.image(src=State.image_url, width="20em"), - ), + State.complete, + rx.image(src=State.image_url, width="20em"), ), align="center", ), @@ -137,17 +140,15 @@ app = rx.App() app.add_page(index, title="Reflex:DALL-E") ``` - ## それぞれの実装を見てみましょう
DALL-E appのフロントエンドとバックエンドのパーツの違いを説明しています。
- ### **Reflex UI** -UIから見てみましょう。 +UI から見てみましょう。 ```python def index(): @@ -158,13 +159,13 @@ def index(): `index`関数において、アプリのフロントエンドを定義しています。 -フロントエンドを実装するにあたり、`center`、`vstack`、`input`、`button`など異なるコンポーネントを使用しています。コンポーネントはお互いにネストが可能であり、複雑なレイアウトを作成できます。また、keyword argsを使うことで、CSSの機能をすべて使ったスタイルが可能です。 +フロントエンドを実装するにあたり、`center`、`vstack`、`input`、`button`など異なるコンポーネントを使用しています。コンポーネントはお互いにネストが可能であり、複雑なレイアウトを作成できます。また、keyword args を使うことで、CSS の機能をすべて使ったスタイルが可能です。 -Reflexは[60を超える内臓コンポーネント](https://reflex.dev/docs/library)があるため、すぐに始められます。私たちは、積極的にコンポーネントを追加していますが、簡単に[自身のコンポーネントを追加](https://reflex.dev/docs/wrapping-react/overview/)することも可能です。 +Reflex は[60 を超える内臓コンポーネント](https://reflex.dev/docs/library)があるため、すぐに始められます。私たちは、積極的にコンポーネントを追加していますが、簡単に[自身のコンポーネントを追加](https://reflex.dev/docs/wrapping-react/overview/)することも可能です。 ### **ステート** -Reflexはステートの関数を用いてUIを表示します。 +Reflex はステートの関数を用いて UI を表示します。 ```python class State(rx.State): @@ -176,9 +177,9 @@ class State(rx.State): ``` -ステートでは、アプリで変更が可能な全ての変数(varsと呼びます)と、varsの変更が可能な関数を定義します。 +ステートでは、アプリで変更が可能な全ての変数(vars と呼びます)と、vars の変更が可能な関数を定義します。 -この例では、ステートを`prompt`と`image_url`で構成しています。そして、ブール型の`processing`と`complete`を用いて、プログレスサークルと画像の表示を切り替えています。 +この例では、ステートを`prompt`と`image_url`で構成しています。そして、ブール型の`processing`と`complete`を用いて、ボタンを無効にするタイミング(画像生成中)や生成された画像を表示するタイミングを示しています。 ### **イベントハンドラ** @@ -197,9 +198,9 @@ def get_image(self): self.processing, self.complete = False, True ``` -ステートにおいて、ステートのvarsを変更できるイベントハンドラ関数を定義しています。イベントハンドラはReflexにおいて、ステートのvarsを変更する方法です。ボタンクリックやテキストボックスの入力など、ユーザのアクションに応じてイベントハンドラが呼ばれます。 +ステートにおいて、ステートの vars を変更できるイベントハンドラ関数を定義しています。イベントハンドラは Reflex において、ステートの vars を変更する方法です。ボタンクリックやテキストボックスの入力など、ユーザのアクションに応じてイベントハンドラが呼ばれます。 -DALL·E.アプリには、OpenAI APIからイメージを取得する`get_image`関数があります。イベントハンドラの最後でUIの更新がかかるため、関数の途中に`yield`を入れることで先にUIを更新しています。 +DALL·E.アプリには、OpenAI API からイメージを取得する`get_image`関数があります。イベントハンドラの最後で UI の更新がかかるため、関数の途中に`yield`を入れることで先に UI を更新しています。 ### **ルーティング** @@ -209,7 +210,7 @@ DALL·E.アプリには、OpenAI APIからイメージを取得する`get_image` app = rx.App() ``` -アプリにページを追加し、ドキュメントルートをindexコンポーネントにルーティングしています。更に、ページのプレビューやブラウザタブに表示されるタイトルを記載しています。 +アプリにページを追加し、ドキュメントルートを index コンポーネントにルーティングしています。更に、ページのプレビューやブラウザタブに表示されるタイトルを記載しています。 ```python app.add_page(index, title="DALL-E") @@ -221,35 +222,34 @@ app.add_page(index, title="DALL-E")
-📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)   +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)  
- ## ✅ ステータス -2022年12月に、ReflexはPyneconeという名前でローンチしました。 +2022 年 12 月に、Reflex は Pynecone という名前でローンチしました。 -2024年2月に、ホスティングサービスをアルファ版でリリースしました!アルファ版では、だれでもReflexアプリケーションを無料でデプロイできます。今後の予定は[ロードマップ](https://github.com/reflex-dev/reflex/issues/2727)において見れます。 +2024 年 2 月に、ホスティングサービスをアルファ版でリリースしました!アルファ版では、だれでも Reflex アプリケーションを無料でデプロイできます。今後の予定は[ロードマップ](https://github.com/reflex-dev/reflex/issues/2727)において見れます。 -Reflexは毎週、新しいリリースや機能追加を行っています!最新情報を逃さないために、 :star: Starや :eyes: Watchをお願いします。 +Reflex は毎週、新しいリリースや機能追加を行っています!最新情報を逃さないために、 :star: Star や :eyes: Watch をお願いします。 ## コントリビュート -様々なサイズのコントリビュートを歓迎しています!Reflexコミュニティに入るための方法を、いくつかリストアップします。 +様々なサイズのコントリビュートを歓迎しています!Reflex コミュニティに入るための方法を、いくつかリストアップします。 -- **Discordに参加**: [Discord](https://discord.gg/T5WSbC2YtQ)は、Reflexプロジェクトの相談や、コントリビュートについての話し合いをするための、最適な場所です。 -- **GitHub Discussions**: GitHub Discussionsでは、追加したい機能や、複雑で解明が必要な事柄についての議論に適している場所です。 -- **GitHub Issues**: [Issues](https://github.com/reflex-dev/reflex/issues)はバグの報告に適している場所です。また、課題を解決したPRのサブミットにチャレンジしていただくことも、可能です。 +- **Discord に参加**: [Discord](https://discord.gg/T5WSbC2YtQ)は、Reflex プロジェクトの相談や、コントリビュートについての話し合いをするための、最適な場所です。 +- **GitHub Discussions**: GitHub Discussions では、追加したい機能や、複雑で解明が必要な事柄についての議論に適している場所です。 +- **GitHub Issues**: [Issues](https://github.com/reflex-dev/reflex/issues)はバグの報告に適している場所です。また、課題を解決した PR のサブミットにチャレンジしていただくことも、可能です。 スキルや経験に関わらず、私たちはコントリビュータを積極的に探しています。コントリビュートするために、[CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md)をご覧ください。 - ## 私たちのコントリビュータに感謝!: + ## ライセンス -Reflexはオープンソースであり、[Apache License 2.0](LICENSE)に基づいてライセンス供与されます。 +Reflex はオープンソースであり、[Apache License 2.0](LICENSE)に基づいてライセンス供与されます。 diff --git a/docs/kr/README.md b/docs/kr/README.md index 266992f9a..a92fcd0c5 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -10,18 +10,17 @@ ### **✨ 순수 Python으로 고성능 사용자 정의 웹앱을 만들어 보세요. 몇 초만에 배포 가능합니다. ✨** [![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) [![Documentaiton](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) --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) --- ## ⚙️ 설치 -터미널을 열고 실행하세요. (Python 3.8+ 필요): +터미널을 열고 실행하세요. (Python 3.9+ 필요): ```bash pip install reflex @@ -70,10 +69,12 @@ http://localhost:3000 에서 앱이 실행 됩니다. import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() + class State(rx.State): """The app state.""" + prompt = "" image_url = "" processing = False @@ -86,33 +87,33 @@ class State(rx.State): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True - + def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( - "Generate Image", + "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", @@ -120,7 +121,7 @@ def index(): # Add state and page to the app. app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` ## 하나씩 살펴보겠습니다. @@ -160,7 +161,7 @@ class State(rx.State): state는 앱에서 변경될 수 있는 모든 변수(vars로 불림)와 이러한 변수를 변경하는 함수를 정의합니다. -여기서 state는 `prompt`와 `image_url`로 구성됩니다. 또한 `processing`과 `complete`라는 불리언 값이 있습니다. 이 값들은 원형 진행률과 이미지를 표시할 때를 나타냅니다. +여기서 state는 `prompt`와 `image_url`로 구성됩니다. 또한 `processing`과 `complete`라는 불리언 값이 있습니다. 이 값들은 이미지 생성 중 버튼을 비활성화할 때와, 결과 이미지를 표시할 때를 나타냅니다. ### **Event Handlers** @@ -172,8 +173,10 @@ def get_image(self): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True ``` diff --git a/docs/pe/README.md b/docs/pe/README.md new file mode 100644 index 000000000..3a0ba044b --- /dev/null +++ b/docs/pe/README.md @@ -0,0 +1,262 @@ +```diff ++ دنبال Pynecone میگردی؟ شما در مخزن درستی قرار داری. Pynecone به Reflex تغییر نام داده است. + +``` + +
+Reflex Logo +Reflex Logo + +
+ +### **✨ برنامه های تحت وب قابل تنظیم، کارآمد تماما پایتونی که در چند ثانیه مستقر(دپلوی) می‎شود. ✨** +[![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex) +![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) +
+ +--- + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) + +--- + +# Reflex - رفلکس + +رفلکس(Reflex) یک کتابخانه برای ساخت برنامه های وب فول استک تماما پایتونی است. + +ویژگی های کلیدی: +* **تماما پایتونی** - فرانت اند و بک اند برنامه خود را همه در پایتون بنویسید، بدون نیاز به یادگیری جاوا اسکریپت. +* **انعطاف پذیری کامل** - شروع به کار با Reflex آسان است، اما می تواند به برنامه های پیچیده نیز تبدیل شود. +* **دپلوی فوری** - پس از ساخت، برنامه خود را با [یک دستور](https://reflex.dev/docs/hosting/deploy-quick-start/) دپلوی کنید یا آن را روی سرور خود میزبانی کنید. + +برای آشنایی با نحوه عملکرد Reflex [صفحه معماری](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) را ببینید. + +## ⚙️ Installation - نصب و راه اندازی + +یک ترمینال را باز کنید و اجرا کنید (نیازمند Python 3.9+): + +```bash +pip install reflex +``` + +## 🥳 اولین برنامه خود را ایجاد کنید + +نصب `reflex` همچنین `reflex` در خط فرمان را نصب میکند. + +با ایجاد یک پروژه جدید موفقیت آمیز بودن نصب را تست کنید. (`my_app_name` را با اسم پروژه خودتان جایگزین کنید): + +```bash +mkdir my_app_name +cd my_app_name +reflex init +``` + +این دستور یک برنامه الگو(تمپلیت) را در فهرست(دایرکتوری) جدید شما مقداردهی اولیه می کند + +می توانید این برنامه را در حالت توسعه(development) اجرا کنید: + +```bash +reflex run +``` + +باید برنامه خود را در حال اجرا ببینید در http://localhost:3000. + +اکنون می‌توانید کد منبع را در «my_app_name/my_app_name.py» تغییر دهید. Reflex دارای تازه‌سازی‌های سریعی است، بنابراین می‌توانید تغییرات خود را بلافاصله پس از ذخیره کد خود مشاهده کنید. + + +## 🫧 Example App - برنامه نمونه + +بیایید یک مثال بزنیم: ایجاد یک رابط کاربری برای تولید تصویر [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node). برای سادگی، ما فراخوانی میکنیم [OpenAI API](https://platform.openai.com/docs/api-reference/authentication), اما می توانید آن را با یک مدل ML که به صورت محلی اجرا می شود جایگزین کنید. + +  + +
+A frontend wrapper for DALL·E, shown in the process of generating an image. +
+ +  + +در اینجا کد کامل برای ایجاد این پروژه آمده است. همه اینها در یک فایل پایتون انجام می شود! + + + +```python +import reflex as rx +import openai + +openai_client = openai.OpenAI() + + +class State(rx.State): + """The app state.""" + + prompt = "" + image_url = "" + processing = False + complete = False + + def get_image(self): + """Get the image from the prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True + + +def index(): + return rx.center( + rx.vstack( + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), + rx.cond( + State.complete, + rx.image(src=State.image_url, width="20em"), + ), + align="center", + ), + width="100%", + height="100vh", + ) + +# Add state and page to the app. +app = rx.App() +app.add_page(index, title="Reflex:DALL-E") +``` + + + + + +## بیاید سادش کنیم + +
+Explaining the differences between backend and frontend parts of the DALL-E app. +
+ + +### **Reflex UI - رابط کاربری رفلکس** + +بیایید با رابط کاربری شروع کنیم. + +```python +def index(): + return rx.center( + ... + ) +``` + +تابع `index` قسمت فرانت اند برنامه را تعریف می کند. + +ما از اجزای مختلفی مثل `center`, `vstack`, `input` و `button` استفاده میکنیم تا فرانت اند را بسازیم. اجزاء را می توان درون یکدیگر قرار داد +برای ایجاد طرح بندی های پیچیده می توانید از args کلمات کلیدی برای استایل دادن به آنها از CSS استفاده کنید. + +رفلکس دارای [بیش از 60 جزء](https://reflex.dev/docs/library) برای کمک به شما برای شروع. ما به طور فعال اجزای بیشتری را اضافه می کنیم, و این خیلی آسان است که [اجزا خود را بسازید](https://reflex.dev/docs/wrapping-react/overview/). + +### **State - حالت** + +رفلکس رابط کاربری شما را به عنوان تابعی از وضعیت شما نشان می دهد. + +```python +class State(rx.State): + """The app state.""" + prompt = "" + image_url = "" + processing = False + complete = False + +``` + +حالت تمام متغیرها(variables) (به نام vars) را در یک برنامه که می توانند تغییر دهند و توابعی که آنها را تغییر می دهند تعریف می کند.. + +در اینجا حالت از یک `prompt` و `image_url` تشکیل شده است. همچنین دو بولی `processing` و `complete` برای نشان دادن زمان غیرفعال کردن دکمه (در طول تولید تصویر) و زمان نمایش تصویر نتیجه وجود دارد. + +### **Event Handlers - کنترل کنندگان رویداد** + +```python +def get_image(self): + """Get the image from the prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True +``` + +در داخل حالت، توابعی به نام کنترل کننده رویداد تعریف می کنیم که متغیرهای حالت را تغییر می دهند. کنترل کننده های رویداد راهی هستند که می توانیم وضعیت را در Reflex تغییر دهیم. آنها را می توان در پاسخ به اقدامات کاربر، مانند کلیک کردن روی یک دکمه یا تایپ کردن در یک متن، فراخوانی کرد. به این اعمال وقایع می گویند. + +برنامه DALL·E ما دارای یک کنترل کننده رویداد، `get_image` است که این تصویر را از OpenAI API دریافت می کند. استفاده از `yield` در وسط کنترل‌کننده رویداد باعث به‌روزرسانی رابط کاربری می‌شود. در غیر این صورت رابط کاربری در پایان کنترل کننده رویداد به روز می شود. + +### **Routing - مسیریابی** + +بالاخره اپلیکیشن خود را تعریف می کنیم. + +```python +app = rx.App() +``` + +ما یک صفحه از root برنامه را به جزء index اضافه می کنیم. ما همچنین عنوانی را اضافه می کنیم که در برگه پیش نمایش/مرورگر صفحه نمایش داده می شود. + +```python +app.add_page(index, title="DALL-E") +``` + +با افزودن صفحات بیشتر می توانید یک برنامه چند صفحه ای ایجاد کنید. + +## 📑 Resources - منابع + +
+ +📑 [اسناد](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [وبلاگ](https://reflex.dev/blog)   |   📱 [کتابخانه جزء](https://reflex.dev/docs/library)   |   🖼️ [گالری](https://reflex.dev/docs/gallery)   |   🛸 [استقرار](https://reflex.dev/docs/hosting/deploy-quick-start)   + +
+ + +## ✅ Status - وضعیت + +رفلکس(reflex) در دسامبر 2022 با نام Pynecone راه اندازی شد. + +از فوریه 2024، سرویس میزبانی ما در آلفا است! در این مدت هر کسی می‌تواند برنامه‌های خود را به صورت رایگان اجرا کند. [نقشه راه](https://github.com/reflex-dev/reflex/issues/2727) را ببینید تا متوجه شوید چه برنامه‌ریزی شده است. + +رفلکس(reflex) هر هفته نسخه ها و ویژگی های جدیدی دارد! مطمئن شوید که :star: ستاره و :eyes: این مخزن را تماشا کنید تا به روز بمانید. + +## Contributing - مشارکت کردن + +ما از مشارکت در هر اندازه استقبال می کنیم! در زیر چند راه خوب برای شروع در انجمن رفلکس آورده شده است. + +- **به Discord ما بپیوندید**: [Discord](https://discord.gg/T5WSbC2YtQ) ما بهترین مکان برای دریافت کمک در مورد پروژه Reflex و بحث در مورد اینکه چگونه می توانید کمک کنید است. +- **بحث های GitHub**: راهی عالی برای صحبت در مورد ویژگی هایی که می خواهید اضافه کنید یا چیزهایی که گیج کننده هستند/نیاز به توضیح دارند. +- **قسمت مشکلات GitHub**: [قسمت مشکلات](https://github.com/reflex-dev/reflex/issues) یک راه عالی برای گزارش اشکال هستند. علاوه بر این، می توانید یک مشکل موجود را حل کنید و یک PR(pull request) ارسال کنید. + +ما فعالانه به دنبال مشارکت کنندگان هستیم، فارغ از سطح مهارت یا تجربه شما. برای مشارکت [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) را بررسی کنید. + + +## All Thanks To Our Contributors - با تشکر از همکاران ما: + + + + +## License - مجوز + +رفلکس متن باز و تحت مجوز [Apache License 2.0](LICENSE) است. diff --git a/docs/pt/pt_br/README.md b/docs/pt/pt_br/README.md index bb35a1475..184b668bc 100644 --- a/docs/pt/pt_br/README.md +++ b/docs/pt/pt_br/README.md @@ -17,11 +17,11 @@ --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) --- ## ⚙️ Instalação -Abra um terminal e execute (Requer Python 3.8+): +Abra um terminal e execute (Requer Python 3.9+): ```bash pip install reflex diff --git a/docs/tr/README.md b/docs/tr/README.md index 03817e738..376547e01 100644 --- a/docs/tr/README.md +++ b/docs/tr/README.md @@ -11,7 +11,6 @@ ### **✨ Saf Python'da performanslı, özelleştirilebilir web uygulamaları. Saniyeler içinde dağıtın. ✨** [![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) [![Documentaiton](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) @@ -19,13 +18,13 @@ --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) --- ## ⚙️ Kurulum -Bir terminal açın ve çalıştırın (Python 3.8+ gerekir): +Bir terminal açın ve çalıştırın (Python 3.9+ gerekir): ```bash pip install reflex diff --git a/docs/vi/README.md b/docs/vi/README.md new file mode 100644 index 000000000..df7a31530 --- /dev/null +++ b/docs/vi/README.md @@ -0,0 +1,267 @@ +```diff ++ Bạn đang tìm kiếm Pynecone? Bạn đã tìm đúng. Pynecone đã được đổi tên thành Reflex. + +``` + +
+Reflex Logo +Reflex Logo + +
+ +### **✨ Ứng dụng web hiệu suất cao, tùy chỉnh bằng Python thuần. Deploy trong vài giây. ✨** +[![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex) +![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) +
+ +--- + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) | [Tiếng Việt](https://github.com/reflex-dev/reflex/blob/main/docs/vi/README.md) + +--- + +# Reflex + +Reflex là một thư viện để xây dựng ứng dụng web toàn bộ bằng Python thuần. + +Các tính năng chính: +* **Python thuần tuý** - Viết toàn bộ ứng dụng cả backend và frontend hoàn toàn bằng Python, không cần học JavaScript. +* **Full Flexibility** - Reflex dễ dàng để bắt đầu, nhưng cũng có thể mở rộng lên các ứng dụng phức tạp. +* **Deploy Instantly** - Sau khi xây dựng ứng dụng, bạn có thể triển khai bằng [một dòng lệnh](https://reflex.dev/docs/hosting/deploy-quick-start/) hoặc triển khai trên server của riêng bạn. + +Đọc [bài viết về kiến trúc hệ thống](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) để hiểu rõ các hoạt động của Reflex. + +## ⚙️ Cài đặt + +Mở cửa sổ lệnh và chạy (Yêu cầu Python phiên bản 3.9+): + +```bash +pip install reflex +``` + +## 🥳 Tạo ứng dụng đầu tiên + +Cài đặt `reflex` cũng như cài đặt công cụ dòng lệnh `reflex`. + +Kiểm tra việc cài đặt đã thành công hay chưa bằng cách tạo mới một ứng dụng. (Thay `my_app_name` bằng tên ứng dụng của bạn): + +```bash +mkdir my_app_name +cd my_app_name +reflex init +``` + +Lệnh này tạo ra một ứng dụng mẫu trong một thư mục mới. + +Bạn có thể chạy ứng dụng ở chế độ phát triển. + +```bash +reflex run +``` + +Bạn có thể xem ứng dụng của bạn ở địa chỉ http://localhost:3000. + +Bạn có thể thay đổi mã nguồn ở `my_app_name/my_app_name.py`. Reflex nhanh chóng làm mới và bạn có thể thấy thay đổi trên ứng dụng của bạn ngay lập tức khi bạn lưu file. + + +## 🫧 Ứng dụng ví dụ + +Bắt đầu với ví dụ: tạo một ứng dụng tạo ảnh bằng [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node). Để cho đơn giản, chúng ta sẽ sử dụng [OpenAI API](https://platform.openai.com/docs/api-reference/authentication), nhưng bạn có thể sử dụng model của chính bạn được triển khai trên local. + +  + +
+A frontend wrapper for DALL·E, shown in the process of generating an image. +
+ +  + +Đây là toàn bộ đoạn mã để xây dựng ứng dụng trên. Nó được viết hoàn toàn trong một file Python! + + + +```python +import reflex as rx +import openai + +openai_client = openai.OpenAI() + + +class State(rx.State): + """The app state.""" + + prompt = "" + image_url = "" + processing = False + complete = False + + def get_image(self): + """Get the image from the prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True + + +def index(): + return rx.center( + rx.vstack( + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), + rx.cond( + State.complete, + rx.image(src=State.image_url, width="20em"), + ), + align="center", + ), + width="100%", + height="100vh", + ) + +# Add state and page to the app. +app = rx.App() +app.add_page(index, title="Reflex:DALL-E") +``` + + + + + +## Hãy phân tích chi tiết. + +
+Explaining the differences between backend and frontend parts of the DALL-E app. +
+ + +### **Reflex UI** + +Bắt đầu với giao diện chính. + +```python +def index(): + return rx.center( + ... + ) +``` + +Hàm `index` định nghĩa phần giao diện chính của ứng dụng. + +Chúng tôi sử dụng các component (thành phần) khác nhau như `center`, `vstack`, `input` và `button` để xây dựng giao diện phía trước. +Các component có thể được lồng vào nhau để tạo ra các bố cục phức tạp. Và bạn cũng có thể sử dụng từ khoá `args` để tận dụng đầy đủ sức mạnh của CSS. + +Reflex có đến hơn [60 component được xây dựng sẵn](https://reflex.dev/docs/library) để giúp bạn bắt đầu. Chúng ta có thể tạo ra một component mới khá dễ dàng, thao khảo: [xây dựng component của riêng bạn](https://reflex.dev/docs/wrapping-react/overview/). + +### **State** + +Reflex biểu diễn giao diện bằng các hàm của state (trạng thái). + +```python +class State(rx.State): + """The app state.""" + prompt = "" + image_url = "" + processing = False + complete = False + +``` + +Một state định nghĩa các biến (được gọi là vars) có thể thay đổi trong một ứng dụng và cho phép các hàm có thể thay đổi chúng. + +Tại đây state được cấu thành từ một `prompt` và `image_url`. +Có cũng những biến boolean `processing` và `complete` +để chỉ ra khi nào tắt nút (trong quá trình tạo hình ảnh) +và khi nào hiển thị hình ảnh kết quả. + +### **Event Handlers** + +```python +def get_image(self): + """Get the image from the prompt.""" + if self.prompt == "": + return rx.window_alert("Prompt Empty") + + self.processing, self.complete = True, False + yield + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url + self.processing, self.complete = False, True +``` + +Với các state, chúng ta định nghĩa các hàm có thể thay đổi state vars được gọi là event handlers. Event handler là cách chúng ta có thể thay đổi state trong Reflex. Chúng có thể là phản hồi khi người dùng thao tác, chằng hạn khi nhấn vào nút hoặc khi đang nhập trong text box. Các hành động này được gọi là event. + +Ứng dụng DALL·E. của chúng ta có một event handler, `get_image` để lấy hình ảnh từ OpenAI API. Sử dụng từ khoá `yield` in ở giữa event handler để cập nhật giao diện. Hoặc giao diện có thể cập nhật ở cuối event handler. + +### **Routing** + +Cuối cùng, chúng ta định nghĩa một ứng dụng. + +```python +app = rx.App() +``` + +Chúng ta thêm một trang ở đầu ứng dụng bằng index component. Chúng ta cũng thêm tiêu đề của ứng dụng để hiển thị lên trình duyệt. + + +```python +app.add_page(index, title="DALL-E") +``` + +Bạn có thể tạo một ứng dụng nhiều trang bằng cách thêm trang. + +## 📑 Tài liệu + +
+ +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)   + +
+ + +## ✅ Status + +Reflex phát hành vào tháng 12/2022 với tên là Pynecone. + +Đến tháng 02/2024, chúng tôi tạo ra dịch vụ dưới phiên bản alpha! Trong thời gian này mọi người có thể triển khai ứng dụng hoàn toàn miễn phí. Xem [roadmap](https://github.com/reflex-dev/reflex/issues/2727) để biết thêm chi tiết. + +Reflex ra phiên bản mới với các tính năng mới hàng tuần! Hãy :star: star và :eyes: watch repo này để thấy các cập nhật mới nhất. + +## Contributing + +Chúng tôi chào đón mọi đóng góp dù lớn hay nhỏ. Dưới đây là các cách để bắt đầu với cộng đồng Reflex. + +- **Discord**: [Discord](https://discord.gg/T5WSbC2YtQ) của chúng tôi là nơi tốt nhất để nhờ sự giúp đỡ và thảo luận các bạn có thể đóng góp. +- **GitHub Discussions**: Là cách tốt nhất để thảo luận về các tính năng mà bạn có thể đóng góp hoặc những điều bạn chưa rõ. +- **GitHub Issues**: [Issues](https://github.com/reflex-dev/reflex/issues) là nơi tốt nhất để thông báo. Ngoài ra bạn có thể sửa chữa các vấn đề bằng cách tạo PR. + +Chúng tôi luôn sẵn sàng tìm kiếm các contributor, bất kể kinh nghiệm. Để tham gia đóng góp, xin mời xem +[CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) + + +## Xin cảm ơn các Contributors: + + + + +## License + +Reflex là mã nguồn mở và sử dụng giấy phép [Apache License 2.0](LICENSE). diff --git a/docs/zh/zh_cn/README.md b/docs/zh/zh_cn/README.md index 8c1fa8572..e114bc1e2 100644 --- a/docs/zh/zh_cn/README.md +++ b/docs/zh/zh_cn/README.md @@ -8,25 +8,35 @@
-**✨ 使用 Python 创建高效且可自定义的网页应用程序,几秒钟内即可部署.** - - +### **✨ 使用 Python 创建高效且可自定义的网页应用程序,几秒钟内即可部署.✨** [![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) [![Documentaiton](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) - --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) + --- + +# Reflex + +Reflex 是一个使用纯Python构建全栈web应用的库。 + +关键特性: +* **纯Python** - 前端、后端开发全都使用Python,不需要学习Javascript。 +* **完整的灵活性** - Reflex很容易上手, 并且也可以扩展到复杂的应用程序。 +* **立即部署** - 构建后,使用[单个命令](https://reflex.dev/docs/hosting/deploy-quick-start/)就能部署应用程序;或者也可以将其托管在您自己的服务器上。 + +请参阅我们的[架构页](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)了解Reflex如何工作。 + ## ⚙️ 安装 -打开一个终端并且运行(要求Python3.8+): +打开一个终端并且运行(要求Python3.9+): -``` +```bash pip install reflex ``` @@ -36,7 +46,7 @@ pip install reflex 通过创建一个新项目来测试是否安装成功(请把 my_app_name 替代为您的项目名字): -``` +```bash mkdir my_app_name cd my_app_name reflex init @@ -45,6 +55,7 @@ reflex init 这段命令会在新文件夹初始化一个应用程序模板. 您可以在开发者模式下运行这个应用程序: + ```bash reflex run ``` @@ -55,7 +66,7 @@ reflex run ## 🫧 范例 -让我们来看一个例子: 创建一个使用 DALL·E 进行图像生成的图形界面.为了保持范例简单,我们只使用 OpenAI API,但是您可以将其替换成本地端的 ML 模型. +让我们来看一个例子: 创建一个使用 [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node) 进行图像生成的图形界面.为了保持范例简单,我们只使用 OpenAI API,但是您可以将其替换成本地端的 ML 模型.   @@ -67,14 +78,19 @@ reflex run 这是这个范例的完整代码,只需要一个 Python 文件就可以完成! + + + ```python import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() + class State(rx.State): """The app state.""" + prompt = "" image_url = "" processing = False @@ -87,33 +103,33 @@ class State(rx.State): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True - + def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( - "Generate Image", + "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", @@ -121,11 +137,20 @@ def index(): # Add state and page to the app. app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` + + + + ## 让我们分解以上步骤. +
+解释 DALL-E app 的前端和后端部分的区别。 +
+ + ### **Reflex UI** 让我们从UI开始. @@ -142,7 +167,7 @@ def index(): 我们用不同的组件比如 `center`, `vstack`, `input`, 和 `button` 来创建前端, 组件之间可以相互嵌入,来创建复杂的布局. 并且您可以使用关键字参数来使用 CSS 的全部功能. -Reflex 拥有 [60+ 个内置组件](https://reflex.dev/docs/library) 来帮助您开始创建应用程序. 我们正在积极添加组件, 但是您也可以 [创建自己的组件](https://reflex.dev/docs/wrapping-react/overview/). +Reflex 拥有 [60+ 个内置组件](https://reflex.dev/docs/library) 来帮助您开始创建应用程序. 我们正在积极添加组件, 但是您也可以容易的 [创建自己的组件](https://reflex.dev/docs/wrapping-react/overview/). ### **State** @@ -155,12 +180,12 @@ class State(rx.State): image_url = "" processing = False complete = False -``` +``` State定义了所有可能会发生变化的变量(称为 vars)以及能够改变这些变量的函数. -在这个范例中,State由 prompt 和 image_url 组成.此外,State还包含有两个布尔值 processing 和 complete,用于指示何时显示循环进度指示器和图像. +在这个范例中,State由 `prompt` 和 `image_url` 组成.此外,State还包含有两个布尔值 `processing` 和 `complete`,用于指示何时显示循环进度指示器和图像. ### **Event Handlers** @@ -172,14 +197,16 @@ def get_image(self): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True ``` 在 State 中,我们定义了称为事件处理器(event handlers)的函数,用于改变状态变量(state vars).在Reflex中,事件处理器是我们可以修改状态的方式.它们可以作为对用户操作的响应而被调用,例如点击一个按钮或在文本框中输入.这些操作被称为事件. -我们的DALL·E应用有一个事件处理器,名为 get_image,它用于从OpenAI API获取图像.在事件处理器中使用 yield 将导致UI进行更新.否则,UI将在事件处理器结束时进行更新. +我们的DALL·E应用有一个事件处理器,名为 `get_image`,它用于从OpenAI API获取图像.在事件处理器中使用 `yield` 将导致UI进行更新.否则,UI将在事件处理器结束时进行更新. ### **Routing** @@ -206,19 +233,13 @@ app.add_page(index, title="DALL-E") - ## ✅ Reflex 的状态 Reflex 于 2022 年 12 月以Pynecone的名称推出. -在2023年7月, 我们处于 **Public Beta** 阶段. +截至2024年2月,我们的托管服务处于alpha测试阶段!在此期间,任何人都可以免费部署他们的应用程序。请查看我们的[路线图](https://github.com/reflex-dev/reflex/issues/2727)以了解我们的计划。 -- :white_check_mark: **Public Alpha**: 任何人都可以安装与使用 Reflex,或许包含问题, 但我们正在积极的解决他们. -- :large_orange_diamond: **Public Beta**: 对于非软件产品来说足够稳定. -- **Public Hosting Beta**: _Optionally_, 部属跟托管您的 Reflex! -- **Public**: 这版本的 Reflex 是可用于软件产品的. - -Reflex 每周都有新功能和发布新版本! 确保您按下 :star: 和 :eyes: watch 这个 repository 来确保知道最新信息. +Reflex 每周都有新功能和发布新版本! 确保您按下 :star: 收藏和 :eyes: 关注 这个 仓库来确保知道最新信息. ## 贡献 @@ -226,10 +247,16 @@ Reflex 每周都有新功能和发布新版本! 确保您按下 :star: 和 :eyes - **加入我们的 Discord**: 我们的 [Discord](https://discord.gg/T5WSbC2YtQ) 是帮助您加入 Reflex 项目和讨论或贡献最棒的地方. - **GitHub Discussions**: 一个来讨论您想要添加的功能或是需要澄清的事情的好地方. -- **GitHub Issues**: 报告错误的绝佳地方,另外您可以试着解决一些 issue 和送出 PR. +- **GitHub Issues**: [报告错误](https://github.com/reflex-dev/reflex/issues)的绝佳地方,另外您可以试着解决一些 issue 和送出 PR. 我们正在积极寻找贡献者,无关您的技能或经验水平. + +## 感谢我们所有的贡献者: + + + + ## 授权 Reflex 是一个开源项目,使用 [Apache License 2.0](LICENSE) 授权. diff --git a/docs/zh/zh_tw/README.md b/docs/zh/zh_tw/README.md index 76839ebc2..83f6b2ae2 100644 --- a/docs/zh/zh_tw/README.md +++ b/docs/zh/zh_tw/README.md @@ -11,18 +11,32 @@ **✨ 使用 Python 建立高效且可自訂的網頁應用程式,幾秒鐘內即可部署。✨** [![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) [![Documentaiton](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) + --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) | [Deutsch](https://github.com/reflex-dev/reflex/blob/main/docs/de/README.md) | [Persian (پارسی)](https://github.com/reflex-dev/reflex/blob/main/docs/pe/README.md) + --- + +# Reflex + +Reflex 是一個可以用純 Python 構建全端網頁應用程式的函式庫。 + +主要特色: + +* **純 Python** - 您可以用 Python 撰寫應用程式的前端和後端,無需學習 Javascript。 +* **完全靈活性** - Reflex 易於上手,但也可以擴展到複雜的應用程式。 +* **立即部署** - 構建後,只需使用[單一指令](https://reflex.dev/docs/hosting/deploy-quick-start/)即可部署您的應用程式,或在您自己的伺服器上託管。 +請參閱我們的[架構頁面](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)了解 Reflex 如何在底層運作。 + ## ⚙️ 安裝 -開啟一個終端機並且執行 (需要 Python 3.8+): +開啟一個終端機並且執行 (需要 Python 3.9+): ```bash pip install reflex @@ -70,7 +84,8 @@ reflex run import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() + class State(rx.State): """應用程式狀態""" @@ -86,33 +101,33 @@ class State(rx.State): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( - "Generate Image", + "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", @@ -120,10 +135,22 @@ def index(): # 把狀態跟頁面添加到應用程式。 app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` + + + + + + ## 讓我們來拆解一下。 + +
+解釋 DALL-E app 的前端和後端部分的區別。 +
+ + ### **Reflex 使用者介面** 讓我們從使用介面開始。 @@ -150,8 +177,9 @@ class State(rx.State): """應用程式狀態""" prompt = "" image_url = "" - image_processing = False - image_made = False + processing = False + complete = False + ``` 應用程式狀態定義了應用程式中所有可以更改的變數及變更他們的函式 (稱為 vars)。 @@ -168,8 +196,10 @@ def get_image(self): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True ``` @@ -199,34 +229,35 @@ app.add_page(index, title="DALL-E")
-📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy)   +📑 [Docs](https://reflex.dev/docs/getting-started/introduction)   |   🗞️ [Blog](https://reflex.dev/blog)   |   📱 [Component Library](https://reflex.dev/docs/library)   |   🖼️ [Gallery](https://reflex.dev/docs/gallery)   |   🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)  
-## ✅ Reflex 狀態 +## ✅ 產品狀態 -Reflex 於 2022 年 12 月推出,當時名為 Pynecone。 +Reflex 在 2022 年 12 月以 Pynecone 的名字推出。 -截至 2023 年 7 月,我們處於 **Public Beta** 階段。 - -- :white_check_mark: **Public Alpha**: 任何人都可以安裝與使用 Reflex,或許包含問題, 但我們正在積極的解決他們。 -- :large_orange_diamond: **Public Beta**: 對於不涉及商業目的使用情境來說足夠穩定。 -- **Public Hosting Beta**: _Optionally_, 部屬跟託管你的 Reflex! -- **Public**: 這版本的 Reflex 是可用於軟體產品的。 +截至 2024 年 2 月,我們的託管服務已進入 alpha 階段!在此期間,任何人都可以免費部署他們的應用程式。請參閱我們的[產品地圖](https://github.com/reflex-dev/reflex/issues/2727)了解未來的計劃。 Reflex 每周都有新功能和釋出新版本! 確保你按下 :star: 和 :eyes: watch 這個 repository 來確保知道最新資訊。 ## 貢獻 -我們歡迎任何大小的貢獻,以下是幾個好的方法來加入 Reflex 社群。 +我們歡迎任何大小的貢獻,以下是一些加入 Reflex 社群的好方法。 -- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是幫助你加入 Reflex 專案和討論或貢獻最棒的地方。 -- **GitHub Discussions**: 一個來討論你想要添加的功能或是需要澄清的事情的好地方。 -- **GitHub Issues**: 報告錯誤的絕佳地方,另外你可以試著解決一些 issue 和送出 PR。 +- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是獲取 Reflex 專案幫助和討論如何貢獻的最佳地方。 +- **GitHub Discussions**: 這是一個討論您想新增的功能或對於一些困惑/需要澄清事項的好方法。 +- **GitHub Issues**: 在 [Issues](https://github.com/reflex-dev/reflex/issues) 頁面報告錯誤是一個絕佳的方式。此外,您也可以嘗試解決現有 Issue 並提交 PR。 -我們正在積極尋找貢獻者,無關你的技能水平或經驗。 +我們積極尋找貢獻者,不論您的技能水平或經驗如何。要貢獻,請查看 [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) + + +## 感謝所有貢獻者: + + + ## 授權 diff --git a/integration/test_component_state.py b/integration/test_component_state.py deleted file mode 100644 index d2c10c766..000000000 --- a/integration/test_component_state.py +++ /dev/null @@ -1,107 +0,0 @@ -"""Test that per-component state scaffold works and operates independently.""" -from typing import Generator - -import pytest -from selenium.webdriver.common.by import By - -from reflex.testing import AppHarness - -from . import utils - - -def ComponentStateApp(): - """App using per component state.""" - import reflex as rx - - class MultiCounter(rx.ComponentState): - count: int = 0 - - def increment(self): - self.count += 1 - - @classmethod - def get_component(cls, *children, **props): - return rx.vstack( - *children, - rx.heading(cls.count, id=f"count-{props.get('id', 'default')}"), - rx.button( - "Increment", - on_click=cls.increment, - id=f"button-{props.get('id', 'default')}", - ), - **props, - ) - - app = rx.App(state=rx.State) # noqa - - @rx.page() - def index(): - mc_a = MultiCounter.create(id="a") - mc_b = MultiCounter.create(id="b") - assert mc_a.State != mc_b.State - return rx.vstack( - mc_a, - mc_b, - rx.button( - "Inc A", - on_click=mc_a.State.increment, # type: ignore - id="inc-a", - ), - ) - - -@pytest.fixture() -def component_state_app(tmp_path) -> Generator[AppHarness, None, None]: - """Start ComponentStateApp app at tmp_path via AppHarness. - - Args: - tmp_path: pytest tmp_path fixture - - Yields: - running AppHarness instance - """ - with AppHarness.create( - root=tmp_path, - app_source=ComponentStateApp, # type: ignore - ) as harness: - yield harness - - -@pytest.mark.asyncio -async def test_component_state_app(component_state_app: AppHarness): - """Increment counters independently. - - Args: - component_state_app: harness for ComponentStateApp app - """ - assert component_state_app.app_instance is not None, "app is not running" - driver = component_state_app.frontend() - - ss = utils.SessionStorage(driver) - token = AppHarness._poll_for(lambda: ss.get("token") is not None) - assert token is not None - - count_a = driver.find_element(By.ID, "count-a") - count_b = driver.find_element(By.ID, "count-b") - button_a = driver.find_element(By.ID, "button-a") - button_b = driver.find_element(By.ID, "button-b") - button_inc_a = driver.find_element(By.ID, "inc-a") - - assert count_a.text == "0" - - button_a.click() - assert component_state_app.poll_for_content(count_a, exp_not_equal="0") == "1" - - button_a.click() - assert component_state_app.poll_for_content(count_a, exp_not_equal="1") == "2" - - button_inc_a.click() - assert component_state_app.poll_for_content(count_a, exp_not_equal="2") == "3" - - assert count_b.text == "0" - - button_b.click() - assert component_state_app.poll_for_content(count_b, exp_not_equal="0") == "1" - - button_b.click() - assert component_state_app.poll_for_content(count_b, exp_not_equal="1") == "2" diff --git a/integration/test_table.py b/integration/test_table.py deleted file mode 100644 index a13d2b3e5..000000000 --- a/integration/test_table.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Integration tests for table and related components.""" -from typing import Generator - -import pytest -from selenium.webdriver.common.by import By - -from reflex.testing import AppHarness - - -def Table(): - """App using table component.""" - from typing import List - - 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( - rx.chakra.input( - id="token", - value=TableState.router.session.client_token, - is_read_only=True, - ), - rx.chakra.table_container( - rx.chakra.table( - headers=TableState.headers, - rows=TableState.rows, - footers=TableState.footers, - caption=TableState.caption, - variant="striped", - color_scheme="blue", - width="100%", - ), - ), - ) - - @app.add_page - def another(): - return rx.center( - rx.chakra.table_container( - rx.chakra.table( # type: ignore - rx.chakra.thead( # type: ignore - rx.chakra.tr( # type: ignore - rx.chakra.th("Name"), - rx.chakra.th("Age"), - rx.chakra.th("Location"), - ) - ), - rx.chakra.tbody( # type: ignore - rx.chakra.tr( # type: ignore - rx.chakra.td("John"), - rx.chakra.td(30), - rx.chakra.td("New York"), - ), - rx.chakra.tr( # type: ignore - rx.chakra.td("Jane"), - rx.chakra.td(31), - rx.chakra.td("San Francisco"), - ), - rx.chakra.tr( # type: ignore - rx.chakra.td("Joe"), - rx.chakra.td(32), - rx.chakra.td("Los Angeles"), - ), - ), - rx.chakra.tfoot( # type: ignore - rx.chakra.tr( - rx.chakra.td("footer1"), - rx.chakra.td("footer2"), - rx.chakra.td("footer3"), - ) # type: ignore - ), - rx.chakra.table_caption("random caption"), - variant="striped", - color_scheme="teal", - ) - ) - ) - - -@pytest.fixture() -def table(tmp_path_factory) -> Generator[AppHarness, None, None]: - """Start Table app at tmp_path via AppHarness. - - Args: - tmp_path_factory: pytest tmp_path_factory fixture - - Yields: - running AppHarness instance - - """ - with AppHarness.create( - root=tmp_path_factory.mktemp("table"), - app_source=Table, # type: ignore - ) as harness: - assert harness.app_instance is not None, "app is not running" - yield harness - - -@pytest.fixture -def driver(table: AppHarness): - """GEt an instance of the browser open to the table app. - - Args: - table: harness for Table app - - Yields: - WebDriver instance. - """ - driver = table.frontend() - try: - token_input = driver.find_element(By.ID, "token") - assert token_input - # wait for the backend connection to send the token - token = table.poll_for_value(token_input) - assert token is not None - - yield driver - finally: - driver.quit() - - -@pytest.mark.parametrize("route", ["", "/another"]) -def test_table(driver, table: AppHarness, route): - """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" - # check first row value - assert ( - driver.find_element(By.TAG_NAME, "tbody") - .find_elements(By.TAG_NAME, "tr")[0] - .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_urls.py b/integration/test_urls.py deleted file mode 100755 index a72de8aa3..000000000 --- a/integration/test_urls.py +++ /dev/null @@ -1,67 +0,0 @@ -"""Integration tests for all urls in Reflex.""" -import os -import re -from pathlib import Path - -import pytest -import requests - - -def check_urls(repo_dir): - """Check that all URLs in the repo are valid and secure. - - Args: - repo_dir: The directory of the repo. - - Returns: - A list of errors. - """ - url_pattern = re.compile(r'http[s]?://reflex\.dev[^\s")]*') - errors = [] - - for root, _dirs, files in os.walk(repo_dir): - if "__pycache__" in root: - continue - - for file_name in files: - if not file_name.endswith(".py") and not file_name.endswith(".md"): - continue - - file_path = os.path.join(root, file_name) - try: - with open(file_path, "r", encoding="utf-8", errors="ignore") as file: - for line in file: - urls = url_pattern.findall(line) - for url in set(urls): - if url.startswith("http://"): - errors.append( - f"Found insecure HTTP URL: {url} in {file_path}" - ) - url = url.strip('"\n') - try: - response = requests.head( - url, allow_redirects=True, timeout=5 - ) - response.raise_for_status() - except requests.RequestException as e: - errors.append( - f"Error accessing URL: {url} in {file_path} | Error: {e}, , Check your path ends with a /" - ) - except Exception as e: - errors.append(f"Error reading file: {file_path} | Error: {e}") - - return errors - - -@pytest.mark.parametrize( - "repo_dir", - [Path(__file__).resolve().parent.parent / "reflex"], -) -def test_find_and_check_urls(repo_dir): - """Test that all URLs in the repo are valid and secure. - - Args: - repo_dir: The directory of the repo. - """ - errors = check_urls(repo_dir) - assert not errors, "\n".join(errors) diff --git a/poetry.lock b/poetry.lock index c22175a23..661fef5f6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,106 +1,133 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + +[[package]] +name = "aiohappyeyeballs" +version = "2.4.3" +description = "Happy Eyeballs for asyncio" +optional = true +python-versions = ">=3.8" +files = [ + {file = "aiohappyeyeballs-2.4.3-py3-none-any.whl", hash = "sha256:8a7a83727b2756f394ab2895ea0765a0a8c475e3c71e98d43d76f22b4b435572"}, + {file = "aiohappyeyeballs-2.4.3.tar.gz", hash = "sha256:75cf88a15106a5002a8eb1dab212525c00d1f4c0fa96e551c9fbe6f09a621586"}, +] [[package]] name = "aiohttp" -version = "3.9.5" +version = "3.10.10" description = "Async http client/server framework (asyncio)" -optional = false +optional = true python-versions = ">=3.8" files = [ - {file = "aiohttp-3.9.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:fcde4c397f673fdec23e6b05ebf8d4751314fa7c24f93334bf1f1364c1c69ac7"}, - {file = "aiohttp-3.9.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5d6b3f1fabe465e819aed2c421a6743d8debbde79b6a8600739300630a01bf2c"}, - {file = "aiohttp-3.9.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6ae79c1bc12c34082d92bf9422764f799aee4746fd7a392db46b7fd357d4a17a"}, - {file = "aiohttp-3.9.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4d3ebb9e1316ec74277d19c5f482f98cc65a73ccd5430540d6d11682cd857430"}, - {file = "aiohttp-3.9.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:84dabd95154f43a2ea80deffec9cb44d2e301e38a0c9d331cc4aa0166fe28ae3"}, - {file = "aiohttp-3.9.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c8a02fbeca6f63cb1f0475c799679057fc9268b77075ab7cf3f1c600e81dd46b"}, - {file = "aiohttp-3.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c26959ca7b75ff768e2776d8055bf9582a6267e24556bb7f7bd29e677932be72"}, - {file = "aiohttp-3.9.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:714d4e5231fed4ba2762ed489b4aec07b2b9953cf4ee31e9871caac895a839c0"}, - {file = "aiohttp-3.9.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e7a6a8354f1b62e15d48e04350f13e726fa08b62c3d7b8401c0a1314f02e3558"}, - {file = "aiohttp-3.9.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:c413016880e03e69d166efb5a1a95d40f83d5a3a648d16486592c49ffb76d0db"}, - {file = "aiohttp-3.9.5-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:ff84aeb864e0fac81f676be9f4685f0527b660f1efdc40dcede3c251ef1e867f"}, - {file = "aiohttp-3.9.5-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:ad7f2919d7dac062f24d6f5fe95d401597fbb015a25771f85e692d043c9d7832"}, - {file = "aiohttp-3.9.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:702e2c7c187c1a498a4e2b03155d52658fdd6fda882d3d7fbb891a5cf108bb10"}, - {file = "aiohttp-3.9.5-cp310-cp310-win32.whl", hash = "sha256:67c3119f5ddc7261d47163ed86d760ddf0e625cd6246b4ed852e82159617b5fb"}, - {file = "aiohttp-3.9.5-cp310-cp310-win_amd64.whl", hash = "sha256:471f0ef53ccedec9995287f02caf0c068732f026455f07db3f01a46e49d76bbb"}, - {file = "aiohttp-3.9.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:e0ae53e33ee7476dd3d1132f932eeb39bf6125083820049d06edcdca4381f342"}, - {file = "aiohttp-3.9.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c088c4d70d21f8ca5c0b8b5403fe84a7bc8e024161febdd4ef04575ef35d474d"}, - {file = "aiohttp-3.9.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:639d0042b7670222f33b0028de6b4e2fad6451462ce7df2af8aee37dcac55424"}, - {file = "aiohttp-3.9.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f26383adb94da5e7fb388d441bf09c61e5e35f455a3217bfd790c6b6bc64b2ee"}, - {file = "aiohttp-3.9.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:66331d00fb28dc90aa606d9a54304af76b335ae204d1836f65797d6fe27f1ca2"}, - {file = "aiohttp-3.9.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ff550491f5492ab5ed3533e76b8567f4b37bd2995e780a1f46bca2024223233"}, - {file = "aiohttp-3.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f22eb3a6c1080d862befa0a89c380b4dafce29dc6cd56083f630073d102eb595"}, - {file = "aiohttp-3.9.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a81b1143d42b66ffc40a441379387076243ef7b51019204fd3ec36b9f69e77d6"}, - {file = "aiohttp-3.9.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f64fd07515dad67f24b6ea4a66ae2876c01031de91c93075b8093f07c0a2d93d"}, - {file = "aiohttp-3.9.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:93e22add827447d2e26d67c9ac0161756007f152fdc5210277d00a85f6c92323"}, - {file = "aiohttp-3.9.5-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:55b39c8684a46e56ef8c8d24faf02de4a2b2ac60d26cee93bc595651ff545de9"}, - {file = "aiohttp-3.9.5-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4715a9b778f4293b9f8ae7a0a7cef9829f02ff8d6277a39d7f40565c737d3771"}, - {file = "aiohttp-3.9.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:afc52b8d969eff14e069a710057d15ab9ac17cd4b6753042c407dcea0e40bf75"}, - {file = "aiohttp-3.9.5-cp311-cp311-win32.whl", hash = "sha256:b3df71da99c98534be076196791adca8819761f0bf6e08e07fd7da25127150d6"}, - {file = "aiohttp-3.9.5-cp311-cp311-win_amd64.whl", hash = "sha256:88e311d98cc0bf45b62fc46c66753a83445f5ab20038bcc1b8a1cc05666f428a"}, - {file = "aiohttp-3.9.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:c7a4b7a6cf5b6eb11e109a9755fd4fda7d57395f8c575e166d363b9fc3ec4678"}, - {file = "aiohttp-3.9.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:0a158704edf0abcac8ac371fbb54044f3270bdbc93e254a82b6c82be1ef08f3c"}, - {file = "aiohttp-3.9.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d153f652a687a8e95ad367a86a61e8d53d528b0530ef382ec5aaf533140ed00f"}, - {file = "aiohttp-3.9.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:82a6a97d9771cb48ae16979c3a3a9a18b600a8505b1115cfe354dfb2054468b4"}, - {file = "aiohttp-3.9.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:60cdbd56f4cad9f69c35eaac0fbbdf1f77b0ff9456cebd4902f3dd1cf096464c"}, - {file = "aiohttp-3.9.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8676e8fd73141ded15ea586de0b7cda1542960a7b9ad89b2b06428e97125d4fa"}, - {file = "aiohttp-3.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da00da442a0e31f1c69d26d224e1efd3a1ca5bcbf210978a2ca7426dfcae9f58"}, - {file = "aiohttp-3.9.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18f634d540dd099c262e9f887c8bbacc959847cfe5da7a0e2e1cf3f14dbf2daf"}, - {file = "aiohttp-3.9.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:320e8618eda64e19d11bdb3bd04ccc0a816c17eaecb7e4945d01deee2a22f95f"}, - {file = "aiohttp-3.9.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:2faa61a904b83142747fc6a6d7ad8fccff898c849123030f8e75d5d967fd4a81"}, - {file = "aiohttp-3.9.5-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:8c64a6dc3fe5db7b1b4d2b5cb84c4f677768bdc340611eca673afb7cf416ef5a"}, - {file = "aiohttp-3.9.5-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:393c7aba2b55559ef7ab791c94b44f7482a07bf7640d17b341b79081f5e5cd1a"}, - {file = "aiohttp-3.9.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:c671dc117c2c21a1ca10c116cfcd6e3e44da7fcde37bf83b2be485ab377b25da"}, - {file = "aiohttp-3.9.5-cp312-cp312-win32.whl", hash = "sha256:5a7ee16aab26e76add4afc45e8f8206c95d1d75540f1039b84a03c3b3800dd59"}, - {file = "aiohttp-3.9.5-cp312-cp312-win_amd64.whl", hash = "sha256:5ca51eadbd67045396bc92a4345d1790b7301c14d1848feaac1d6a6c9289e888"}, - {file = "aiohttp-3.9.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:694d828b5c41255e54bc2dddb51a9f5150b4eefa9886e38b52605a05d96566e8"}, - {file = "aiohttp-3.9.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0605cc2c0088fcaae79f01c913a38611ad09ba68ff482402d3410bf59039bfb8"}, - {file = "aiohttp-3.9.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4558e5012ee03d2638c681e156461d37b7a113fe13970d438d95d10173d25f78"}, - {file = "aiohttp-3.9.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9dbc053ac75ccc63dc3a3cc547b98c7258ec35a215a92bd9f983e0aac95d3d5b"}, - {file = "aiohttp-3.9.5-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4109adee842b90671f1b689901b948f347325045c15f46b39797ae1bf17019de"}, - {file = "aiohttp-3.9.5-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a6ea1a5b409a85477fd8e5ee6ad8f0e40bf2844c270955e09360418cfd09abac"}, - {file = "aiohttp-3.9.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3c2890ca8c59ee683fd09adf32321a40fe1cf164e3387799efb2acebf090c11"}, - {file = "aiohttp-3.9.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3916c8692dbd9d55c523374a3b8213e628424d19116ac4308e434dbf6d95bbdd"}, - {file = "aiohttp-3.9.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8d1964eb7617907c792ca00b341b5ec3e01ae8c280825deadbbd678447b127e1"}, - {file = "aiohttp-3.9.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d5ab8e1f6bee051a4bf6195e38a5c13e5e161cb7bad83d8854524798bd9fcd6e"}, - {file = "aiohttp-3.9.5-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:52c27110f3862a1afbcb2af4281fc9fdc40327fa286c4625dfee247c3ba90156"}, - {file = "aiohttp-3.9.5-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:7f64cbd44443e80094309875d4f9c71d0401e966d191c3d469cde4642bc2e031"}, - {file = "aiohttp-3.9.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8b4f72fbb66279624bfe83fd5eb6aea0022dad8eec62b71e7bf63ee1caadeafe"}, - {file = "aiohttp-3.9.5-cp38-cp38-win32.whl", hash = "sha256:6380c039ec52866c06d69b5c7aad5478b24ed11696f0e72f6b807cfb261453da"}, - {file = "aiohttp-3.9.5-cp38-cp38-win_amd64.whl", hash = "sha256:da22dab31d7180f8c3ac7c7635f3bcd53808f374f6aa333fe0b0b9e14b01f91a"}, - {file = "aiohttp-3.9.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:1732102949ff6087589408d76cd6dea656b93c896b011ecafff418c9661dc4ed"}, - {file = "aiohttp-3.9.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c6021d296318cb6f9414b48e6a439a7f5d1f665464da507e8ff640848ee2a58a"}, - {file = "aiohttp-3.9.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:239f975589a944eeb1bad26b8b140a59a3a320067fb3cd10b75c3092405a1372"}, - {file = "aiohttp-3.9.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b7b30258348082826d274504fbc7c849959f1989d86c29bc355107accec6cfb"}, - {file = "aiohttp-3.9.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cd2adf5c87ff6d8b277814a28a535b59e20bfea40a101db6b3bdca7e9926bc24"}, - {file = "aiohttp-3.9.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e9a3d838441bebcf5cf442700e3963f58b5c33f015341f9ea86dcd7d503c07e2"}, - {file = "aiohttp-3.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e3a1ae66e3d0c17cf65c08968a5ee3180c5a95920ec2731f53343fac9bad106"}, - {file = "aiohttp-3.9.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9c69e77370cce2d6df5d12b4e12bdcca60c47ba13d1cbbc8645dd005a20b738b"}, - {file = "aiohttp-3.9.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0cbf56238f4bbf49dab8c2dc2e6b1b68502b1e88d335bea59b3f5b9f4c001475"}, - {file = "aiohttp-3.9.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:d1469f228cd9ffddd396d9948b8c9cd8022b6d1bf1e40c6f25b0fb90b4f893ed"}, - {file = "aiohttp-3.9.5-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:45731330e754f5811c314901cebdf19dd776a44b31927fa4b4dbecab9e457b0c"}, - {file = "aiohttp-3.9.5-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:3fcb4046d2904378e3aeea1df51f697b0467f2aac55d232c87ba162709478c46"}, - {file = "aiohttp-3.9.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8cf142aa6c1a751fcb364158fd710b8a9be874b81889c2bd13aa8893197455e2"}, - {file = "aiohttp-3.9.5-cp39-cp39-win32.whl", hash = "sha256:7b179eea70833c8dee51ec42f3b4097bd6370892fa93f510f76762105568cf09"}, - {file = "aiohttp-3.9.5-cp39-cp39-win_amd64.whl", hash = "sha256:38d80498e2e169bc61418ff36170e0aad0cd268da8b38a17c4cf29d254a8b3f1"}, - {file = "aiohttp-3.9.5.tar.gz", hash = "sha256:edea7d15772ceeb29db4aff55e482d4bcfb6ae160ce144f2682de02f6d693551"}, + {file = "aiohttp-3.10.10-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:be7443669ae9c016b71f402e43208e13ddf00912f47f623ee5994e12fc7d4b3f"}, + {file = "aiohttp-3.10.10-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7b06b7843929e41a94ea09eb1ce3927865387e3e23ebe108e0d0d09b08d25be9"}, + {file = "aiohttp-3.10.10-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:333cf6cf8e65f6a1e06e9eb3e643a0c515bb850d470902274239fea02033e9a8"}, + {file = "aiohttp-3.10.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:274cfa632350225ce3fdeb318c23b4a10ec25c0e2c880eff951a3842cf358ac1"}, + {file = "aiohttp-3.10.10-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d9e5e4a85bdb56d224f412d9c98ae4cbd032cc4f3161818f692cd81766eee65a"}, + {file = "aiohttp-3.10.10-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2b606353da03edcc71130b52388d25f9a30a126e04caef1fd637e31683033abd"}, + {file = "aiohttp-3.10.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ab5a5a0c7a7991d90446a198689c0535be89bbd6b410a1f9a66688f0880ec026"}, + {file = "aiohttp-3.10.10-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:578a4b875af3e0daaf1ac6fa983d93e0bbfec3ead753b6d6f33d467100cdc67b"}, + {file = "aiohttp-3.10.10-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:8105fd8a890df77b76dd3054cddf01a879fc13e8af576805d667e0fa0224c35d"}, + {file = "aiohttp-3.10.10-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:3bcd391d083f636c06a68715e69467963d1f9600f85ef556ea82e9ef25f043f7"}, + {file = "aiohttp-3.10.10-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:fbc6264158392bad9df19537e872d476f7c57adf718944cc1e4495cbabf38e2a"}, + {file = "aiohttp-3.10.10-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e48d5021a84d341bcaf95c8460b152cfbad770d28e5fe14a768988c461b821bc"}, + {file = "aiohttp-3.10.10-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2609e9ab08474702cc67b7702dbb8a80e392c54613ebe80db7e8dbdb79837c68"}, + {file = "aiohttp-3.10.10-cp310-cp310-win32.whl", hash = "sha256:84afcdea18eda514c25bc68b9af2a2b1adea7c08899175a51fe7c4fb6d551257"}, + {file = "aiohttp-3.10.10-cp310-cp310-win_amd64.whl", hash = "sha256:9c72109213eb9d3874f7ac8c0c5fa90e072d678e117d9061c06e30c85b4cf0e6"}, + {file = "aiohttp-3.10.10-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c30a0eafc89d28e7f959281b58198a9fa5e99405f716c0289b7892ca345fe45f"}, + {file = "aiohttp-3.10.10-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:258c5dd01afc10015866114e210fb7365f0d02d9d059c3c3415382ab633fcbcb"}, + {file = "aiohttp-3.10.10-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:15ecd889a709b0080f02721255b3f80bb261c2293d3c748151274dfea93ac871"}, + {file = "aiohttp-3.10.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3935f82f6f4a3820270842e90456ebad3af15810cf65932bd24da4463bc0a4c"}, + {file = "aiohttp-3.10.10-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:413251f6fcf552a33c981c4709a6bba37b12710982fec8e558ae944bfb2abd38"}, + {file = "aiohttp-3.10.10-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d1720b4f14c78a3089562b8875b53e36b51c97c51adc53325a69b79b4b48ebcb"}, + {file = "aiohttp-3.10.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:679abe5d3858b33c2cf74faec299fda60ea9de62916e8b67e625d65bf069a3b7"}, + {file = "aiohttp-3.10.10-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:79019094f87c9fb44f8d769e41dbb664d6e8fcfd62f665ccce36762deaa0e911"}, + {file = "aiohttp-3.10.10-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:fe2fb38c2ed905a2582948e2de560675e9dfbee94c6d5ccdb1301c6d0a5bf092"}, + {file = "aiohttp-3.10.10-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:a3f00003de6eba42d6e94fabb4125600d6e484846dbf90ea8e48a800430cc142"}, + {file = "aiohttp-3.10.10-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:1bbb122c557a16fafc10354b9d99ebf2f2808a660d78202f10ba9d50786384b9"}, + {file = "aiohttp-3.10.10-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:30ca7c3b94708a9d7ae76ff281b2f47d8eaf2579cd05971b5dc681db8caac6e1"}, + {file = "aiohttp-3.10.10-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:df9270660711670e68803107d55c2b5949c2e0f2e4896da176e1ecfc068b974a"}, + {file = "aiohttp-3.10.10-cp311-cp311-win32.whl", hash = "sha256:aafc8ee9b742ce75044ae9a4d3e60e3d918d15a4c2e08a6c3c3e38fa59b92d94"}, + {file = "aiohttp-3.10.10-cp311-cp311-win_amd64.whl", hash = "sha256:362f641f9071e5f3ee6f8e7d37d5ed0d95aae656adf4ef578313ee585b585959"}, + {file = "aiohttp-3.10.10-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:9294bbb581f92770e6ed5c19559e1e99255e4ca604a22c5c6397b2f9dd3ee42c"}, + {file = "aiohttp-3.10.10-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a8fa23fe62c436ccf23ff930149c047f060c7126eae3ccea005f0483f27b2e28"}, + {file = "aiohttp-3.10.10-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5c6a5b8c7926ba5d8545c7dd22961a107526562da31a7a32fa2456baf040939f"}, + {file = "aiohttp-3.10.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:007ec22fbc573e5eb2fb7dec4198ef8f6bf2fe4ce20020798b2eb5d0abda6138"}, + {file = "aiohttp-3.10.10-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9627cc1a10c8c409b5822a92d57a77f383b554463d1884008e051c32ab1b3742"}, + {file = "aiohttp-3.10.10-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:50edbcad60d8f0e3eccc68da67f37268b5144ecc34d59f27a02f9611c1d4eec7"}, + {file = "aiohttp-3.10.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a45d85cf20b5e0d0aa5a8dca27cce8eddef3292bc29d72dcad1641f4ed50aa16"}, + {file = "aiohttp-3.10.10-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0b00807e2605f16e1e198f33a53ce3c4523114059b0c09c337209ae55e3823a8"}, + {file = "aiohttp-3.10.10-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f2d4324a98062be0525d16f768a03e0bbb3b9fe301ceee99611dc9a7953124e6"}, + {file = "aiohttp-3.10.10-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:438cd072f75bb6612f2aca29f8bd7cdf6e35e8f160bc312e49fbecab77c99e3a"}, + {file = "aiohttp-3.10.10-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:baa42524a82f75303f714108fea528ccacf0386af429b69fff141ffef1c534f9"}, + {file = "aiohttp-3.10.10-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:a7d8d14fe962153fc681f6366bdec33d4356f98a3e3567782aac1b6e0e40109a"}, + {file = "aiohttp-3.10.10-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c1277cd707c465cd09572a774559a3cc7c7a28802eb3a2a9472588f062097205"}, + {file = "aiohttp-3.10.10-cp312-cp312-win32.whl", hash = "sha256:59bb3c54aa420521dc4ce3cc2c3fe2ad82adf7b09403fa1f48ae45c0cbde6628"}, + {file = "aiohttp-3.10.10-cp312-cp312-win_amd64.whl", hash = "sha256:0e1b370d8007c4ae31ee6db7f9a2fe801a42b146cec80a86766e7ad5c4a259cf"}, + {file = "aiohttp-3.10.10-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ad7593bb24b2ab09e65e8a1d385606f0f47c65b5a2ae6c551db67d6653e78c28"}, + {file = "aiohttp-3.10.10-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1eb89d3d29adaf533588f209768a9c02e44e4baf832b08118749c5fad191781d"}, + {file = "aiohttp-3.10.10-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3fe407bf93533a6fa82dece0e74dbcaaf5d684e5a51862887f9eaebe6372cd79"}, + {file = "aiohttp-3.10.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50aed5155f819873d23520919e16703fc8925e509abbb1a1491b0087d1cd969e"}, + {file = "aiohttp-3.10.10-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4f05e9727ce409358baa615dbeb9b969db94324a79b5a5cea45d39bdb01d82e6"}, + {file = "aiohttp-3.10.10-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3dffb610a30d643983aeb185ce134f97f290f8935f0abccdd32c77bed9388b42"}, + {file = "aiohttp-3.10.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa6658732517ddabe22c9036479eabce6036655ba87a0224c612e1ae6af2087e"}, + {file = "aiohttp-3.10.10-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:741a46d58677d8c733175d7e5aa618d277cd9d880301a380fd296975a9cdd7bc"}, + {file = "aiohttp-3.10.10-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e00e3505cd80440f6c98c6d69269dcc2a119f86ad0a9fd70bccc59504bebd68a"}, + {file = "aiohttp-3.10.10-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ffe595f10566f8276b76dc3a11ae4bb7eba1aac8ddd75811736a15b0d5311414"}, + {file = "aiohttp-3.10.10-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:bdfcf6443637c148c4e1a20c48c566aa694fa5e288d34b20fcdc58507882fed3"}, + {file = "aiohttp-3.10.10-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:d183cf9c797a5291e8301790ed6d053480ed94070637bfaad914dd38b0981f67"}, + {file = "aiohttp-3.10.10-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:77abf6665ae54000b98b3c742bc6ea1d1fb31c394bcabf8b5d2c1ac3ebfe7f3b"}, + {file = "aiohttp-3.10.10-cp313-cp313-win32.whl", hash = "sha256:4470c73c12cd9109db8277287d11f9dd98f77fc54155fc71a7738a83ffcc8ea8"}, + {file = "aiohttp-3.10.10-cp313-cp313-win_amd64.whl", hash = "sha256:486f7aabfa292719a2753c016cc3a8f8172965cabb3ea2e7f7436c7f5a22a151"}, + {file = "aiohttp-3.10.10-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:1b66ccafef7336a1e1f0e389901f60c1d920102315a56df85e49552308fc0486"}, + {file = "aiohttp-3.10.10-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:acd48d5b80ee80f9432a165c0ac8cbf9253eaddb6113269a5e18699b33958dbb"}, + {file = "aiohttp-3.10.10-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3455522392fb15ff549d92fbf4b73b559d5e43dc522588f7eb3e54c3f38beee7"}, + {file = "aiohttp-3.10.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45c3b868724137f713a38376fef8120c166d1eadd50da1855c112fe97954aed8"}, + {file = "aiohttp-3.10.10-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:da1dee8948d2137bb51fbb8a53cce6b1bcc86003c6b42565f008438b806cccd8"}, + {file = "aiohttp-3.10.10-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c5ce2ce7c997e1971b7184ee37deb6ea9922ef5163c6ee5aa3c274b05f9e12fa"}, + {file = "aiohttp-3.10.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28529e08fde6f12eba8677f5a8608500ed33c086f974de68cc65ab218713a59d"}, + {file = "aiohttp-3.10.10-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f7db54c7914cc99d901d93a34704833568d86c20925b2762f9fa779f9cd2e70f"}, + {file = "aiohttp-3.10.10-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:03a42ac7895406220124c88911ebee31ba8b2d24c98507f4a8bf826b2937c7f2"}, + {file = "aiohttp-3.10.10-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:7e338c0523d024fad378b376a79faff37fafb3c001872a618cde1d322400a572"}, + {file = "aiohttp-3.10.10-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:038f514fe39e235e9fef6717fbf944057bfa24f9b3db9ee551a7ecf584b5b480"}, + {file = "aiohttp-3.10.10-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:64f6c17757251e2b8d885d728b6433d9d970573586a78b78ba8929b0f41d045a"}, + {file = "aiohttp-3.10.10-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:93429602396f3383a797a2a70e5f1de5df8e35535d7806c9f91df06f297e109b"}, + {file = "aiohttp-3.10.10-cp38-cp38-win32.whl", hash = "sha256:c823bc3971c44ab93e611ab1a46b1eafeae474c0c844aff4b7474287b75fe49c"}, + {file = "aiohttp-3.10.10-cp38-cp38-win_amd64.whl", hash = "sha256:54ca74df1be3c7ca1cf7f4c971c79c2daf48d9aa65dea1a662ae18926f5bc8ce"}, + {file = "aiohttp-3.10.10-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:01948b1d570f83ee7bbf5a60ea2375a89dfb09fd419170e7f5af029510033d24"}, + {file = "aiohttp-3.10.10-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9fc1500fd2a952c5c8e3b29aaf7e3cc6e27e9cfc0a8819b3bce48cc1b849e4cc"}, + {file = "aiohttp-3.10.10-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f614ab0c76397661b90b6851a030004dac502e48260ea10f2441abd2207fbcc7"}, + {file = "aiohttp-3.10.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00819de9e45d42584bed046314c40ea7e9aea95411b38971082cad449392b08c"}, + {file = "aiohttp-3.10.10-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:05646ebe6b94cc93407b3bf34b9eb26c20722384d068eb7339de802154d61bc5"}, + {file = "aiohttp-3.10.10-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:998f3bd3cfc95e9424a6acd7840cbdd39e45bc09ef87533c006f94ac47296090"}, + {file = "aiohttp-3.10.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d9010c31cd6fa59438da4e58a7f19e4753f7f264300cd152e7f90d4602449762"}, + {file = "aiohttp-3.10.10-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7ea7ffc6d6d6f8a11e6f40091a1040995cdff02cfc9ba4c2f30a516cb2633554"}, + {file = "aiohttp-3.10.10-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ef9c33cc5cbca35808f6c74be11eb7f5f6b14d2311be84a15b594bd3e58b5527"}, + {file = "aiohttp-3.10.10-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ce0cdc074d540265bfeb31336e678b4e37316849d13b308607efa527e981f5c2"}, + {file = "aiohttp-3.10.10-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:597a079284b7ee65ee102bc3a6ea226a37d2b96d0418cc9047490f231dc09fe8"}, + {file = "aiohttp-3.10.10-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:7789050d9e5d0c309c706953e5e8876e38662d57d45f936902e176d19f1c58ab"}, + {file = "aiohttp-3.10.10-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:e7f8b04d83483577fd9200461b057c9f14ced334dcb053090cea1da9c8321a91"}, + {file = "aiohttp-3.10.10-cp39-cp39-win32.whl", hash = "sha256:c02a30b904282777d872266b87b20ed8cc0d1501855e27f831320f471d54d983"}, + {file = "aiohttp-3.10.10-cp39-cp39-win_amd64.whl", hash = "sha256:edfe3341033a6b53a5c522c802deb2079eee5cbfbb0af032a55064bd65c73a23"}, + {file = "aiohttp-3.10.10.tar.gz", hash = "sha256:0631dd7c9f0822cc61c88586ca76d5b5ada26538097d0f1df510b082bad3411a"}, ] [package.dependencies] +aiohappyeyeballs = ">=2.3.0" aiosignal = ">=1.1.2" async-timeout = {version = ">=4.0,<5.0", markers = "python_version < \"3.11\""} attrs = ">=17.3.0" frozenlist = ">=1.1.1" multidict = ">=4.5,<7.0" -yarl = ">=1.0,<2.0" +yarl = ">=1.12.0,<2.0" [package.extras] -speedups = ["Brotli", "aiodns", "brotlicffi"] +speedups = ["Brotli", "aiodns (>=3.2.0)", "brotlicffi"] [[package]] name = "aiosignal" version = "1.3.1" description = "aiosignal: a list of registered asynchronous callbacks" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "aiosignal-1.3.1-py3-none-any.whl", hash = "sha256:f8376fb07dd1e86a584e4fcdec80b36b7f81aac666ebc724e2c090300dd83b17"}, @@ -112,18 +139,16 @@ frozenlist = ">=1.1.0" [[package]] name = "alembic" -version = "1.13.1" +version = "1.13.3" description = "A database migration tool for SQLAlchemy." optional = false python-versions = ">=3.8" files = [ - {file = "alembic-1.13.1-py3-none-any.whl", hash = "sha256:2edcc97bed0bd3272611ce3a98d98279e9c209e7186e43e75bbb1b2bdfdbcc43"}, - {file = "alembic-1.13.1.tar.gz", hash = "sha256:4932c8558bf68f2ee92b9bbcb8218671c627064d5b08939437af6d77dc05e595"}, + {file = "alembic-1.13.3-py3-none-any.whl", hash = "sha256:908e905976d15235fae59c9ac42c4c5b75cfcefe3d27c0fbf7ae15a37715d80e"}, + {file = "alembic-1.13.3.tar.gz", hash = "sha256:203503117415561e203aa14541740643a611f641517f0209fcae63e9fa09f1a2"}, ] [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" @@ -133,27 +158,24 @@ tz = ["backports.zoneinfo"] [[package]] name = "annotated-types" -version = "0.6.0" +version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" optional = false python-versions = ">=3.8" files = [ - {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, - {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {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.3.0" +version = "4.6.2.post1" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, - {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, + {file = "anyio-4.6.2.post1-py3-none-any.whl", hash = "sha256:6d170c36fba3bdd840c73d3868c1e777e33676a69c3a72cf0a0d5d6d8009b61d"}, + {file = "anyio-4.6.2.post1.tar.gz", hash = "sha256:4c8bc31ccdb51c7f7bd251f51c609e038d63e34219b44aa86e47576389880b4c"}, ] [package.dependencies] @@ -163,15 +185,15 @@ 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", "truststore (>=0.9.1)", "uvloop (>=0.21.0b1)"] +trio = ["trio (>=0.26.1)"] [[package]] name = "asgiproxy" version = "0.1.1" description = "Tools for building HTTP and Websocket proxies for the asynchronous ASGI protocol" -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "asgiproxy-0.1.1-py3-none-any.whl", hash = "sha256:f5175d43691367c51cc972dda0631096e5f23b3536ca29d859be52de87844734"}, @@ -207,37 +229,37 @@ files = [ [[package]] name = "attrs" -version = "23.2.0" +version = "24.2.0" description = "Classes Without Boilerplate" optional = false python-versions = ">=3.7" files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, + {file = "attrs-24.2.0-py3-none-any.whl", hash = "sha256:81921eb96de3191c8258c199618104dd27ac608d9366f5e35d011eae1867ede2"}, + {file = "attrs-24.2.0.tar.gz", hash = "sha256:5cfb1b9148b5b086569baec03f20d7b6bf3bcacc9a42bebf87ffaaca362f6346"}, ] [package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] +benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] +tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] [[package]] name = "backports-tarfile" -version = "1.1.1" +version = "1.2.0" description = "Backport of CPython tarfile module" optional = false python-versions = ">=3.8" files = [ - {file = "backports.tarfile-1.1.1-py3-none-any.whl", hash = "sha256:73e0179647803d3726d82e76089d01d8549ceca9bace469953fcb4d97cf2d417"}, - {file = "backports_tarfile-1.1.1.tar.gz", hash = "sha256:9c2ef9696cb73374f7164e17fc761389393ca76777036f5aad42e8b93fcd8009"}, + {file = "backports.tarfile-1.2.0-py3-none-any.whl", hash = "sha256:77e284d754527b01fb1e6fa8a1afe577858ebe4e9dad8919e34c862cb399bc34"}, + {file = "backports_tarfile-1.2.0.tar.gz", hash = "sha256:d75e02c268746e1b8144c278978b6e98e85de6ad16f8e4b0844a154557eca991"}, ] [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["jaraco.test", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)"] +testing = ["jaraco.test", "pytest (!=8.0.*)", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)"] [[package]] name = "bidict" @@ -250,50 +272,15 @@ files = [ {file = "bidict-0.23.1.tar.gz", hash = "sha256:03069d763bc387bbd20e7d49914e75fc4132a41937fa3405417e1a5a2d006d71"}, ] -[[package]] -name = "black" -version = "22.12.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.7" -files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "build" -version = "1.2.1" +version = "1.2.2.post1" 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.post1-py3-none-any.whl", hash = "sha256:1d61c0887fa860c01971625baae8bdd338e517b836a2f70dd1f7aa3a6b2fc5b5"}, + {file = "build-1.2.2.post1.tar.gz", hash = "sha256:b36993e92ca9375a219c99e606a122ff365a760a2d4bba0caa09bd5278b608b7"}, ] [package.dependencies] @@ -312,74 +299,89 @@ virtualenv = ["virtualenv (>=20.0.35)"] [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {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.16.0" +version = "1.17.1" description = "Foreign Function Interface for Python calling C code." optional = false python-versions = ">=3.8" files = [ - {file = "cffi-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6b3d6606d369fc1da4fd8c357d026317fbb9c9b75d36dc16e90e84c26854b088"}, - {file = "cffi-1.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ac0f5edd2360eea2f1daa9e26a41db02dd4b0451b48f7c318e217ee092a213e9"}, - {file = "cffi-1.16.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7e61e3e4fa664a8588aa25c883eab612a188c725755afff6289454d6362b9673"}, - {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a72e8961a86d19bdb45851d8f1f08b041ea37d2bd8d4fd19903bc3083d80c896"}, - {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5b50bf3f55561dac5438f8e70bfcdfd74543fd60df5fa5f62d94e5867deca684"}, - {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7651c50c8c5ef7bdb41108b7b8c5a83013bfaa8a935590c5d74627c047a583c7"}, - {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e4108df7fe9b707191e55f33efbcb2d81928e10cea45527879a4749cbe472614"}, - {file = "cffi-1.16.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:32c68ef735dbe5857c810328cb2481e24722a59a2003018885514d4c09af9743"}, - {file = "cffi-1.16.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:673739cb539f8cdaa07d92d02efa93c9ccf87e345b9a0b556e3ecc666718468d"}, - {file = "cffi-1.16.0-cp310-cp310-win32.whl", hash = "sha256:9f90389693731ff1f659e55c7d1640e2ec43ff725cc61b04b2f9c6d8d017df6a"}, - {file = "cffi-1.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:e6024675e67af929088fda399b2094574609396b1decb609c55fa58b028a32a1"}, - {file = "cffi-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b84834d0cf97e7d27dd5b7f3aca7b6e9263c56308ab9dc8aae9784abb774d404"}, - {file = "cffi-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b8ebc27c014c59692bb2664c7d13ce7a6e9a629be20e54e7271fa696ff2b417"}, - {file = "cffi-1.16.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ee07e47c12890ef248766a6e55bd38ebfb2bb8edd4142d56db91b21ea68b7627"}, - {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8a9d3ebe49f084ad71f9269834ceccbf398253c9fac910c4fd7053ff1386936"}, - {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e70f54f1796669ef691ca07d046cd81a29cb4deb1e5f942003f401c0c4a2695d"}, - {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5bf44d66cdf9e893637896c7faa22298baebcd18d1ddb6d2626a6e39793a1d56"}, - {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b78010e7b97fef4bee1e896df8a4bbb6712b7f05b7ef630f9d1da00f6444d2e"}, - {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c6a164aa47843fb1b01e941d385aab7215563bb8816d80ff3a363a9f8448a8dc"}, - {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e09f3ff613345df5e8c3667da1d918f9149bd623cd9070c983c013792a9a62eb"}, - {file = "cffi-1.16.0-cp311-cp311-win32.whl", hash = "sha256:2c56b361916f390cd758a57f2e16233eb4f64bcbeee88a4881ea90fca14dc6ab"}, - {file = "cffi-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:db8e577c19c0fda0beb7e0d4e09e0ba74b1e4c092e0e40bfa12fe05b6f6d75ba"}, - {file = "cffi-1.16.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:fa3a0128b152627161ce47201262d3140edb5a5c3da88d73a1b790a959126956"}, - {file = "cffi-1.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:68e7c44931cc171c54ccb702482e9fc723192e88d25a0e133edd7aff8fcd1f6e"}, - {file = "cffi-1.16.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:abd808f9c129ba2beda4cfc53bde801e5bcf9d6e0f22f095e45327c038bfe68e"}, - {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:88e2b3c14bdb32e440be531ade29d3c50a1a59cd4e51b1dd8b0865c54ea5d2e2"}, - {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fcc8eb6d5902bb1cf6dc4f187ee3ea80a1eba0a89aba40a5cb20a5087d961357"}, - {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b7be2d771cdba2942e13215c4e340bfd76398e9227ad10402a8767ab1865d2e6"}, - {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e715596e683d2ce000574bae5d07bd522c781a822866c20495e52520564f0969"}, - {file = "cffi-1.16.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2d92b25dbf6cae33f65005baf472d2c245c050b1ce709cc4588cdcdd5495b520"}, - {file = "cffi-1.16.0-cp312-cp312-win32.whl", hash = "sha256:b2ca4e77f9f47c55c194982e10f058db063937845bb2b7a86c84a6cfe0aefa8b"}, - {file = "cffi-1.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:68678abf380b42ce21a5f2abde8efee05c114c2fdb2e9eef2efdb0257fba1235"}, - {file = "cffi-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc"}, - {file = "cffi-1.16.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a09582f178759ee8128d9270cd1344154fd473bb77d94ce0aeb2a93ebf0feaf0"}, - {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e760191dd42581e023a68b758769e2da259b5d52e3103c6060ddc02c9edb8d7b"}, - {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:80876338e19c951fdfed6198e70bc88f1c9758b94578d5a7c4c91a87af3cf31c"}, - {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a6a14b17d7e17fa0d207ac08642c8820f84f25ce17a442fd15e27ea18d67c59b"}, - {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6602bc8dc6f3a9e02b6c22c4fc1e47aa50f8f8e6d3f78a5e16ac33ef5fefa324"}, - {file = "cffi-1.16.0-cp38-cp38-win32.whl", hash = "sha256:131fd094d1065b19540c3d72594260f118b231090295d8c34e19a7bbcf2e860a"}, - {file = "cffi-1.16.0-cp38-cp38-win_amd64.whl", hash = "sha256:31d13b0f99e0836b7ff893d37af07366ebc90b678b6664c955b54561fc36ef36"}, - {file = "cffi-1.16.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:582215a0e9adbe0e379761260553ba11c58943e4bbe9c36430c4ca6ac74b15ed"}, - {file = "cffi-1.16.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b29ebffcf550f9da55bec9e02ad430c992a87e5f512cd63388abb76f1036d8d2"}, - {file = "cffi-1.16.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dc9b18bf40cc75f66f40a7379f6a9513244fe33c0e8aa72e2d56b0196a7ef872"}, - {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cb4a35b3642fc5c005a6755a5d17c6c8b6bcb6981baf81cea8bfbc8903e8ba8"}, - {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b86851a328eedc692acf81fb05444bdf1891747c25af7529e39ddafaf68a4f3f"}, - {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c0f31130ebc2d37cdd8e44605fb5fa7ad59049298b3f745c74fa74c62fbfcfc4"}, - {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f8e709127c6c77446a8c0a8c8bf3c8ee706a06cd44b1e827c3e6a2ee6b8c098"}, - {file = "cffi-1.16.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:748dcd1e3d3d7cd5443ef03ce8685043294ad6bd7c02a38d1bd367cfd968e000"}, - {file = "cffi-1.16.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8895613bcc094d4a1b2dbe179d88d7fb4a15cee43c052e8885783fac397d91fe"}, - {file = "cffi-1.16.0-cp39-cp39-win32.whl", hash = "sha256:ed86a35631f7bfbb28e108dd96773b9d5a6ce4811cf6ea468bb6a359b256b1e4"}, - {file = "cffi-1.16.0-cp39-cp39-win_amd64.whl", hash = "sha256:3686dffb02459559c74dd3d81748269ffb0eb027c39a6fc99502de37d501faa8"}, - {file = "cffi-1.16.0.tar.gz", hash = "sha256:bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0"}, + {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] @@ -398,101 +400,116 @@ files = [ [[package]] name = "charset-normalizer" -version = "3.3.2" +version = "3.4.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7.0" files = [ - {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, - {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-win32.whl", hash = "sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-win32.whl", hash = "sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-win32.whl", hash = "sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-win32.whl", hash = "sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_ppc64le.whl", hash = "sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_s390x.whl", hash = "sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-win32.whl", hash = "sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-win32.whl", hash = "sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-win32.whl", hash = "sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca"}, + {file = "charset_normalizer-3.4.0-py3-none-any.whl", hash = "sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079"}, + {file = "charset_normalizer-3.4.0.tar.gz", hash = "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e"}, ] [[package]] @@ -522,63 +539,73 @@ files = [ [[package]] name = "coverage" -version = "7.5.1" +version = "7.6.4" description = "Code coverage measurement for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "coverage-7.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0884920835a033b78d1c73b6d3bbcda8161a900f38a488829a83982925f6c2e"}, - {file = "coverage-7.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:39afcd3d4339329c5f58de48a52f6e4e50f6578dd6099961cf22228feb25f38f"}, - {file = "coverage-7.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4a7b0ceee8147444347da6a66be737c9d78f3353b0681715b668b72e79203e4a"}, - {file = "coverage-7.5.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a9ca3f2fae0088c3c71d743d85404cec8df9be818a005ea065495bedc33da35"}, - {file = "coverage-7.5.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fd215c0c7d7aab005221608a3c2b46f58c0285a819565887ee0b718c052aa4e"}, - {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4bf0655ab60d754491004a5efd7f9cccefcc1081a74c9ef2da4735d6ee4a6223"}, - {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:61c4bf1ba021817de12b813338c9be9f0ad5b1e781b9b340a6d29fc13e7c1b5e"}, - {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:db66fc317a046556a96b453a58eced5024af4582a8dbdc0c23ca4dbc0d5b3146"}, - {file = "coverage-7.5.1-cp310-cp310-win32.whl", hash = "sha256:b016ea6b959d3b9556cb401c55a37547135a587db0115635a443b2ce8f1c7228"}, - {file = "coverage-7.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:df4e745a81c110e7446b1cc8131bf986157770fa405fe90e15e850aaf7619bc8"}, - {file = "coverage-7.5.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:796a79f63eca8814ca3317a1ea443645c9ff0d18b188de470ed7ccd45ae79428"}, - {file = "coverage-7.5.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4fc84a37bfd98db31beae3c2748811a3fa72bf2007ff7902f68746d9757f3746"}, - {file = "coverage-7.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6175d1a0559986c6ee3f7fccfc4a90ecd12ba0a383dcc2da30c2b9918d67d8a3"}, - {file = "coverage-7.5.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fc81d5878cd6274ce971e0a3a18a8803c3fe25457165314271cf78e3aae3aa2"}, - {file = "coverage-7.5.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:556cf1a7cbc8028cb60e1ff0be806be2eded2daf8129b8811c63e2b9a6c43bca"}, - {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9981706d300c18d8b220995ad22627647be11a4276721c10911e0e9fa44c83e8"}, - {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:d7fed867ee50edf1a0b4a11e8e5d0895150e572af1cd6d315d557758bfa9c057"}, - {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ef48e2707fb320c8f139424a596f5b69955a85b178f15af261bab871873bb987"}, - {file = "coverage-7.5.1-cp311-cp311-win32.whl", hash = "sha256:9314d5678dcc665330df5b69c1e726a0e49b27df0461c08ca12674bcc19ef136"}, - {file = "coverage-7.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:5fa567e99765fe98f4e7d7394ce623e794d7cabb170f2ca2ac5a4174437e90dd"}, - {file = "coverage-7.5.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b6cf3764c030e5338e7f61f95bd21147963cf6aa16e09d2f74f1fa52013c1206"}, - {file = "coverage-7.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2ec92012fefebee89a6b9c79bc39051a6cb3891d562b9270ab10ecfdadbc0c34"}, - {file = "coverage-7.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:16db7f26000a07efcf6aea00316f6ac57e7d9a96501e990a36f40c965ec7a95d"}, - {file = "coverage-7.5.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:beccf7b8a10b09c4ae543582c1319c6df47d78fd732f854ac68d518ee1fb97fa"}, - {file = "coverage-7.5.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8748731ad392d736cc9ccac03c9845b13bb07d020a33423fa5b3a36521ac6e4e"}, - {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7352b9161b33fd0b643ccd1f21f3a3908daaddf414f1c6cb9d3a2fd618bf2572"}, - {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:7a588d39e0925f6a2bff87154752481273cdb1736270642aeb3635cb9b4cad07"}, - {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:68f962d9b72ce69ea8621f57551b2fa9c70509af757ee3b8105d4f51b92b41a7"}, - {file = "coverage-7.5.1-cp312-cp312-win32.whl", hash = "sha256:f152cbf5b88aaeb836127d920dd0f5e7edff5a66f10c079157306c4343d86c19"}, - {file = "coverage-7.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:5a5740d1fb60ddf268a3811bcd353de34eb56dc24e8f52a7f05ee513b2d4f596"}, - {file = "coverage-7.5.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e2213def81a50519d7cc56ed643c9e93e0247f5bbe0d1247d15fa520814a7cd7"}, - {file = "coverage-7.5.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5037f8fcc2a95b1f0e80585bd9d1ec31068a9bcb157d9750a172836e98bc7a90"}, - {file = "coverage-7.5.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c3721c2c9e4c4953a41a26c14f4cef64330392a6d2d675c8b1db3b645e31f0e"}, - {file = "coverage-7.5.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca498687ca46a62ae590253fba634a1fe9836bc56f626852fb2720f334c9e4e5"}, - {file = "coverage-7.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0cdcbc320b14c3e5877ee79e649677cb7d89ef588852e9583e6b24c2e5072661"}, - {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:57e0204b5b745594e5bc14b9b50006da722827f0b8c776949f1135677e88d0b8"}, - {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8fe7502616b67b234482c3ce276ff26f39ffe88adca2acf0261df4b8454668b4"}, - {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:9e78295f4144f9dacfed4f92935fbe1780021247c2fabf73a819b17f0ccfff8d"}, - {file = "coverage-7.5.1-cp38-cp38-win32.whl", hash = "sha256:1434e088b41594baa71188a17533083eabf5609e8e72f16ce8c186001e6b8c41"}, - {file = "coverage-7.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:0646599e9b139988b63704d704af8e8df7fa4cbc4a1f33df69d97f36cb0a38de"}, - {file = "coverage-7.5.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4cc37def103a2725bc672f84bd939a6fe4522310503207aae4d56351644682f1"}, - {file = "coverage-7.5.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fc0b4d8bfeabd25ea75e94632f5b6e047eef8adaed0c2161ada1e922e7f7cece"}, - {file = "coverage-7.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d0a0f5e06881ecedfe6f3dd2f56dcb057b6dbeb3327fd32d4b12854df36bf26"}, - {file = "coverage-7.5.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9735317685ba6ec7e3754798c8871c2f49aa5e687cc794a0b1d284b2389d1bd5"}, - {file = "coverage-7.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d21918e9ef11edf36764b93101e2ae8cc82aa5efdc7c5a4e9c6c35a48496d601"}, - {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:c3e757949f268364b96ca894b4c342b41dc6f8f8b66c37878aacef5930db61be"}, - {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:79afb6197e2f7f60c4824dd4b2d4c2ec5801ceb6ba9ce5d2c3080e5660d51a4f"}, - {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d1d0d98d95dd18fe29dc66808e1accf59f037d5716f86a501fc0256455219668"}, - {file = "coverage-7.5.1-cp39-cp39-win32.whl", hash = "sha256:1cc0fe9b0b3a8364093c53b0b4c0c2dd4bb23acbec4c9240b5f284095ccf7981"}, - {file = "coverage-7.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:dde0070c40ea8bb3641e811c1cfbf18e265d024deff6de52c5950677a8fb1e0f"}, - {file = "coverage-7.5.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:6537e7c10cc47c595828b8a8be04c72144725c383c4702703ff4e42e44577312"}, - {file = "coverage-7.5.1.tar.gz", hash = "sha256:54de9ef3a9da981f7af93eafde4ede199e0846cd819eb27c88e2b712aae9708c"}, + {file = "coverage-7.6.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5f8ae553cba74085db385d489c7a792ad66f7f9ba2ee85bfa508aeb84cf0ba07"}, + {file = "coverage-7.6.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8165b796df0bd42e10527a3f493c592ba494f16ef3c8b531288e3d0d72c1f6f0"}, + {file = "coverage-7.6.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7c8b95bf47db6d19096a5e052ffca0a05f335bc63cef281a6e8fe864d450a72"}, + {file = "coverage-7.6.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8ed9281d1b52628e81393f5eaee24a45cbd64965f41857559c2b7ff19385df51"}, + {file = "coverage-7.6.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0809082ee480bb8f7416507538243c8863ac74fd8a5d2485c46f0f7499f2b491"}, + {file = "coverage-7.6.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d541423cdd416b78626b55f123412fcf979d22a2c39fce251b350de38c15c15b"}, + {file = "coverage-7.6.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:58809e238a8a12a625c70450b48e8767cff9eb67c62e6154a642b21ddf79baea"}, + {file = "coverage-7.6.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c9b8e184898ed014884ca84c70562b4a82cbc63b044d366fedc68bc2b2f3394a"}, + {file = "coverage-7.6.4-cp310-cp310-win32.whl", hash = "sha256:6bd818b7ea14bc6e1f06e241e8234508b21edf1b242d49831831a9450e2f35fa"}, + {file = "coverage-7.6.4-cp310-cp310-win_amd64.whl", hash = "sha256:06babbb8f4e74b063dbaeb74ad68dfce9186c595a15f11f5d5683f748fa1d172"}, + {file = "coverage-7.6.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:73d2b73584446e66ee633eaad1a56aad577c077f46c35ca3283cd687b7715b0b"}, + {file = "coverage-7.6.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:51b44306032045b383a7a8a2c13878de375117946d68dcb54308111f39775a25"}, + {file = "coverage-7.6.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b3fb02fe73bed561fa12d279a417b432e5b50fe03e8d663d61b3d5990f29546"}, + {file = "coverage-7.6.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed8fe9189d2beb6edc14d3ad19800626e1d9f2d975e436f84e19efb7fa19469b"}, + {file = "coverage-7.6.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b369ead6527d025a0fe7bd3864e46dbee3aa8f652d48df6174f8d0bac9e26e0e"}, + {file = "coverage-7.6.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:ade3ca1e5f0ff46b678b66201f7ff477e8fa11fb537f3b55c3f0568fbfe6e718"}, + {file = "coverage-7.6.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:27fb4a050aaf18772db513091c9c13f6cb94ed40eacdef8dad8411d92d9992db"}, + {file = "coverage-7.6.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4f704f0998911abf728a7783799444fcbbe8261c4a6c166f667937ae6a8aa522"}, + {file = "coverage-7.6.4-cp311-cp311-win32.whl", hash = "sha256:29155cd511ee058e260db648b6182c419422a0d2e9a4fa44501898cf918866cf"}, + {file = "coverage-7.6.4-cp311-cp311-win_amd64.whl", hash = "sha256:8902dd6a30173d4ef09954bfcb24b5d7b5190cf14a43170e386979651e09ba19"}, + {file = "coverage-7.6.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:12394842a3a8affa3ba62b0d4ab7e9e210c5e366fbac3e8b2a68636fb19892c2"}, + {file = "coverage-7.6.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2b6b4c83d8e8ea79f27ab80778c19bc037759aea298da4b56621f4474ffeb117"}, + {file = "coverage-7.6.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d5b8007f81b88696d06f7df0cb9af0d3b835fe0c8dbf489bad70b45f0e45613"}, + {file = "coverage-7.6.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b57b768feb866f44eeed9f46975f3d6406380275c5ddfe22f531a2bf187eda27"}, + {file = "coverage-7.6.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5915fcdec0e54ee229926868e9b08586376cae1f5faa9bbaf8faf3561b393d52"}, + {file = "coverage-7.6.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0b58c672d14f16ed92a48db984612f5ce3836ae7d72cdd161001cc54512571f2"}, + {file = "coverage-7.6.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:2fdef0d83a2d08d69b1f2210a93c416d54e14d9eb398f6ab2f0a209433db19e1"}, + {file = "coverage-7.6.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8cf717ee42012be8c0cb205dbbf18ffa9003c4cbf4ad078db47b95e10748eec5"}, + {file = "coverage-7.6.4-cp312-cp312-win32.whl", hash = "sha256:7bb92c539a624cf86296dd0c68cd5cc286c9eef2d0c3b8b192b604ce9de20a17"}, + {file = "coverage-7.6.4-cp312-cp312-win_amd64.whl", hash = "sha256:1032e178b76a4e2b5b32e19d0fd0abbce4b58e77a1ca695820d10e491fa32b08"}, + {file = "coverage-7.6.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:023bf8ee3ec6d35af9c1c6ccc1d18fa69afa1cb29eaac57cb064dbb262a517f9"}, + {file = "coverage-7.6.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b0ac3d42cb51c4b12df9c5f0dd2f13a4f24f01943627120ec4d293c9181219ba"}, + {file = "coverage-7.6.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f8fe4984b431f8621ca53d9380901f62bfb54ff759a1348cd140490ada7b693c"}, + {file = "coverage-7.6.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5fbd612f8a091954a0c8dd4c0b571b973487277d26476f8480bfa4b2a65b5d06"}, + {file = "coverage-7.6.4-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dacbc52de979f2823a819571f2e3a350a7e36b8cb7484cdb1e289bceaf35305f"}, + {file = "coverage-7.6.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:dab4d16dfef34b185032580e2f2f89253d302facba093d5fa9dbe04f569c4f4b"}, + {file = "coverage-7.6.4-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:862264b12ebb65ad8d863d51f17758b1684560b66ab02770d4f0baf2ff75da21"}, + {file = "coverage-7.6.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5beb1ee382ad32afe424097de57134175fea3faf847b9af002cc7895be4e2a5a"}, + {file = "coverage-7.6.4-cp313-cp313-win32.whl", hash = "sha256:bf20494da9653f6410213424f5f8ad0ed885e01f7e8e59811f572bdb20b8972e"}, + {file = "coverage-7.6.4-cp313-cp313-win_amd64.whl", hash = "sha256:182e6cd5c040cec0a1c8d415a87b67ed01193ed9ad458ee427741c7d8513d963"}, + {file = "coverage-7.6.4-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:a181e99301a0ae128493a24cfe5cfb5b488c4e0bf2f8702091473d033494d04f"}, + {file = "coverage-7.6.4-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:df57bdbeffe694e7842092c5e2e0bc80fff7f43379d465f932ef36f027179806"}, + {file = "coverage-7.6.4-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0bcd1069e710600e8e4cf27f65c90c7843fa8edfb4520fb0ccb88894cad08b11"}, + {file = "coverage-7.6.4-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:99b41d18e6b2a48ba949418db48159d7a2e81c5cc290fc934b7d2380515bd0e3"}, + {file = "coverage-7.6.4-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6b1e54712ba3474f34b7ef7a41e65bd9037ad47916ccb1cc78769bae324c01a"}, + {file = "coverage-7.6.4-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:53d202fd109416ce011578f321460795abfe10bb901b883cafd9b3ef851bacfc"}, + {file = "coverage-7.6.4-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:c48167910a8f644671de9f2083a23630fbf7a1cb70ce939440cd3328e0919f70"}, + {file = "coverage-7.6.4-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:cc8ff50b50ce532de2fa7a7daae9dd12f0a699bfcd47f20945364e5c31799fef"}, + {file = "coverage-7.6.4-cp313-cp313t-win32.whl", hash = "sha256:b8d3a03d9bfcaf5b0141d07a88456bb6a4c3ce55c080712fec8418ef3610230e"}, + {file = "coverage-7.6.4-cp313-cp313t-win_amd64.whl", hash = "sha256:f3ddf056d3ebcf6ce47bdaf56142af51bb7fad09e4af310241e9db7a3a8022e1"}, + {file = "coverage-7.6.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9cb7fa111d21a6b55cbf633039f7bc2749e74932e3aa7cb7333f675a58a58bf3"}, + {file = "coverage-7.6.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:11a223a14e91a4693d2d0755c7a043db43d96a7450b4f356d506c2562c48642c"}, + {file = "coverage-7.6.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a413a096c4cbac202433c850ee43fa326d2e871b24554da8327b01632673a076"}, + {file = "coverage-7.6.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:00a1d69c112ff5149cabe60d2e2ee948752c975d95f1e1096742e6077affd376"}, + {file = "coverage-7.6.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f76846299ba5c54d12c91d776d9605ae33f8ae2b9d1d3c3703cf2db1a67f2c0"}, + {file = "coverage-7.6.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:fe439416eb6380de434886b00c859304338f8b19f6f54811984f3420a2e03858"}, + {file = "coverage-7.6.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:0294ca37f1ba500667b1aef631e48d875ced93ad5e06fa665a3295bdd1d95111"}, + {file = "coverage-7.6.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:6f01ba56b1c0e9d149f9ac85a2f999724895229eb36bd997b61e62999e9b0901"}, + {file = "coverage-7.6.4-cp39-cp39-win32.whl", hash = "sha256:bc66f0bf1d7730a17430a50163bb264ba9ded56739112368ba985ddaa9c3bd09"}, + {file = "coverage-7.6.4-cp39-cp39-win_amd64.whl", hash = "sha256:c481b47f6b5845064c65a7bc78bc0860e635a9b055af0df46fdf1c58cebf8e8f"}, + {file = "coverage-7.6.4-pp39.pp310-none-any.whl", hash = "sha256:3c65d37f3a9ebb703e710befdc489a38683a5b152242664b973a7b7b22348a4e"}, + {file = "coverage-7.6.4.tar.gz", hash = "sha256:29fc0f17b1d3fea332f8001d4558f8214af7f1d87a345f3a133c901d60347c73"}, ] [package.dependencies] @@ -589,43 +616,38 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "42.0.7" +version = "43.0.3" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = ">=3.7" files = [ - {file = "cryptography-42.0.7-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:a987f840718078212fdf4504d0fd4c6effe34a7e4740378e59d47696e8dfb477"}, - {file = "cryptography-42.0.7-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:bd13b5e9b543532453de08bcdc3cc7cebec6f9883e886fd20a92f26940fd3e7a"}, - {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a79165431551042cc9d1d90e6145d5d0d3ab0f2d66326c201d9b0e7f5bf43604"}, - {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a47787a5e3649008a1102d3df55424e86606c9bae6fb77ac59afe06d234605f8"}, - {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:02c0eee2d7133bdbbc5e24441258d5d2244beb31da5ed19fbb80315f4bbbff55"}, - {file = "cryptography-42.0.7-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:5e44507bf8d14b36b8389b226665d597bc0f18ea035d75b4e53c7b1ea84583cc"}, - {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:7f8b25fa616d8b846aef64b15c606bb0828dbc35faf90566eb139aa9cff67af2"}, - {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:93a3209f6bb2b33e725ed08ee0991b92976dfdcf4e8b38646540674fc7508e13"}, - {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:e6b8f1881dac458c34778d0a424ae5769de30544fc678eac51c1c8bb2183e9da"}, - {file = "cryptography-42.0.7-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3de9a45d3b2b7d8088c3fbf1ed4395dfeff79d07842217b38df14ef09ce1d8d7"}, - {file = "cryptography-42.0.7-cp37-abi3-win32.whl", hash = "sha256:789caea816c6704f63f6241a519bfa347f72fbd67ba28d04636b7c6b7da94b0b"}, - {file = "cryptography-42.0.7-cp37-abi3-win_amd64.whl", hash = "sha256:8cb8ce7c3347fcf9446f201dc30e2d5a3c898d009126010cbd1f443f28b52678"}, - {file = "cryptography-42.0.7-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:a3a5ac8b56fe37f3125e5b72b61dcde43283e5370827f5233893d461b7360cd4"}, - {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:779245e13b9a6638df14641d029add5dc17edbef6ec915688f3acb9e720a5858"}, - {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d563795db98b4cd57742a78a288cdbdc9daedac29f2239793071fe114f13785"}, - {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:31adb7d06fe4383226c3e963471f6837742889b3c4caa55aac20ad951bc8ffda"}, - {file = "cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:efd0bf5205240182e0f13bcaea41be4fdf5c22c5129fc7ced4a0282ac86998c9"}, - {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:a9bc127cdc4ecf87a5ea22a2556cab6c7eda2923f84e4f3cc588e8470ce4e42e"}, - {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:3577d029bc3f4827dd5bf8bf7710cac13527b470bbf1820a3f394adb38ed7d5f"}, - {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2e47577f9b18723fa294b0ea9a17d5e53a227867a0a4904a1a076d1646d45ca1"}, - {file = "cryptography-42.0.7-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:1a58839984d9cb34c855197043eaae2c187d930ca6d644612843b4fe8513c886"}, - {file = "cryptography-42.0.7-cp39-abi3-win32.whl", hash = "sha256:e6b79d0adb01aae87e8a44c2b64bc3f3fe59515280e00fb6d57a7267a2583cda"}, - {file = "cryptography-42.0.7-cp39-abi3-win_amd64.whl", hash = "sha256:16268d46086bb8ad5bf0a2b5544d8a9ed87a0e33f5e77dd3c3301e63d941a83b"}, - {file = "cryptography-42.0.7-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:2954fccea107026512b15afb4aa664a5640cd0af630e2ee3962f2602693f0c82"}, - {file = "cryptography-42.0.7-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:362e7197754c231797ec45ee081f3088a27a47c6c01eff2ac83f60f85a50fe60"}, - {file = "cryptography-42.0.7-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:4f698edacf9c9e0371112792558d2f705b5645076cc0aaae02f816a0171770fd"}, - {file = "cryptography-42.0.7-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:5482e789294854c28237bba77c4c83be698be740e31a3ae5e879ee5444166582"}, - {file = "cryptography-42.0.7-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:e9b2a6309f14c0497f348d08a065d52f3020656f675819fc405fb63bbcd26562"}, - {file = "cryptography-42.0.7-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:d8e3098721b84392ee45af2dd554c947c32cc52f862b6a3ae982dbb90f577f14"}, - {file = "cryptography-42.0.7-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:c65f96dad14f8528a447414125e1fc8feb2ad5a272b8f68477abbcc1ea7d94b9"}, - {file = "cryptography-42.0.7-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:36017400817987670037fbb0324d71489b6ead6231c9604f8fc1f7d008087c68"}, - {file = "cryptography-42.0.7.tar.gz", hash = "sha256:ecbfbc00bf55888edda9868a4cf927205de8499e7fabe6c050322298382953f2"}, + {file = "cryptography-43.0.3-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:bf7a1932ac4176486eab36a19ed4c0492da5d97123f1406cf15e41b05e787d2e"}, + {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63efa177ff54aec6e1c0aefaa1a241232dcd37413835a9b674b6e3f0ae2bfd3e"}, + {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e1ce50266f4f70bf41a2c6dc4358afadae90e2a1e5342d3c08883df1675374f"}, + {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:443c4a81bb10daed9a8f334365fe52542771f25aedaf889fd323a853ce7377d6"}, + {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:74f57f24754fe349223792466a709f8e0c093205ff0dca557af51072ff47ab18"}, + {file = "cryptography-43.0.3-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:9762ea51a8fc2a88b70cf2995e5675b38d93bf36bd67d91721c309df184f49bd"}, + {file = "cryptography-43.0.3-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:81ef806b1fef6b06dcebad789f988d3b37ccaee225695cf3e07648eee0fc6b73"}, + {file = "cryptography-43.0.3-cp37-abi3-win32.whl", hash = "sha256:cbeb489927bd7af4aa98d4b261af9a5bc025bd87f0e3547e11584be9e9427be2"}, + {file = "cryptography-43.0.3-cp37-abi3-win_amd64.whl", hash = "sha256:f46304d6f0c6ab8e52770addfa2fc41e6629495548862279641972b6215451cd"}, + {file = "cryptography-43.0.3-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:8ac43ae87929a5982f5948ceda07001ee5e83227fd69cf55b109144938d96984"}, + {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:846da004a5804145a5f441b8530b4bf35afbf7da70f82409f151695b127213d5"}, + {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f996e7268af62598f2fc1204afa98a3b5712313a55c4c9d434aef49cadc91d4"}, + {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f7b178f11ed3664fd0e995a47ed2b5ff0a12d893e41dd0494f406d1cf555cab7"}, + {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:c2e6fc39c4ab499049df3bdf567f768a723a5e8464816e8f009f121a5a9f4405"}, + {file = "cryptography-43.0.3-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:e1be4655c7ef6e1bbe6b5d0403526601323420bcf414598955968c9ef3eb7d16"}, + {file = "cryptography-43.0.3-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:df6b6c6d742395dd77a23ea3728ab62f98379eff8fb61be2744d4679ab678f73"}, + {file = "cryptography-43.0.3-cp39-abi3-win32.whl", hash = "sha256:d56e96520b1020449bbace2b78b603442e7e378a9b3bd68de65c782db1507995"}, + {file = "cryptography-43.0.3-cp39-abi3-win_amd64.whl", hash = "sha256:0c580952eef9bf68c4747774cde7ec1d85a6e61de97281f2dba83c7d2c806362"}, + {file = "cryptography-43.0.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d03b5621a135bffecad2c73e9f4deb1a0f977b9a8ffe6f8e002bf6c9d07b918c"}, + {file = "cryptography-43.0.3-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:a2a431ee15799d6db9fe80c82b055bae5a752bef645bba795e8e52687c69efe3"}, + {file = "cryptography-43.0.3-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:281c945d0e28c92ca5e5930664c1cefd85efe80e5c0d2bc58dd63383fda29f83"}, + {file = "cryptography-43.0.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:f18c716be16bc1fea8e95def49edf46b82fccaa88587a45f8dc0ff6ab5d8e0a7"}, + {file = "cryptography-43.0.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:4a02ded6cd4f0a5562a8887df8b3bd14e822a90f97ac5e544c162899bc467664"}, + {file = "cryptography-43.0.3-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:53a583b6637ab4c4e3591a15bc9db855b8d9dee9a669b550f311480acab6eb08"}, + {file = "cryptography-43.0.3-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:1ec0bcf7e17c0c5669d881b1cd38c4972fade441b27bda1051665faaa89bdcaa"}, + {file = "cryptography-43.0.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2ce6fae5bdad59577b44e4dfed356944fbf1d925269114c28be377692643b4ff"}, + {file = "cryptography-43.0.3.tar.gz", hash = "sha256:315b9001266a492a6ff443b61238f956b214dbec9910a081ba5b6646a055a805"}, ] [package.dependencies] @@ -638,7 +660,7 @@ nox = ["nox"] pep8test = ["check-sdist", "click", "mypy", "ruff"] sdist = ["build"] ssh = ["bcrypt (>=3.1.5)"] -test = ["certifi", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] +test = ["certifi", "cryptography-vectors (==43.0.3)", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] test-randomorder = ["pytest-randomly"] [[package]] @@ -654,13 +676,13 @@ files = [ [[package]] name = "dill" -version = "0.3.8" +version = "0.3.9" description = "serialize all of Python" optional = false python-versions = ">=3.8" files = [ - {file = "dill-0.3.8-py3-none-any.whl", hash = "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7"}, - {file = "dill-0.3.8.tar.gz", hash = "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca"}, + {file = "dill-0.3.9-py3-none-any.whl", hash = "sha256:468dff3b89520b474c0397703366b7b95eebe6303f108adf9b19da1f702be87a"}, + {file = "dill-0.3.9.tar.gz", hash = "sha256:81aa267dddf68cbfe8029c42ca9ec6a4ab3b22371d1c450abc54422577b4512c"}, ] [package.extras] @@ -669,13 +691,13 @@ profile = ["gprof2dot (>=2022.7.29)"] [[package]] name = "distlib" -version = "0.3.8" +version = "0.3.9" description = "Distribution utilities" optional = false python-versions = "*" files = [ - {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, - {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, + {file = "distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87"}, + {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, ] [[package]] @@ -691,24 +713,24 @@ files = [ [[package]] name = "docutils" -version = "0.20.1" +version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" files = [ - {file = "docutils-0.20.1-py3-none-any.whl", hash = "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6"}, - {file = "docutils-0.20.1.tar.gz", hash = "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b"}, + {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" -version = "1.2.1" +version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] @@ -716,190 +738,221 @@ test = ["pytest (>=6)"] [[package]] name = "fastapi" -version = "0.110.3" +version = "0.115.4" 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.4-py3-none-any.whl", hash = "sha256:0b504a063ffb3cf96a5e27dc1bc32c80ca743a2528574f9cdc77daa2d31b4742"}, + {file = "fastapi-0.115.4.tar.gz", hash = "sha256:db653475586b091cb8b2fec2ac54a680ac6a158e07406e1abae31679e8826349"}, ] [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.40.0,<0.42.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.14.0" +version = "3.16.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, - {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, + {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-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.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 = "frozenlist" -version = "1.4.1" +version = "1.5.0" description = "A list-like structure which implements collections.abc.MutableSequence" -optional = false +optional = true python-versions = ">=3.8" files = [ - {file = "frozenlist-1.4.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f9aa1878d1083b276b0196f2dfbe00c9b7e752475ed3b682025ff20c1c1f51ac"}, - {file = "frozenlist-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:29acab3f66f0f24674b7dc4736477bcd4bc3ad4b896f5f45379a67bce8b96868"}, - {file = "frozenlist-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:74fb4bee6880b529a0c6560885fce4dc95936920f9f20f53d99a213f7bf66776"}, - {file = "frozenlist-1.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:590344787a90ae57d62511dd7c736ed56b428f04cd8c161fcc5e7232c130c69a"}, - {file = "frozenlist-1.4.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:068b63f23b17df8569b7fdca5517edef76171cf3897eb68beb01341131fbd2ad"}, - {file = "frozenlist-1.4.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5c849d495bf5154cd8da18a9eb15db127d4dba2968d88831aff6f0331ea9bd4c"}, - {file = "frozenlist-1.4.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9750cc7fe1ae3b1611bb8cfc3f9ec11d532244235d75901fb6b8e42ce9229dfe"}, - {file = "frozenlist-1.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9b2de4cf0cdd5bd2dee4c4f63a653c61d2408055ab77b151c1957f221cabf2a"}, - {file = "frozenlist-1.4.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:0633c8d5337cb5c77acbccc6357ac49a1770b8c487e5b3505c57b949b4b82e98"}, - {file = "frozenlist-1.4.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:27657df69e8801be6c3638054e202a135c7f299267f1a55ed3a598934f6c0d75"}, - {file = "frozenlist-1.4.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:f9a3ea26252bd92f570600098783d1371354d89d5f6b7dfd87359d669f2109b5"}, - {file = "frozenlist-1.4.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:4f57dab5fe3407b6c0c1cc907ac98e8a189f9e418f3b6e54d65a718aaafe3950"}, - {file = "frozenlist-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e02a0e11cf6597299b9f3bbd3f93d79217cb90cfd1411aec33848b13f5c656cc"}, - {file = "frozenlist-1.4.1-cp310-cp310-win32.whl", hash = "sha256:a828c57f00f729620a442881cc60e57cfcec6842ba38e1b19fd3e47ac0ff8dc1"}, - {file = "frozenlist-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:f56e2333dda1fe0f909e7cc59f021eba0d2307bc6f012a1ccf2beca6ba362439"}, - {file = "frozenlist-1.4.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:a0cb6f11204443f27a1628b0e460f37fb30f624be6051d490fa7d7e26d4af3d0"}, - {file = "frozenlist-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b46c8ae3a8f1f41a0d2ef350c0b6e65822d80772fe46b653ab6b6274f61d4a49"}, - {file = "frozenlist-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:fde5bd59ab5357e3853313127f4d3565fc7dad314a74d7b5d43c22c6a5ed2ced"}, - {file = "frozenlist-1.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:722e1124aec435320ae01ee3ac7bec11a5d47f25d0ed6328f2273d287bc3abb0"}, - {file = "frozenlist-1.4.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2471c201b70d58a0f0c1f91261542a03d9a5e088ed3dc6c160d614c01649c106"}, - {file = "frozenlist-1.4.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c757a9dd70d72b076d6f68efdbb9bc943665ae954dad2801b874c8c69e185068"}, - {file = "frozenlist-1.4.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f146e0911cb2f1da549fc58fc7bcd2b836a44b79ef871980d605ec392ff6b0d2"}, - {file = "frozenlist-1.4.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f9c515e7914626b2a2e1e311794b4c35720a0be87af52b79ff8e1429fc25f19"}, - {file = "frozenlist-1.4.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c302220494f5c1ebeb0912ea782bcd5e2f8308037b3c7553fad0e48ebad6ad82"}, - {file = "frozenlist-1.4.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:442acde1e068288a4ba7acfe05f5f343e19fac87bfc96d89eb886b0363e977ec"}, - {file = "frozenlist-1.4.1-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:1b280e6507ea8a4fa0c0a7150b4e526a8d113989e28eaaef946cc77ffd7efc0a"}, - {file = "frozenlist-1.4.1-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:fe1a06da377e3a1062ae5fe0926e12b84eceb8a50b350ddca72dc85015873f74"}, - {file = "frozenlist-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:db9e724bebd621d9beca794f2a4ff1d26eed5965b004a97f1f1685a173b869c2"}, - {file = "frozenlist-1.4.1-cp311-cp311-win32.whl", hash = "sha256:e774d53b1a477a67838a904131c4b0eef6b3d8a651f8b138b04f748fccfefe17"}, - {file = "frozenlist-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:fb3c2db03683b5767dedb5769b8a40ebb47d6f7f45b1b3e3b4b51ec8ad9d9825"}, - {file = "frozenlist-1.4.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:1979bc0aeb89b33b588c51c54ab0161791149f2461ea7c7c946d95d5f93b56ae"}, - {file = "frozenlist-1.4.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:cc7b01b3754ea68a62bd77ce6020afaffb44a590c2289089289363472d13aedb"}, - {file = "frozenlist-1.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c9c92be9fd329ac801cc420e08452b70e7aeab94ea4233a4804f0915c14eba9b"}, - {file = "frozenlist-1.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c3894db91f5a489fc8fa6a9991820f368f0b3cbdb9cd8849547ccfab3392d86"}, - {file = "frozenlist-1.4.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ba60bb19387e13597fb059f32cd4d59445d7b18b69a745b8f8e5db0346f33480"}, - {file = "frozenlist-1.4.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8aefbba5f69d42246543407ed2461db31006b0f76c4e32dfd6f42215a2c41d09"}, - {file = "frozenlist-1.4.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:780d3a35680ced9ce682fbcf4cb9c2bad3136eeff760ab33707b71db84664e3a"}, - {file = "frozenlist-1.4.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9acbb16f06fe7f52f441bb6f413ebae6c37baa6ef9edd49cdd567216da8600cd"}, - {file = "frozenlist-1.4.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:23b701e65c7b36e4bf15546a89279bd4d8675faabc287d06bbcfac7d3c33e1e6"}, - {file = "frozenlist-1.4.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:3e0153a805a98f5ada7e09826255ba99fb4f7524bb81bf6b47fb702666484ae1"}, - {file = "frozenlist-1.4.1-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:dd9b1baec094d91bf36ec729445f7769d0d0cf6b64d04d86e45baf89e2b9059b"}, - {file = "frozenlist-1.4.1-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:1a4471094e146b6790f61b98616ab8e44f72661879cc63fa1049d13ef711e71e"}, - {file = "frozenlist-1.4.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5667ed53d68d91920defdf4035d1cdaa3c3121dc0b113255124bcfada1cfa1b8"}, - {file = "frozenlist-1.4.1-cp312-cp312-win32.whl", hash = "sha256:beee944ae828747fd7cb216a70f120767fc9f4f00bacae8543c14a6831673f89"}, - {file = "frozenlist-1.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:64536573d0a2cb6e625cf309984e2d873979709f2cf22839bf2d61790b448ad5"}, - {file = "frozenlist-1.4.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:20b51fa3f588ff2fe658663db52a41a4f7aa6c04f6201449c6c7c476bd255c0d"}, - {file = "frozenlist-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:410478a0c562d1a5bcc2f7ea448359fcb050ed48b3c6f6f4f18c313a9bdb1826"}, - {file = "frozenlist-1.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c6321c9efe29975232da3bd0af0ad216800a47e93d763ce64f291917a381b8eb"}, - {file = "frozenlist-1.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48f6a4533887e189dae092f1cf981f2e3885175f7a0f33c91fb5b7b682b6bab6"}, - {file = "frozenlist-1.4.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6eb73fa5426ea69ee0e012fb59cdc76a15b1283d6e32e4f8dc4482ec67d1194d"}, - {file = "frozenlist-1.4.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbeb989b5cc29e8daf7f976b421c220f1b8c731cbf22b9130d8815418ea45887"}, - {file = "frozenlist-1.4.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:32453c1de775c889eb4e22f1197fe3bdfe457d16476ea407472b9442e6295f7a"}, - {file = "frozenlist-1.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:693945278a31f2086d9bf3df0fe8254bbeaef1fe71e1351c3bd730aa7d31c41b"}, - {file = "frozenlist-1.4.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:1d0ce09d36d53bbbe566fe296965b23b961764c0bcf3ce2fa45f463745c04701"}, - {file = "frozenlist-1.4.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:3a670dc61eb0d0eb7080890c13de3066790f9049b47b0de04007090807c776b0"}, - {file = "frozenlist-1.4.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:dca69045298ce5c11fd539682cff879cc1e664c245d1c64da929813e54241d11"}, - {file = "frozenlist-1.4.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:a06339f38e9ed3a64e4c4e43aec7f59084033647f908e4259d279a52d3757d09"}, - {file = "frozenlist-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b7f2f9f912dca3934c1baec2e4585a674ef16fe00218d833856408c48d5beee7"}, - {file = "frozenlist-1.4.1-cp38-cp38-win32.whl", hash = "sha256:e7004be74cbb7d9f34553a5ce5fb08be14fb33bc86f332fb71cbe5216362a497"}, - {file = "frozenlist-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:5a7d70357e7cee13f470c7883a063aae5fe209a493c57d86eb7f5a6f910fae09"}, - {file = "frozenlist-1.4.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:bfa4a17e17ce9abf47a74ae02f32d014c5e9404b6d9ac7f729e01562bbee601e"}, - {file = "frozenlist-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b7e3ed87d4138356775346e6845cccbe66cd9e207f3cd11d2f0b9fd13681359d"}, - {file = "frozenlist-1.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c99169d4ff810155ca50b4da3b075cbde79752443117d89429595c2e8e37fed8"}, - {file = "frozenlist-1.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:edb678da49d9f72c9f6c609fbe41a5dfb9a9282f9e6a2253d5a91e0fc382d7c0"}, - {file = "frozenlist-1.4.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6db4667b187a6742b33afbbaf05a7bc551ffcf1ced0000a571aedbb4aa42fc7b"}, - {file = "frozenlist-1.4.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:55fdc093b5a3cb41d420884cdaf37a1e74c3c37a31f46e66286d9145d2063bd0"}, - {file = "frozenlist-1.4.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82e8211d69a4f4bc360ea22cd6555f8e61a1bd211d1d5d39d3d228b48c83a897"}, - {file = "frozenlist-1.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:89aa2c2eeb20957be2d950b85974b30a01a762f3308cd02bb15e1ad632e22dc7"}, - {file = "frozenlist-1.4.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9d3e0c25a2350080e9319724dede4f31f43a6c9779be48021a7f4ebde8b2d742"}, - {file = "frozenlist-1.4.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:7268252af60904bf52c26173cbadc3a071cece75f873705419c8681f24d3edea"}, - {file = "frozenlist-1.4.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:0c250a29735d4f15321007fb02865f0e6b6a41a6b88f1f523ca1596ab5f50bd5"}, - {file = "frozenlist-1.4.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:96ec70beabbd3b10e8bfe52616a13561e58fe84c0101dd031dc78f250d5128b9"}, - {file = "frozenlist-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:23b2d7679b73fe0e5a4560b672a39f98dfc6f60df63823b0a9970525325b95f6"}, - {file = "frozenlist-1.4.1-cp39-cp39-win32.whl", hash = "sha256:a7496bfe1da7fb1a4e1cc23bb67c58fab69311cc7d32b5a99c2007b4b2a0e932"}, - {file = "frozenlist-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:e6a20a581f9ce92d389a8c7d7c3dd47c81fd5d6e655c8dddf341e14aa48659d0"}, - {file = "frozenlist-1.4.1-py3-none-any.whl", hash = "sha256:04ced3e6a46b4cfffe20f9ae482818e34eba9b5fb0ce4056e4cc9b6e212d09b7"}, - {file = "frozenlist-1.4.1.tar.gz", hash = "sha256:c037a86e8513059a2613aaba4d817bb90b9d9b6b69aace3ce9c877e8c8ed402b"}, + {file = "frozenlist-1.5.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:5b6a66c18b5b9dd261ca98dffcb826a525334b2f29e7caa54e182255c5f6a65a"}, + {file = "frozenlist-1.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d1b3eb7b05ea246510b43a7e53ed1653e55c2121019a97e60cad7efb881a97bb"}, + {file = "frozenlist-1.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:15538c0cbf0e4fa11d1e3a71f823524b0c46299aed6e10ebb4c2089abd8c3bec"}, + {file = "frozenlist-1.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e79225373c317ff1e35f210dd5f1344ff31066ba8067c307ab60254cd3a78ad5"}, + {file = "frozenlist-1.5.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9272fa73ca71266702c4c3e2d4a28553ea03418e591e377a03b8e3659d94fa76"}, + {file = "frozenlist-1.5.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:498524025a5b8ba81695761d78c8dd7382ac0b052f34e66939c42df860b8ff17"}, + {file = "frozenlist-1.5.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:92b5278ed9d50fe610185ecd23c55d8b307d75ca18e94c0e7de328089ac5dcba"}, + {file = "frozenlist-1.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f3c8c1dacd037df16e85227bac13cca58c30da836c6f936ba1df0c05d046d8d"}, + {file = "frozenlist-1.5.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f2ac49a9bedb996086057b75bf93538240538c6d9b38e57c82d51f75a73409d2"}, + {file = "frozenlist-1.5.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e66cc454f97053b79c2ab09c17fbe3c825ea6b4de20baf1be28919460dd7877f"}, + {file = "frozenlist-1.5.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:5a3ba5f9a0dfed20337d3e966dc359784c9f96503674c2faf015f7fe8e96798c"}, + {file = "frozenlist-1.5.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:6321899477db90bdeb9299ac3627a6a53c7399c8cd58d25da094007402b039ab"}, + {file = "frozenlist-1.5.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:76e4753701248476e6286f2ef492af900ea67d9706a0155335a40ea21bf3b2f5"}, + {file = "frozenlist-1.5.0-cp310-cp310-win32.whl", hash = "sha256:977701c081c0241d0955c9586ffdd9ce44f7a7795df39b9151cd9a6fd0ce4cfb"}, + {file = "frozenlist-1.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:189f03b53e64144f90990d29a27ec4f7997d91ed3d01b51fa39d2dbe77540fd4"}, + {file = "frozenlist-1.5.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:fd74520371c3c4175142d02a976aee0b4cb4a7cc912a60586ffd8d5929979b30"}, + {file = "frozenlist-1.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2f3f7a0fbc219fb4455264cae4d9f01ad41ae6ee8524500f381de64ffaa077d5"}, + {file = "frozenlist-1.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f47c9c9028f55a04ac254346e92977bf0f166c483c74b4232bee19a6697e4778"}, + {file = "frozenlist-1.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0996c66760924da6e88922756d99b47512a71cfd45215f3570bf1e0b694c206a"}, + {file = "frozenlist-1.5.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a2fe128eb4edeabe11896cb6af88fca5346059f6c8d807e3b910069f39157869"}, + {file = "frozenlist-1.5.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1a8ea951bbb6cacd492e3948b8da8c502a3f814f5d20935aae74b5df2b19cf3d"}, + {file = "frozenlist-1.5.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:de537c11e4aa01d37db0d403b57bd6f0546e71a82347a97c6a9f0dcc532b3a45"}, + {file = "frozenlist-1.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c2623347b933fcb9095841f1cc5d4ff0b278addd743e0e966cb3d460278840d"}, + {file = "frozenlist-1.5.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cee6798eaf8b1416ef6909b06f7dc04b60755206bddc599f52232606e18179d3"}, + {file = "frozenlist-1.5.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:f5f9da7f5dbc00a604fe74aa02ae7c98bcede8a3b8b9666f9f86fc13993bc71a"}, + {file = "frozenlist-1.5.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:90646abbc7a5d5c7c19461d2e3eeb76eb0b204919e6ece342feb6032c9325ae9"}, + {file = "frozenlist-1.5.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:bdac3c7d9b705d253b2ce370fde941836a5f8b3c5c2b8fd70940a3ea3af7f4f2"}, + {file = "frozenlist-1.5.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:03d33c2ddbc1816237a67f66336616416e2bbb6beb306e5f890f2eb22b959cdf"}, + {file = "frozenlist-1.5.0-cp311-cp311-win32.whl", hash = "sha256:237f6b23ee0f44066219dae14c70ae38a63f0440ce6750f868ee08775073f942"}, + {file = "frozenlist-1.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:0cc974cc93d32c42e7b0f6cf242a6bd941c57c61b618e78b6c0a96cb72788c1d"}, + {file = "frozenlist-1.5.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:31115ba75889723431aa9a4e77d5f398f5cf976eea3bdf61749731f62d4a4a21"}, + {file = "frozenlist-1.5.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7437601c4d89d070eac8323f121fcf25f88674627505334654fd027b091db09d"}, + {file = "frozenlist-1.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7948140d9f8ece1745be806f2bfdf390127cf1a763b925c4a805c603df5e697e"}, + {file = "frozenlist-1.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:feeb64bc9bcc6b45c6311c9e9b99406660a9c05ca8a5b30d14a78555088b0b3a"}, + {file = "frozenlist-1.5.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:683173d371daad49cffb8309779e886e59c2f369430ad28fe715f66d08d4ab1a"}, + {file = "frozenlist-1.5.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7d57d8f702221405a9d9b40f9da8ac2e4a1a8b5285aac6100f3393675f0a85ee"}, + {file = "frozenlist-1.5.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:30c72000fbcc35b129cb09956836c7d7abf78ab5416595e4857d1cae8d6251a6"}, + {file = "frozenlist-1.5.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:000a77d6034fbad9b6bb880f7ec073027908f1b40254b5d6f26210d2dab1240e"}, + {file = "frozenlist-1.5.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:5d7f5a50342475962eb18b740f3beecc685a15b52c91f7d975257e13e029eca9"}, + {file = "frozenlist-1.5.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:87f724d055eb4785d9be84e9ebf0f24e392ddfad00b3fe036e43f489fafc9039"}, + {file = "frozenlist-1.5.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:6e9080bb2fb195a046e5177f10d9d82b8a204c0736a97a153c2466127de87784"}, + {file = "frozenlist-1.5.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:9b93d7aaa36c966fa42efcaf716e6b3900438632a626fb09c049f6a2f09fc631"}, + {file = "frozenlist-1.5.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:52ef692a4bc60a6dd57f507429636c2af8b6046db8b31b18dac02cbc8f507f7f"}, + {file = "frozenlist-1.5.0-cp312-cp312-win32.whl", hash = "sha256:29d94c256679247b33a3dc96cce0f93cbc69c23bf75ff715919332fdbb6a32b8"}, + {file = "frozenlist-1.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:8969190d709e7c48ea386db202d708eb94bdb29207a1f269bab1196ce0dcca1f"}, + {file = "frozenlist-1.5.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:7a1a048f9215c90973402e26c01d1cff8a209e1f1b53f72b95c13db61b00f953"}, + {file = "frozenlist-1.5.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:dd47a5181ce5fcb463b5d9e17ecfdb02b678cca31280639255ce9d0e5aa67af0"}, + {file = "frozenlist-1.5.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1431d60b36d15cda188ea222033eec8e0eab488f39a272461f2e6d9e1a8e63c2"}, + {file = "frozenlist-1.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6482a5851f5d72767fbd0e507e80737f9c8646ae7fd303def99bfe813f76cf7f"}, + {file = "frozenlist-1.5.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:44c49271a937625619e862baacbd037a7ef86dd1ee215afc298a417ff3270608"}, + {file = "frozenlist-1.5.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:12f78f98c2f1c2429d42e6a485f433722b0061d5c0b0139efa64f396efb5886b"}, + {file = "frozenlist-1.5.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ce3aa154c452d2467487765e3adc730a8c153af77ad84096bc19ce19a2400840"}, + {file = "frozenlist-1.5.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9b7dc0c4338e6b8b091e8faf0db3168a37101943e687f373dce00959583f7439"}, + {file = "frozenlist-1.5.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:45e0896250900b5aa25180f9aec243e84e92ac84bd4a74d9ad4138ef3f5c97de"}, + {file = "frozenlist-1.5.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:561eb1c9579d495fddb6da8959fd2a1fca2c6d060d4113f5844b433fc02f2641"}, + {file = "frozenlist-1.5.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:df6e2f325bfee1f49f81aaac97d2aa757c7646534a06f8f577ce184afe2f0a9e"}, + {file = "frozenlist-1.5.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:140228863501b44b809fb39ec56b5d4071f4d0aa6d216c19cbb08b8c5a7eadb9"}, + {file = "frozenlist-1.5.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7707a25d6a77f5d27ea7dc7d1fc608aa0a478193823f88511ef5e6b8a48f9d03"}, + {file = "frozenlist-1.5.0-cp313-cp313-win32.whl", hash = "sha256:31a9ac2b38ab9b5a8933b693db4939764ad3f299fcaa931a3e605bc3460e693c"}, + {file = "frozenlist-1.5.0-cp313-cp313-win_amd64.whl", hash = "sha256:11aabdd62b8b9c4b84081a3c246506d1cddd2dd93ff0ad53ede5defec7886b28"}, + {file = "frozenlist-1.5.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:dd94994fc91a6177bfaafd7d9fd951bc8689b0a98168aa26b5f543868548d3ca"}, + {file = "frozenlist-1.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2d0da8bbec082bf6bf18345b180958775363588678f64998c2b7609e34719b10"}, + {file = "frozenlist-1.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:73f2e31ea8dd7df61a359b731716018c2be196e5bb3b74ddba107f694fbd7604"}, + {file = "frozenlist-1.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:828afae9f17e6de596825cf4228ff28fbdf6065974e5ac1410cecc22f699d2b3"}, + {file = "frozenlist-1.5.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1577515d35ed5649d52ab4319db757bb881ce3b2b796d7283e6634d99ace307"}, + {file = "frozenlist-1.5.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2150cc6305a2c2ab33299453e2968611dacb970d2283a14955923062c8d00b10"}, + {file = "frozenlist-1.5.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a72b7a6e3cd2725eff67cd64c8f13335ee18fc3c7befc05aed043d24c7b9ccb9"}, + {file = "frozenlist-1.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c16d2fa63e0800723139137d667e1056bee1a1cf7965153d2d104b62855e9b99"}, + {file = "frozenlist-1.5.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:17dcc32fc7bda7ce5875435003220a457bcfa34ab7924a49a1c19f55b6ee185c"}, + {file = "frozenlist-1.5.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:97160e245ea33d8609cd2b8fd997c850b56db147a304a262abc2b3be021a9171"}, + {file = "frozenlist-1.5.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:f1e6540b7fa044eee0bb5111ada694cf3dc15f2b0347ca125ee9ca984d5e9e6e"}, + {file = "frozenlist-1.5.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:91d6c171862df0a6c61479d9724f22efb6109111017c87567cfeb7b5d1449fdf"}, + {file = "frozenlist-1.5.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:c1fac3e2ace2eb1052e9f7c7db480818371134410e1f5c55d65e8f3ac6d1407e"}, + {file = "frozenlist-1.5.0-cp38-cp38-win32.whl", hash = "sha256:b97f7b575ab4a8af9b7bc1d2ef7f29d3afee2226bd03ca3875c16451ad5a7723"}, + {file = "frozenlist-1.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:374ca2dabdccad8e2a76d40b1d037f5bd16824933bf7bcea3e59c891fd4a0923"}, + {file = "frozenlist-1.5.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9bbcdfaf4af7ce002694a4e10a0159d5a8d20056a12b05b45cea944a4953f972"}, + {file = "frozenlist-1.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1893f948bf6681733aaccf36c5232c231e3b5166d607c5fa77773611df6dc336"}, + {file = "frozenlist-1.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2b5e23253bb709ef57a8e95e6ae48daa9ac5f265637529e4ce6b003a37b2621f"}, + {file = "frozenlist-1.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f253985bb515ecd89629db13cb58d702035ecd8cfbca7d7a7e29a0e6d39af5f"}, + {file = "frozenlist-1.5.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:04a5c6babd5e8fb7d3c871dc8b321166b80e41b637c31a995ed844a6139942b6"}, + {file = "frozenlist-1.5.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a9fe0f1c29ba24ba6ff6abf688cb0b7cf1efab6b6aa6adc55441773c252f7411"}, + {file = "frozenlist-1.5.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:226d72559fa19babe2ccd920273e767c96a49b9d3d38badd7c91a0fdeda8ea08"}, + {file = "frozenlist-1.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15b731db116ab3aedec558573c1a5eec78822b32292fe4f2f0345b7f697745c2"}, + {file = "frozenlist-1.5.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:366d8f93e3edfe5a918c874702f78faac300209a4d5bf38352b2c1bdc07a766d"}, + {file = "frozenlist-1.5.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1b96af8c582b94d381a1c1f51ffaedeb77c821c690ea5f01da3d70a487dd0a9b"}, + {file = "frozenlist-1.5.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:c03eff4a41bd4e38415cbed054bbaff4a075b093e2394b6915dca34a40d1e38b"}, + {file = "frozenlist-1.5.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:50cf5e7ee9b98f22bdecbabf3800ae78ddcc26e4a435515fc72d97903e8488e0"}, + {file = "frozenlist-1.5.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:1e76bfbc72353269c44e0bc2cfe171900fbf7f722ad74c9a7b638052afe6a00c"}, + {file = "frozenlist-1.5.0-cp39-cp39-win32.whl", hash = "sha256:666534d15ba8f0fda3f53969117383d5dc021266b3c1a42c9ec4855e4b58b9d3"}, + {file = "frozenlist-1.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:5c28f4b5dbef8a0d8aad0d4de24d1e9e981728628afaf4ea0792f5d0939372f0"}, + {file = "frozenlist-1.5.0-py3-none-any.whl", hash = "sha256:d994863bba198a4a518b467bb971c56e1db3f180a25c6cf7bb1949c267f748c3"}, + {file = "frozenlist-1.5.0.tar.gz", hash = "sha256:81d5af29e61b9c8348e876d442253723928dce6433e0e76cd925cd83f1b4b817"}, ] [[package]] name = "greenlet" -version = "3.0.3" +version = "3.1.1" 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.1-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:0bbae94a29c9e5c7e4a2b7f0aae5c17e8e90acbfd3bf6270eeba60c39fce3563"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fde093fb93f35ca72a556cf72c92ea3ebfda3d79fc35bb19fbe685853869a83"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:36b89d13c49216cadb828db8dfa6ce86bbbc476a82d3a6c397f0efae0525bdd0"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94b6150a85e1b33b40b1464a3f9988dcc5251d6ed06842abff82e42632fac120"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:93147c513fac16385d1036b7e5b102c7fbbdb163d556b791f0f11eada7ba65dc"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da7a9bff22ce038e19bf62c4dd1ec8391062878710ded0a845bcf47cc0200617"}, + {file = "greenlet-3.1.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b2795058c23988728eec1f36a4e5e4ebad22f8320c85f3587b539b9ac84128d7"}, + {file = "greenlet-3.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ed10eac5830befbdd0c32f83e8aa6288361597550ba669b04c48f0f9a2c843c6"}, + {file = "greenlet-3.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:77c386de38a60d1dfb8e55b8c1101d68c79dfdd25c7095d51fec2dd800892b80"}, + {file = "greenlet-3.1.1-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:e4d333e558953648ca09d64f13e6d8f0523fa705f51cae3f03b5983489958c70"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fc016b73c94e98e29af67ab7b9a879c307c6731a2c9da0db5a7d9b7edd1159"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d5e975ca70269d66d17dd995dafc06f1b06e8cb1ec1e9ed54c1d1e4a7c4cf26e"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3b2813dc3de8c1ee3f924e4d4227999285fd335d1bcc0d2be6dc3f1f6a318ec1"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e347b3bfcf985a05e8c0b7d462ba6f15b1ee1c909e2dcad795e49e91b152c383"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e8f8c9cb53cdac7ba9793c276acd90168f416b9ce36799b9b885790f8ad6c0a"}, + {file = "greenlet-3.1.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:62ee94988d6b4722ce0028644418d93a52429e977d742ca2ccbe1c4f4a792511"}, + {file = "greenlet-3.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1776fd7f989fc6b8d8c8cb8da1f6b82c5814957264d1f6cf818d475ec2bf6395"}, + {file = "greenlet-3.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:48ca08c771c268a768087b408658e216133aecd835c0ded47ce955381105ba39"}, + {file = "greenlet-3.1.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:4afe7ea89de619adc868e087b4d2359282058479d7cfb94970adf4b55284574d"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f406b22b7c9a9b4f8aa9d2ab13d6ae0ac3e85c9a809bd590ad53fed2bf70dc79"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c3a701fe5a9695b238503ce5bbe8218e03c3bcccf7e204e455e7462d770268aa"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2846930c65b47d70b9d178e89c7e1a69c95c1f68ea5aa0a58646b7a96df12441"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99cfaa2110534e2cf3ba31a7abcac9d328d1d9f1b95beede58294a60348fba36"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1443279c19fca463fc33e65ef2a935a5b09bb90f978beab37729e1c3c6c25fe9"}, + {file = "greenlet-3.1.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b7cede291382a78f7bb5f04a529cb18e068dd29e0fb27376074b6d0317bf4dd0"}, + {file = "greenlet-3.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:23f20bb60ae298d7d8656c6ec6db134bca379ecefadb0b19ce6f19d1f232a942"}, + {file = "greenlet-3.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:7124e16b4c55d417577c2077be379514321916d5790fa287c9ed6f23bd2ffd01"}, + {file = "greenlet-3.1.1-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:05175c27cb459dcfc05d026c4232f9de8913ed006d42713cb8a5137bd49375f1"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:935e943ec47c4afab8965954bf49bfa639c05d4ccf9ef6e924188f762145c0ff"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:667a9706c970cb552ede35aee17339a18e8f2a87a51fba2ed39ceeeb1004798a"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b8a678974d1f3aa55f6cc34dc480169d58f2e6d8958895d68845fa4ab566509e"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:efc0f674aa41b92da8c49e0346318c6075d734994c3c4e4430b1c3f853e498e4"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0153404a4bb921f0ff1abeb5ce8a5131da56b953eda6e14b88dc6bbc04d2049e"}, + {file = "greenlet-3.1.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:275f72decf9932639c1c6dd1013a1bc266438eb32710016a1c742df5da6e60a1"}, + {file = "greenlet-3.1.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c4aab7f6381f38a4b42f269057aee279ab0fc7bf2e929e3d4abfae97b682a12c"}, + {file = "greenlet-3.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:b42703b1cf69f2aa1df7d1030b9d77d3e584a70755674d60e710f0af570f3761"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1695e76146579f8c06c1509c7ce4dfe0706f49c6831a817ac04eebb2fd02011"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7876452af029456b3f3549b696bb36a06db7c90747740c5302f74a9e9fa14b13"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ead44c85f8ab905852d3de8d86f6f8baf77109f9da589cb4fa142bd3b57b475"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8320f64b777d00dd7ccdade271eaf0cad6636343293a25074cc5566160e4de7b"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6510bf84a6b643dabba74d3049ead221257603a253d0a9873f55f6a59a65f822"}, + {file = "greenlet-3.1.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:04b013dc07c96f83134b1e99888e7a79979f1a247e2a9f59697fa14b5862ed01"}, + {file = "greenlet-3.1.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:411f015496fec93c1c8cd4e5238da364e1da7a124bcb293f085bf2860c32c6f6"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:47da355d8687fd65240c364c90a31569a133b7b60de111c255ef5b606f2ae291"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98884ecf2ffb7d7fe6bd517e8eb99d31ff7855a840fa6d0d63cd07c037f6a981"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f1d4aeb8891338e60d1ab6127af1fe45def5259def8094b9c7e34690c8858803"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db32b5348615a04b82240cc67983cb315309e88d444a288934ee6ceaebcad6cc"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dcc62f31eae24de7f8dce72134c8651c58000d3b1868e01392baea7c32c247de"}, + {file = "greenlet-3.1.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1d3755bcb2e02de341c55b4fca7a745a24a9e7212ac953f6b3a48d117d7257aa"}, + {file = "greenlet-3.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:b8da394b34370874b4572676f36acabac172602abf054cbc4ac910219f3340af"}, + {file = "greenlet-3.1.1-cp37-cp37m-win32.whl", hash = "sha256:a0dfc6c143b519113354e780a50381508139b07d2177cb6ad6a08278ec655798"}, + {file = "greenlet-3.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:54558ea205654b50c438029505def3834e80f0869a70fb15b871c29b4575ddef"}, + {file = "greenlet-3.1.1-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:346bed03fe47414091be4ad44786d1bd8bef0c3fcad6ed3dee074a032ab408a9"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dfc59d69fc48664bc693842bd57acfdd490acafda1ab52c7836e3fc75c90a111"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d21e10da6ec19b457b82636209cbe2331ff4306b54d06fa04b7c138ba18c8a81"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:37b9de5a96111fc15418819ab4c4432e4f3c2ede61e660b1e33971eba26ef9ba"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ef9ea3f137e5711f0dbe5f9263e8c009b7069d8a1acea822bd5e9dae0ae49c8"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:85f3ff71e2e60bd4b4932a043fbbe0f499e263c628390b285cb599154a3b03b1"}, + {file = "greenlet-3.1.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:95ffcf719966dd7c453f908e208e14cde192e09fde6c7186c8f1896ef778d8cd"}, + {file = "greenlet-3.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:03a088b9de532cbfe2ba2034b2b85e82df37874681e8c470d6fb2f8c04d7e4b7"}, + {file = "greenlet-3.1.1-cp38-cp38-win32.whl", hash = "sha256:8b8b36671f10ba80e159378df9c4f15c14098c4fd73a36b9ad715f057272fbef"}, + {file = "greenlet-3.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:7017b2be767b9d43cc31416aba48aab0d2309ee31b4dbf10a1d38fb7972bdf9d"}, + {file = "greenlet-3.1.1-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:396979749bd95f018296af156201d6211240e7a23090f50a8d5d18c370084dc3"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca9d0ff5ad43e785350894d97e13633a66e2b50000e8a183a50a88d834752d42"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f6ff3b14f2df4c41660a7dec01045a045653998784bf8cfcb5a525bdffffbc8f"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94ebba31df2aa506d7b14866fed00ac141a867e63143fe5bca82a8e503b36437"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:73aaad12ac0ff500f62cebed98d8789198ea0e6f233421059fa68a5aa7220145"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63e4844797b975b9af3a3fb8f7866ff08775f5426925e1e0bbcfe7932059a12c"}, + {file = "greenlet-3.1.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:7939aa3ca7d2a1593596e7ac6d59391ff30281ef280d8632fa03d81f7c5f955e"}, + {file = "greenlet-3.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d0028e725ee18175c6e422797c407874da24381ce0690d6b9396c204c7f7276e"}, + {file = "greenlet-3.1.1-cp39-cp39-win32.whl", hash = "sha256:5e06afd14cbaf9e00899fae69b24a32f2196c19de08fcb9f4779dd4f004e5e7c"}, + {file = "greenlet-3.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:3319aa75e0e0639bc15ff54ca327e8dc7a6fe404003496e3c6925cd3142e0e22"}, + {file = "greenlet-3.1.1.tar.gz", hash = "sha256:4ce3ac6cdb6adf7946475d7ef31777c26d94bccc377e070a7986bd2d5c515467"}, ] [package.extras] @@ -908,13 +961,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] @@ -940,13 +993,13 @@ files = [ [[package]] name = "httpcore" -version = "1.0.5" +version = "1.0.6" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" files = [ - {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, - {file = "httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61"}, + {file = "httpcore-1.0.6-py3-none-any.whl", hash = "sha256:27b59625743b85577a8c0e10e55b50b5368a4f2cfe8cc7bcfa9cf00829c2682f"}, + {file = "httpcore-1.0.6.tar.gz", hash = "sha256:73f6dbd6eb8c21bbf7ef8efad555481853f5f6acdeaff1edb0694289269ee17f"}, ] [package.dependencies] @@ -957,17 +1010,17 @@ h11 = ">=0.13,<0.15" asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] -trio = ["trio (>=0.22.0,<0.26.0)"] +trio = ["trio (>=0.22.0,<1.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] @@ -982,16 +1035,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.5.36" +version = "2.6.1" description = "File identification library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "identify-2.5.36-py2.py3-none-any.whl", hash = "sha256:37d93f380f4de590500d9dba7db359d0d3da95ffe7f9de1753faa159e71e7dfa"}, - {file = "identify-2.5.36.tar.gz", hash = "sha256:e5e00f54165f9047fbebeb4a560f9acfb8af4c88232be60a488e9b68d122745d"}, + {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] @@ -999,51 +1053,40 @@ license = ["ukkonen"] [[package]] name = "idna" -version = "3.7" +version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" files = [ - {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, - {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, + {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 = "7.1.0" +version = "8.5.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-7.1.0-py3-none-any.whl", hash = "sha256:30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570"}, - {file = "importlib_metadata-7.1.0.tar.gz", hash = "sha256:b78938b926ee8d5f020fc4772d487045805a55ddbad2ecf21c6d60938dc7fcd2"}, + {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" +zipp = ">=3.20" [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +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)"] perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6)", "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.0" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_resources-6.4.0-py3-none-any.whl", hash = "sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c"}, - {file = "importlib_resources-6.4.0.tar.gz", hash = "sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145"}, -] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] +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]] name = "iniconfig" @@ -1076,39 +1119,43 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-ena [[package]] name = "jaraco-context" -version = "5.3.0" +version = "6.0.1" description = "Useful decorators and context managers" optional = false python-versions = ">=3.8" files = [ - {file = "jaraco.context-5.3.0-py3-none-any.whl", hash = "sha256:3e16388f7da43d384a1a7cd3452e72e14732ac9fe459678773a3608a812bf266"}, - {file = "jaraco.context-5.3.0.tar.gz", hash = "sha256:c2f67165ce1f9be20f32f650f25d8edfc1646a8aeee48ae06fb35f90763576d2"}, + {file = "jaraco.context-6.0.1-py3-none-any.whl", hash = "sha256:f797fc481b490edb305122c9181830a3a5b76d84ef6d1aef2fb9b47ab956f9e4"}, + {file = "jaraco_context-6.0.1.tar.gz", hash = "sha256:9bae4ea555cf0b14938dc0aee7c9f32ed303aa20a3b73e7dc80111628792d1b3"}, ] [package.dependencies] "backports.tarfile" = {version = "*", markers = "python_version < \"3.12\""} [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["portend", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +test = ["portend", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)"] [[package]] name = "jaraco-functools" -version = "4.0.1" +version = "4.1.0" description = "Functools like those found in stdlib" optional = false python-versions = ">=3.8" files = [ - {file = "jaraco.functools-4.0.1-py3-none-any.whl", hash = "sha256:3b24ccb921d6b593bdceb56ce14799204f473976e2a9d4b15b04d0f2c2326664"}, - {file = "jaraco_functools-4.0.1.tar.gz", hash = "sha256:d33fa765374c0611b52f8b3a795f8900869aa88c84769d4d1746cd68fb28c3e8"}, + {file = "jaraco.functools-4.1.0-py3-none-any.whl", hash = "sha256:ad159f13428bc4acbf5541ad6dec511f91573b90fba04df61dafa2a1231cf649"}, + {file = "jaraco_functools-4.1.0.tar.gz", hash = "sha256:70f7e0e2ae076498e212562325e805204fc092d7b4c17e0e86c959e249701a9d"}, ] [package.dependencies] more-itertools = "*" [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["jaraco.classes", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +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.classes", "pytest (>=6,!=8.1.*)"] +type = ["pytest-mypy"] [[package]] name = "jeepney" @@ -1144,18 +1191,17 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "keyring" -version = "25.2.0" +version = "25.5.0" description = "Store and access your passwords safely." optional = false python-versions = ">=3.8" files = [ - {file = "keyring-25.2.0-py3-none-any.whl", hash = "sha256:19f17d40335444aab84b19a0d16a77ec0758a9c384e3446ae2ed8bd6d53b67a5"}, - {file = "keyring-25.2.0.tar.gz", hash = "sha256:7045f367268ce42dba44745050164b431e46f6e92f99ef2937dfadaef368d8cf"}, + {file = "keyring-25.5.0-py3-none-any.whl", hash = "sha256:e67f8ac32b04be4714b42fe84ce7dad9c40985b9ca827c592cc303e7c26d9741"}, + {file = "keyring-25.5.0.tar.gz", hash = "sha256:4c753b3ec91717fe713c4edd522d625889d8973a349b0e582622f49766de58e6"}, ] [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" = "*" @@ -1164,19 +1210,42 @@ 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)"] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "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 = ["pyfakefs", "pytest (>=6,!=8.1.*)"] +type = ["pygobject-stubs", "pytest-mypy", "shtab", "types-pywin32"] + +[[package]] +name = "lazy-loader" +version = "0.4" +description = "Makes it easy to load subpackages and functions on demand." +optional = false +python-versions = ">=3.7" +files = [ + {file = "lazy_loader-0.4-py3-none-any.whl", hash = "sha256:342aa8e14d543a154047afb4ba8ef17f5563baad3fc610d7b15b213b0f119efc"}, + {file = "lazy_loader-0.4.tar.gz", hash = "sha256:47c75182589b91a4e1a85a136c074285a5ad4d9f39c63e0d7fb76391c4574cd1"}, +] + +[package.dependencies] +packaging = "*" + +[package.extras] +dev = ["changelist (==0.5)"] +lint = ["pre-commit (==3.7.0)"] +test = ["pytest (>=7.4)", "pytest-cov (>=4.1)"] [[package]] name = "mako" -version = "1.3.3" +version = "1.3.6" description = "A super-fast templating language that borrows the best ideas from the existing templating languages." optional = false python-versions = ">=3.8" files = [ - {file = "Mako-1.3.3-py3-none-any.whl", hash = "sha256:5324b88089a8978bf76d1629774fcc2f1c07b82acdf00f4c5dd8ceadfffc4b40"}, - {file = "Mako-1.3.3.tar.gz", hash = "sha256:e16c01d9ab9c11f7290eef1cfefc093fb5a45ee4a3da09e2fec2e4d1bae54e73"}, + {file = "Mako-1.3.6-py3-none-any.whl", hash = "sha256:a91198468092a2f1a0de86ca92690fb0cfc43ca90ee17e15d93662b4c04b241a"}, + {file = "mako-1.3.6.tar.gz", hash = "sha256:9ec3a1583713479fae654f83ed9fa8c9a4c16b7bb0daba0e6bbebff50c0d983d"}, ] [package.dependencies] @@ -1213,71 +1282,72 @@ testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] [[package]] name = "markupsafe" -version = "2.1.5" +version = "3.0.2" description = "Safely add untrusted strings to HTML/XML markup." optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" files = [ - {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a17a92de5231666cfbe003f0e4b9b3a7ae3afb1ec2845aadc2bacc93ff85febc"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:72b6be590cc35924b02c78ef34b467da4ba07e4e0f0454a2c5907f473fc50ce5"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61659ba32cf2cf1481e575d0462554625196a1f2fc06a1c777d3f48e8865d46"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2174c595a0d73a3080ca3257b40096db99799265e1c27cc5a610743acd86d62f"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae2ad8ae6ebee9d2d94b17fb62763125f3f374c25618198f40cbb8b525411900"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:075202fa5b72c86ad32dc7d0b56024ebdbcf2048c0ba09f1cde31bfdd57bcfff"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:598e3276b64aff0e7b3451b72e94fa3c238d452e7ddcd893c3ab324717456bad"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fce659a462a1be54d2ffcacea5e3ba2d74daa74f30f5f143fe0c58636e355fdd"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-win32.whl", hash = "sha256:d9fad5155d72433c921b782e58892377c44bd6252b5af2f67f16b194987338a4"}, - {file = "MarkupSafe-2.1.5-cp310-cp310-win_amd64.whl", hash = "sha256:bf50cd79a75d181c9181df03572cdce0fbb75cc353bc350712073108cba98de5"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:629ddd2ca402ae6dbedfceeba9c46d5f7b2a61d9749597d4307f943ef198fc1f"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5b7b716f97b52c5a14bffdf688f971b2d5ef4029127f1ad7a513973cfd818df2"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6ec585f69cec0aa07d945b20805be741395e28ac1627333b1c5b0105962ffced"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b91c037585eba9095565a3556f611e3cbfaa42ca1e865f7b8015fe5c7336d5a5"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7502934a33b54030eaf1194c21c692a534196063db72176b0c4028e140f8f32c"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0e397ac966fdf721b2c528cf028494e86172b4feba51d65f81ffd65c63798f3f"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c061bb86a71b42465156a3ee7bd58c8c2ceacdbeb95d05a99893e08b8467359a"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3a57fdd7ce31c7ff06cdfbf31dafa96cc533c21e443d57f5b1ecc6cdc668ec7f"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-win32.whl", hash = "sha256:397081c1a0bfb5124355710fe79478cdbeb39626492b15d399526ae53422b906"}, - {file = "MarkupSafe-2.1.5-cp311-cp311-win_amd64.whl", hash = "sha256:2b7c57a4dfc4f16f7142221afe5ba4e093e09e728ca65c51f5620c9aaeb9a617"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8dec4936e9c3100156f8a2dc89c4b88d5c435175ff03413b443469c7c8c5f4d1"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:3c6b973f22eb18a789b1460b4b91bf04ae3f0c4234a0a6aa6b0a92f6f7b951d4"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ac07bad82163452a6884fe8fa0963fb98c2346ba78d779ec06bd7a6262132aee"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5dfb42c4604dddc8e4305050aa6deb084540643ed5804d7455b5df8fe16f5e5"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ea3d8a3d18833cf4304cd2fc9cbb1efe188ca9b5efef2bdac7adc20594a0e46b"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d050b3361367a06d752db6ead6e7edeb0009be66bc3bae0ee9d97fb326badc2a"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:bec0a414d016ac1a18862a519e54b2fd0fc8bbfd6890376898a6c0891dd82e9f"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:58c98fee265677f63a4385256a6d7683ab1832f3ddd1e66fe948d5880c21a169"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-win32.whl", hash = "sha256:8590b4ae07a35970728874632fed7bd57b26b0102df2d2b233b6d9d82f6c62ad"}, - {file = "MarkupSafe-2.1.5-cp312-cp312-win_amd64.whl", hash = "sha256:823b65d8706e32ad2df51ed89496147a42a2a6e01c13cfb6ffb8b1e92bc910bb"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c8b29db45f8fe46ad280a7294f5c3ec36dbac9491f2d1c17345be8e69cc5928f"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec6a563cff360b50eed26f13adc43e61bc0c04d94b8be985e6fb24b81f6dcfdf"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a549b9c31bec33820e885335b451286e2969a2d9e24879f83fe904a5ce59d70a"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4f11aa001c540f62c6166c7726f71f7573b52c68c31f014c25cc7901deea0b52"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7b2e5a267c855eea6b4283940daa6e88a285f5f2a67f2220203786dfa59b37e9"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:2d2d793e36e230fd32babe143b04cec8a8b3eb8a3122d2aceb4a371e6b09b8df"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:ce409136744f6521e39fd8e2a24c53fa18ad67aa5bc7c2cf83645cce5b5c4e50"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-win32.whl", hash = "sha256:4096e9de5c6fdf43fb4f04c26fb114f61ef0bf2e5604b6ee3019d51b69e8c371"}, - {file = "MarkupSafe-2.1.5-cp37-cp37m-win_amd64.whl", hash = "sha256:4275d846e41ecefa46e2015117a9f491e57a71ddd59bbead77e904dc02b1bed2"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:656f7526c69fac7f600bd1f400991cc282b417d17539a1b228617081106feb4a"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:97cafb1f3cbcd3fd2b6fbfb99ae11cdb14deea0736fc2b0952ee177f2b813a46"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f3fbcb7ef1f16e48246f704ab79d79da8a46891e2da03f8783a5b6fa41a9532"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fa9db3f79de01457b03d4f01b34cf91bc0048eb2c3846ff26f66687c2f6d16ab"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffee1f21e5ef0d712f9033568f8344d5da8cc2869dbd08d87c84656e6a2d2f68"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:5dedb4db619ba5a2787a94d877bc8ffc0566f92a01c0ef214865e54ecc9ee5e0"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:30b600cf0a7ac9234b2638fbc0fb6158ba5bdcdf46aeb631ead21248b9affbc4"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8dd717634f5a044f860435c1d8c16a270ddf0ef8588d4887037c5028b859b0c3"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-win32.whl", hash = "sha256:daa4ee5a243f0f20d528d939d06670a298dd39b1ad5f8a72a4275124a7819eff"}, - {file = "MarkupSafe-2.1.5-cp38-cp38-win_amd64.whl", hash = "sha256:619bc166c4f2de5caa5a633b8b7326fbe98e0ccbfacabd87268a2b15ff73a029"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7a68b554d356a91cce1236aa7682dc01df0edba8d043fd1ce607c49dd3c1edcf"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:db0b55e0f3cc0be60c1f19efdde9a637c32740486004f20d1cff53c3c0ece4d2"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e53af139f8579a6d5f7b76549125f0d94d7e630761a2111bc431fd820e163b8"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17b950fccb810b3293638215058e432159d2b71005c74371d784862b7e4683f3"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c31f53cdae6ecfa91a77820e8b151dba54ab528ba65dfd235c80b086d68a465"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:bff1b4290a66b490a2f4719358c0cdcd9bafb6b8f061e45c7a2460866bf50c2e"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:bc1667f8b83f48511b94671e0e441401371dfd0f0a795c7daa4a3cd1dde55bea"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5049256f536511ee3f7e1b3f87d1d1209d327e818e6ae1365e8653d7e3abb6a6"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-win32.whl", hash = "sha256:00e046b6dd71aa03a41079792f8473dc494d564611a8f89bbbd7cb93295ebdcf"}, - {file = "MarkupSafe-2.1.5-cp39-cp39-win_amd64.whl", hash = "sha256:fa173ec60341d6bb97a89f5ea19c85c5643c1e7dedebc22f5181eb73573142c5"}, - {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38a9ef736c01fccdd6600705b09dc574584b89bea478200c5fbf112a6b0d5579"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:57cb5a3cf367aeb1d316576250f65edec5bb3be939e9247ae594b4bcbc317dfb"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3809ede931876f5b2ec92eef964286840ed3540dadf803dd570c3b7e13141a3b"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e07c3764494e3776c602c1e78e298937c3315ccc9043ead7e685b7f2b8d47b3c"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-win32.whl", hash = "sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50"}, + {file = "MarkupSafe-3.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:6af100e168aa82a50e186c82875a5893c5597a0c1ccdb0d8b40240b1f28b969a"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2cb8438c3cbb25e220c2ab33bb226559e7afb3baec11c4f218ffa7308603c832"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a123e330ef0853c6e822384873bef7507557d8e4a082961e1defa947aa59ba84"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e084f686b92e5b83186b07e8a17fc09e38fff551f3602b249881fec658d3eca"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d8213e09c917a951de9d09ecee036d5c7d36cb6cb7dbaece4c71a60d79fb9798"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:5b02fb34468b6aaa40dfc198d813a641e3a63b98c2b05a16b9f80b7ec314185e"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-win32.whl", hash = "sha256:6c89876f41da747c8d3677a2b540fb32ef5715f97b66eeb0c6b66f5e3ef6f59d"}, + {file = "MarkupSafe-3.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:70a87b411535ccad5ef2f1df5136506a10775d267e197e4cf531ced10537bd6b"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-win32.whl", hash = "sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30"}, + {file = "MarkupSafe-3.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-win32.whl", hash = "sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1"}, + {file = "MarkupSafe-3.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-win32.whl", hash = "sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6"}, + {file = "MarkupSafe-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:eaa0a10b7f72326f1372a713e73c3f739b524b3af41feb43e4921cb529f5929a"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:48032821bbdf20f5799ff537c7ac3d1fba0ba032cfc06194faffa8cda8b560ff"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a9d3f5f0901fdec14d8d2f66ef7d035f2157240a433441719ac9a3fba440b13"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88b49a3b9ff31e19998750c38e030fc7bb937398b1f78cfa599aaef92d693144"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cfad01eed2c2e0c01fd0ecd2ef42c492f7f93902e39a42fc9ee1692961443a29"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1225beacc926f536dc82e45f8a4d68502949dc67eea90eab715dea3a21c1b5f0"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:3169b1eefae027567d1ce6ee7cae382c57fe26e82775f460f0b2778beaad66c0"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:eb7972a85c54febfb25b5c4b4f3af4dcc731994c7da0d8a0b4a6eb0640e1d178"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-win32.whl", hash = "sha256:8c4e8c3ce11e1f92f6536ff07154f9d49677ebaaafc32db9db4620bc11ed480f"}, + {file = "MarkupSafe-3.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a"}, + {file = "markupsafe-3.0.2.tar.gz", hash = "sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0"}, ] [[package]] @@ -1293,244 +1363,269 @@ files = [ [[package]] name = "more-itertools" -version = "10.2.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.2.0.tar.gz", hash = "sha256:8fccb480c43d3e99a00087634c06dd02b0d50fbf088b380de5a41a015ec239e1"}, - {file = "more_itertools-10.2.0-py3-none-any.whl", hash = "sha256:686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684"}, + {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]] name = "multidict" -version = "6.0.5" +version = "6.1.0" description = "multidict implementation" -optional = false -python-versions = ">=3.7" +optional = true +python-versions = ">=3.8" files = [ - {file = "multidict-6.0.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:228b644ae063c10e7f324ab1ab6b548bdf6f8b47f3ec234fef1093bc2735e5f9"}, - {file = "multidict-6.0.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:896ebdcf62683551312c30e20614305f53125750803b614e9e6ce74a96232604"}, - {file = "multidict-6.0.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:411bf8515f3be9813d06004cac41ccf7d1cd46dfe233705933dd163b60e37600"}, - {file = "multidict-6.0.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d147090048129ce3c453f0292e7697d333db95e52616b3793922945804a433c"}, - {file = "multidict-6.0.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:215ed703caf15f578dca76ee6f6b21b7603791ae090fbf1ef9d865571039ade5"}, - {file = "multidict-6.0.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7c6390cf87ff6234643428991b7359b5f59cc15155695deb4eda5c777d2b880f"}, - {file = "multidict-6.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21fd81c4ebdb4f214161be351eb5bcf385426bf023041da2fd9e60681f3cebae"}, - {file = "multidict-6.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3cc2ad10255f903656017363cd59436f2111443a76f996584d1077e43ee51182"}, - {file = "multidict-6.0.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6939c95381e003f54cd4c5516740faba40cf5ad3eeff460c3ad1d3e0ea2549bf"}, - {file = "multidict-6.0.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:220dd781e3f7af2c2c1053da9fa96d9cf3072ca58f057f4c5adaaa1cab8fc442"}, - {file = "multidict-6.0.5-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:766c8f7511df26d9f11cd3a8be623e59cca73d44643abab3f8c8c07620524e4a"}, - {file = "multidict-6.0.5-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:fe5d7785250541f7f5019ab9cba2c71169dc7d74d0f45253f8313f436458a4ef"}, - {file = "multidict-6.0.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c1c1496e73051918fcd4f58ff2e0f2f3066d1c76a0c6aeffd9b45d53243702cc"}, - {file = "multidict-6.0.5-cp310-cp310-win32.whl", hash = "sha256:7afcdd1fc07befad18ec4523a782cde4e93e0a2bf71239894b8d61ee578c1319"}, - {file = "multidict-6.0.5-cp310-cp310-win_amd64.whl", hash = "sha256:99f60d34c048c5c2fabc766108c103612344c46e35d4ed9ae0673d33c8fb26e8"}, - {file = "multidict-6.0.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:f285e862d2f153a70586579c15c44656f888806ed0e5b56b64489afe4a2dbfba"}, - {file = "multidict-6.0.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:53689bb4e102200a4fafa9de9c7c3c212ab40a7ab2c8e474491914d2305f187e"}, - {file = "multidict-6.0.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:612d1156111ae11d14afaf3a0669ebf6c170dbb735e510a7438ffe2369a847fd"}, - {file = "multidict-6.0.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7be7047bd08accdb7487737631d25735c9a04327911de89ff1b26b81745bd4e3"}, - {file = "multidict-6.0.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de170c7b4fe6859beb8926e84f7d7d6c693dfe8e27372ce3b76f01c46e489fcf"}, - {file = "multidict-6.0.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:04bde7a7b3de05732a4eb39c94574db1ec99abb56162d6c520ad26f83267de29"}, - {file = "multidict-6.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85f67aed7bb647f93e7520633d8f51d3cbc6ab96957c71272b286b2f30dc70ed"}, - {file = "multidict-6.0.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:425bf820055005bfc8aa9a0b99ccb52cc2f4070153e34b701acc98d201693733"}, - {file = "multidict-6.0.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:d3eb1ceec286eba8220c26f3b0096cf189aea7057b6e7b7a2e60ed36b373b77f"}, - {file = "multidict-6.0.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:7901c05ead4b3fb75113fb1dd33eb1253c6d3ee37ce93305acd9d38e0b5f21a4"}, - {file = "multidict-6.0.5-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:e0e79d91e71b9867c73323a3444724d496c037e578a0e1755ae159ba14f4f3d1"}, - {file = "multidict-6.0.5-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:29bfeb0dff5cb5fdab2023a7a9947b3b4af63e9c47cae2a10ad58394b517fddc"}, - {file = "multidict-6.0.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e030047e85cbcedbfc073f71836d62dd5dadfbe7531cae27789ff66bc551bd5e"}, - {file = "multidict-6.0.5-cp311-cp311-win32.whl", hash = "sha256:2f4848aa3baa109e6ab81fe2006c77ed4d3cd1e0ac2c1fbddb7b1277c168788c"}, - {file = "multidict-6.0.5-cp311-cp311-win_amd64.whl", hash = "sha256:2faa5ae9376faba05f630d7e5e6be05be22913782b927b19d12b8145968a85ea"}, - {file = "multidict-6.0.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:51d035609b86722963404f711db441cf7134f1889107fb171a970c9701f92e1e"}, - {file = "multidict-6.0.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:cbebcd5bcaf1eaf302617c114aa67569dd3f090dd0ce8ba9e35e9985b41ac35b"}, - {file = "multidict-6.0.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2ffc42c922dbfddb4a4c3b438eb056828719f07608af27d163191cb3e3aa6cc5"}, - {file = "multidict-6.0.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ceb3b7e6a0135e092de86110c5a74e46bda4bd4fbfeeb3a3bcec79c0f861e450"}, - {file = "multidict-6.0.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:79660376075cfd4b2c80f295528aa6beb2058fd289f4c9252f986751a4cd0496"}, - {file = "multidict-6.0.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e4428b29611e989719874670fd152b6625500ad6c686d464e99f5aaeeaca175a"}, - {file = "multidict-6.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d84a5c3a5f7ce6db1f999fb9438f686bc2e09d38143f2d93d8406ed2dd6b9226"}, - {file = "multidict-6.0.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:76c0de87358b192de7ea9649beb392f107dcad9ad27276324c24c91774ca5271"}, - {file = "multidict-6.0.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:79a6d2ba910adb2cbafc95dad936f8b9386e77c84c35bc0add315b856d7c3abb"}, - {file = "multidict-6.0.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:92d16a3e275e38293623ebf639c471d3e03bb20b8ebb845237e0d3664914caef"}, - {file = "multidict-6.0.5-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:fb616be3538599e797a2017cccca78e354c767165e8858ab5116813146041a24"}, - {file = "multidict-6.0.5-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:14c2976aa9038c2629efa2c148022ed5eb4cb939e15ec7aace7ca932f48f9ba6"}, - {file = "multidict-6.0.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:435a0984199d81ca178b9ae2c26ec3d49692d20ee29bc4c11a2a8d4514c67eda"}, - {file = "multidict-6.0.5-cp312-cp312-win32.whl", hash = "sha256:9fe7b0653ba3d9d65cbe7698cca585bf0f8c83dbbcc710db9c90f478e175f2d5"}, - {file = "multidict-6.0.5-cp312-cp312-win_amd64.whl", hash = "sha256:01265f5e40f5a17f8241d52656ed27192be03bfa8764d88e8220141d1e4b3556"}, - {file = "multidict-6.0.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:19fe01cea168585ba0f678cad6f58133db2aa14eccaf22f88e4a6dccadfad8b3"}, - {file = "multidict-6.0.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6bf7a982604375a8d49b6cc1b781c1747f243d91b81035a9b43a2126c04766f5"}, - {file = "multidict-6.0.5-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:107c0cdefe028703fb5dafe640a409cb146d44a6ae201e55b35a4af8e95457dd"}, - {file = "multidict-6.0.5-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:403c0911cd5d5791605808b942c88a8155c2592e05332d2bf78f18697a5fa15e"}, - {file = "multidict-6.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aeaf541ddbad8311a87dd695ed9642401131ea39ad7bc8cf3ef3967fd093b626"}, - {file = "multidict-6.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e4972624066095e52b569e02b5ca97dbd7a7ddd4294bf4e7247d52635630dd83"}, - {file = "multidict-6.0.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d946b0a9eb8aaa590df1fe082cee553ceab173e6cb5b03239716338629c50c7a"}, - {file = "multidict-6.0.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:b55358304d7a73d7bdf5de62494aaf70bd33015831ffd98bc498b433dfe5b10c"}, - {file = "multidict-6.0.5-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:a3145cb08d8625b2d3fee1b2d596a8766352979c9bffe5d7833e0503d0f0b5e5"}, - {file = "multidict-6.0.5-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:d65f25da8e248202bd47445cec78e0025c0fe7582b23ec69c3b27a640dd7a8e3"}, - {file = "multidict-6.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c9bf56195c6bbd293340ea82eafd0071cb3d450c703d2c93afb89f93b8386ccc"}, - {file = "multidict-6.0.5-cp37-cp37m-win32.whl", hash = "sha256:69db76c09796b313331bb7048229e3bee7928eb62bab5e071e9f7fcc4879caee"}, - {file = "multidict-6.0.5-cp37-cp37m-win_amd64.whl", hash = "sha256:fce28b3c8a81b6b36dfac9feb1de115bab619b3c13905b419ec71d03a3fc1423"}, - {file = "multidict-6.0.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:76f067f5121dcecf0d63a67f29080b26c43c71a98b10c701b0677e4a065fbd54"}, - {file = "multidict-6.0.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b82cc8ace10ab5bd93235dfaab2021c70637005e1ac787031f4d1da63d493c1d"}, - {file = "multidict-6.0.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5cb241881eefd96b46f89b1a056187ea8e9ba14ab88ba632e68d7a2ecb7aadf7"}, - {file = "multidict-6.0.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8e94e6912639a02ce173341ff62cc1201232ab86b8a8fcc05572741a5dc7d93"}, - {file = "multidict-6.0.5-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:09a892e4a9fb47331da06948690ae38eaa2426de97b4ccbfafbdcbe5c8f37ff8"}, - {file = "multidict-6.0.5-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:55205d03e8a598cfc688c71ca8ea5f66447164efff8869517f175ea632c7cb7b"}, - {file = "multidict-6.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:37b15024f864916b4951adb95d3a80c9431299080341ab9544ed148091b53f50"}, - {file = "multidict-6.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2a1dee728b52b33eebff5072817176c172050d44d67befd681609b4746e1c2e"}, - {file = "multidict-6.0.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:edd08e6f2f1a390bf137080507e44ccc086353c8e98c657e666c017718561b89"}, - {file = "multidict-6.0.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:60d698e8179a42ec85172d12f50b1668254628425a6bd611aba022257cac1386"}, - {file = "multidict-6.0.5-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:3d25f19500588cbc47dc19081d78131c32637c25804df8414463ec908631e453"}, - {file = "multidict-6.0.5-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:4cc0ef8b962ac7a5e62b9e826bd0cd5040e7d401bc45a6835910ed699037a461"}, - {file = "multidict-6.0.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:eca2e9d0cc5a889850e9bbd68e98314ada174ff6ccd1129500103df7a94a7a44"}, - {file = "multidict-6.0.5-cp38-cp38-win32.whl", hash = "sha256:4a6a4f196f08c58c59e0b8ef8ec441d12aee4125a7d4f4fef000ccb22f8d7241"}, - {file = "multidict-6.0.5-cp38-cp38-win_amd64.whl", hash = "sha256:0275e35209c27a3f7951e1ce7aaf93ce0d163b28948444bec61dd7badc6d3f8c"}, - {file = "multidict-6.0.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:e7be68734bd8c9a513f2b0cfd508802d6609da068f40dc57d4e3494cefc92929"}, - {file = "multidict-6.0.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1d9ea7a7e779d7a3561aade7d596649fbecfa5c08a7674b11b423783217933f9"}, - {file = "multidict-6.0.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ea1456df2a27c73ce51120fa2f519f1bea2f4a03a917f4a43c8707cf4cbbae1a"}, - {file = "multidict-6.0.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cf590b134eb70629e350691ecca88eac3e3b8b3c86992042fb82e3cb1830d5e1"}, - {file = "multidict-6.0.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5c0631926c4f58e9a5ccce555ad7747d9a9f8b10619621f22f9635f069f6233e"}, - {file = "multidict-6.0.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dce1c6912ab9ff5f179eaf6efe7365c1f425ed690b03341911bf4939ef2f3046"}, - {file = "multidict-6.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0868d64af83169e4d4152ec612637a543f7a336e4a307b119e98042e852ad9c"}, - {file = "multidict-6.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:141b43360bfd3bdd75f15ed811850763555a251e38b2405967f8e25fb43f7d40"}, - {file = "multidict-6.0.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:7df704ca8cf4a073334e0427ae2345323613e4df18cc224f647f251e5e75a527"}, - {file = "multidict-6.0.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:6214c5a5571802c33f80e6c84713b2c79e024995b9c5897f794b43e714daeec9"}, - {file = "multidict-6.0.5-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:cd6c8fca38178e12c00418de737aef1261576bd1b6e8c6134d3e729a4e858b38"}, - {file = "multidict-6.0.5-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:e02021f87a5b6932fa6ce916ca004c4d441509d33bbdbeca70d05dff5e9d2479"}, - {file = "multidict-6.0.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ebd8d160f91a764652d3e51ce0d2956b38efe37c9231cd82cfc0bed2e40b581c"}, - {file = "multidict-6.0.5-cp39-cp39-win32.whl", hash = "sha256:04da1bb8c8dbadf2a18a452639771951c662c5ad03aefe4884775454be322c9b"}, - {file = "multidict-6.0.5-cp39-cp39-win_amd64.whl", hash = "sha256:d6f6d4f185481c9669b9447bf9d9cf3b95a0e9df9d169bbc17e363b7d5487755"}, - {file = "multidict-6.0.5-py3-none-any.whl", hash = "sha256:0d63c74e3d7ab26de115c49bffc92cc77ed23395303d496eae515d4204a625e7"}, - {file = "multidict-6.0.5.tar.gz", hash = "sha256:f7e301075edaf50500f0b341543c41194d8df3ae5caf4702f2095f3ca73dd8da"}, + {file = "multidict-6.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3380252550e372e8511d49481bd836264c009adb826b23fefcc5dd3c69692f60"}, + {file = "multidict-6.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:99f826cbf970077383d7de805c0681799491cb939c25450b9b5b3ced03ca99f1"}, + {file = "multidict-6.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a114d03b938376557927ab23f1e950827c3b893ccb94b62fd95d430fd0e5cf53"}, + {file = "multidict-6.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1c416351ee6271b2f49b56ad7f308072f6f44b37118d69c2cad94f3fa8a40d5"}, + {file = "multidict-6.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6b5d83030255983181005e6cfbac1617ce9746b219bc2aad52201ad121226581"}, + {file = "multidict-6.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3e97b5e938051226dc025ec80980c285b053ffb1e25a3db2a3aa3bc046bf7f56"}, + {file = "multidict-6.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d618649d4e70ac6efcbba75be98b26ef5078faad23592f9b51ca492953012429"}, + {file = "multidict-6.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:10524ebd769727ac77ef2278390fb0068d83f3acb7773792a5080f2b0abf7748"}, + {file = "multidict-6.1.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ff3827aef427c89a25cc96ded1759271a93603aba9fb977a6d264648ebf989db"}, + {file = "multidict-6.1.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:06809f4f0f7ab7ea2cabf9caca7d79c22c0758b58a71f9d32943ae13c7ace056"}, + {file = "multidict-6.1.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:f179dee3b863ab1c59580ff60f9d99f632f34ccb38bf67a33ec6b3ecadd0fd76"}, + {file = "multidict-6.1.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:aaed8b0562be4a0876ee3b6946f6869b7bcdb571a5d1496683505944e268b160"}, + {file = "multidict-6.1.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:3c8b88a2ccf5493b6c8da9076fb151ba106960a2df90c2633f342f120751a9e7"}, + {file = "multidict-6.1.0-cp310-cp310-win32.whl", hash = "sha256:4a9cb68166a34117d6646c0023c7b759bf197bee5ad4272f420a0141d7eb03a0"}, + {file = "multidict-6.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:20b9b5fbe0b88d0bdef2012ef7dee867f874b72528cf1d08f1d59b0e3850129d"}, + {file = "multidict-6.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:3efe2c2cb5763f2f1b275ad2bf7a287d3f7ebbef35648a9726e3b69284a4f3d6"}, + {file = "multidict-6.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c7053d3b0353a8b9de430a4f4b4268ac9a4fb3481af37dfe49825bf45ca24156"}, + {file = "multidict-6.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:27e5fc84ccef8dfaabb09d82b7d179c7cf1a3fbc8a966f8274fcb4ab2eb4cadb"}, + {file = "multidict-6.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0e2b90b43e696f25c62656389d32236e049568b39320e2735d51f08fd362761b"}, + {file = "multidict-6.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d83a047959d38a7ff552ff94be767b7fd79b831ad1cd9920662db05fec24fe72"}, + {file = "multidict-6.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d1a9dd711d0877a1ece3d2e4fea11a8e75741ca21954c919406b44e7cf971304"}, + {file = "multidict-6.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ec2abea24d98246b94913b76a125e855eb5c434f7c46546046372fe60f666351"}, + {file = "multidict-6.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4867cafcbc6585e4b678876c489b9273b13e9fff9f6d6d66add5e15d11d926cb"}, + {file = "multidict-6.1.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5b48204e8d955c47c55b72779802b219a39acc3ee3d0116d5080c388970b76e3"}, + {file = "multidict-6.1.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:d8fff389528cad1618fb4b26b95550327495462cd745d879a8c7c2115248e399"}, + {file = "multidict-6.1.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:a7a9541cd308eed5e30318430a9c74d2132e9a8cb46b901326272d780bf2d423"}, + {file = "multidict-6.1.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:da1758c76f50c39a2efd5e9859ce7d776317eb1dd34317c8152ac9251fc574a3"}, + {file = "multidict-6.1.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:c943a53e9186688b45b323602298ab727d8865d8c9ee0b17f8d62d14b56f0753"}, + {file = "multidict-6.1.0-cp311-cp311-win32.whl", hash = "sha256:90f8717cb649eea3504091e640a1b8568faad18bd4b9fcd692853a04475a4b80"}, + {file = "multidict-6.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:82176036e65644a6cc5bd619f65f6f19781e8ec2e5330f51aa9ada7504cc1926"}, + {file = "multidict-6.1.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:b04772ed465fa3cc947db808fa306d79b43e896beb677a56fb2347ca1a49c1fa"}, + {file = "multidict-6.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6180c0ae073bddeb5a97a38c03f30c233e0a4d39cd86166251617d1bbd0af436"}, + {file = "multidict-6.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:071120490b47aa997cca00666923a83f02c7fbb44f71cf7f136df753f7fa8761"}, + {file = "multidict-6.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50b3a2710631848991d0bf7de077502e8994c804bb805aeb2925a981de58ec2e"}, + {file = "multidict-6.1.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b58c621844d55e71c1b7f7c498ce5aa6985d743a1a59034c57a905b3f153c1ef"}, + {file = "multidict-6.1.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:55b6d90641869892caa9ca42ff913f7ff1c5ece06474fbd32fb2cf6834726c95"}, + {file = "multidict-6.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b820514bfc0b98a30e3d85462084779900347e4d49267f747ff54060cc33925"}, + {file = "multidict-6.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:10a9b09aba0c5b48c53761b7c720aaaf7cf236d5fe394cd399c7ba662d5f9966"}, + {file = "multidict-6.1.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1e16bf3e5fc9f44632affb159d30a437bfe286ce9e02754759be5536b169b305"}, + {file = "multidict-6.1.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:76f364861c3bfc98cbbcbd402d83454ed9e01a5224bb3a28bf70002a230f73e2"}, + {file = "multidict-6.1.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:820c661588bd01a0aa62a1283f20d2be4281b086f80dad9e955e690c75fb54a2"}, + {file = "multidict-6.1.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:0e5f362e895bc5b9e67fe6e4ded2492d8124bdf817827f33c5b46c2fe3ffaca6"}, + {file = "multidict-6.1.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3ec660d19bbc671e3a6443325f07263be452c453ac9e512f5eb935e7d4ac28b3"}, + {file = "multidict-6.1.0-cp312-cp312-win32.whl", hash = "sha256:58130ecf8f7b8112cdb841486404f1282b9c86ccb30d3519faf301b2e5659133"}, + {file = "multidict-6.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:188215fc0aafb8e03341995e7c4797860181562380f81ed0a87ff455b70bf1f1"}, + {file = "multidict-6.1.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:d569388c381b24671589335a3be6e1d45546c2988c2ebe30fdcada8457a31008"}, + {file = "multidict-6.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:052e10d2d37810b99cc170b785945421141bf7bb7d2f8799d431e7db229c385f"}, + {file = "multidict-6.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f90c822a402cb865e396a504f9fc8173ef34212a342d92e362ca498cad308e28"}, + {file = "multidict-6.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b225d95519a5bf73860323e633a664b0d85ad3d5bede6d30d95b35d4dfe8805b"}, + {file = "multidict-6.1.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:23bfd518810af7de1116313ebd9092cb9aa629beb12f6ed631ad53356ed6b86c"}, + {file = "multidict-6.1.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5c09fcfdccdd0b57867577b719c69e347a436b86cd83747f179dbf0cc0d4c1f3"}, + {file = "multidict-6.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf6bea52ec97e95560af5ae576bdac3aa3aae0b6758c6efa115236d9e07dae44"}, + {file = "multidict-6.1.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:57feec87371dbb3520da6192213c7d6fc892d5589a93db548331954de8248fd2"}, + {file = "multidict-6.1.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0c3f390dc53279cbc8ba976e5f8035eab997829066756d811616b652b00a23a3"}, + {file = "multidict-6.1.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:59bfeae4b25ec05b34f1956eaa1cb38032282cd4dfabc5056d0a1ec4d696d3aa"}, + {file = "multidict-6.1.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:b2f59caeaf7632cc633b5cf6fc449372b83bbdf0da4ae04d5be36118e46cc0aa"}, + {file = "multidict-6.1.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:37bb93b2178e02b7b618893990941900fd25b6b9ac0fa49931a40aecdf083fe4"}, + {file = "multidict-6.1.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4e9f48f58c2c523d5a06faea47866cd35b32655c46b443f163d08c6d0ddb17d6"}, + {file = "multidict-6.1.0-cp313-cp313-win32.whl", hash = "sha256:3a37ffb35399029b45c6cc33640a92bef403c9fd388acce75cdc88f58bd19a81"}, + {file = "multidict-6.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:e9aa71e15d9d9beaad2c6b9319edcdc0a49a43ef5c0a4c8265ca9ee7d6c67774"}, + {file = "multidict-6.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:db7457bac39421addd0c8449933ac32d8042aae84a14911a757ae6ca3eef1392"}, + {file = "multidict-6.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d094ddec350a2fb899fec68d8353c78233debde9b7d8b4beeafa70825f1c281a"}, + {file = "multidict-6.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5845c1fd4866bb5dd3125d89b90e57ed3138241540897de748cdf19de8a2fca2"}, + {file = "multidict-6.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9079dfc6a70abe341f521f78405b8949f96db48da98aeb43f9907f342f627cdc"}, + {file = "multidict-6.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3914f5aaa0f36d5d60e8ece6a308ee1c9784cd75ec8151062614657a114c4478"}, + {file = "multidict-6.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c08be4f460903e5a9d0f76818db3250f12e9c344e79314d1d570fc69d7f4eae4"}, + {file = "multidict-6.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d093be959277cb7dee84b801eb1af388b6ad3ca6a6b6bf1ed7585895789d027d"}, + {file = "multidict-6.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3702ea6872c5a2a4eeefa6ffd36b042e9773f05b1f37ae3ef7264b1163c2dcf6"}, + {file = "multidict-6.1.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:2090f6a85cafc5b2db085124d752757c9d251548cedabe9bd31afe6363e0aff2"}, + {file = "multidict-6.1.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:f67f217af4b1ff66c68a87318012de788dd95fcfeb24cc889011f4e1c7454dfd"}, + {file = "multidict-6.1.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:189f652a87e876098bbc67b4da1049afb5f5dfbaa310dd67c594b01c10388db6"}, + {file = "multidict-6.1.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:6bb5992037f7a9eff7991ebe4273ea7f51f1c1c511e6a2ce511d0e7bdb754492"}, + {file = "multidict-6.1.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:ac10f4c2b9e770c4e393876e35a7046879d195cd123b4f116d299d442b335bcd"}, + {file = "multidict-6.1.0-cp38-cp38-win32.whl", hash = "sha256:e27bbb6d14416713a8bd7aaa1313c0fc8d44ee48d74497a0ff4c3a1b6ccb5167"}, + {file = "multidict-6.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:22f3105d4fb15c8f57ff3959a58fcab6ce36814486500cd7485651230ad4d4ef"}, + {file = "multidict-6.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:4e18b656c5e844539d506a0a06432274d7bd52a7487e6828c63a63d69185626c"}, + {file = "multidict-6.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a185f876e69897a6f3325c3f19f26a297fa058c5e456bfcff8015e9a27e83ae1"}, + {file = "multidict-6.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ab7c4ceb38d91570a650dba194e1ca87c2b543488fe9309b4212694174fd539c"}, + {file = "multidict-6.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e617fb6b0b6953fffd762669610c1c4ffd05632c138d61ac7e14ad187870669c"}, + {file = "multidict-6.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:16e5f4bf4e603eb1fdd5d8180f1a25f30056f22e55ce51fb3d6ad4ab29f7d96f"}, + {file = "multidict-6.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f4c035da3f544b1882bac24115f3e2e8760f10a0107614fc9839fd232200b875"}, + {file = "multidict-6.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:957cf8e4b6e123a9eea554fa7ebc85674674b713551de587eb318a2df3e00255"}, + {file = "multidict-6.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:483a6aea59cb89904e1ceabd2b47368b5600fb7de78a6e4a2c2987b2d256cf30"}, + {file = "multidict-6.1.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:87701f25a2352e5bf7454caa64757642734da9f6b11384c1f9d1a8e699758057"}, + {file = "multidict-6.1.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:682b987361e5fd7a139ed565e30d81fd81e9629acc7d925a205366877d8c8657"}, + {file = "multidict-6.1.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:ce2186a7df133a9c895dea3331ddc5ddad42cdd0d1ea2f0a51e5d161e4762f28"}, + {file = "multidict-6.1.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:9f636b730f7e8cb19feb87094949ba54ee5357440b9658b2a32a5ce4bce53972"}, + {file = "multidict-6.1.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:73eae06aa53af2ea5270cc066dcaf02cc60d2994bbb2c4ef5764949257d10f43"}, + {file = "multidict-6.1.0-cp39-cp39-win32.whl", hash = "sha256:1ca0083e80e791cffc6efce7660ad24af66c8d4079d2a750b29001b53ff59ada"}, + {file = "multidict-6.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:aa466da5b15ccea564bdab9c89175c762bc12825f4659c11227f515cee76fa4a"}, + {file = "multidict-6.1.0-py3-none-any.whl", hash = "sha256:48e171e52d1c4d33888e529b999e5900356b9ae588c2f09a52dcefb158b27506"}, + {file = "multidict-6.1.0.tar.gz", hash = "sha256:22ae2ebf9b0c69d206c003e2f6a914ea33f0a932d4aa16f236afc049d9958f4a"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] +[package.dependencies] +typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.11\""} [[package]] name = "nh3" -version = "0.2.17" +version = "0.2.18" description = "Python bindings to the ammonia HTML sanitization library." optional = false python-versions = "*" files = [ - {file = "nh3-0.2.17-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:551672fd71d06cd828e282abdb810d1be24e1abb7ae2543a8fa36a71c1006fe9"}, - {file = "nh3-0.2.17-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:c551eb2a3876e8ff2ac63dff1585236ed5dfec5ffd82216a7a174f7c5082a78a"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:66f17d78826096291bd264f260213d2b3905e3c7fae6dfc5337d49429f1dc9f3"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0316c25b76289cf23be6b66c77d3608a4fdf537b35426280032f432f14291b9a"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:22c26e20acbb253a5bdd33d432a326d18508a910e4dcf9a3316179860d53345a"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:85cdbcca8ef10733bd31f931956f7fbb85145a4d11ab9e6742bbf44d88b7e351"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:40015514022af31975c0b3bca4014634fa13cb5dc4dbcbc00570acc781316dcc"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ba73a2f8d3a1b966e9cdba7b211779ad8a2561d2dba9674b8a19ed817923f65f"}, - {file = "nh3-0.2.17-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c21bac1a7245cbd88c0b0e4a420221b7bfa838a2814ee5bb924e9c2f10a1120b"}, - {file = "nh3-0.2.17-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d7a25fd8c86657f5d9d576268e3b3767c5cd4f42867c9383618be8517f0f022a"}, - {file = "nh3-0.2.17-cp37-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:c790769152308421283679a142dbdb3d1c46c79c823008ecea8e8141db1a2062"}, - {file = "nh3-0.2.17-cp37-abi3-musllinux_1_2_i686.whl", hash = "sha256:b4427ef0d2dfdec10b641ed0bdaf17957eb625b2ec0ea9329b3d28806c153d71"}, - {file = "nh3-0.2.17-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a3f55fabe29164ba6026b5ad5c3151c314d136fd67415a17660b4aaddacf1b10"}, - {file = "nh3-0.2.17-cp37-abi3-win32.whl", hash = "sha256:1a814dd7bba1cb0aba5bcb9bebcc88fd801b63e21e2450ae6c52d3b3336bc911"}, - {file = "nh3-0.2.17-cp37-abi3-win_amd64.whl", hash = "sha256:1aa52a7def528297f256de0844e8dd680ee279e79583c76d6fa73a978186ddfb"}, - {file = "nh3-0.2.17.tar.gz", hash = "sha256:40d0741a19c3d645e54efba71cb0d8c475b59135c1e3c580f879ad5514cbf028"}, + {file = "nh3-0.2.18-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:14c5a72e9fe82aea5fe3072116ad4661af5cf8e8ff8fc5ad3450f123e4925e86"}, + {file = "nh3-0.2.18-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:7b7c2a3c9eb1a827d42539aa64091640bd275b81e097cd1d8d82ef91ffa2e811"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42c64511469005058cd17cc1537578eac40ae9f7200bedcfd1fc1a05f4f8c200"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0411beb0589eacb6734f28d5497ca2ed379eafab8ad8c84b31bb5c34072b7164"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5f36b271dae35c465ef5e9090e1fdaba4a60a56f0bb0ba03e0932a66f28b9189"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:34c03fa78e328c691f982b7c03d4423bdfd7da69cd707fe572f544cf74ac23ad"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19aaba96e0f795bd0a6c56291495ff59364f4300d4a39b29a0abc9cb3774a84b"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de3ceed6e661954871d6cd78b410213bdcb136f79aafe22aa7182e028b8c7307"}, + {file = "nh3-0.2.18-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6955369e4d9f48f41e3f238a9e60f9410645db7e07435e62c6a9ea6135a4907f"}, + {file = "nh3-0.2.18-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:f0eca9ca8628dbb4e916ae2491d72957fdd35f7a5d326b7032a345f111ac07fe"}, + {file = "nh3-0.2.18-cp37-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:3a157ab149e591bb638a55c8c6bcb8cdb559c8b12c13a8affaba6cedfe51713a"}, + {file = "nh3-0.2.18-cp37-abi3-musllinux_1_2_i686.whl", hash = "sha256:c8b3a1cebcba9b3669ed1a84cc65bf005728d2f0bc1ed2a6594a992e817f3a50"}, + {file = "nh3-0.2.18-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:36c95d4b70530b320b365659bb5034341316e6a9b30f0b25fa9c9eff4c27a204"}, + {file = "nh3-0.2.18-cp37-abi3-win32.whl", hash = "sha256:a7f1b5b2c15866f2db413a3649a8fe4fd7b428ae58be2c0f6bca5eefd53ca2be"}, + {file = "nh3-0.2.18-cp37-abi3-win_amd64.whl", hash = "sha256:8ce0f819d2f1933953fca255db2471ad58184a60508f03e6285e5114b6254844"}, + {file = "nh3-0.2.18.tar.gz", hash = "sha256:94a166927e53972a9698af9542ace4e38b9de50c34352b962f4d9a7d4c927af4"}, ] [[package]] name = "nodeenv" -version = "1.8.0" +version = "1.9.1" description = "Node.js virtual environment builder" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ - {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, - {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, -] - -[package.dependencies] -setuptools = "*" - -[[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"}, + {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, + {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, ] [[package]] name = "numpy" -version = "1.26.4" +version = "2.0.2" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.9" files = [ - {file = "numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0"}, - {file = "numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2e4ee3380d6de9c9ec04745830fd9e2eccb3e6cf790d39d7b98ffd19b0dd754a"}, - {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d209d8969599b27ad20994c8e41936ee0964e6da07478d6c35016bc386b66ad4"}, - {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f"}, - {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:62b8e4b1e28009ef2846b4c7852046736bab361f7aeadeb6a5b89ebec3c7055a"}, - {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a4abb4f9001ad2858e7ac189089c42178fcce737e4169dc61321660f1a96c7d2"}, - {file = "numpy-1.26.4-cp310-cp310-win32.whl", hash = "sha256:bfe25acf8b437eb2a8b2d49d443800a5f18508cd811fea3181723922a8a82b07"}, - {file = "numpy-1.26.4-cp310-cp310-win_amd64.whl", hash = "sha256:b97fe8060236edf3662adfc2c633f56a08ae30560c56310562cb4f95500022d5"}, - {file = "numpy-1.26.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c66707fabe114439db9068ee468c26bbdf909cac0fb58686a42a24de1760c71"}, - {file = "numpy-1.26.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:96ff0b2ad353d8f990b63294c8986f1ec3cb19d749234014f4e7eb0112ceba5a"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:60dedbb91afcbfdc9bc0b1f3f402804070deed7392c23eb7a7f07fa857868e8a"}, - {file = "numpy-1.26.4-cp311-cp311-win32.whl", hash = "sha256:1af303d6b2210eb850fcf03064d364652b7120803a0b872f5211f5234b399f20"}, - {file = "numpy-1.26.4-cp311-cp311-win_amd64.whl", hash = "sha256:cd25bcecc4974d09257ffcd1f098ee778f7834c3ad767fe5db785be9a4aa9cb2"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b3ce300f3644fb06443ee2222c2201dd3a89ea6040541412b8fa189341847218"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ab47dbe5cc8210f55aa58e4805fe224dac469cde56b9f731a4c098b91917159a"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1dda2e7b4ec9dd512f84935c5f126c8bd8b9f2fc001e9f54af255e8c5f16b0e0"}, - {file = "numpy-1.26.4-cp312-cp312-win32.whl", hash = "sha256:50193e430acfc1346175fcbdaa28ffec49947a06918b7b92130744e81e640110"}, - {file = "numpy-1.26.4-cp312-cp312-win_amd64.whl", hash = "sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818"}, - {file = "numpy-1.26.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7349ab0fa0c429c82442a27a9673fc802ffdb7c7775fad780226cb234965e53c"}, - {file = "numpy-1.26.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:52b8b60467cd7dd1e9ed082188b4e6bb35aa5cdd01777621a1658910745b90be"}, - {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5241e0a80d808d70546c697135da2c613f30e28251ff8307eb72ba696945764"}, - {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3"}, - {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:679b0076f67ecc0138fd2ede3a8fd196dddc2ad3254069bcb9faf9a79b1cebcd"}, - {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:47711010ad8555514b434df65f7d7b076bb8261df1ca9bb78f53d3b2db02e95c"}, - {file = "numpy-1.26.4-cp39-cp39-win32.whl", hash = "sha256:a354325ee03388678242a4d7ebcd08b5c727033fcff3b2f536aea978e15ee9e6"}, - {file = "numpy-1.26.4-cp39-cp39-win_amd64.whl", hash = "sha256:3373d5d70a5fe74a2c1bb6d2cfd9609ecf686d47a2d7b1d37a8f3b6bf6003aea"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:afedb719a9dcfc7eaf2287b839d8198e06dcd4cb5d276a3df279231138e83d30"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95a7476c59002f2f6c590b9b7b998306fba6a5aa646b1e22ddfeaf8f78c3a29c"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7e50d0a0cc3189f9cb0aeb3a6a6af18c16f59f004b866cd2be1c14b36134a4a0"}, - {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:8c5713284ce4e282544c68d1c3b2c7161d38c256d2eefc93c1d683cf47683e66"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:becfae3ddd30736fe1889a37f1f580e245ba79a5855bff5f2a29cb3ccc22dd7b"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2da5960c3cf0df7eafefd806d4e612c5e19358de82cb3c343631188991566ccd"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a61ec659f68ae254e4d237816e33171497e978140353c0c2038d46e63282d0c8"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d731a1c6116ba289c1e9ee714b08a8ff882944d4ad631fd411106a30f083c326"}, + {file = "numpy-2.0.2-cp310-cp310-win32.whl", hash = "sha256:984d96121c9f9616cd33fbd0618b7f08e0cfc9600a7ee1d6fd9b239186d19d97"}, + {file = "numpy-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:c7b0be4ef08607dd04da4092faee0b86607f111d5ae68036f16cc787e250a131"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:49ca4decb342d66018b01932139c0961a8f9ddc7589611158cb3c27cbcf76448"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:11a76c372d1d37437857280aa142086476136a8c0f373b2e648ab2c8f18fb195"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:807ec44583fd708a21d4a11d94aedf2f4f3c3719035c76a2bbe1fe8e217bdc57"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:8cafab480740e22f8d833acefed5cc87ce276f4ece12fdaa2e8903db2f82897a"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a15f476a45e6e5a3a79d8a14e62161d27ad897381fecfa4a09ed5322f2085669"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13e689d772146140a252c3a28501da66dfecd77490b498b168b501835041f951"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9ea91dfb7c3d1c56a0e55657c0afb38cf1eeae4544c208dc465c3c9f3a7c09f9"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c1c9307701fec8f3f7a1e6711f9089c06e6284b3afbbcd259f7791282d660a15"}, + {file = "numpy-2.0.2-cp311-cp311-win32.whl", hash = "sha256:a392a68bd329eafac5817e5aefeb39038c48b671afd242710b451e76090e81f4"}, + {file = "numpy-2.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:286cd40ce2b7d652a6f22efdfc6d1edf879440e53e76a75955bc0c826c7e64dc"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:df55d490dea7934f330006d0f81e8551ba6010a5bf035a249ef61a94f21c500b"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8df823f570d9adf0978347d1f926b2a867d5608f434a7cff7f7908c6570dcf5e"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9a92ae5c14811e390f3767053ff54eaee3bf84576d99a2456391401323f4ec2c"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:a842d573724391493a97a62ebbb8e731f8a5dcc5d285dfc99141ca15a3302d0c"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c05e238064fc0610c840d1cf6a13bf63d7e391717d247f1bf0318172e759e692"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:96a55f64139912d61de9137f11bf39a55ec8faec288c75a54f93dfd39f7eb40c"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ec9852fb39354b5a45a80bdab5ac02dd02b15f44b3804e9f00c556bf24b4bded"}, + {file = "numpy-2.0.2-cp312-cp312-win32.whl", hash = "sha256:671bec6496f83202ed2d3c8fdc486a8fc86942f2e69ff0e986140339a63bcbe5"}, + {file = "numpy-2.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:cfd41e13fdc257aa5778496b8caa5e856dc4896d4ccf01841daee1d96465467a"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9059e10581ce4093f735ed23f3b9d283b9d517ff46009ddd485f1747eb22653c"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:423e89b23490805d2a5a96fe40ec507407b8ee786d66f7328be214f9679df6dd"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:2b2955fa6f11907cf7a70dab0d0755159bca87755e831e47932367fc8f2f2d0b"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:97032a27bd9d8988b9a97a8c4d2c9f2c15a81f61e2f21404d7e8ef00cb5be729"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e795a8be3ddbac43274f18588329c72939870a16cae810c2b73461c40718ab1"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f26b258c385842546006213344c50655ff1555a9338e2e5e02a0756dc3e803dd"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fec9451a7789926bcf7c2b8d187292c9f93ea30284802a0ab3f5be8ab36865d"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9189427407d88ff25ecf8f12469d4d39d35bee1db5d39fc5c168c6f088a6956d"}, + {file = "numpy-2.0.2-cp39-cp39-win32.whl", hash = "sha256:905d16e0c60200656500c95b6b8dca5d109e23cb24abc701d41c02d74c6b3afa"}, + {file = "numpy-2.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:a3f4ab0caa7f053f6797fcd4e1e25caee367db3112ef2b6ef82d749530768c73"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7f0a0c6f12e07fa94133c8a67404322845220c06a9e80e85999afe727f7438b8"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:312950fdd060354350ed123c0e25a71327d3711584beaef30cdaa93320c392d4"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26df23238872200f63518dd2aa984cfca675d82469535dc7162dc2ee52d9dd5c"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a46288ec55ebbd58947d31d72be2c63cbf839f0a63b49cb755022310792a3385"}, + {file = "numpy-2.0.2.tar.gz", hash = "sha256:883c987dee1880e2a864ab0dc9892292582510604156762362d9326444636e78"}, +] + +[[package]] +name = "numpy" +version = "2.1.2" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.10" +files = [ + {file = "numpy-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:30d53720b726ec36a7f88dc873f0eec8447fbc93d93a8f079dfac2629598d6ee"}, + {file = "numpy-2.1.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8d3ca0a72dd8846eb6f7dfe8f19088060fcb76931ed592d29128e0219652884"}, + {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:fc44e3c68ff00fd991b59092a54350e6e4911152682b4782f68070985aa9e648"}, + {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:7c1c60328bd964b53f8b835df69ae8198659e2b9302ff9ebb7de4e5a5994db3d"}, + {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cdb606a7478f9ad91c6283e238544451e3a95f30fb5467fbf715964341a8a86"}, + {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d666cb72687559689e9906197e3bec7b736764df6a2e58ee265e360663e9baf7"}, + {file = "numpy-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c6eef7a2dbd0abfb0d9eaf78b73017dbfd0b54051102ff4e6a7b2980d5ac1a03"}, + {file = "numpy-2.1.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:12edb90831ff481f7ef5f6bc6431a9d74dc0e5ff401559a71e5e4611d4f2d466"}, + {file = "numpy-2.1.2-cp310-cp310-win32.whl", hash = "sha256:a65acfdb9c6ebb8368490dbafe83c03c7e277b37e6857f0caeadbbc56e12f4fb"}, + {file = "numpy-2.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:860ec6e63e2c5c2ee5e9121808145c7bf86c96cca9ad396c0bd3e0f2798ccbe2"}, + {file = "numpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b42a1a511c81cc78cbc4539675713bbcf9d9c3913386243ceff0e9429ca892fe"}, + {file = "numpy-2.1.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:faa88bc527d0f097abdc2c663cddf37c05a1c2f113716601555249805cf573f1"}, + {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:c82af4b2ddd2ee72d1fc0c6695048d457e00b3582ccde72d8a1c991b808bb20f"}, + {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:13602b3174432a35b16c4cfb5de9a12d229727c3dd47a6ce35111f2ebdf66ff4"}, + {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ebec5fd716c5a5b3d8dfcc439be82a8407b7b24b230d0ad28a81b61c2f4659a"}, + {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2b49c3c0804e8ecb05d59af8386ec2f74877f7ca8fd9c1e00be2672e4d399b1"}, + {file = "numpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2cbba4b30bf31ddbe97f1c7205ef976909a93a66bb1583e983adbd155ba72ac2"}, + {file = "numpy-2.1.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8e00ea6fc82e8a804433d3e9cedaa1051a1422cb6e443011590c14d2dea59146"}, + {file = "numpy-2.1.2-cp311-cp311-win32.whl", hash = "sha256:5006b13a06e0b38d561fab5ccc37581f23c9511879be7693bd33c7cd15ca227c"}, + {file = "numpy-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:f1eb068ead09f4994dec71c24b2844f1e4e4e013b9629f812f292f04bd1510d9"}, + {file = "numpy-2.1.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7bf0a4f9f15b32b5ba53147369e94296f5fffb783db5aacc1be15b4bf72f43b"}, + {file = "numpy-2.1.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b1d0fcae4f0949f215d4632be684a539859b295e2d0cb14f78ec231915d644db"}, + {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:f751ed0a2f250541e19dfca9f1eafa31a392c71c832b6bb9e113b10d050cb0f1"}, + {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:bd33f82e95ba7ad632bc57837ee99dba3d7e006536200c4e9124089e1bf42426"}, + {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b8cde4f11f0a975d1fd59373b32e2f5a562ade7cde4f85b7137f3de8fbb29a0"}, + {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d95f286b8244b3649b477ac066c6906fbb2905f8ac19b170e2175d3d799f4df"}, + {file = "numpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ab4754d432e3ac42d33a269c8567413bdb541689b02d93788af4131018cbf366"}, + {file = "numpy-2.1.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e585c8ae871fd38ac50598f4763d73ec5497b0de9a0ab4ef5b69f01c6a046142"}, + {file = "numpy-2.1.2-cp312-cp312-win32.whl", hash = "sha256:9c6c754df29ce6a89ed23afb25550d1c2d5fdb9901d9c67a16e0b16eaf7e2550"}, + {file = "numpy-2.1.2-cp312-cp312-win_amd64.whl", hash = "sha256:456e3b11cb79ac9946c822a56346ec80275eaf2950314b249b512896c0d2505e"}, + {file = "numpy-2.1.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a84498e0d0a1174f2b3ed769b67b656aa5460c92c9554039e11f20a05650f00d"}, + {file = "numpy-2.1.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4d6ec0d4222e8ffdab1744da2560f07856421b367928026fb540e1945f2eeeaf"}, + {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:259ec80d54999cc34cd1eb8ded513cb053c3bf4829152a2e00de2371bd406f5e"}, + {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:675c741d4739af2dc20cd6c6a5c4b7355c728167845e3c6b0e824e4e5d36a6c3"}, + {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05b2d4e667895cc55e3ff2b56077e4c8a5604361fc21a042845ea3ad67465aa8"}, + {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43cca367bf94a14aca50b89e9bc2061683116cfe864e56740e083392f533ce7a"}, + {file = "numpy-2.1.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:76322dcdb16fccf2ac56f99048af32259dcc488d9b7e25b51e5eca5147a3fb98"}, + {file = "numpy-2.1.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:32e16a03138cabe0cb28e1007ee82264296ac0983714094380b408097a418cfe"}, + {file = "numpy-2.1.2-cp313-cp313-win32.whl", hash = "sha256:242b39d00e4944431a3cd2db2f5377e15b5785920421993770cddb89992c3f3a"}, + {file = "numpy-2.1.2-cp313-cp313-win_amd64.whl", hash = "sha256:f2ded8d9b6f68cc26f8425eda5d3877b47343e68ca23d0d0846f4d312ecaa445"}, + {file = "numpy-2.1.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2ffef621c14ebb0188a8633348504a35c13680d6da93ab5cb86f4e54b7e922b5"}, + {file = "numpy-2.1.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ad369ed238b1959dfbade9018a740fb9392c5ac4f9b5173f420bd4f37ba1f7a0"}, + {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:d82075752f40c0ddf57e6e02673a17f6cb0f8eb3f587f63ca1eaab5594da5b17"}, + {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1600068c262af1ca9580a527d43dc9d959b0b1d8e56f8a05d830eea39b7c8af6"}, + {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a26ae94658d3ba3781d5e103ac07a876b3e9b29db53f68ed7df432fd033358a8"}, + {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13311c2db4c5f7609b462bc0f43d3c465424d25c626d95040f073e30f7570e35"}, + {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:2abbf905a0b568706391ec6fa15161fad0fb5d8b68d73c461b3c1bab6064dd62"}, + {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:ef444c57d664d35cac4e18c298c47d7b504c66b17c2ea91312e979fcfbdfb08a"}, + {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:bdd407c40483463898b84490770199d5714dcc9dd9b792f6c6caccc523c00952"}, + {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:da65fb46d4cbb75cb417cddf6ba5e7582eb7bb0b47db4b99c9fe5787ce5d91f5"}, + {file = "numpy-2.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c193d0b0238638e6fc5f10f1b074a6993cb13b0b431f64079a509d63d3aa8b7"}, + {file = "numpy-2.1.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a7d80b2e904faa63068ead63107189164ca443b42dd1930299e0d1cb041cec2e"}, + {file = "numpy-2.1.2.tar.gz", hash = "sha256:13532a088217fa624c99b843eeb54640de23b3414b14aa66d023805eb731066c"}, ] [[package]] @@ -1549,95 +1644,64 @@ attrs = ">=19.2.0" [[package]] name = "packaging" -version = "24.0" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, -] - -[[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"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] -[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" +version = "2.2.3" description = "Powerful data structures for data analysis, time series, and statistics" optional = false python-versions = ">=3.9" files = [ - {file = "pandas-2.2.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90c6fca2acf139569e74e8781709dccb6fe25940488755716d1d354d6bc58bce"}, - {file = "pandas-2.2.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c7adfc142dac335d8c1e0dcbd37eb8617eac386596eb9e1a1b77791cf2498238"}, - {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4abfe0be0d7221be4f12552995e58723c7422c80a659da13ca382697de830c08"}, - {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8635c16bf3d99040fdf3ca3db669a7250ddf49c55dc4aa8fe0ae0fa8d6dcc1f0"}, - {file = "pandas-2.2.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:40ae1dffb3967a52203105a077415a86044a2bea011b5f321c6aa64b379a3f51"}, - {file = "pandas-2.2.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8e5a0b00e1e56a842f922e7fae8ae4077aee4af0acb5ae3622bd4b4c30aedf99"}, - {file = "pandas-2.2.2-cp310-cp310-win_amd64.whl", hash = "sha256:ddf818e4e6c7c6f4f7c8a12709696d193976b591cc7dc50588d3d1a6b5dc8772"}, - {file = "pandas-2.2.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:696039430f7a562b74fa45f540aca068ea85fa34c244d0deee539cb6d70aa288"}, - {file = "pandas-2.2.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8e90497254aacacbc4ea6ae5e7a8cd75629d6ad2b30025a4a8b09aa4faf55151"}, - {file = "pandas-2.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:58b84b91b0b9f4bafac2a0ac55002280c094dfc6402402332c0913a59654ab2b"}, - {file = "pandas-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2123dc9ad6a814bcdea0f099885276b31b24f7edf40f6cdbc0912672e22eee"}, - {file = "pandas-2.2.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:2925720037f06e89af896c70bca73459d7e6a4be96f9de79e2d440bd499fe0db"}, - {file = "pandas-2.2.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0cace394b6ea70c01ca1595f839cf193df35d1575986e484ad35c4aeae7266c1"}, - {file = "pandas-2.2.2-cp311-cp311-win_amd64.whl", hash = "sha256:873d13d177501a28b2756375d59816c365e42ed8417b41665f346289adc68d24"}, - {file = "pandas-2.2.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:9dfde2a0ddef507a631dc9dc4af6a9489d5e2e740e226ad426a05cabfbd7c8ef"}, - {file = "pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e9b79011ff7a0f4b1d6da6a61aa1aa604fb312d6647de5bad20013682d1429ce"}, - {file = "pandas-2.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1cb51fe389360f3b5a4d57dbd2848a5f033350336ca3b340d1c53a1fad33bcad"}, - {file = "pandas-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eee3a87076c0756de40b05c5e9a6069c035ba43e8dd71c379e68cab2c20f16ad"}, - {file = "pandas-2.2.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3e374f59e440d4ab45ca2fffde54b81ac3834cf5ae2cdfa69c90bc03bde04d76"}, - {file = "pandas-2.2.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:43498c0bdb43d55cb162cdc8c06fac328ccb5d2eabe3cadeb3529ae6f0517c32"}, - {file = "pandas-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:d187d355ecec3629624fccb01d104da7d7f391db0311145817525281e2804d23"}, - {file = "pandas-2.2.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0ca6377b8fca51815f382bd0b697a0814c8bda55115678cbc94c30aacbb6eff2"}, - {file = "pandas-2.2.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9057e6aa78a584bc93a13f0a9bf7e753a5e9770a30b4d758b8d5f2a62a9433cd"}, - {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:001910ad31abc7bf06f49dcc903755d2f7f3a9186c0c040b827e522e9cef0863"}, - {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66b479b0bd07204e37583c191535505410daa8df638fd8e75ae1b383851fe921"}, - {file = "pandas-2.2.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a77e9d1c386196879aa5eb712e77461aaee433e54c68cf253053a73b7e49c33a"}, - {file = "pandas-2.2.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:92fd6b027924a7e178ac202cfbe25e53368db90d56872d20ffae94b96c7acc57"}, - {file = "pandas-2.2.2-cp39-cp39-win_amd64.whl", hash = "sha256:640cef9aa381b60e296db324337a554aeeb883ead99dc8f6c18e81a93942f5f4"}, - {file = "pandas-2.2.2.tar.gz", hash = "sha256:9e79019aba43cb4fda9e4d983f8e88ca0373adbb697ae9c6c43093218de28b54"}, + {file = "pandas-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1948ddde24197a0f7add2bdc4ca83bf2b1ef84a1bc8ccffd95eda17fd836ecb5"}, + {file = "pandas-2.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:381175499d3802cde0eabbaf6324cce0c4f5d52ca6f8c377c29ad442f50f6348"}, + {file = "pandas-2.2.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d9c45366def9a3dd85a6454c0e7908f2b3b8e9c138f5dc38fed7ce720d8453ed"}, + {file = "pandas-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:86976a1c5b25ae3f8ccae3a5306e443569ee3c3faf444dfd0f41cda24667ad57"}, + {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b8661b0238a69d7aafe156b7fa86c44b881387509653fdf857bebc5e4008ad42"}, + {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:37e0aced3e8f539eccf2e099f65cdb9c8aa85109b0be6e93e2baff94264bdc6f"}, + {file = "pandas-2.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:56534ce0746a58afaf7942ba4863e0ef81c9c50d3f0ae93e9497d6a41a057645"}, + {file = "pandas-2.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:66108071e1b935240e74525006034333f98bcdb87ea116de573a6a0dccb6c039"}, + {file = "pandas-2.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7c2875855b0ff77b2a64a0365e24455d9990730d6431b9e0ee18ad8acee13dbd"}, + {file = "pandas-2.2.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd8d0c3be0515c12fed0bdbae072551c8b54b7192c7b1fda0ba56059a0179698"}, + {file = "pandas-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c124333816c3a9b03fbeef3a9f230ba9a737e9e5bb4060aa2107a86cc0a497fc"}, + {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:63cc132e40a2e084cf01adf0775b15ac515ba905d7dcca47e9a251819c575ef3"}, + {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:29401dbfa9ad77319367d36940cd8a0b3a11aba16063e39632d98b0e931ddf32"}, + {file = "pandas-2.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:3fc6873a41186404dad67245896a6e440baacc92f5b716ccd1bc9ed2995ab2c5"}, + {file = "pandas-2.2.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b1d432e8d08679a40e2a6d8b2f9770a5c21793a6f9f47fdd52c5ce1948a5a8a9"}, + {file = "pandas-2.2.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a5a1595fe639f5988ba6a8e5bc9649af3baf26df3998a0abe56c02609392e0a4"}, + {file = "pandas-2.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5de54125a92bb4d1c051c0659e6fcb75256bf799a732a87184e5ea503965bce3"}, + {file = "pandas-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fffb8ae78d8af97f849404f21411c95062db1496aeb3e56f146f0355c9989319"}, + {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6dfcb5ee8d4d50c06a51c2fffa6cff6272098ad6540aed1a76d15fb9318194d8"}, + {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:062309c1b9ea12a50e8ce661145c6aab431b1e99530d3cd60640e255778bd43a"}, + {file = "pandas-2.2.3-cp312-cp312-win_amd64.whl", hash = "sha256:59ef3764d0fe818125a5097d2ae867ca3fa64df032331b7e0917cf5d7bf66b13"}, + {file = "pandas-2.2.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f00d1345d84d8c86a63e476bb4955e46458b304b9575dcf71102b5c705320015"}, + {file = "pandas-2.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3508d914817e153ad359d7e069d752cdd736a247c322d932eb89e6bc84217f28"}, + {file = "pandas-2.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:22a9d949bfc9a502d320aa04e5d02feab689d61da4e7764b62c30b991c42c5f0"}, + {file = "pandas-2.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3a255b2c19987fbbe62a9dfd6cff7ff2aa9ccab3fc75218fd4b7530f01efa24"}, + {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:800250ecdadb6d9c78eae4990da62743b857b470883fa27f652db8bdde7f6659"}, + {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6374c452ff3ec675a8f46fd9ab25c4ad0ba590b71cf0656f8b6daa5202bca3fb"}, + {file = "pandas-2.2.3-cp313-cp313-win_amd64.whl", hash = "sha256:61c5ad4043f791b61dd4752191d9f07f0ae412515d59ba8f005832a532f8736d"}, + {file = "pandas-2.2.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:3b71f27954685ee685317063bf13c7709a7ba74fc996b84fc6821c59b0f06468"}, + {file = "pandas-2.2.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:38cf8125c40dae9d5acc10fa66af8ea6fdf760b2714ee482ca691fc66e6fcb18"}, + {file = "pandas-2.2.3-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ba96630bc17c875161df3818780af30e43be9b166ce51c9a18c1feae342906c2"}, + {file = "pandas-2.2.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1db71525a1538b30142094edb9adc10be3f3e176748cd7acc2240c2f2e5aa3a4"}, + {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:15c0e1e02e93116177d29ff83e8b1619c93ddc9c49083f237d4312337a61165d"}, + {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ad5b65698ab28ed8d7f18790a0dc58005c7629f227be9ecc1072aa74c0c1d43a"}, + {file = "pandas-2.2.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bc6b93f9b966093cb0fd62ff1a7e4c09e6d546ad7c1de191767baffc57628f39"}, + {file = "pandas-2.2.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5dbca4c1acd72e8eeef4753eeca07de9b1db4f398669d5994086f788a5d7cc30"}, + {file = "pandas-2.2.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8cd6d7cc958a3910f934ea8dbdf17b2364827bb4dafc38ce6eef6bb3d65ff09c"}, + {file = "pandas-2.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99df71520d25fade9db7c1076ac94eb994f4d2673ef2aa2e86ee039b6746d20c"}, + {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:31d0ced62d4ea3e231a9f228366919a5ea0b07440d9d4dac345376fd8e1477ea"}, + {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7eee9e7cea6adf3e3d24e304ac6b8300646e2a5d1cd3a3c2abed9101b0846761"}, + {file = "pandas-2.2.3-cp39-cp39-win_amd64.whl", hash = "sha256:4850ba03528b6dd51d6c5d273c46f183f39a9baf3f0143e566b89450965b105e"}, + {file = "pandas-2.2.3.tar.gz", hash = "sha256:4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667"}, ] [package.dependencies] @@ -1675,97 +1739,92 @@ sql-other = ["SQLAlchemy (>=2.0.0)", "adbc-driver-postgresql (>=0.8.0)", "adbc-d test = ["hypothesis (>=6.46.1)", "pytest (>=7.3.2)", "pytest-xdist (>=2.2.0)"] xml = ["lxml (>=4.9.2)"] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - [[package]] name = "pillow" -version = "10.3.0" +version = "11.0.0" description = "Python Imaging Library (Fork)" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "pillow-10.3.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:90b9e29824800e90c84e4022dd5cc16eb2d9605ee13f05d47641eb183cd73d45"}, - {file = "pillow-10.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a2c405445c79c3f5a124573a051062300936b0281fee57637e706453e452746c"}, - {file = "pillow-10.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:78618cdbccaa74d3f88d0ad6cb8ac3007f1a6fa5c6f19af64b55ca170bfa1edf"}, - {file = "pillow-10.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:261ddb7ca91fcf71757979534fb4c128448b5b4c55cb6152d280312062f69599"}, - {file = "pillow-10.3.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:ce49c67f4ea0609933d01c0731b34b8695a7a748d6c8d186f95e7d085d2fe475"}, - {file = "pillow-10.3.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:b14f16f94cbc61215115b9b1236f9c18403c15dd3c52cf629072afa9d54c1cbf"}, - {file = "pillow-10.3.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d33891be6df59d93df4d846640f0e46f1a807339f09e79a8040bc887bdcd7ed3"}, - {file = "pillow-10.3.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b50811d664d392f02f7761621303eba9d1b056fb1868c8cdf4231279645c25f5"}, - {file = "pillow-10.3.0-cp310-cp310-win32.whl", hash = "sha256:ca2870d5d10d8726a27396d3ca4cf7976cec0f3cb706debe88e3a5bd4610f7d2"}, - {file = "pillow-10.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:f0d0591a0aeaefdaf9a5e545e7485f89910c977087e7de2b6c388aec32011e9f"}, - {file = "pillow-10.3.0-cp310-cp310-win_arm64.whl", hash = "sha256:ccce24b7ad89adb5a1e34a6ba96ac2530046763912806ad4c247356a8f33a67b"}, - {file = "pillow-10.3.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:5f77cf66e96ae734717d341c145c5949c63180842a545c47a0ce7ae52ca83795"}, - {file = "pillow-10.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e4b878386c4bf293578b48fc570b84ecfe477d3b77ba39a6e87150af77f40c57"}, - {file = "pillow-10.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdcbb4068117dfd9ce0138d068ac512843c52295ed996ae6dd1faf537b6dbc27"}, - {file = "pillow-10.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9797a6c8fe16f25749b371c02e2ade0efb51155e767a971c61734b1bf6293994"}, - {file = "pillow-10.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:9e91179a242bbc99be65e139e30690e081fe6cb91a8e77faf4c409653de39451"}, - {file = "pillow-10.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:1b87bd9d81d179bd8ab871603bd80d8645729939f90b71e62914e816a76fc6bd"}, - {file = "pillow-10.3.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:81d09caa7b27ef4e61cb7d8fbf1714f5aec1c6b6c5270ee53504981e6e9121ad"}, - {file = "pillow-10.3.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:048ad577748b9fa4a99a0548c64f2cb8d672d5bf2e643a739ac8faff1164238c"}, - {file = "pillow-10.3.0-cp311-cp311-win32.whl", hash = "sha256:7161ec49ef0800947dc5570f86568a7bb36fa97dd09e9827dc02b718c5643f09"}, - {file = "pillow-10.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:8eb0908e954d093b02a543dc963984d6e99ad2b5e36503d8a0aaf040505f747d"}, - {file = "pillow-10.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:4e6f7d1c414191c1199f8996d3f2282b9ebea0945693fb67392c75a3a320941f"}, - {file = "pillow-10.3.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:e46f38133e5a060d46bd630faa4d9fa0202377495df1f068a8299fd78c84de84"}, - {file = "pillow-10.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:50b8eae8f7334ec826d6eeffaeeb00e36b5e24aa0b9df322c247539714c6df19"}, - {file = "pillow-10.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d3bea1c75f8c53ee4d505c3e67d8c158ad4df0d83170605b50b64025917f338"}, - {file = "pillow-10.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:19aeb96d43902f0a783946a0a87dbdad5c84c936025b8419da0a0cd7724356b1"}, - {file = "pillow-10.3.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:74d28c17412d9caa1066f7a31df8403ec23d5268ba46cd0ad2c50fb82ae40462"}, - {file = "pillow-10.3.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:ff61bfd9253c3915e6d41c651d5f962da23eda633cf02262990094a18a55371a"}, - {file = "pillow-10.3.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d886f5d353333b4771d21267c7ecc75b710f1a73d72d03ca06df49b09015a9ef"}, - {file = "pillow-10.3.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4b5ec25d8b17217d635f8935dbc1b9aa5907962fae29dff220f2659487891cd3"}, - {file = "pillow-10.3.0-cp312-cp312-win32.whl", hash = "sha256:51243f1ed5161b9945011a7360e997729776f6e5d7005ba0c6879267d4c5139d"}, - {file = "pillow-10.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:412444afb8c4c7a6cc11a47dade32982439925537e483be7c0ae0cf96c4f6a0b"}, - {file = "pillow-10.3.0-cp312-cp312-win_arm64.whl", hash = "sha256:798232c92e7665fe82ac085f9d8e8ca98826f8e27859d9a96b41d519ecd2e49a"}, - {file = "pillow-10.3.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:4eaa22f0d22b1a7e93ff0a596d57fdede2e550aecffb5a1ef1106aaece48e96b"}, - {file = "pillow-10.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:cd5e14fbf22a87321b24c88669aad3a51ec052eb145315b3da3b7e3cc105b9a2"}, - {file = "pillow-10.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1530e8f3a4b965eb6a7785cf17a426c779333eb62c9a7d1bbcf3ffd5bf77a4aa"}, - {file = "pillow-10.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d512aafa1d32efa014fa041d38868fda85028e3f930a96f85d49c7d8ddc0383"}, - {file = "pillow-10.3.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:339894035d0ede518b16073bdc2feef4c991ee991a29774b33e515f1d308e08d"}, - {file = "pillow-10.3.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:aa7e402ce11f0885305bfb6afb3434b3cd8f53b563ac065452d9d5654c7b86fd"}, - {file = "pillow-10.3.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:0ea2a783a2bdf2a561808fe4a7a12e9aa3799b701ba305de596bc48b8bdfce9d"}, - {file = "pillow-10.3.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c78e1b00a87ce43bb37642c0812315b411e856a905d58d597750eb79802aaaa3"}, - {file = "pillow-10.3.0-cp38-cp38-win32.whl", hash = "sha256:72d622d262e463dfb7595202d229f5f3ab4b852289a1cd09650362db23b9eb0b"}, - {file = "pillow-10.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:2034f6759a722da3a3dbd91a81148cf884e91d1b747992ca288ab88c1de15999"}, - {file = "pillow-10.3.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:2ed854e716a89b1afcedea551cd85f2eb2a807613752ab997b9974aaa0d56936"}, - {file = "pillow-10.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:dc1a390a82755a8c26c9964d457d4c9cbec5405896cba94cf51f36ea0d855002"}, - {file = "pillow-10.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4203efca580f0dd6f882ca211f923168548f7ba334c189e9eab1178ab840bf60"}, - {file = "pillow-10.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3102045a10945173d38336f6e71a8dc71bcaeed55c3123ad4af82c52807b9375"}, - {file = "pillow-10.3.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:6fb1b30043271ec92dc65f6d9f0b7a830c210b8a96423074b15c7bc999975f57"}, - {file = "pillow-10.3.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:1dfc94946bc60ea375cc39cff0b8da6c7e5f8fcdc1d946beb8da5c216156ddd8"}, - {file = "pillow-10.3.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b09b86b27a064c9624d0a6c54da01c1beaf5b6cadfa609cf63789b1d08a797b9"}, - {file = "pillow-10.3.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d3b2348a78bc939b4fed6552abfd2e7988e0f81443ef3911a4b8498ca084f6eb"}, - {file = "pillow-10.3.0-cp39-cp39-win32.whl", hash = "sha256:45ebc7b45406febf07fef35d856f0293a92e7417ae7933207e90bf9090b70572"}, - {file = "pillow-10.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:0ba26351b137ca4e0db0342d5d00d2e355eb29372c05afd544ebf47c0956ffeb"}, - {file = "pillow-10.3.0-cp39-cp39-win_arm64.whl", hash = "sha256:50fd3f6b26e3441ae07b7c979309638b72abc1a25da31a81a7fbd9495713ef4f"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-macosx_10_10_x86_64.whl", hash = "sha256:6b02471b72526ab8a18c39cb7967b72d194ec53c1fd0a70b050565a0f366d355"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:8ab74c06ffdab957d7670c2a5a6e1a70181cd10b727cd788c4dd9005b6a8acd9"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:048eeade4c33fdf7e08da40ef402e748df113fd0b4584e32c4af74fe78baaeb2"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e2ec1e921fd07c7cda7962bad283acc2f2a9ccc1b971ee4b216b75fad6f0463"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:4c8e73e99da7db1b4cad7f8d682cf6abad7844da39834c288fbfa394a47bbced"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:16563993329b79513f59142a6b02055e10514c1a8e86dca8b48a893e33cf91e3"}, - {file = "pillow-10.3.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:dd78700f5788ae180b5ee8902c6aea5a5726bac7c364b202b4b3e3ba2d293170"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:aff76a55a8aa8364d25400a210a65ff59d0168e0b4285ba6bf2bd83cf675ba32"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:b7bc2176354defba3edc2b9a777744462da2f8e921fbaf61e52acb95bafa9828"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:793b4e24db2e8742ca6423d3fde8396db336698c55cd34b660663ee9e45ed37f"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d93480005693d247f8346bc8ee28c72a2191bdf1f6b5db469c096c0c867ac015"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:c83341b89884e2b2e55886e8fbbf37c3fa5efd6c8907124aeb72f285ae5696e5"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:1a1d1915db1a4fdb2754b9de292642a39a7fb28f1736699527bb649484fb966a"}, - {file = "pillow-10.3.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a0eaa93d054751ee9964afa21c06247779b90440ca41d184aeb5d410f20ff591"}, - {file = "pillow-10.3.0.tar.gz", hash = "sha256:9d2455fbf44c914840c793e89aa82d0e1763a14253a000743719ae5946814b2d"}, + {file = "pillow-11.0.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:6619654954dc4936fcff82db8eb6401d3159ec6be81e33c6000dfd76ae189947"}, + {file = "pillow-11.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b3c5ac4bed7519088103d9450a1107f76308ecf91d6dabc8a33a2fcfb18d0fba"}, + {file = "pillow-11.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a65149d8ada1055029fcb665452b2814fe7d7082fcb0c5bed6db851cb69b2086"}, + {file = "pillow-11.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88a58d8ac0cc0e7f3a014509f0455248a76629ca9b604eca7dc5927cc593c5e9"}, + {file = "pillow-11.0.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:c26845094b1af3c91852745ae78e3ea47abf3dbcd1cf962f16b9a5fbe3ee8488"}, + {file = "pillow-11.0.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:1a61b54f87ab5786b8479f81c4b11f4d61702830354520837f8cc791ebba0f5f"}, + {file = "pillow-11.0.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:674629ff60030d144b7bca2b8330225a9b11c482ed408813924619c6f302fdbb"}, + {file = "pillow-11.0.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:598b4e238f13276e0008299bd2482003f48158e2b11826862b1eb2ad7c768b97"}, + {file = "pillow-11.0.0-cp310-cp310-win32.whl", hash = "sha256:9a0f748eaa434a41fccf8e1ee7a3eed68af1b690e75328fd7a60af123c193b50"}, + {file = "pillow-11.0.0-cp310-cp310-win_amd64.whl", hash = "sha256:a5629742881bcbc1f42e840af185fd4d83a5edeb96475a575f4da50d6ede337c"}, + {file = "pillow-11.0.0-cp310-cp310-win_arm64.whl", hash = "sha256:ee217c198f2e41f184f3869f3e485557296d505b5195c513b2bfe0062dc537f1"}, + {file = "pillow-11.0.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:1c1d72714f429a521d8d2d018badc42414c3077eb187a59579f28e4270b4b0fc"}, + {file = "pillow-11.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:499c3a1b0d6fc8213519e193796eb1a86a1be4b1877d678b30f83fd979811d1a"}, + {file = "pillow-11.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c8b2351c85d855293a299038e1f89db92a2f35e8d2f783489c6f0b2b5f3fe8a3"}, + {file = "pillow-11.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f4dba50cfa56f910241eb7f883c20f1e7b1d8f7d91c750cd0b318bad443f4d5"}, + {file = "pillow-11.0.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:5ddbfd761ee00c12ee1be86c9c0683ecf5bb14c9772ddbd782085779a63dd55b"}, + {file = "pillow-11.0.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:45c566eb10b8967d71bf1ab8e4a525e5a93519e29ea071459ce517f6b903d7fa"}, + {file = "pillow-11.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:b4fd7bd29610a83a8c9b564d457cf5bd92b4e11e79a4ee4716a63c959699b306"}, + {file = "pillow-11.0.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:cb929ca942d0ec4fac404cbf520ee6cac37bf35be479b970c4ffadf2b6a1cad9"}, + {file = "pillow-11.0.0-cp311-cp311-win32.whl", hash = "sha256:006bcdd307cc47ba43e924099a038cbf9591062e6c50e570819743f5607404f5"}, + {file = "pillow-11.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:52a2d8323a465f84faaba5236567d212c3668f2ab53e1c74c15583cf507a0291"}, + {file = "pillow-11.0.0-cp311-cp311-win_arm64.whl", hash = "sha256:16095692a253047fe3ec028e951fa4221a1f3ed3d80c397e83541a3037ff67c9"}, + {file = "pillow-11.0.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d2c0a187a92a1cb5ef2c8ed5412dd8d4334272617f532d4ad4de31e0495bd923"}, + {file = "pillow-11.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:084a07ef0821cfe4858fe86652fffac8e187b6ae677e9906e192aafcc1b69903"}, + {file = "pillow-11.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8069c5179902dcdce0be9bfc8235347fdbac249d23bd90514b7a47a72d9fecf4"}, + {file = "pillow-11.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f02541ef64077f22bf4924f225c0fd1248c168f86e4b7abdedd87d6ebaceab0f"}, + {file = "pillow-11.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:fcb4621042ac4b7865c179bb972ed0da0218a076dc1820ffc48b1d74c1e37fe9"}, + {file = "pillow-11.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:00177a63030d612148e659b55ba99527803288cea7c75fb05766ab7981a8c1b7"}, + {file = "pillow-11.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8853a3bf12afddfdf15f57c4b02d7ded92c7a75a5d7331d19f4f9572a89c17e6"}, + {file = "pillow-11.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3107c66e43bda25359d5ef446f59c497de2b5ed4c7fdba0894f8d6cf3822dafc"}, + {file = "pillow-11.0.0-cp312-cp312-win32.whl", hash = "sha256:86510e3f5eca0ab87429dd77fafc04693195eec7fd6a137c389c3eeb4cfb77c6"}, + {file = "pillow-11.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:8ec4a89295cd6cd4d1058a5e6aec6bf51e0eaaf9714774e1bfac7cfc9051db47"}, + {file = "pillow-11.0.0-cp312-cp312-win_arm64.whl", hash = "sha256:27a7860107500d813fcd203b4ea19b04babe79448268403172782754870dac25"}, + {file = "pillow-11.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:bcd1fb5bb7b07f64c15618c89efcc2cfa3e95f0e3bcdbaf4642509de1942a699"}, + {file = "pillow-11.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0e038b0745997c7dcaae350d35859c9715c71e92ffb7e0f4a8e8a16732150f38"}, + {file = "pillow-11.0.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ae08bd8ffc41aebf578c2af2f9d8749d91f448b3bfd41d7d9ff573d74f2a6b2"}, + {file = "pillow-11.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d69bfd8ec3219ae71bcde1f942b728903cad25fafe3100ba2258b973bd2bc1b2"}, + {file = "pillow-11.0.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:61b887f9ddba63ddf62fd02a3ba7add935d053b6dd7d58998c630e6dbade8527"}, + {file = "pillow-11.0.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:c6a660307ca9d4867caa8d9ca2c2658ab685de83792d1876274991adec7b93fa"}, + {file = "pillow-11.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:73e3a0200cdda995c7e43dd47436c1548f87a30bb27fb871f352a22ab8dcf45f"}, + {file = "pillow-11.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fba162b8872d30fea8c52b258a542c5dfd7b235fb5cb352240c8d63b414013eb"}, + {file = "pillow-11.0.0-cp313-cp313-win32.whl", hash = "sha256:f1b82c27e89fffc6da125d5eb0ca6e68017faf5efc078128cfaa42cf5cb38798"}, + {file = "pillow-11.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:8ba470552b48e5835f1d23ecb936bb7f71d206f9dfeee64245f30c3270b994de"}, + {file = "pillow-11.0.0-cp313-cp313-win_arm64.whl", hash = "sha256:846e193e103b41e984ac921b335df59195356ce3f71dcfd155aa79c603873b84"}, + {file = "pillow-11.0.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:4ad70c4214f67d7466bea6a08061eba35c01b1b89eaa098040a35272a8efb22b"}, + {file = "pillow-11.0.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:6ec0d5af64f2e3d64a165f490d96368bb5dea8b8f9ad04487f9ab60dc4bb6003"}, + {file = "pillow-11.0.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c809a70e43c7977c4a42aefd62f0131823ebf7dd73556fa5d5950f5b354087e2"}, + {file = "pillow-11.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:4b60c9520f7207aaf2e1d94de026682fc227806c6e1f55bba7606d1c94dd623a"}, + {file = "pillow-11.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:1e2688958a840c822279fda0086fec1fdab2f95bf2b717b66871c4ad9859d7e8"}, + {file = "pillow-11.0.0-cp313-cp313t-win32.whl", hash = "sha256:607bbe123c74e272e381a8d1957083a9463401f7bd01287f50521ecb05a313f8"}, + {file = "pillow-11.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:5c39ed17edea3bc69c743a8dd3e9853b7509625c2462532e62baa0732163a904"}, + {file = "pillow-11.0.0-cp313-cp313t-win_arm64.whl", hash = "sha256:75acbbeb05b86bc53cbe7b7e6fe00fbcf82ad7c684b3ad82e3d711da9ba287d3"}, + {file = "pillow-11.0.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:2e46773dc9f35a1dd28bd6981332fd7f27bec001a918a72a79b4133cf5291dba"}, + {file = "pillow-11.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2679d2258b7f1192b378e2893a8a0a0ca472234d4c2c0e6bdd3380e8dfa21b6a"}, + {file = "pillow-11.0.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eda2616eb2313cbb3eebbe51f19362eb434b18e3bb599466a1ffa76a033fb916"}, + {file = "pillow-11.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:20ec184af98a121fb2da42642dea8a29ec80fc3efbaefb86d8fdd2606619045d"}, + {file = "pillow-11.0.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:8594f42df584e5b4bb9281799698403f7af489fba84c34d53d1c4bfb71b7c4e7"}, + {file = "pillow-11.0.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:c12b5ae868897c7338519c03049a806af85b9b8c237b7d675b8c5e089e4a618e"}, + {file = "pillow-11.0.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:70fbbdacd1d271b77b7721fe3cdd2d537bbbd75d29e6300c672ec6bb38d9672f"}, + {file = "pillow-11.0.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:5178952973e588b3f1360868847334e9e3bf49d19e169bbbdfaf8398002419ae"}, + {file = "pillow-11.0.0-cp39-cp39-win32.whl", hash = "sha256:8c676b587da5673d3c75bd67dd2a8cdfeb282ca38a30f37950511766b26858c4"}, + {file = "pillow-11.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:94f3e1780abb45062287b4614a5bc0874519c86a777d4a7ad34978e86428b8dd"}, + {file = "pillow-11.0.0-cp39-cp39-win_arm64.whl", hash = "sha256:290f2cc809f9da7d6d622550bbf4c1e57518212da51b6a30fe8e0a270a5b78bd"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1187739620f2b365de756ce086fdb3604573337cc28a0d3ac4a01ab6b2d2a6d2"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:fbbcb7b57dc9c794843e3d1258c0fbf0f48656d46ffe9e09b63bbd6e8cd5d0a2"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d203af30149ae339ad1b4f710d9844ed8796e97fda23ffbc4cc472968a47d0b"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21a0d3b115009ebb8ac3d2ebec5c2982cc693da935f4ab7bb5c8ebe2f47d36f2"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:73853108f56df97baf2bb8b522f3578221e56f646ba345a372c78326710d3830"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:e58876c91f97b0952eb766123bfef372792ab3f4e3e1f1a2267834c2ab131734"}, + {file = "pillow-11.0.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:224aaa38177597bb179f3ec87eeefcce8e4f85e608025e9cfac60de237ba6316"}, + {file = "pillow-11.0.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:5bd2d3bdb846d757055910f0a59792d33b555800813c3b39ada1829c372ccb06"}, + {file = "pillow-11.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:375b8dd15a1f5d2feafff536d47e22f69625c1aa92f12b339ec0b2ca40263273"}, + {file = "pillow-11.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:daffdf51ee5db69a82dd127eabecce20729e21f7a3680cf7cbb23f0829189790"}, + {file = "pillow-11.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7326a1787e3c7b0429659e0a944725e1b03eeaa10edd945a86dead1913383944"}, + {file = "pillow-11.0.0.tar.gz", hash = "sha256:72bacbaf24ac003fea9bff9837d1eedb6088758d41e100c1552930151f677739"}, ] [package.extras] -docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] +docs = ["furo", "olefile", "sphinx (>=8.1)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinxext-opengraph"] fpx = ["olefile"] mic = ["olefile"] tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] @@ -1774,13 +1833,13 @@ xmp = ["defusedxml"] [[package]] name = "pip" -version = "24.0" +version = "24.3.1" description = "The PyPA recommended tool for installing Python packages." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pip-24.0-py3-none-any.whl", hash = "sha256:ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc"}, - {file = "pip-24.0.tar.gz", hash = "sha256:ea9bd1a847e8c5774a5777bb398c19e80bcd4e2aa16a4b301b718fe6f593aba2"}, + {file = "pip-24.3.1-py3-none-any.whl", hash = "sha256:3790624780082365f47549d032f3770eeb2b1e8bd1f7b2e02dace1afa361b4ed"}, + {file = "pip-24.3.1.tar.gz", hash = "sha256:ebcb60557f2aefabc2e0f918751cd24ea0d56d8ec5445fe1807f1d2109660b99"}, ] [[package]] @@ -1817,29 +1876,49 @@ testing = ["pytest", "pytest-cov", "wheel"] [[package]] name = "platformdirs" -version = "4.2.1" +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.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"}, - {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"}, + {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 = "playwright" +version = "1.48.0" +description = "A high-level API to automate web browsers" +optional = false +python-versions = ">=3.8" +files = [ + {file = "playwright-1.48.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:082bce2739f1078acc7d0734da8cc0e23eb91b7fae553f3316d733276f09a6b1"}, + {file = "playwright-1.48.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7da2eb51a19c7f3b523e9faa9d98e7af92e52eb983a099979ea79c9668e3cbf7"}, + {file = "playwright-1.48.0-py3-none-macosx_11_0_universal2.whl", hash = "sha256:115b988d1da322358b77bc3bf2d3cc90f8c881e691461538e7df91614c4833c9"}, + {file = "playwright-1.48.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:8dabb80e62f667fe2640a8b694e26a7b884c0b4803f7514a3954fc849126227b"}, + {file = "playwright-1.48.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8ff8303409ebed76bed4c3d655340320b768817d900ba208b394fdd7d7939a5c"}, + {file = "playwright-1.48.0-py3-none-win32.whl", hash = "sha256:85598c360c590076d4f435525be991246d74a905b654ac19d26eab7ed9b98b2d"}, + {file = "playwright-1.48.0-py3-none-win_amd64.whl", hash = "sha256:e0e87b0c4dc8fce83c725dd851aec37bc4e882bb225ec8a96bd83cf32d4f1623"}, +] + +[package.dependencies] +greenlet = "3.1.1" +pyee = "12.0.0" [[package]] name = "plotly" -version = "5.22.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.22.0-py3-none-any.whl", hash = "sha256:68fc1901f098daeb233cc3dd44ec9dc31fb3ca4f4e53189344199c43496ed006"}, - {file = "plotly-5.22.0.tar.gz", hash = "sha256:859fdadbd86b5770ae2466e542b761b247d1c6b49daed765b95bb8c7063e7469"}, + {file = "plotly-5.24.1-py3-none-any.whl", hash = "sha256:f67073a1e637eb0dc3e46324d9d51e2fe76e9727c892dde64ddf1e1b51f29089"}, + {file = "plotly-5.24.1.tar.gz", hash = "sha256:dbc8ac8339d248a4bcc36e08a5659bacfe1b079390b8953533f4eb22169b4bae"}, ] [package.dependencies] @@ -1863,13 +1942,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.5.0" +version = "4.0.1" 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-4.0.1-py2.py3-none-any.whl", hash = "sha256:efde913840816312445dc98787724647c65473daefe420785f885e8ed9a06878"}, + {file = "pre_commit-4.0.1.tar.gz", hash = "sha256:80905ac375958c0444c65e9cebebd948b3cdb518f335a091a670a89d652139d2"}, ] [package.dependencies] @@ -1879,33 +1958,142 @@ nodeenv = ">=0.11.1" pyyaml = ">=5.1" virtualenv = ">=20.10.0" +[[package]] +name = "propcache" +version = "0.2.0" +description = "Accelerated property cache" +optional = true +python-versions = ">=3.8" +files = [ + {file = "propcache-0.2.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:c5869b8fd70b81835a6f187c5fdbe67917a04d7e52b6e7cc4e5fe39d55c39d58"}, + {file = "propcache-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:952e0d9d07609d9c5be361f33b0d6d650cd2bae393aabb11d9b719364521984b"}, + {file = "propcache-0.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:33ac8f098df0585c0b53009f039dfd913b38c1d2edafed0cedcc0c32a05aa110"}, + {file = "propcache-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:97e48e8875e6c13909c800fa344cd54cc4b2b0db1d5f911f840458a500fde2c2"}, + {file = "propcache-0.2.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:388f3217649d6d59292b722d940d4d2e1e6a7003259eb835724092a1cca0203a"}, + {file = "propcache-0.2.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f571aea50ba5623c308aa146eb650eebf7dbe0fd8c5d946e28343cb3b5aad577"}, + {file = "propcache-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3dfafb44f7bb35c0c06eda6b2ab4bfd58f02729e7c4045e179f9a861b07c9850"}, + {file = "propcache-0.2.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a3ebe9a75be7ab0b7da2464a77bb27febcb4fab46a34f9288f39d74833db7f61"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d2f0d0f976985f85dfb5f3d685697ef769faa6b71993b46b295cdbbd6be8cc37"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:a3dc1a4b165283bd865e8f8cb5f0c64c05001e0718ed06250d8cac9bec115b48"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:9e0f07b42d2a50c7dd2d8675d50f7343d998c64008f1da5fef888396b7f84630"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:e63e3e1e0271f374ed489ff5ee73d4b6e7c60710e1f76af5f0e1a6117cd26394"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:56bb5c98f058a41bb58eead194b4db8c05b088c93d94d5161728515bd52b052b"}, + {file = "propcache-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7665f04d0c7f26ff8bb534e1c65068409bf4687aa2534faf7104d7182debb336"}, + {file = "propcache-0.2.0-cp310-cp310-win32.whl", hash = "sha256:7cf18abf9764746b9c8704774d8b06714bcb0a63641518a3a89c7f85cc02c2ad"}, + {file = "propcache-0.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:cfac69017ef97db2438efb854edf24f5a29fd09a536ff3a992b75990720cdc99"}, + {file = "propcache-0.2.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:63f13bf09cc3336eb04a837490b8f332e0db41da66995c9fd1ba04552e516354"}, + {file = "propcache-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:608cce1da6f2672a56b24a015b42db4ac612ee709f3d29f27a00c943d9e851de"}, + {file = "propcache-0.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:466c219deee4536fbc83c08d09115249db301550625c7fef1c5563a584c9bc87"}, + {file = "propcache-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc2db02409338bf36590aa985a461b2c96fce91f8e7e0f14c50c5fcc4f229016"}, + {file = "propcache-0.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a6ed8db0a556343d566a5c124ee483ae113acc9a557a807d439bcecc44e7dfbb"}, + {file = "propcache-0.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:91997d9cb4a325b60d4e3f20967f8eb08dfcb32b22554d5ef78e6fd1dda743a2"}, + {file = "propcache-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c7dde9e533c0a49d802b4f3f218fa9ad0a1ce21f2c2eb80d5216565202acab4"}, + {file = "propcache-0.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffcad6c564fe6b9b8916c1aefbb37a362deebf9394bd2974e9d84232e3e08504"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:97a58a28bcf63284e8b4d7b460cbee1edaab24634e82059c7b8c09e65284f178"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:945db8ee295d3af9dbdbb698cce9bbc5c59b5c3fe328bbc4387f59a8a35f998d"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:39e104da444a34830751715f45ef9fc537475ba21b7f1f5b0f4d71a3b60d7fe2"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:c5ecca8f9bab618340c8e848d340baf68bcd8ad90a8ecd7a4524a81c1764b3db"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:c436130cc779806bdf5d5fae0d848713105472b8566b75ff70048c47d3961c5b"}, + {file = "propcache-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:191db28dc6dcd29d1a3e063c3be0b40688ed76434622c53a284e5427565bbd9b"}, + {file = "propcache-0.2.0-cp311-cp311-win32.whl", hash = "sha256:5f2564ec89058ee7c7989a7b719115bdfe2a2fb8e7a4543b8d1c0cc4cf6478c1"}, + {file = "propcache-0.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:6e2e54267980349b723cff366d1e29b138b9a60fa376664a157a342689553f71"}, + {file = "propcache-0.2.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:2ee7606193fb267be4b2e3b32714f2d58cad27217638db98a60f9efb5efeccc2"}, + {file = "propcache-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:91ee8fc02ca52e24bcb77b234f22afc03288e1dafbb1f88fe24db308910c4ac7"}, + {file = "propcache-0.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2e900bad2a8456d00a113cad8c13343f3b1f327534e3589acc2219729237a2e8"}, + {file = "propcache-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f52a68c21363c45297aca15561812d542f8fc683c85201df0bebe209e349f793"}, + {file = "propcache-0.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1e41d67757ff4fbc8ef2af99b338bfb955010444b92929e9e55a6d4dcc3c4f09"}, + {file = "propcache-0.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a64e32f8bd94c105cc27f42d3b658902b5bcc947ece3c8fe7bc1b05982f60e89"}, + {file = "propcache-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:55346705687dbd7ef0d77883ab4f6fabc48232f587925bdaf95219bae072491e"}, + {file = "propcache-0.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:00181262b17e517df2cd85656fcd6b4e70946fe62cd625b9d74ac9977b64d8d9"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6994984550eaf25dd7fc7bd1b700ff45c894149341725bb4edc67f0ffa94efa4"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:56295eb1e5f3aecd516d91b00cfd8bf3a13991de5a479df9e27dd569ea23959c"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:439e76255daa0f8151d3cb325f6dd4a3e93043e6403e6491813bcaaaa8733887"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f6475a1b2ecb310c98c28d271a30df74f9dd436ee46d09236a6b750a7599ce57"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:3444cdba6628accf384e349014084b1cacd866fbb88433cd9d279d90a54e0b23"}, + {file = "propcache-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:4a9d9b4d0a9b38d1c391bb4ad24aa65f306c6f01b512e10a8a34a2dc5675d348"}, + {file = "propcache-0.2.0-cp312-cp312-win32.whl", hash = "sha256:69d3a98eebae99a420d4b28756c8ce6ea5a29291baf2dc9ff9414b42676f61d5"}, + {file = "propcache-0.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:ad9c9b99b05f163109466638bd30ada1722abb01bbb85c739c50b6dc11f92dc3"}, + {file = "propcache-0.2.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ecddc221a077a8132cf7c747d5352a15ed763b674c0448d811f408bf803d9ad7"}, + {file = "propcache-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0e53cb83fdd61cbd67202735e6a6687a7b491c8742dfc39c9e01e80354956763"}, + {file = "propcache-0.2.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:92fe151145a990c22cbccf9ae15cae8ae9eddabfc949a219c9f667877e40853d"}, + {file = "propcache-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d6a21ef516d36909931a2967621eecb256018aeb11fc48656e3257e73e2e247a"}, + {file = "propcache-0.2.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f88a4095e913f98988f5b338c1d4d5d07dbb0b6bad19892fd447484e483ba6b"}, + {file = "propcache-0.2.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5a5b3bb545ead161be780ee85a2b54fdf7092815995661947812dde94a40f6fb"}, + {file = "propcache-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67aeb72e0f482709991aa91345a831d0b707d16b0257e8ef88a2ad246a7280bf"}, + {file = "propcache-0.2.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3c997f8c44ec9b9b0bcbf2d422cc00a1d9b9c681f56efa6ca149a941e5560da2"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:2a66df3d4992bc1d725b9aa803e8c5a66c010c65c741ad901e260ece77f58d2f"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:3ebbcf2a07621f29638799828b8d8668c421bfb94c6cb04269130d8de4fb7136"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1235c01ddaa80da8235741e80815ce381c5267f96cc49b1477fdcf8c047ef325"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:3947483a381259c06921612550867b37d22e1df6d6d7e8361264b6d037595f44"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:d5bed7f9805cc29c780f3aee05de3262ee7ce1f47083cfe9f77471e9d6777e83"}, + {file = "propcache-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e4a91d44379f45f5e540971d41e4626dacd7f01004826a18cb048e7da7e96544"}, + {file = "propcache-0.2.0-cp313-cp313-win32.whl", hash = "sha256:f902804113e032e2cdf8c71015651c97af6418363bea8d78dc0911d56c335032"}, + {file = "propcache-0.2.0-cp313-cp313-win_amd64.whl", hash = "sha256:8f188cfcc64fb1266f4684206c9de0e80f54622c3f22a910cbd200478aeae61e"}, + {file = "propcache-0.2.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:53d1bd3f979ed529f0805dd35ddaca330f80a9a6d90bc0121d2ff398f8ed8861"}, + {file = "propcache-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:83928404adf8fb3d26793665633ea79b7361efa0287dfbd372a7e74311d51ee6"}, + {file = "propcache-0.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:77a86c261679ea5f3896ec060be9dc8e365788248cc1e049632a1be682442063"}, + {file = "propcache-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:218db2a3c297a3768c11a34812e63b3ac1c3234c3a086def9c0fee50d35add1f"}, + {file = "propcache-0.2.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7735e82e3498c27bcb2d17cb65d62c14f1100b71723b68362872bca7d0913d90"}, + {file = "propcache-0.2.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:20a617c776f520c3875cf4511e0d1db847a076d720714ae35ffe0df3e440be68"}, + {file = "propcache-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67b69535c870670c9f9b14a75d28baa32221d06f6b6fa6f77a0a13c5a7b0a5b9"}, + {file = "propcache-0.2.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4569158070180c3855e9c0791c56be3ceeb192defa2cdf6a3f39e54319e56b89"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:db47514ffdbd91ccdc7e6f8407aac4ee94cc871b15b577c1c324236b013ddd04"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_armv7l.whl", hash = "sha256:2a60ad3e2553a74168d275a0ef35e8c0a965448ffbc3b300ab3a5bb9956c2162"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:662dd62358bdeaca0aee5761de8727cfd6861432e3bb828dc2a693aa0471a563"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:25a1f88b471b3bc911d18b935ecb7115dff3a192b6fef46f0bfaf71ff4f12418"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:f60f0ac7005b9f5a6091009b09a419ace1610e163fa5deaba5ce3484341840e7"}, + {file = "propcache-0.2.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:74acd6e291f885678631b7ebc85d2d4aec458dd849b8c841b57ef04047833bed"}, + {file = "propcache-0.2.0-cp38-cp38-win32.whl", hash = "sha256:d9b6ddac6408194e934002a69bcaadbc88c10b5f38fb9307779d1c629181815d"}, + {file = "propcache-0.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:676135dcf3262c9c5081cc8f19ad55c8a64e3f7282a21266d05544450bffc3a5"}, + {file = "propcache-0.2.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:25c8d773a62ce0451b020c7b29a35cfbc05de8b291163a7a0f3b7904f27253e6"}, + {file = "propcache-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:375a12d7556d462dc64d70475a9ee5982465fbb3d2b364f16b86ba9135793638"}, + {file = "propcache-0.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1ec43d76b9677637a89d6ab86e1fef70d739217fefa208c65352ecf0282be957"}, + {file = "propcache-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f45eec587dafd4b2d41ac189c2156461ebd0c1082d2fe7013571598abb8505d1"}, + {file = "propcache-0.2.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc092ba439d91df90aea38168e11f75c655880c12782facf5cf9c00f3d42b562"}, + {file = "propcache-0.2.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fa1076244f54bb76e65e22cb6910365779d5c3d71d1f18b275f1dfc7b0d71b4d"}, + {file = "propcache-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:682a7c79a2fbf40f5dbb1eb6bfe2cd865376deeac65acf9beb607505dced9e12"}, + {file = "propcache-0.2.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8e40876731f99b6f3c897b66b803c9e1c07a989b366c6b5b475fafd1f7ba3fb8"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:363ea8cd3c5cb6679f1c2f5f1f9669587361c062e4899fce56758efa928728f8"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:140fbf08ab3588b3468932974a9331aff43c0ab8a2ec2c608b6d7d1756dbb6cb"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:e70fac33e8b4ac63dfc4c956fd7d85a0b1139adcfc0d964ce288b7c527537fea"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:b33d7a286c0dc1a15f5fc864cc48ae92a846df287ceac2dd499926c3801054a6"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:f6d5749fdd33d90e34c2efb174c7e236829147a2713334d708746e94c4bde40d"}, + {file = "propcache-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:22aa8f2272d81d9317ff5756bb108021a056805ce63dd3630e27d042c8092798"}, + {file = "propcache-0.2.0-cp39-cp39-win32.whl", hash = "sha256:73e4b40ea0eda421b115248d7e79b59214411109a5bc47d0d48e4c73e3b8fcf9"}, + {file = "propcache-0.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:9517d5e9e0731957468c29dbfd0f976736a0e55afaea843726e887f36fe017df"}, + {file = "propcache-0.2.0-py3-none-any.whl", hash = "sha256:2ccc28197af5313706511fab3a8b66dcd6da067a1331372c82ea1cb74285e036"}, + {file = "propcache-0.2.0.tar.gz", hash = "sha256:df81779732feb9d01e5d513fad0122efb3d53bbc75f61b2a4f29a020bc985e70"}, +] + [[package]] name = "psutil" -version = "5.9.8" +version = "6.1.0" description = "Cross-platform lib for process and system monitoring in Python." optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ - {file = "psutil-5.9.8-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:26bd09967ae00920df88e0352a91cff1a78f8d69b3ecabbfe733610c0af486c8"}, - {file = "psutil-5.9.8-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:05806de88103b25903dff19bb6692bd2e714ccf9e668d050d144012055cbca73"}, - {file = "psutil-5.9.8-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:611052c4bc70432ec770d5d54f64206aa7203a101ec273a0cd82418c86503bb7"}, - {file = "psutil-5.9.8-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:50187900d73c1381ba1454cf40308c2bf6f34268518b3f36a9b663ca87e65e36"}, - {file = "psutil-5.9.8-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:02615ed8c5ea222323408ceba16c60e99c3f91639b07da6373fb7e6539abc56d"}, - {file = "psutil-5.9.8-cp27-none-win32.whl", hash = "sha256:36f435891adb138ed3c9e58c6af3e2e6ca9ac2f365efe1f9cfef2794e6c93b4e"}, - {file = "psutil-5.9.8-cp27-none-win_amd64.whl", hash = "sha256:bd1184ceb3f87651a67b2708d4c3338e9b10c5df903f2e3776b62303b26cb631"}, - {file = "psutil-5.9.8-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:aee678c8720623dc456fa20659af736241f575d79429a0e5e9cf88ae0605cc81"}, - {file = "psutil-5.9.8-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8cb6403ce6d8e047495a701dc7c5bd788add903f8986d523e3e20b98b733e421"}, - {file = "psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d06016f7f8625a1825ba3732081d77c94589dca78b7a3fc072194851e88461a4"}, - {file = "psutil-5.9.8-cp36-cp36m-win32.whl", hash = "sha256:7d79560ad97af658a0f6adfef8b834b53f64746d45b403f225b85c5c2c140eee"}, - {file = "psutil-5.9.8-cp36-cp36m-win_amd64.whl", hash = "sha256:27cc40c3493bb10de1be4b3f07cae4c010ce715290a5be22b98493509c6299e2"}, - {file = "psutil-5.9.8-cp37-abi3-win32.whl", hash = "sha256:bc56c2a1b0d15aa3eaa5a60c9f3f8e3e565303b465dbf57a1b730e7a2b9844e0"}, - {file = "psutil-5.9.8-cp37-abi3-win_amd64.whl", hash = "sha256:8db4c1b57507eef143a15a6884ca10f7c73876cdf5d51e713151c1236a0e68cf"}, - {file = "psutil-5.9.8-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:d16bbddf0693323b8c6123dd804100241da461e41d6e332fb0ba6058f630f8c8"}, - {file = "psutil-5.9.8.tar.gz", hash = "sha256:6be126e3225486dff286a8fb9a06246a5253f4c7c53b475ea5f5ac934e64194c"}, + {file = "psutil-6.1.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ff34df86226c0227c52f38b919213157588a678d049688eded74c76c8ba4a5d0"}, + {file = "psutil-6.1.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:c0e0c00aa18ca2d3b2b991643b799a15fc8f0563d2ebb6040f64ce8dc027b942"}, + {file = "psutil-6.1.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:000d1d1ebd634b4efb383f4034437384e44a6d455260aaee2eca1e9c1b55f047"}, + {file = "psutil-6.1.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:5cd2bcdc75b452ba2e10f0e8ecc0b57b827dd5d7aaffbc6821b2a9a242823a76"}, + {file = "psutil-6.1.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:045f00a43c737f960d273a83973b2511430d61f283a44c96bf13a6e829ba8fdc"}, + {file = "psutil-6.1.0-cp27-none-win32.whl", hash = "sha256:9118f27452b70bb1d9ab3198c1f626c2499384935aaf55388211ad982611407e"}, + {file = "psutil-6.1.0-cp27-none-win_amd64.whl", hash = "sha256:a8506f6119cff7015678e2bce904a4da21025cc70ad283a53b099e7620061d85"}, + {file = "psutil-6.1.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:6e2dcd475ce8b80522e51d923d10c7871e45f20918e027ab682f94f1c6351688"}, + {file = "psutil-6.1.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:0895b8414afafc526712c498bd9de2b063deaac4021a3b3c34566283464aff8e"}, + {file = "psutil-6.1.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9dcbfce5d89f1d1f2546a2090f4fcf87c7f669d1d90aacb7d7582addece9fb38"}, + {file = "psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:498c6979f9c6637ebc3a73b3f87f9eb1ec24e1ce53a7c5173b8508981614a90b"}, + {file = "psutil-6.1.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d905186d647b16755a800e7263d43df08b790d709d575105d419f8b6ef65423a"}, + {file = "psutil-6.1.0-cp36-cp36m-win32.whl", hash = "sha256:6d3fbbc8d23fcdcb500d2c9f94e07b1342df8ed71b948a2649b5cb060a7c94ca"}, + {file = "psutil-6.1.0-cp36-cp36m-win_amd64.whl", hash = "sha256:1209036fbd0421afde505a4879dee3b2fd7b1e14fee81c0069807adcbbcca747"}, + {file = "psutil-6.1.0-cp37-abi3-win32.whl", hash = "sha256:1ad45a1f5d0b608253b11508f80940985d1d0c8f6111b5cb637533a0e6ddc13e"}, + {file = "psutil-6.1.0-cp37-abi3-win_amd64.whl", hash = "sha256:a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be"}, + {file = "psutil-6.1.0.tar.gz", hash = "sha256:353815f59a7f64cdaca1c0307ee13558a0512f6db064e92fe833784f08539c7a"}, ] [package.extras] -test = ["enum34", "ipaddress", "mock", "pywin32", "wmi"] +dev = ["black", "check-manifest", "coverage", "packaging", "pylint", "pyperf", "pypinfo", "pytest-cov", "requests", "rstcheck", "ruff", "sphinx", "sphinx_rtd_theme", "toml-sort", "twine", "virtualenv", "wheel"] +test = ["pytest", "pytest-xdist", "setuptools"] [[package]] name = "py-cpuinfo" @@ -1931,114 +2119,145 @@ files = [ [[package]] name = "pydantic" -version = "2.7.1" +version = "2.9.2" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.1-py3-none-any.whl", hash = "sha256:e029badca45266732a9a79898a15ae2e8b14840b1eabbb25844be28f0b33f3d5"}, - {file = "pydantic-2.7.1.tar.gz", hash = "sha256:e9dbb5eada8abe4d9ae5f46b9939aead650cd2b68f249bb3a8139dbe125803cc"}, + {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.18.2" -typing-extensions = ">=4.6.1" +annotated-types = ">=0.6.0" +pydantic-core = "2.23.4" +typing-extensions = [ + {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.18.2" +version = "2.23.4" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.18.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:9e08e867b306f525802df7cd16c44ff5ebbe747ff0ca6cf3fde7f36c05a59a81"}, - {file = "pydantic_core-2.18.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f0a21cbaa69900cbe1a2e7cad2aa74ac3cf21b10c3efb0fa0b80305274c0e8a2"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0680b1f1f11fda801397de52c36ce38ef1c1dc841a0927a94f226dea29c3ae3d"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:95b9d5e72481d3780ba3442eac863eae92ae43a5f3adb5b4d0a1de89d42bb250"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4fcf5cd9c4b655ad666ca332b9a081112cd7a58a8b5a6ca7a3104bc950f2038"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b5155ff768083cb1d62f3e143b49a8a3432e6789a3abee8acd005c3c7af1c74"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:553ef617b6836fc7e4df130bb851e32fe357ce36336d897fd6646d6058d980af"}, - {file = "pydantic_core-2.18.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b89ed9eb7d616ef5714e5590e6cf7f23b02d0d539767d33561e3675d6f9e3857"}, - {file = "pydantic_core-2.18.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:75f7e9488238e920ab6204399ded280dc4c307d034f3924cd7f90a38b1829563"}, - {file = "pydantic_core-2.18.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ef26c9e94a8c04a1b2924149a9cb081836913818e55681722d7f29af88fe7b38"}, - {file = "pydantic_core-2.18.2-cp310-none-win32.whl", hash = "sha256:182245ff6b0039e82b6bb585ed55a64d7c81c560715d1bad0cbad6dfa07b4027"}, - {file = "pydantic_core-2.18.2-cp310-none-win_amd64.whl", hash = "sha256:e23ec367a948b6d812301afc1b13f8094ab7b2c280af66ef450efc357d2ae543"}, - {file = "pydantic_core-2.18.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:219da3f096d50a157f33645a1cf31c0ad1fe829a92181dd1311022f986e5fbe3"}, - {file = "pydantic_core-2.18.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:cc1cfd88a64e012b74e94cd00bbe0f9c6df57049c97f02bb07d39e9c852e19a4"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05b7133a6e6aeb8df37d6f413f7705a37ab4031597f64ab56384c94d98fa0e90"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:224c421235f6102e8737032483f43c1a8cfb1d2f45740c44166219599358c2cd"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b14d82cdb934e99dda6d9d60dc84a24379820176cc4a0d123f88df319ae9c150"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2728b01246a3bba6de144f9e3115b532ee44bd6cf39795194fb75491824a1413"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:470b94480bb5ee929f5acba6995251ada5e059a5ef3e0dfc63cca287283ebfa6"}, - {file = "pydantic_core-2.18.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:997abc4df705d1295a42f95b4eec4950a37ad8ae46d913caeee117b6b198811c"}, - {file = "pydantic_core-2.18.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:75250dbc5290e3f1a0f4618db35e51a165186f9034eff158f3d490b3fed9f8a0"}, - {file = "pydantic_core-2.18.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4456f2dca97c425231d7315737d45239b2b51a50dc2b6f0c2bb181fce6207664"}, - {file = "pydantic_core-2.18.2-cp311-none-win32.whl", hash = "sha256:269322dcc3d8bdb69f054681edff86276b2ff972447863cf34c8b860f5188e2e"}, - {file = "pydantic_core-2.18.2-cp311-none-win_amd64.whl", hash = "sha256:800d60565aec896f25bc3cfa56d2277d52d5182af08162f7954f938c06dc4ee3"}, - {file = "pydantic_core-2.18.2-cp311-none-win_arm64.whl", hash = "sha256:1404c69d6a676245199767ba4f633cce5f4ad4181f9d0ccb0577e1f66cf4c46d"}, - {file = "pydantic_core-2.18.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:fb2bd7be70c0fe4dfd32c951bc813d9fe6ebcbfdd15a07527796c8204bd36242"}, - {file = "pydantic_core-2.18.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6132dd3bd52838acddca05a72aafb6eab6536aa145e923bb50f45e78b7251043"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7d904828195733c183d20a54230c0df0eb46ec746ea1a666730787353e87182"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c9bd70772c720142be1020eac55f8143a34ec9f82d75a8e7a07852023e46617f"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2b8ed04b3582771764538f7ee7001b02e1170223cf9b75dff0bc698fadb00cf3"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e6dac87ddb34aaec85f873d737e9d06a3555a1cc1a8e0c44b7f8d5daeb89d86f"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7ca4ae5a27ad7a4ee5170aebce1574b375de390bc01284f87b18d43a3984df72"}, - {file = "pydantic_core-2.18.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:886eec03591b7cf058467a70a87733b35f44707bd86cf64a615584fd72488b7c"}, - {file = "pydantic_core-2.18.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ca7b0c1f1c983e064caa85f3792dd2fe3526b3505378874afa84baf662e12241"}, - {file = "pydantic_core-2.18.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4b4356d3538c3649337df4074e81b85f0616b79731fe22dd11b99499b2ebbdf3"}, - {file = "pydantic_core-2.18.2-cp312-none-win32.whl", hash = "sha256:8b172601454f2d7701121bbec3425dd71efcb787a027edf49724c9cefc14c038"}, - {file = "pydantic_core-2.18.2-cp312-none-win_amd64.whl", hash = "sha256:b1bd7e47b1558ea872bd16c8502c414f9e90dcf12f1395129d7bb42a09a95438"}, - {file = "pydantic_core-2.18.2-cp312-none-win_arm64.whl", hash = "sha256:98758d627ff397e752bc339272c14c98199c613f922d4a384ddc07526c86a2ec"}, - {file = "pydantic_core-2.18.2-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:9fdad8e35f278b2c3eb77cbdc5c0a49dada440657bf738d6905ce106dc1de439"}, - {file = "pydantic_core-2.18.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1d90c3265ae107f91a4f279f4d6f6f1d4907ac76c6868b27dc7fb33688cfb347"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:390193c770399861d8df9670fb0d1874f330c79caaca4642332df7c682bf6b91"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:82d5d4d78e4448683cb467897fe24e2b74bb7b973a541ea1dcfec1d3cbce39fb"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4774f3184d2ef3e14e8693194f661dea5a4d6ca4e3dc8e39786d33a94865cefd"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d4d938ec0adf5167cb335acb25a4ee69a8107e4984f8fbd2e897021d9e4ca21b"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0e8b1be28239fc64a88a8189d1df7fad8be8c1ae47fcc33e43d4be15f99cc70"}, - {file = "pydantic_core-2.18.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:868649da93e5a3d5eacc2b5b3b9235c98ccdbfd443832f31e075f54419e1b96b"}, - {file = "pydantic_core-2.18.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:78363590ef93d5d226ba21a90a03ea89a20738ee5b7da83d771d283fd8a56761"}, - {file = "pydantic_core-2.18.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:852e966fbd035a6468fc0a3496589b45e2208ec7ca95c26470a54daed82a0788"}, - {file = "pydantic_core-2.18.2-cp38-none-win32.whl", hash = "sha256:6a46e22a707e7ad4484ac9ee9f290f9d501df45954184e23fc29408dfad61350"}, - {file = "pydantic_core-2.18.2-cp38-none-win_amd64.whl", hash = "sha256:d91cb5ea8b11607cc757675051f61b3d93f15eca3cefb3e6c704a5d6e8440f4e"}, - {file = "pydantic_core-2.18.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:ae0a8a797a5e56c053610fa7be147993fe50960fa43609ff2a9552b0e07013e8"}, - {file = "pydantic_core-2.18.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:042473b6280246b1dbf530559246f6842b56119c2926d1e52b631bdc46075f2a"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a388a77e629b9ec814c1b1e6b3b595fe521d2cdc625fcca26fbc2d44c816804"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e25add29b8f3b233ae90ccef2d902d0ae0432eb0d45370fe315d1a5cf231004b"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f459a5ce8434614dfd39bbebf1041952ae01da6bed9855008cb33b875cb024c0"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eff2de745698eb46eeb51193a9f41d67d834d50e424aef27df2fcdee1b153845"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8309f67285bdfe65c372ea3722b7a5642680f3dba538566340a9d36e920b5f0"}, - {file = "pydantic_core-2.18.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f93a8a2e3938ff656a7c1bc57193b1319960ac015b6e87d76c76bf14fe0244b4"}, - {file = "pydantic_core-2.18.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:22057013c8c1e272eb8d0eebc796701167d8377441ec894a8fed1af64a0bf399"}, - {file = "pydantic_core-2.18.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cfeecd1ac6cc1fb2692c3d5110781c965aabd4ec5d32799773ca7b1456ac636b"}, - {file = "pydantic_core-2.18.2-cp39-none-win32.whl", hash = "sha256:0d69b4c2f6bb3e130dba60d34c0845ba31b69babdd3f78f7c0c8fae5021a253e"}, - {file = "pydantic_core-2.18.2-cp39-none-win_amd64.whl", hash = "sha256:d9319e499827271b09b4e411905b24a426b8fb69464dfa1696258f53a3334641"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a1874c6dd4113308bd0eb568418e6114b252afe44319ead2b4081e9b9521fe75"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:ccdd111c03bfd3666bd2472b674c6899550e09e9f298954cfc896ab92b5b0e6d"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e18609ceaa6eed63753037fc06ebb16041d17d28199ae5aba0052c51449650a9"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e5c584d357c4e2baf0ff7baf44f4994be121e16a2c88918a5817331fc7599d7"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43f0f463cf89ace478de71a318b1b4f05ebc456a9b9300d027b4b57c1a2064fb"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:e1b395e58b10b73b07b7cf740d728dd4ff9365ac46c18751bf8b3d8cca8f625a"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:0098300eebb1c837271d3d1a2cd2911e7c11b396eac9661655ee524a7f10587b"}, - {file = "pydantic_core-2.18.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:36789b70d613fbac0a25bb07ab3d9dba4d2e38af609c020cf4d888d165ee0bf3"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:3f9a801e7c8f1ef8718da265bba008fa121243dfe37c1cea17840b0944dfd72c"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:3a6515ebc6e69d85502b4951d89131ca4e036078ea35533bb76327f8424531ce"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20aca1e2298c56ececfd8ed159ae4dde2df0781988c97ef77d5c16ff4bd5b400"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:223ee893d77a310a0391dca6df00f70bbc2f36a71a895cecd9a0e762dc37b349"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2334ce8c673ee93a1d6a65bd90327588387ba073c17e61bf19b4fd97d688d63c"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:cbca948f2d14b09d20268cda7b0367723d79063f26c4ffc523af9042cad95592"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:b3ef08e20ec49e02d5c6717a91bb5af9b20f1805583cb0adfe9ba2c6b505b5ae"}, - {file = "pydantic_core-2.18.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:c6fdc8627910eed0c01aed6a390a252fe3ea6d472ee70fdde56273f198938374"}, - {file = "pydantic_core-2.18.2.tar.gz", hash = "sha256:2e29d20810dfc3043ee13ac7d9e25105799817683348823f305ab3f349b9386e"}, + {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] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" +[[package]] +name = "pyee" +version = "12.0.0" +description = "A rough port of Node.js's EventEmitter to Python with a few tricks of its own" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyee-12.0.0-py3-none-any.whl", hash = "sha256:7b14b74320600049ccc7d0e0b1becd3b4bd0a03c745758225e31a59f4095c990"}, + {file = "pyee-12.0.0.tar.gz", hash = "sha256:c480603f4aa2927d4766eb41fa82793fe60a82cbfdb8d688e0d08c55a534e145"}, +] + +[package.dependencies] +typing-extensions = "*" + +[package.extras] +dev = ["black", "build", "flake8", "flake8-black", "isort", "jupyter-console", "mkdocs", "mkdocs-include-markdown-plugin", "mkdocstrings[python]", "pytest", "pytest-asyncio", "pytest-trio", "sphinx", "toml", "tox", "trio", "trio", "trio-typing", "twine", "twisted", "validate-pyproject[all]"] + [[package]] name = "pygments" version = "2.18.0" @@ -2055,13 +2274,13 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pyproject-hooks" -version = "1.1.0" +version = "1.2.0" description = "Wrappers to call pyproject.toml-based build backend hooks." optional = false python-versions = ">=3.7" files = [ - {file = "pyproject_hooks-1.1.0-py3-none-any.whl", hash = "sha256:7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2"}, - {file = "pyproject_hooks-1.1.0.tar.gz", hash = "sha256:4b37730834edbd6bd37f26ece6b44802fb1c1ee2ece0e54ddff8bfc06db86965"}, + {file = "pyproject_hooks-1.2.0-py3-none-any.whl", hash = "sha256:9e5c6bfa8dcc30091c74b0cf803c81fdd29d94f01992a7707bc97babb1141913"}, + {file = "pyproject_hooks-1.2.0.tar.gz", hash = "sha256:1e859bd5c40fae9448642dd871adf459e5e2084186e8d2c2a79a824c970da1f8"}, ] [[package]] @@ -2096,13 +2315,13 @@ files = [ [[package]] name = "pytest" -version = "7.4.4" +version = "8.3.3" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, - {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, + {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, + {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, ] [package.dependencies] @@ -2110,29 +2329,47 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} +pluggy = ">=1.5,<2" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-asyncio" -version = "0.21.2" +version = "0.24.0" description = "Pytest support for asyncio" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest_asyncio-0.21.2-py3-none-any.whl", hash = "sha256:ab664c88bb7998f711d8039cacd4884da6430886ae8bbd4eded552ed2004f16b"}, - {file = "pytest_asyncio-0.21.2.tar.gz", hash = "sha256:d67738fc232b94b326b9d060750beb16e0074210b98dd8b58a5239fa2a154f45"}, + {file = "pytest_asyncio-0.24.0-py3-none-any.whl", hash = "sha256:a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b"}, + {file = "pytest_asyncio-0.24.0.tar.gz", hash = "sha256:d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276"}, +] + +[package.dependencies] +pytest = ">=8.2,<9" + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] + +[[package]] +name = "pytest-base-url" +version = "2.1.0" +description = "pytest plugin for URL based testing" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_base_url-2.1.0-py3-none-any.whl", hash = "sha256:3ad15611778764d451927b2a53240c1a7a591b521ea44cebfe45849d2d2812e6"}, + {file = "pytest_base_url-2.1.0.tar.gz", hash = "sha256:02748589a54f9e63fcbe62301d6b0496da0d10231b753e950c63e03aee745d45"}, ] [package.dependencies] pytest = ">=7.0.0" +requests = ">=2.9" [package.extras] -docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] -testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] +test = ["black (>=22.1.0)", "flake8 (>=4.0.1)", "pre-commit (>=2.17.0)", "pytest-localserver (>=0.7.1)", "tox (>=3.24.5)"] [[package]] name = "pytest-benchmark" @@ -2156,13 +2393,13 @@ histogram = ["pygal", "pygaljs"] [[package]] name = "pytest-cov" -version = "4.1.0" +version = "5.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, - {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, + {file = "pytest-cov-5.0.0.tar.gz", hash = "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"}, + {file = "pytest_cov-5.0.0-py3-none-any.whl", hash = "sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652"}, ] [package.dependencies] @@ -2170,7 +2407,7 @@ coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" [package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-mock" @@ -2189,6 +2426,23 @@ pytest = ">=6.2.5" [package.extras] dev = ["pre-commit", "pytest-asyncio", "tox"] +[[package]] +name = "pytest-playwright" +version = "0.5.2" +description = "A pytest wrapper with fixtures for Playwright to automate web browsers" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_playwright-0.5.2-py3-none-any.whl", hash = "sha256:2c5720591364a1cdf66610b972ff8492512bc380953e043c85f705b78b2ed582"}, + {file = "pytest_playwright-0.5.2.tar.gz", hash = "sha256:c6d603df9e6c50b35f057b0528e11d41c0963283e98c257267117f5ed6ba1924"}, +] + +[package.dependencies] +playwright = ">=1.18" +pytest = ">=6.2.4,<9.0.0" +pytest-base-url = ">=1.0.0,<3.0.0" +python-slugify = ">=6.0.0,<9.0.0" + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -2205,13 +2459,13 @@ six = ">=1.5" [[package]] name = "python-engineio" -version = "4.9.0" +version = "4.10.1" description = "Engine.IO server and client for Python" optional = false python-versions = ">=3.6" files = [ - {file = "python-engineio-4.9.0.tar.gz", hash = "sha256:e87459c15638e567711fd156e6f9c4a402668871bed79523f0ecfec744729ec7"}, - {file = "python_engineio-4.9.0-py3-none-any.whl", hash = "sha256:979859bff770725b75e60353d7ae53b397e8b517d05ba76733b404a3dcca3e4c"}, + {file = "python_engineio-4.10.1-py3-none-any.whl", hash = "sha256:445a94004ec8034960ab99e7ce4209ec619c6e6b6a12aedcb05abeab924025c0"}, + {file = "python_engineio-4.10.1.tar.gz", hash = "sha256:166cea8dd7429638c5c4e3a4895beae95196e860bc6f29ed0b9fe753d1ef2072"}, ] [package.dependencies] @@ -2224,27 +2478,41 @@ docs = ["sphinx"] [[package]] name = "python-multipart" -version = "0.0.9" +version = "0.0.17" description = "A streaming multipart parser for Python" optional = false python-versions = ">=3.8" files = [ - {file = "python_multipart-0.0.9-py3-none-any.whl", hash = "sha256:97ca7b8ea7b05f977dc3849c3ba99d51689822fab725c3703af7c866a0c2b215"}, - {file = "python_multipart-0.0.9.tar.gz", hash = "sha256:03f54688c663f1b7977105f021043b0793151e4cb1c1a9d4a11fc13d622c4026"}, + {file = "python_multipart-0.0.17-py3-none-any.whl", hash = "sha256:15dc4f487e0a9476cc1201261188ee0940165cffc94429b6fc565c4d3045cb5d"}, + {file = "python_multipart-0.0.17.tar.gz", hash = "sha256:41330d831cae6e2f22902704ead2826ea038d0419530eadff3ea80175aec5538"}, ] +[[package]] +name = "python-slugify" +version = "8.0.4" +description = "A Python slugify application that also handles Unicode" +optional = false +python-versions = ">=3.7" +files = [ + {file = "python-slugify-8.0.4.tar.gz", hash = "sha256:59202371d1d05b54a9e7720c5e038f928f45daaffe41dd10822f3907b937c856"}, + {file = "python_slugify-8.0.4-py2.py3-none-any.whl", hash = "sha256:276540b79961052b66b7d116620b36518847f52d5fd9e3a70164fc8c50faa6b8"}, +] + +[package.dependencies] +text-unidecode = ">=1.3" + [package.extras] -dev = ["atomicwrites (==1.4.1)", "attrs (==23.2.0)", "coverage (==7.4.1)", "hatch", "invoke (==2.2.0)", "more-itertools (==10.2.0)", "pbr (==6.0.0)", "pluggy (==1.4.0)", "py (==1.11.0)", "pytest (==8.0.0)", "pytest-cov (==4.1.0)", "pytest-timeout (==2.2.0)", "pyyaml (==6.0.1)", "ruff (==0.2.1)"] +unidecode = ["Unidecode (>=1.1.1)"] [[package]] name = "python-socketio" -version = "5.11.2" +version = "5.11.4" description = "Socket.IO server and client for Python" optional = false python-versions = ">=3.8" files = [ - {file = "python-socketio-5.11.2.tar.gz", hash = "sha256:ae6a1de5c5209ca859dc574dccc8931c4be17ee003e74ce3b8d1306162bb4a37"}, - {file = "python_socketio-5.11.2-py3-none-any.whl", hash = "sha256:b9f22a8ff762d7a6e123d16a43ddb1a27d50f07c3c88ea999334f2f89b0ad52b"}, + {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] @@ -2258,88 +2526,101 @@ 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]] name = "pywin32-ctypes" -version = "0.2.2" +version = "0.2.3" description = "A (partial) reimplementation of pywin32 using ctypes/cffi" optional = false python-versions = ">=3.6" files = [ - {file = "pywin32-ctypes-0.2.2.tar.gz", hash = "sha256:3426e063bdd5fd4df74a14fa3cf80a0b42845a87e1d1e81f6549f9daec593a60"}, - {file = "pywin32_ctypes-0.2.2-py3-none-any.whl", hash = "sha256:bf490a1a709baf35d688fe0ecf980ed4de11d2b3e37b51e5442587a75d9957e7"}, + {file = "pywin32-ctypes-0.2.3.tar.gz", hash = "sha256:d162dc04946d704503b2edc4d55f3dba5c1d539ead017afa00142c38b9885755"}, + {file = "pywin32_ctypes-0.2.3-py3-none-any.whl", hash = "sha256:8a1513379d709975552d202d942d9837758905c8d01eb82b8bcc30918929e7b8"}, ] [[package]] name = "pyyaml" -version = "6.0.1" +version = "6.0.2" description = "YAML parser and emitter for Python" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, - {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, - {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, - {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, - {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, - {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, - {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, - {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, - {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, + {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, + {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed"}, + {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180"}, + {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68"}, + {file = "PyYAML-6.0.2-cp310-cp310-win32.whl", hash = "sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99"}, + {file = "PyYAML-6.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e"}, + {file = "PyYAML-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774"}, + {file = "PyYAML-6.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85"}, + {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4"}, + {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e"}, + {file = "PyYAML-6.0.2-cp311-cp311-win32.whl", hash = "sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5"}, + {file = "PyYAML-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44"}, + {file = "PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab"}, + {file = "PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476"}, + {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48"}, + {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b"}, + {file = "PyYAML-6.0.2-cp312-cp312-win32.whl", hash = "sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4"}, + {file = "PyYAML-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8"}, + {file = "PyYAML-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba"}, + {file = "PyYAML-6.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5"}, + {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc"}, + {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652"}, + {file = "PyYAML-6.0.2-cp313-cp313-win32.whl", hash = "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183"}, + {file = "PyYAML-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563"}, + {file = "PyYAML-6.0.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083"}, + {file = "PyYAML-6.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706"}, + {file = "PyYAML-6.0.2-cp38-cp38-win32.whl", hash = "sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a"}, + {file = "PyYAML-6.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff"}, + {file = "PyYAML-6.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d"}, + {file = "PyYAML-6.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19"}, + {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e"}, + {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725"}, + {file = "PyYAML-6.0.2-cp39-cp39-win32.whl", hash = "sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631"}, + {file = "PyYAML-6.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8"}, + {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] [[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" @@ -2348,21 +2629,35 @@ md = ["cmarkgfm (>=0.8.0)"] [[package]] name = "redis" -version = "5.0.4" +version = "5.2.0" description = "Python client for Redis database and key-value store" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "redis-5.0.4-py3-none-any.whl", hash = "sha256:7adc2835c7a9b5033b7ad8f8918d09b7344188228809c98df07af226d39dec91"}, - {file = "redis-5.0.4.tar.gz", hash = "sha256:ec31f2ed9675cc54c21ba854cfe0462e6faf1d83c8ce5944709db8a4700b9c61"}, + {file = "redis-5.2.0-py3-none-any.whl", hash = "sha256:ae174f2bb3b1bf2b09d54bf3e51fbc1469cf6c10aa03e21141f51969801a7897"}, + {file = "redis-5.2.0.tar.gz", hash = "sha256:0b1087665a771b1ff2e003aa5bdd354f15a70c9e25d5a7dbf9c722c16528a7b0"}, ] [package.dependencies] async-timeout = {version = ">=4.0.3", markers = "python_full_version < \"3.11.3\""} [package.extras] -hiredis = ["hiredis (>=1.0.0)"] -ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"] +hiredis = ["hiredis (>=3.0.0)"] +ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==23.2.1)", "requests (>=2.31.0)"] + +[[package]] +name = "reflex-chakra" +version = "0.6.2" +description = "reflex using chakra components" +optional = false +python-versions = "<4.0,>=3.9" +files = [ + {file = "reflex_chakra-0.6.2-py3-none-any.whl", hash = "sha256:b8aa19f39a02601c560b97f4b17f171c0b5980e13a58069e3a5dd0999e362e4f"}, + {file = "reflex_chakra-0.6.2.tar.gz", hash = "sha256:81ddb7f182cc454922cc817312755b799d4e1a49a46ef2e81305052dc76ef86d"}, +] + +[package.dependencies] +reflex = ">=0.6.0a" [[package]] name = "reflex-hosting-cli" @@ -2389,13 +2684,13 @@ websockets = ">=10.4" [[package]] name = "requests" -version = "2.31.0" +version = "2.32.3" description = "Python HTTP for Humans." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -2438,47 +2733,48 @@ idna2008 = ["idna"] [[package]] name = "rich" -version = "13.7.1" +version = "13.9.3" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false -python-versions = ">=3.7.0" +python-versions = ">=3.8.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.9.3-py3-none-any.whl", hash = "sha256:9836f5096eb2172c9e77df411c1b009bace4193d6a481d534fea75ebba758283"}, + {file = "rich-13.9.3.tar.gz", hash = "sha256:bc1e01b899537598cf02579d2b9f4a415104d3fc439313a7a2c165d76557a08e"}, ] [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\""} +typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.11\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.1.0" -description = "An extremely fast Python linter, written in Rust." +version = "0.7.1" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.0-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:87114e254dee35e069e1b922d85d4b21a5b61aec759849f393e1dbb308a00439"}, - {file = "ruff-0.1.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:764f36d2982cc4a703e69fb73a280b7c539fd74b50c9ee531a4e3fe88152f521"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:65f4b7fb539e5cf0f71e9bd74f8ddab74cabdd673c6fb7f17a4dcfd29f126255"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:299fff467a0f163baa282266b310589b21400de0a42d8f68553422fa6bf7ee01"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0d412678bf205787263bb702c984012a4f97e460944c072fd7cfa2bd084857c4"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a5391b49b1669b540924640587d8d24128e45be17d1a916b1801d6645e831581"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee8cd57f454cdd77bbcf1e11ff4e0046fb6547cac1922cc6e3583ce4b9c326d1"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fa7aeed7bc23861a2b38319b636737bf11cfa55d2109620b49cf995663d3e888"}, - {file = "ruff-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b04cd4298b43b16824d9a37800e4c145ba75c29c43ce0d74cad1d66d7ae0a4c5"}, - {file = "ruff-0.1.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7186ccf54707801d91e6314a016d1c7895e21d2e4cd614500d55870ed983aa9f"}, - {file = "ruff-0.1.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d88adfd93849bc62449518228581d132e2023e30ebd2da097f73059900d8dce3"}, - {file = "ruff-0.1.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:ad2ccdb3bad5a61013c76a9c1240fdfadf2c7103a2aeebd7bcbbed61f363138f"}, - {file = "ruff-0.1.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b77f6cfa72c6eb19b5cac967cc49762ae14d036db033f7d97a72912770fd8e1c"}, - {file = "ruff-0.1.0-py3-none-win32.whl", hash = "sha256:480bd704e8af1afe3fd444cc52e3c900b936e6ca0baf4fb0281124330b6ceba2"}, - {file = "ruff-0.1.0-py3-none-win_amd64.whl", hash = "sha256:a76ba81860f7ee1f2d5651983f87beb835def94425022dc5f0803108f1b8bfa2"}, - {file = "ruff-0.1.0-py3-none-win_arm64.whl", hash = "sha256:45abdbdab22509a2c6052ecf7050b3f5c7d6b7898dc07e82869401b531d46da4"}, - {file = "ruff-0.1.0.tar.gz", hash = "sha256:ad6b13824714b19c5f8225871cf532afb994470eecb74631cd3500fe817e6b3f"}, + {file = "ruff-0.7.1-py3-none-linux_armv6l.whl", hash = "sha256:cb1bc5ed9403daa7da05475d615739cc0212e861b7306f314379d958592aaa89"}, + {file = "ruff-0.7.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:27c1c52a8d199a257ff1e5582d078eab7145129aa02721815ca8fa4f9612dc35"}, + {file = "ruff-0.7.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:588a34e1ef2ea55b4ddfec26bbe76bc866e92523d8c6cdec5e8aceefeff02d99"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94fc32f9cdf72dc75c451e5f072758b118ab8100727168a3df58502b43a599ca"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:985818742b833bffa543a84d1cc11b5e6871de1b4e0ac3060a59a2bae3969250"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:32f1e8a192e261366c702c5fb2ece9f68d26625f198a25c408861c16dc2dea9c"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:699085bf05819588551b11751eff33e9ca58b1b86a6843e1b082a7de40da1565"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:344cc2b0814047dc8c3a8ff2cd1f3d808bb23c6658db830d25147339d9bf9ea7"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4316bbf69d5a859cc937890c7ac7a6551252b6a01b1d2c97e8fc96e45a7c8b4a"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79d3af9dca4c56043e738a4d6dd1e9444b6d6c10598ac52d146e331eb155a8ad"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c5c121b46abde94a505175524e51891f829414e093cd8326d6e741ecfc0a9112"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8422104078324ea250886954e48f1373a8fe7de59283d747c3a7eca050b4e378"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:56aad830af8a9db644e80098fe4984a948e2b6fc2e73891538f43bbe478461b8"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:658304f02f68d3a83c998ad8bf91f9b4f53e93e5412b8f2388359d55869727fd"}, + {file = "ruff-0.7.1-py3-none-win32.whl", hash = "sha256:b517a2011333eb7ce2d402652ecaa0ac1a30c114fbbd55c6b8ee466a7f600ee9"}, + {file = "ruff-0.7.1-py3-none-win_amd64.whl", hash = "sha256:f38c41fcde1728736b4eb2b18850f6d1e3eedd9678c914dede554a70d5241307"}, + {file = "ruff-0.7.1-py3-none-win_arm64.whl", hash = "sha256:19aa200ec824c0f36d0c9114c8ec0087082021732979a359d6f3c390a6ff2a37"}, + {file = "ruff-0.7.1.tar.gz", hash = "sha256:9d8a41d4aa2dad1575adb98a82870cf5db5f76b2938cf2206c22c940034a36f4"}, ] [[package]] @@ -2498,37 +2794,42 @@ jeepney = ">=0.6" [[package]] name = "selenium" -version = "4.20.0" -description = "" +version = "4.26.1" +description = "Official Python bindings for Selenium WebDriver" optional = false python-versions = ">=3.8" files = [ - {file = "selenium-4.20.0-py3-none-any.whl", hash = "sha256:b1d0c33b38ca27d0499183e48e1dd09ff26973481f5d3ef2983073813ae6588d"}, - {file = "selenium-4.20.0.tar.gz", hash = "sha256:0bd564ee166980d419a8aaf4ac00289bc152afcf2eadca5efe8c8e36711853fd"}, + {file = "selenium-4.26.1-py3-none-any.whl", hash = "sha256:1db3f3a0cd5bb07624fa8a3905a6fdde1595a42185a0617077c361dc53d104fb"}, + {file = "selenium-4.26.1.tar.gz", hash = "sha256:7640f3f08ae7f4e450f895678e8a10a55eb4e4ca18311ed675ecc4684b96b683"}, ] [package.dependencies] certifi = ">=2021.10.8" trio = ">=0.17,<1.0" trio-websocket = ">=0.9,<1.0" -typing_extensions = ">=4.9.0" +typing_extensions = ">=4.9,<5.0" urllib3 = {version = ">=1.26,<3", extras = ["socks"]} +websocket-client = ">=1.8,<2.0" [[package]] name = "setuptools" -version = "69.5.1" +version = "75.3.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-69.5.1-py3-none-any.whl", hash = "sha256:c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32"}, - {file = "setuptools-69.5.1.tar.gz", hash = "sha256:6c1fccdac05a97e598fb0ae3bbed5904ccb317337a51139dcd51453611bbb987"}, + {file = "setuptools-75.3.0-py3-none-any.whl", hash = "sha256:f2504966861356aa38616760c0f66568e535562374995367b4e69c7143cf6bcd"}, + {file = "setuptools-75.3.0.tar.gz", hash = "sha256:fba5dd4d766e97be1b1681d98712680ae8f2f26d7881245f2ce9e40714f1a686"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)", "ruff (>=0.5.2)"] +core = ["importlib-metadata (>=6)", "importlib-resources (>=5.10.2)", "jaraco.collections", "jaraco.functools", "jaraco.text (>=3.7)", "more-itertools", "more-itertools (>=8.8)", "packaging", "packaging (>=24)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1)", "wheel (>=0.43.0)"] +cover = ["pytest-cov"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test (>=5.5)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] +type = ["importlib-metadata (>=7.0.2)", "jaraco.develop (>=7.21)", "mypy (==1.12.*)", "pytest-mypy"] [[package]] name = "shellingham" @@ -2543,19 +2844,20 @@ files = [ [[package]] name = "simple-websocket" -version = "1.0.0" +version = "1.1.0" description = "Simple WebSocket server and client for Python" optional = false python-versions = ">=3.6" files = [ - {file = "simple-websocket-1.0.0.tar.gz", hash = "sha256:17d2c72f4a2bd85174a97e3e4c88b01c40c3f81b7b648b0cc3ce1305968928c8"}, - {file = "simple_websocket-1.0.0-py3-none-any.whl", hash = "sha256:1d5bf585e415eaa2083e2bcf02a3ecf91f9712e7b3e6b9fa0b461ad04e0837bc"}, + {file = "simple_websocket-1.1.0-py3-none-any.whl", hash = "sha256:4af6069630a38ed6c561010f0e11a5bc0d4ca569b36306eb257cd9a192497c8c"}, + {file = "simple_websocket-1.1.0.tar.gz", hash = "sha256:7939234e7aa067c534abdab3a9ed933ec9ce4691b0713c78acb195560aa52ae4"}, ] [package.dependencies] wsproto = "*" [package.extras] +dev = ["flake8", "pytest", "pytest-cov", "tox"] docs = ["sphinx"] [[package]] @@ -2593,64 +2895,72 @@ files = [ [[package]] name = "sqlalchemy" -version = "2.0.30" +version = "2.0.36" description = "Database Abstraction Library" optional = false python-versions = ">=3.7" files = [ - {file = "SQLAlchemy-2.0.30-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3b48154678e76445c7ded1896715ce05319f74b1e73cf82d4f8b59b46e9c0ddc"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2753743c2afd061bb95a61a51bbb6a1a11ac1c44292fad898f10c9839a7f75b2"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a7bfc726d167f425d4c16269a9a10fe8630ff6d14b683d588044dcef2d0f6be7"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4f61ada6979223013d9ab83a3ed003ded6959eae37d0d685db2c147e9143797"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3a365eda439b7a00732638f11072907c1bc8e351c7665e7e5da91b169af794af"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bba002a9447b291548e8d66fd8c96a6a7ed4f2def0bb155f4f0a1309fd2735d5"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-win32.whl", hash = "sha256:0138c5c16be3600923fa2169532205d18891b28afa817cb49b50e08f62198bb8"}, - {file = "SQLAlchemy-2.0.30-cp310-cp310-win_amd64.whl", hash = "sha256:99650e9f4cf3ad0d409fed3eec4f071fadd032e9a5edc7270cd646a26446feeb"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:955991a09f0992c68a499791a753523f50f71a6885531568404fa0f231832aa0"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f69e4c756ee2686767eb80f94c0125c8b0a0b87ede03eacc5c8ae3b54b99dc46"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69c9db1ce00e59e8dd09d7bae852a9add716efdc070a3e2068377e6ff0d6fdaa"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1429a4b0f709f19ff3b0cf13675b2b9bfa8a7e79990003207a011c0db880a13"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:efedba7e13aa9a6c8407c48facfdfa108a5a4128e35f4c68f20c3407e4376aa9"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:16863e2b132b761891d6c49f0a0f70030e0bcac4fd208117f6b7e053e68668d0"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-win32.whl", hash = "sha256:2ecabd9ccaa6e914e3dbb2aa46b76dede7eadc8cbf1b8083c94d936bcd5ffb49"}, - {file = "SQLAlchemy-2.0.30-cp311-cp311-win_amd64.whl", hash = "sha256:0b3f4c438e37d22b83e640f825ef0f37b95db9aa2d68203f2c9549375d0b2260"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5a79d65395ac5e6b0c2890935bad892eabb911c4aa8e8015067ddb37eea3d56c"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9a5baf9267b752390252889f0c802ea13b52dfee5e369527da229189b8bd592e"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cb5a646930c5123f8461f6468901573f334c2c63c795b9af350063a736d0134"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:296230899df0b77dec4eb799bcea6fbe39a43707ce7bb166519c97b583cfcab3"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c62d401223f468eb4da32627bffc0c78ed516b03bb8a34a58be54d618b74d472"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:3b69e934f0f2b677ec111b4d83f92dc1a3210a779f69bf905273192cf4ed433e"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-win32.whl", hash = "sha256:77d2edb1f54aff37e3318f611637171e8ec71472f1fdc7348b41dcb226f93d90"}, - {file = "SQLAlchemy-2.0.30-cp312-cp312-win_amd64.whl", hash = "sha256:b6c7ec2b1f4969fc19b65b7059ed00497e25f54069407a8701091beb69e591a5"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5a8e3b0a7e09e94be7510d1661339d6b52daf202ed2f5b1f9f48ea34ee6f2d57"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b60203c63e8f984df92035610c5fb76d941254cf5d19751faab7d33b21e5ddc0"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f1dc3eabd8c0232ee8387fbe03e0a62220a6f089e278b1f0aaf5e2d6210741ad"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:40ad017c672c00b9b663fcfcd5f0864a0a97828e2ee7ab0c140dc84058d194cf"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e42203d8d20dc704604862977b1470a122e4892791fe3ed165f041e4bf447a1b"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-win32.whl", hash = "sha256:2a4f4da89c74435f2bc61878cd08f3646b699e7d2eba97144030d1be44e27584"}, - {file = "SQLAlchemy-2.0.30-cp37-cp37m-win_amd64.whl", hash = "sha256:b6bf767d14b77f6a18b6982cbbf29d71bede087edae495d11ab358280f304d8e"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bc0c53579650a891f9b83fa3cecd4e00218e071d0ba00c4890f5be0c34887ed3"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:311710f9a2ee235f1403537b10c7687214bb1f2b9ebb52702c5aa4a77f0b3af7"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:408f8b0e2c04677e9c93f40eef3ab22f550fecb3011b187f66a096395ff3d9fd"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:37a4b4fb0dd4d2669070fb05b8b8824afd0af57587393015baee1cf9890242d9"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a943d297126c9230719c27fcbbeab57ecd5d15b0bd6bfd26e91bfcfe64220621"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:0a089e218654e740a41388893e090d2e2c22c29028c9d1353feb38638820bbeb"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-win32.whl", hash = "sha256:fa561138a64f949f3e889eb9ab8c58e1504ab351d6cf55259dc4c248eaa19da6"}, - {file = "SQLAlchemy-2.0.30-cp38-cp38-win_amd64.whl", hash = "sha256:7d74336c65705b986d12a7e337ba27ab2b9d819993851b140efdf029248e818e"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ae8c62fe2480dd61c532ccafdbce9b29dacc126fe8be0d9a927ca3e699b9491a"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2383146973a15435e4717f94c7509982770e3e54974c71f76500a0136f22810b"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8409de825f2c3b62ab15788635ccaec0c881c3f12a8af2b12ae4910a0a9aeef6"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0094c5dc698a5f78d3d1539853e8ecec02516b62b8223c970c86d44e7a80f6c7"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:edc16a50f5e1b7a06a2dcc1f2205b0b961074c123ed17ebda726f376a5ab0953"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f7703c2010355dd28f53deb644a05fc30f796bd8598b43f0ba678878780b6e4c"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-win32.whl", hash = "sha256:1f9a727312ff6ad5248a4367358e2cf7e625e98b1028b1d7ab7b806b7d757513"}, - {file = "SQLAlchemy-2.0.30-cp39-cp39-win_amd64.whl", hash = "sha256:a0ef36b28534f2a5771191be6edb44cc2673c7b2edf6deac6562400288664221"}, - {file = "SQLAlchemy-2.0.30-py3-none-any.whl", hash = "sha256:7108d569d3990c71e26a42f60474b4c02c8586c4681af5fd67e51a044fdea86a"}, - {file = "SQLAlchemy-2.0.30.tar.gz", hash = "sha256:2b1708916730f4830bc69d6f49d37f7698b5bd7530aca7f04f785f8849e95255"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:59b8f3adb3971929a3e660337f5dacc5942c2cdb760afcabb2614ffbda9f9f72"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:37350015056a553e442ff672c2d20e6f4b6d0b2495691fa239d8aa18bb3bc908"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8318f4776c85abc3f40ab185e388bee7a6ea99e7fa3a30686580b209eaa35c08"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c245b1fbade9c35e5bd3b64270ab49ce990369018289ecfde3f9c318411aaa07"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:69f93723edbca7342624d09f6704e7126b152eaed3cdbb634cb657a54332a3c5"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f9511d8dd4a6e9271d07d150fb2f81874a3c8c95e11ff9af3a2dfc35fe42ee44"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-win32.whl", hash = "sha256:c3f3631693003d8e585d4200730616b78fafd5a01ef8b698f6967da5c605b3fa"}, + {file = "SQLAlchemy-2.0.36-cp310-cp310-win_amd64.whl", hash = "sha256:a86bfab2ef46d63300c0f06936bd6e6c0105faa11d509083ba8f2f9d237fb5b5"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fd3a55deef00f689ce931d4d1b23fa9f04c880a48ee97af488fd215cf24e2a6c"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4f5e9cd989b45b73bd359f693b935364f7e1f79486e29015813c338450aa5a71"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0ddd9db6e59c44875211bc4c7953a9f6638b937b0a88ae6d09eb46cced54eff"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2519f3a5d0517fc159afab1015e54bb81b4406c278749779be57a569d8d1bb0d"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:59b1ee96617135f6e1d6f275bbe988f419c5178016f3d41d3c0abb0c819f75bb"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:39769a115f730d683b0eb7b694db9789267bcd027326cccc3125e862eb03bfd8"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-win32.whl", hash = "sha256:66bffbad8d6271bb1cc2f9a4ea4f86f80fe5e2e3e501a5ae2a3dc6a76e604e6f"}, + {file = "SQLAlchemy-2.0.36-cp311-cp311-win_amd64.whl", hash = "sha256:23623166bfefe1487d81b698c423f8678e80df8b54614c2bf4b4cfcd7c711959"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f7b64e6ec3f02c35647be6b4851008b26cff592a95ecb13b6788a54ef80bbdd4"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:46331b00096a6db1fdc052d55b101dbbfc99155a548e20a0e4a8e5e4d1362855"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdf3386a801ea5aba17c6410dd1dc8d39cf454ca2565541b5ac42a84e1e28f53"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac9dfa18ff2a67b09b372d5db8743c27966abf0e5344c555d86cc7199f7ad83a"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:90812a8933df713fdf748b355527e3af257a11e415b613dd794512461eb8a686"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1bc330d9d29c7f06f003ab10e1eaced295e87940405afe1b110f2eb93a233588"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-win32.whl", hash = "sha256:79d2e78abc26d871875b419e1fd3c0bca31a1cb0043277d0d850014599626c2e"}, + {file = "SQLAlchemy-2.0.36-cp312-cp312-win_amd64.whl", hash = "sha256:b544ad1935a8541d177cb402948b94e871067656b3a0b9e91dbec136b06a2ff5"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b5cc79df7f4bc3d11e4b542596c03826063092611e481fcf1c9dfee3c94355ef"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3c01117dd36800f2ecaa238c65365b7b16497adc1522bf84906e5710ee9ba0e8"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9bc633f4ee4b4c46e7adcb3a9b5ec083bf1d9a97c1d3854b92749d935de40b9b"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e46ed38affdfc95d2c958de328d037d87801cfcbea6d421000859e9789e61c2"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b2985c0b06e989c043f1dc09d4fe89e1616aadd35392aea2844f0458a989eacf"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4a121d62ebe7d26fec9155f83f8be5189ef1405f5973ea4874a26fab9f1e262c"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-win32.whl", hash = "sha256:0572f4bd6f94752167adfd7c1bed84f4b240ee6203a95e05d1e208d488d0d436"}, + {file = "SQLAlchemy-2.0.36-cp313-cp313-win_amd64.whl", hash = "sha256:8c78ac40bde930c60e0f78b3cd184c580f89456dd87fc08f9e3ee3ce8765ce88"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:be9812b766cad94a25bc63bec11f88c4ad3629a0cec1cd5d4ba48dc23860486b"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50aae840ebbd6cdd41af1c14590e5741665e5272d2fee999306673a1bb1fdb4d"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4557e1f11c5f653ebfdd924f3f9d5ebfc718283b0b9beebaa5dd6b77ec290971"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:07b441f7d03b9a66299ce7ccf3ef2900abc81c0db434f42a5694a37bd73870f2"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:28120ef39c92c2dd60f2721af9328479516844c6b550b077ca450c7d7dc68575"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-win32.whl", hash = "sha256:b81ee3d84803fd42d0b154cb6892ae57ea6b7c55d8359a02379965706c7efe6c"}, + {file = "SQLAlchemy-2.0.36-cp37-cp37m-win_amd64.whl", hash = "sha256:f942a799516184c855e1a32fbc7b29d7e571b52612647866d4ec1c3242578fcb"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3d6718667da04294d7df1670d70eeddd414f313738d20a6f1d1f379e3139a545"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:72c28b84b174ce8af8504ca28ae9347d317f9dba3999e5981a3cd441f3712e24"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b11d0cfdd2b095e7b0686cf5fabeb9c67fae5b06d265d8180715b8cfa86522e3"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e32092c47011d113dc01ab3e1d3ce9f006a47223b18422c5c0d150af13a00687"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:6a440293d802d3011028e14e4226da1434b373cbaf4a4bbb63f845761a708346"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:c54a1e53a0c308a8e8a7dffb59097bff7facda27c70c286f005327f21b2bd6b1"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-win32.whl", hash = "sha256:1e0d612a17581b6616ff03c8e3d5eff7452f34655c901f75d62bd86449d9750e"}, + {file = "SQLAlchemy-2.0.36-cp38-cp38-win_amd64.whl", hash = "sha256:8958b10490125124463095bbdadda5aa22ec799f91958e410438ad6c97a7b793"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:dc022184d3e5cacc9579e41805a681187650e170eb2fd70e28b86192a479dcaa"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b817d41d692bf286abc181f8af476c4fbef3fd05e798777492618378448ee689"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a4e46a888b54be23d03a89be510f24a7652fe6ff660787b96cd0e57a4ebcb46d"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4ae3005ed83f5967f961fd091f2f8c5329161f69ce8480aa8168b2d7fe37f06"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:03e08af7a5f9386a43919eda9de33ffda16b44eb11f3b313e6822243770e9763"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:3dbb986bad3ed5ceaf090200eba750b5245150bd97d3e67343a3cfed06feecf7"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-win32.whl", hash = "sha256:9fe53b404f24789b5ea9003fc25b9a3988feddebd7e7b369c8fac27ad6f52f28"}, + {file = "SQLAlchemy-2.0.36-cp39-cp39-win_amd64.whl", hash = "sha256:af148a33ff0349f53512a049c6406923e4e02bf2f26c5fb285f143faf4f0e46a"}, + {file = "SQLAlchemy-2.0.36-py3-none-any.whl", hash = "sha256:fddbe92b4760c6f5d48162aef14824add991aeda8ddadb3c31d56eb15ca69f8e"}, + {file = "sqlalchemy-2.0.36.tar.gz", hash = "sha256:7f2767680b6d2398aea7082e45a774b2b0767b5c8d8ffb9c8b683088ea9b29c5"}, ] [package.dependencies] -greenlet = {version = "!=0.4.17", markers = "platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\""} +greenlet = {version = "!=0.4.17", markers = "python_version < \"3.13\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"} typing-extensions = ">=4.6.0" [package.extras] @@ -2659,7 +2969,7 @@ aioodbc = ["aioodbc", "greenlet (!=0.4.17)"] aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing_extensions (!=3.10.0.1)"] asyncio = ["greenlet (!=0.4.17)"] asyncmy = ["asyncmy (>=0.2.3,!=0.2.4,!=0.2.6)", "greenlet (!=0.4.17)"] -mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2,!=1.1.5)"] +mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2,!=1.1.5,!=1.1.10)"] mssql = ["pyodbc"] mssql-pymssql = ["pymssql"] mssql-pyodbc = ["pyodbc"] @@ -2680,28 +2990,28 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "sqlmodel" -version = "0.0.18" +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.18-py3-none-any.whl", hash = "sha256:d70fdf8fe595e30a918660cf4537b9c5fc2fffdbfcba851a0135de73c3ebcbb7"}, - {file = "sqlmodel-0.0.18.tar.gz", hash = "sha256:2e520efe03810ef2c268a1004cfc5ef8f8a936312232f38d6c8e62c11af2cac3"}, + {file = "sqlmodel-0.0.22-py3-none-any.whl", hash = "sha256:a1ed13e28a1f4057cbf4ff6cdb4fc09e85702621d3259ba17b3c230bfb2f941b"}, + {file = "sqlmodel-0.0.22.tar.gz", hash = "sha256:7d37c882a30c43464d143e35e9ecaf945d88035e20117bf5ec2834a23cbe505e"}, ] [package.dependencies] pydantic = ">=1.10.13,<3.0.0" -SQLAlchemy = ">=2.0.0,<2.1.0" +SQLAlchemy = ">=2.0.14,<2.1.0" [[package]] name = "starlette" -version = "0.37.2" +version = "0.41.2" 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.41.2-py3-none-any.whl", hash = "sha256:fbc189474b4731cf30fcef52f18a8d070e3f3b46c6a04c97579e85e6ffca942d"}, + {file = "starlette-0.41.2.tar.gz", hash = "sha256:9834fd799d1a87fd346deb76158668cfa0b0d56f85caefe8268e2d97c3468b62"}, ] [package.dependencies] @@ -2713,13 +3023,13 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.7 [[package]] name = "starlette-admin" -version = "0.13.2" +version = "0.14.1" description = "Fast, beautiful and extensible administrative interface framework for Starlette/FastApi applications" optional = false python-versions = ">=3.8" files = [ - {file = "starlette_admin-0.13.2-py3-none-any.whl", hash = "sha256:95b60ce71f05696df49d95b8664726abb9e3f76a44b49aeea25d1d6b68c039ed"}, - {file = "starlette_admin-0.13.2.tar.gz", hash = "sha256:4a2ee4e5e24b49aaaa6c034ba7f538a6accdd736c4ae7ea2c38cfb0c2c09bcce"}, + {file = "starlette_admin-0.14.1-py3-none-any.whl", hash = "sha256:5b6260d7ed3db455585852d669feb7ed9a8c5f9a1e3d48d21a52912ec37e18f9"}, + {file = "starlette_admin-0.14.1.tar.gz", hash = "sha256:45e2baa3b9a8deec7a6e8ca9295123f648bb0d2070abe68f27193c6d5e32cc38"}, ] [package.dependencies] @@ -2729,10 +3039,10 @@ starlette = "*" [package.extras] cov = ["coverage[toml] (>=7.0.0,<7.4.0)"] -dev = ["pre-commit (>=2.20.0,<4.0.0)", "uvicorn (>=0.20.0,<0.26.0)"] -doc = ["mkdocs (>=1.4.2,<2.0.0)", "mkdocs-material (>=9.0.0,<10.0.0)", "mkdocs-static-i18n (>=0.53.0,<0.57.0)", "mkdocstrings[python] (>=0.19.0,<0.25.0)"] +dev = ["pre-commit (>=2.20.0,<4.0.0)", "uvicorn (>=0.20.0,<0.31.0)"] +doc = ["mkdocs (>=1.4.2,<2.0.0)", "mkdocs-material (>=9.0.0,<10.0.0)", "mkdocs-static-i18n (>=1.2.3,<1.3)", "mkdocstrings[python] (>=0.19.0,<0.26.0)"] i18n = ["babel (>=2.13.0)"] -test = ["aiomysql (>=0.1.1,<0.3.0)", "aiosqlite (>=0.17.0,<0.20.0)", "arrow (>=1.2.3,<1.4.0)", "asyncpg (>=0.27.0,<0.30.0)", "backports-zoneinfo", "black (==24.1.1)", "colour (>=0.1.5,<0.2.0)", "fasteners (==0.19)", "httpx (>=0.23.3,<0.27.0)", "itsdangerous (>=2.1.2,<2.2.0)", "mongoengine (>=0.25.0,<0.28.0)", "mypy (==1.8.0)", "odmantic (>=0.9.0,<0.10.0)", "passlib (>=1.7.4,<1.8.0)", "phonenumbers (>=8.13.3,<8.14.0)", "pillow (>=9.4.0,<9.6.0)", "psycopg2-binary (>=2.9.5,<3.0.0)", "pydantic[email] (>=1.10.2,<2.6.0)", "pymysql[rsa] (>=1.0.2,<1.2.0)", "pytest (>=7.2.0,<7.5.0)", "pytest-asyncio (>=0.20.2,<0.24.0)", "ruff (==0.1.15)", "sqlalchemy-file (>=0.5.0,<0.7.0)", "sqlalchemy-utils (>=0.40.0,<0.42.0)", "sqlmodel (>=0.0.11,<0.15.0)", "tinydb (>=4.7.0,<4.9.0)"] +test = ["aiomysql (>=0.1.1,<0.3.0)", "aiosqlite (>=0.17.0,<0.21.0)", "arrow (>=1.2.3,<1.4.0)", "asyncpg (>=0.27.0,<0.30.0)", "backports-zoneinfo", "black (==24.4.2)", "colour (>=0.1.5,<0.2.0)", "fasteners (==0.19)", "httpx (>=0.23.3,<0.27.0)", "itsdangerous (>=2.2.0,<2.3.0)", "mongoengine (>=0.25.0,<0.29.0)", "mypy (==1.10.0)", "odmantic (>=0.9.0,<0.10.0)", "passlib (>=1.7.4,<1.8.0)", "phonenumbers (>=8.13.3,<8.14.0)", "pillow (>=9.4.0,<9.6.0)", "psycopg2-binary (>=2.9.5,<3.0.0)", "pydantic[email] (>=1.10.2,<2.8.0)", "pymysql[rsa] (>=1.0.2,<1.2.0)", "pytest (>=7.2.0,<7.5.0)", "pytest-asyncio (>=0.20.2,<0.24.0)", "ruff (==0.4.8)", "sqlalchemy-file (>=0.5.0,<0.7.0)", "sqlalchemy-utils (>=0.40.0,<0.42.0)", "sqlmodel (>=0.0.11,<0.15.0)", "tinydb (>=4.7.0,<4.9.0)"] [[package]] name = "tabulate" @@ -2750,19 +3060,30 @@ widechars = ["wcwidth"] [[package]] name = "tenacity" -version = "8.3.0" +version = "9.0.0" description = "Retry code until it succeeds" optional = false python-versions = ">=3.8" files = [ - {file = "tenacity-8.3.0-py3-none-any.whl", hash = "sha256:3649f6443dbc0d9b01b9d8020a9c4ec7a1ff5f6f3c6c8a036ef371f573fe9185"}, - {file = "tenacity-8.3.0.tar.gz", hash = "sha256:953d4e6ad24357bceffbc9707bc74349aca9d245f68eb65419cf0c249a1949a2"}, + {file = "tenacity-9.0.0-py3-none-any.whl", hash = "sha256:93de0c98785b27fcf659856aa9f54bfbd399e29969b0621bc7f762bd441b4539"}, + {file = "tenacity-9.0.0.tar.gz", hash = "sha256:807f37ca97d62aa361264d497b0e31e92b8027044942bfa756160d908320d73b"}, ] [package.extras] doc = ["reno", "sphinx"] test = ["pytest", "tornado (>=4.5)", "typeguard"] +[[package]] +name = "text-unidecode" +version = "1.3" +description = "The most basic Text::Unidecode port" +optional = false +python-versions = "*" +files = [ + {file = "text-unidecode-1.3.tar.gz", hash = "sha256:bad6603bb14d279193107714b288be206cac565dfa49aa5b105294dd5c4aab93"}, + {file = "text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8"}, +] + [[package]] name = "toml" version = "0.10.2" @@ -2776,35 +3097,35 @@ files = [ [[package]] name = "tomli" -version = "2.0.1" +version = "2.0.2" description = "A lil' TOML parser" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, + {file = "tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38"}, + {file = "tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed"}, ] [[package]] name = "tomlkit" -version = "0.12.4" +version = "0.13.2" description = "Style preserving TOML library" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "tomlkit-0.12.4-py3-none-any.whl", hash = "sha256:5cd82d48a3dd89dee1f9d64420aa20ae65cfbd00668d6f094d7578a78efbb77b"}, - {file = "tomlkit-0.12.4.tar.gz", hash = "sha256:7ca1cfc12232806517a8515047ba66a19369e71edf2439d0f5824f91032b6cc3"}, + {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, + {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, ] [[package]] name = "trio" -version = "0.25.0" +version = "0.27.0" description = "A friendly Python library for async concurrency and I/O" optional = false python-versions = ">=3.8" files = [ - {file = "trio-0.25.0-py3-none-any.whl", hash = "sha256:e6458efe29cc543e557a91e614e2b51710eba2961669329ce9c862d50c6e8e81"}, - {file = "trio-0.25.0.tar.gz", hash = "sha256:9b41f5993ad2c0e5f62d0acca320ec657fdb6b2a2c22b8c7aed6caf154475c4e"}, + {file = "trio-0.27.0-py3-none-any.whl", hash = "sha256:68eabbcf8f457d925df62da780eff15ff5dc68fd6b367e2dde59f7aaf2a0b884"}, + {file = "trio-0.27.0.tar.gz", hash = "sha256:1dcc95ab1726b2da054afea8fd761af74bad79bd52381b84eae408e983c76831"}, ] [package.dependencies] @@ -2834,19 +3155,19 @@ wsproto = ">=0.14" [[package]] name = "twine" -version = "5.0.0" +version = "5.1.1" description = "Collection of utilities for publishing packages on PyPI" optional = false python-versions = ">=3.8" files = [ - {file = "twine-5.0.0-py3-none-any.whl", hash = "sha256:a262933de0b484c53408f9edae2e7821c1c45a3314ff2df9bdd343aa7ab8edc0"}, - {file = "twine-5.0.0.tar.gz", hash = "sha256:89b0cc7d370a4b66421cc6102f269aa910fe0f1861c124f573cf2ddedbc10cf4"}, + {file = "twine-5.1.1-py3-none-any.whl", hash = "sha256:215dbe7b4b94c2c50a7315c0275d2258399280fbb7d04182c7e55e24b5f93997"}, + {file = "twine-5.1.1.tar.gz", hash = "sha256:9aa0825139c02b3434d913545c7b847a21c835e11597f5255842d457da2322db"}, ] [package.dependencies] importlib-metadata = ">=3.6" keyring = ">=15.1" -pkginfo = ">=1.8.1" +pkginfo = ">=1.8.1,<1.11" readme-renderer = ">=35.0" requests = ">=2.20" requests-toolbelt = ">=0.8.0,<0.9.0 || >0.9.0" @@ -2856,13 +3177,13 @@ urllib3 = ">=1.26.0" [[package]] name = "typer" -version = "0.12.3" +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.3-py3-none-any.whl", hash = "sha256:070d7ca53f785acbccba8e7d28b08dcd88f79f1fbda035ade0aecec71ca5c914"}, - {file = "typer-0.12.3.tar.gz", hash = "sha256:49e73131481d804288ef62598d97a1ceef3058905aa536a1134f90891ba35482"}, + {file = "typer-0.12.5-py3-none-any.whl", hash = "sha256:62fe4e471711b147e3365034133904df3e235698399bc4de2b36c8579298d52b"}, + {file = "typer-0.12.5.tar.gz", hash = "sha256:f592f089bedcc8ec1b974125d64851029c3b1af145f04aca64d69410f0c9b722"}, ] [package.dependencies] @@ -2873,35 +3194,35 @@ typing-extensions = ">=3.7.4.3" [[package]] name = "typing-extensions" -version = "4.11.0" +version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, - {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] [[package]] name = "tzdata" -version = "2024.1" +version = "2024.2" description = "Provider of IANA time zone data" optional = false python-versions = ">=2" files = [ - {file = "tzdata-2024.1-py2.py3-none-any.whl", hash = "sha256:9068bc196136463f5245e51efda838afa15aaeca9903f49050dfa2679db4d252"}, - {file = "tzdata-2024.1.tar.gz", hash = "sha256:2674120f8d891909751c38abcdfd386ac0a5a1127954fbc332af6b5ceae07efd"}, + {file = "tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd"}, + {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, ] [[package]] name = "urllib3" -version = "2.2.1" +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.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, - {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, + {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, + {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, ] [package.dependencies] @@ -2915,49 +3236,32 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "uvicorn" -version = "0.20.0" -description = "The lightning-fast ASGI server." -optional = false -python-versions = ">=3.7" -files = [ - {file = "uvicorn-0.20.0-py3-none-any.whl", hash = "sha256:c3ed1598a5668208723f2bb49336f4509424ad198d6ab2615b7783db58d919fd"}, - {file = "uvicorn-0.20.0.tar.gz", hash = "sha256:a4e12017b940247f836bc90b72e725d7dfd0c8ed1c51eb365f5ba30d9f5127d8"}, -] - -[package.dependencies] -click = ">=7.0" -h11 = ">=0.8" - -[package.extras] -standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"] - -[[package]] -name = "uvicorn" -version = "0.24.0.post1" +version = "0.32.0" description = "The lightning-fast ASGI server." optional = false python-versions = ">=3.8" files = [ - {file = "uvicorn-0.24.0.post1-py3-none-any.whl", hash = "sha256:7c84fea70c619d4a710153482c0d230929af7bcf76c7bfa6de151f0a3a80121e"}, - {file = "uvicorn-0.24.0.post1.tar.gz", hash = "sha256:09c8e5a79dc466bdf28dead50093957db184de356fcdc48697bad3bde4c2588e"}, + {file = "uvicorn-0.32.0-py3-none-any.whl", hash = "sha256:60b8f3a5ac027dcd31448f411ced12b5ef452c646f76f02f8cc3f25d8d26fd82"}, + {file = "uvicorn-0.32.0.tar.gz", hash = "sha256:f78b36b143c16f54ccdb8190d0a26b5f1901fe5a3c777e1ab29f26391af8551e"}, ] [package.dependencies] click = ">=7.0" h11 = ">=0.8" +typing-extensions = {version = ">=4.0", markers = "python_version < \"3.11\""} [package.extras] standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"] [[package]] name = "virtualenv" -version = "20.26.1" +version = "20.27.1" description = "Virtual Python Environment builder" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"}, - {file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"}, + {file = "virtualenv-20.27.1-py3-none-any.whl", hash = "sha256:f11f1b8a29525562925f745563bfd48b189450f61fb34c4f9cc79dd5aa32a1f4"}, + {file = "virtualenv-20.27.1.tar.gz", hash = "sha256:142c6be10212543b32c6c45d3d3893dff89112cc588b7d0879ae5a1ec03a47ba"}, ] [package.dependencies] @@ -2970,223 +3274,125 @@ docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "s 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.0" -description = "Filesystem events monitoring" +name = "websocket-client" +version = "1.8.0" +description = "WebSocket client for Python with low level API options" optional = false python-versions = ">=3.8" files = [ - {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:39cb34b1f1afbf23e9562501673e7146777efe95da24fab5707b88f7fb11649b"}, - {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c522392acc5e962bcac3b22b9592493ffd06d1fc5d755954e6be9f4990de932b"}, - {file = "watchdog-4.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6c47bdd680009b11c9ac382163e05ca43baf4127954c5f6d0250e7d772d2b80c"}, - {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:8350d4055505412a426b6ad8c521bc7d367d1637a762c70fdd93a3a0d595990b"}, - {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c17d98799f32e3f55f181f19dd2021d762eb38fdd381b4a748b9f5a36738e935"}, - {file = "watchdog-4.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4986db5e8880b0e6b7cd52ba36255d4793bf5cdc95bd6264806c233173b1ec0b"}, - {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:11e12fafb13372e18ca1bbf12d50f593e7280646687463dd47730fd4f4d5d257"}, - {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5369136a6474678e02426bd984466343924d1df8e2fd94a9b443cb7e3aa20d19"}, - {file = "watchdog-4.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76ad8484379695f3fe46228962017a7e1337e9acadafed67eb20aabb175df98b"}, - {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:45cc09cc4c3b43fb10b59ef4d07318d9a3ecdbff03abd2e36e77b6dd9f9a5c85"}, - {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:eed82cdf79cd7f0232e2fdc1ad05b06a5e102a43e331f7d041e5f0e0a34a51c4"}, - {file = "watchdog-4.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ba30a896166f0fee83183cec913298151b73164160d965af2e93a20bbd2ab605"}, - {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d18d7f18a47de6863cd480734613502904611730f8def45fc52a5d97503e5101"}, - {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2895bf0518361a9728773083908801a376743bcc37dfa252b801af8fd281b1ca"}, - {file = "watchdog-4.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:87e9df830022488e235dd601478c15ad73a0389628588ba0b028cb74eb72fed8"}, - {file = "watchdog-4.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6e949a8a94186bced05b6508faa61b7adacc911115664ccb1923b9ad1f1ccf7b"}, - {file = "watchdog-4.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6a4db54edea37d1058b08947c789a2354ee02972ed5d1e0dca9b0b820f4c7f92"}, - {file = "watchdog-4.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d31481ccf4694a8416b681544c23bd271f5a123162ab603c7d7d2dd7dd901a07"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8fec441f5adcf81dd240a5fe78e3d83767999771630b5ddfc5867827a34fa3d3"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:6a9c71a0b02985b4b0b6d14b875a6c86ddea2fdbebd0c9a720a806a8bbffc69f"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:557ba04c816d23ce98a06e70af6abaa0485f6d94994ec78a42b05d1c03dcbd50"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:d0f9bd1fd919134d459d8abf954f63886745f4660ef66480b9d753a7c9d40927"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:f9b2fdca47dc855516b2d66eef3c39f2672cbf7e7a42e7e67ad2cbfcd6ba107d"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:73c7a935e62033bd5e8f0da33a4dcb763da2361921a69a5a95aaf6c93aa03a87"}, - {file = "watchdog-4.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:6a80d5cae8c265842c7419c560b9961561556c4361b297b4c431903f8c33b269"}, - {file = "watchdog-4.0.0-py3-none-win32.whl", hash = "sha256:8f9a542c979df62098ae9c58b19e03ad3df1c9d8c6895d96c0d51da17b243b1c"}, - {file = "watchdog-4.0.0-py3-none-win_amd64.whl", hash = "sha256:f970663fa4f7e80401a7b0cbeec00fa801bf0287d93d48368fc3e6fa32716245"}, - {file = "watchdog-4.0.0-py3-none-win_ia64.whl", hash = "sha256:9a03e16e55465177d416699331b0f3564138f1807ecc5f2de9d55d8f188d08c7"}, - {file = "watchdog-4.0.0.tar.gz", hash = "sha256:e3e7065cbdabe6183ab82199d7a4f6b3ba0a438c5a512a68559846ccb76a78ec"}, + {file = "websocket_client-1.8.0-py3-none-any.whl", hash = "sha256:17b44cc997f5c498e809b22cdf2d9c7a9e71c02c8cc2b6c56e7c2d1239bfa526"}, + {file = "websocket_client-1.8.0.tar.gz", hash = "sha256:3239df9f44da632f96012472805d40a23281a991027ce11d2f45a6f24ac4c3da"}, ] [package.extras] -watchmedo = ["PyYAML (>=3.10)"] - -[[package]] -name = "watchfiles" -version = "0.21.0" -description = "Simple, modern and high performance file watching and code reload in python." -optional = false -python-versions = ">=3.8" -files = [ - {file = "watchfiles-0.21.0-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:27b4035013f1ea49c6c0b42d983133b136637a527e48c132d368eb19bf1ac6aa"}, - {file = "watchfiles-0.21.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c81818595eff6e92535ff32825f31c116f867f64ff8cdf6562cd1d6b2e1e8f3e"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6c107ea3cf2bd07199d66f156e3ea756d1b84dfd43b542b2d870b77868c98c03"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d9ac347653ebd95839a7c607608703b20bc07e577e870d824fa4801bc1cb124"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5eb86c6acb498208e7663ca22dbe68ca2cf42ab5bf1c776670a50919a56e64ab"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f564bf68404144ea6b87a78a3f910cc8de216c6b12a4cf0b27718bf4ec38d303"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d0f32ebfaa9c6011f8454994f86108c2eb9c79b8b7de00b36d558cadcedaa3d"}, - {file = "watchfiles-0.21.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b6d45d9b699ecbac6c7bd8e0a2609767491540403610962968d258fd6405c17c"}, - {file = "watchfiles-0.21.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:aff06b2cac3ef4616e26ba17a9c250c1fe9dd8a5d907d0193f84c499b1b6e6a9"}, - {file = "watchfiles-0.21.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d9792dff410f266051025ecfaa927078b94cc7478954b06796a9756ccc7e14a9"}, - {file = "watchfiles-0.21.0-cp310-none-win32.whl", hash = "sha256:214cee7f9e09150d4fb42e24919a1e74d8c9b8a9306ed1474ecaddcd5479c293"}, - {file = "watchfiles-0.21.0-cp310-none-win_amd64.whl", hash = "sha256:1ad7247d79f9f55bb25ab1778fd47f32d70cf36053941f07de0b7c4e96b5d235"}, - {file = "watchfiles-0.21.0-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:668c265d90de8ae914f860d3eeb164534ba2e836811f91fecc7050416ee70aa7"}, - {file = "watchfiles-0.21.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a23092a992e61c3a6a70f350a56db7197242f3490da9c87b500f389b2d01eef"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:e7941bbcfdded9c26b0bf720cb7e6fd803d95a55d2c14b4bd1f6a2772230c586"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:11cd0c3100e2233e9c53106265da31d574355c288e15259c0d40a4405cbae317"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d78f30cbe8b2ce770160d3c08cff01b2ae9306fe66ce899b73f0409dc1846c1b"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6674b00b9756b0af620aa2a3346b01f8e2a3dc729d25617e1b89cf6af4a54eb1"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd7ac678b92b29ba630d8c842d8ad6c555abda1b9ef044d6cc092dacbfc9719d"}, - {file = "watchfiles-0.21.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c873345680c1b87f1e09e0eaf8cf6c891b9851d8b4d3645e7efe2ec20a20cc7"}, - {file = "watchfiles-0.21.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:49f56e6ecc2503e7dbe233fa328b2be1a7797d31548e7a193237dcdf1ad0eee0"}, - {file = "watchfiles-0.21.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:02d91cbac553a3ad141db016e3350b03184deaafeba09b9d6439826ee594b365"}, - {file = "watchfiles-0.21.0-cp311-none-win32.whl", hash = "sha256:ebe684d7d26239e23d102a2bad2a358dedf18e462e8808778703427d1f584400"}, - {file = "watchfiles-0.21.0-cp311-none-win_amd64.whl", hash = "sha256:4566006aa44cb0d21b8ab53baf4b9c667a0ed23efe4aaad8c227bfba0bf15cbe"}, - {file = "watchfiles-0.21.0-cp311-none-win_arm64.whl", hash = "sha256:c550a56bf209a3d987d5a975cdf2063b3389a5d16caf29db4bdddeae49f22078"}, - {file = "watchfiles-0.21.0-cp312-cp312-macosx_10_7_x86_64.whl", hash = "sha256:51ddac60b96a42c15d24fbdc7a4bfcd02b5a29c047b7f8bf63d3f6f5a860949a"}, - {file = "watchfiles-0.21.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:511f0b034120cd1989932bf1e9081aa9fb00f1f949fbd2d9cab6264916ae89b1"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:cfb92d49dbb95ec7a07511bc9efb0faff8fe24ef3805662b8d6808ba8409a71a"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f92944efc564867bbf841c823c8b71bb0be75e06b8ce45c084b46411475a915"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:642d66b75eda909fd1112d35c53816d59789a4b38c141a96d62f50a3ef9b3360"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d23bcd6c8eaa6324fe109d8cac01b41fe9a54b8c498af9ce464c1aeeb99903d6"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18d5b4da8cf3e41895b34e8c37d13c9ed294954907929aacd95153508d5d89d7"}, - {file = "watchfiles-0.21.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1b8d1eae0f65441963d805f766c7e9cd092f91e0c600c820c764a4ff71a0764c"}, - {file = "watchfiles-0.21.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1fd9a5205139f3c6bb60d11f6072e0552f0a20b712c85f43d42342d162be1235"}, - {file = "watchfiles-0.21.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a1e3014a625bcf107fbf38eece0e47fa0190e52e45dc6eee5a8265ddc6dc5ea7"}, - {file = "watchfiles-0.21.0-cp312-none-win32.whl", hash = "sha256:9d09869f2c5a6f2d9df50ce3064b3391d3ecb6dced708ad64467b9e4f2c9bef3"}, - {file = "watchfiles-0.21.0-cp312-none-win_amd64.whl", hash = "sha256:18722b50783b5e30a18a8a5db3006bab146d2b705c92eb9a94f78c72beb94094"}, - {file = "watchfiles-0.21.0-cp312-none-win_arm64.whl", hash = "sha256:a3b9bec9579a15fb3ca2d9878deae789df72f2b0fdaf90ad49ee389cad5edab6"}, - {file = "watchfiles-0.21.0-cp38-cp38-macosx_10_7_x86_64.whl", hash = "sha256:4ea10a29aa5de67de02256a28d1bf53d21322295cb00bd2d57fcd19b850ebd99"}, - {file = "watchfiles-0.21.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:40bca549fdc929b470dd1dbfcb47b3295cb46a6d2c90e50588b0a1b3bd98f429"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:9b37a7ba223b2f26122c148bb8d09a9ff312afca998c48c725ff5a0a632145f7"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec8c8900dc5c83650a63dd48c4d1d245343f904c4b64b48798c67a3767d7e165"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8ad3fe0a3567c2f0f629d800409cd528cb6251da12e81a1f765e5c5345fd0137"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9d353c4cfda586db2a176ce42c88f2fc31ec25e50212650c89fdd0f560ee507b"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:83a696da8922314ff2aec02987eefb03784f473281d740bf9170181829133765"}, - {file = "watchfiles-0.21.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a03651352fc20975ee2a707cd2d74a386cd303cc688f407296064ad1e6d1562"}, - {file = "watchfiles-0.21.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:3ad692bc7792be8c32918c699638b660c0de078a6cbe464c46e1340dadb94c19"}, - {file = "watchfiles-0.21.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06247538e8253975bdb328e7683f8515ff5ff041f43be6c40bff62d989b7d0b0"}, - {file = "watchfiles-0.21.0-cp38-none-win32.whl", hash = "sha256:9a0aa47f94ea9a0b39dd30850b0adf2e1cd32a8b4f9c7aa443d852aacf9ca214"}, - {file = "watchfiles-0.21.0-cp38-none-win_amd64.whl", hash = "sha256:8d5f400326840934e3507701f9f7269247f7c026d1b6cfd49477d2be0933cfca"}, - {file = "watchfiles-0.21.0-cp39-cp39-macosx_10_7_x86_64.whl", hash = "sha256:7f762a1a85a12cc3484f77eee7be87b10f8c50b0b787bb02f4e357403cad0c0e"}, - {file = "watchfiles-0.21.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6e9be3ef84e2bb9710f3f777accce25556f4a71e15d2b73223788d528fcc2052"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4c48a10d17571d1275701e14a601e36959ffada3add8cdbc9e5061a6e3579a5d"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c889025f59884423428c261f212e04d438de865beda0b1e1babab85ef4c0f01"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:66fac0c238ab9a2e72d026b5fb91cb902c146202bbd29a9a1a44e8db7b710b6f"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b4a21f71885aa2744719459951819e7bf5a906a6448a6b2bbce8e9cc9f2c8128"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1c9198c989f47898b2c22201756f73249de3748e0fc9de44adaf54a8b259cc0c"}, - {file = "watchfiles-0.21.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8f57c4461cd24fda22493109c45b3980863c58a25b8bec885ca8bea6b8d4b28"}, - {file = "watchfiles-0.21.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:853853cbf7bf9408b404754b92512ebe3e3a83587503d766d23e6bf83d092ee6"}, - {file = "watchfiles-0.21.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d5b1dc0e708fad9f92c296ab2f948af403bf201db8fb2eb4c8179db143732e49"}, - {file = "watchfiles-0.21.0-cp39-none-win32.whl", hash = "sha256:59137c0c6826bd56c710d1d2bda81553b5e6b7c84d5a676747d80caf0409ad94"}, - {file = "watchfiles-0.21.0-cp39-none-win_amd64.whl", hash = "sha256:6cb8fdc044909e2078c248986f2fc76f911f72b51ea4a4fbbf472e01d14faa58"}, - {file = "watchfiles-0.21.0-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:ab03a90b305d2588e8352168e8c5a1520b721d2d367f31e9332c4235b30b8994"}, - {file = "watchfiles-0.21.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:927c589500f9f41e370b0125c12ac9e7d3a2fd166b89e9ee2828b3dda20bfe6f"}, - {file = "watchfiles-0.21.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bd467213195e76f838caf2c28cd65e58302d0254e636e7c0fca81efa4a2e62c"}, - {file = "watchfiles-0.21.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:02b73130687bc3f6bb79d8a170959042eb56eb3a42df3671c79b428cd73f17cc"}, - {file = "watchfiles-0.21.0-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:08dca260e85ffae975448e344834d765983237ad6dc308231aa16e7933db763e"}, - {file = "watchfiles-0.21.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:3ccceb50c611c433145502735e0370877cced72a6c70fd2410238bcbc7fe51d8"}, - {file = "watchfiles-0.21.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57d430f5fb63fea141ab71ca9c064e80de3a20b427ca2febcbfcef70ff0ce895"}, - {file = "watchfiles-0.21.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0dd5fad9b9c0dd89904bbdea978ce89a2b692a7ee8a0ce19b940e538c88a809c"}, - {file = "watchfiles-0.21.0-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:be6dd5d52b73018b21adc1c5d28ac0c68184a64769052dfeb0c5d9998e7f56a2"}, - {file = "watchfiles-0.21.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:b3cab0e06143768499384a8a5efb9c4dc53e19382952859e4802f294214f36ec"}, - {file = "watchfiles-0.21.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c6ed10c2497e5fedadf61e465b3ca12a19f96004c15dcffe4bd442ebadc2d85"}, - {file = "watchfiles-0.21.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43babacef21c519bc6631c5fce2a61eccdfc011b4bcb9047255e9620732c8097"}, - {file = "watchfiles-0.21.0.tar.gz", hash = "sha256:c76c635fabf542bb78524905718c39f736a98e5ab25b23ec6d4abede1a85a6a3"}, -] - -[package.dependencies] -anyio = ">=3.0.0" +docs = ["Sphinx (>=6.0)", "myst-parser (>=2.0.0)", "sphinx-rtd-theme (>=1.1.0)"] +optional = ["python-socks", "wsaccel"] +test = ["websockets"] [[package]] name = "websockets" -version = "12.0" +version = "13.1" description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" optional = false python-versions = ">=3.8" files = [ - {file = "websockets-12.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d554236b2a2006e0ce16315c16eaa0d628dab009c33b63ea03f41c6107958374"}, - {file = "websockets-12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2d225bb6886591b1746b17c0573e29804619c8f755b5598d875bb4235ea639be"}, - {file = "websockets-12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:eb809e816916a3b210bed3c82fb88eaf16e8afcf9c115ebb2bacede1797d2547"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c588f6abc13f78a67044c6b1273a99e1cf31038ad51815b3b016ce699f0d75c2"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5aa9348186d79a5f232115ed3fa9020eab66d6c3437d72f9d2c8ac0c6858c558"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6350b14a40c95ddd53e775dbdbbbc59b124a5c8ecd6fbb09c2e52029f7a9f480"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:70ec754cc2a769bcd218ed8d7209055667b30860ffecb8633a834dde27d6307c"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:6e96f5ed1b83a8ddb07909b45bd94833b0710f738115751cdaa9da1fb0cb66e8"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4d87be612cbef86f994178d5186add3d94e9f31cc3cb499a0482b866ec477603"}, - {file = "websockets-12.0-cp310-cp310-win32.whl", hash = "sha256:befe90632d66caaf72e8b2ed4d7f02b348913813c8b0a32fae1cc5fe3730902f"}, - {file = "websockets-12.0-cp310-cp310-win_amd64.whl", hash = "sha256:363f57ca8bc8576195d0540c648aa58ac18cf85b76ad5202b9f976918f4219cf"}, - {file = "websockets-12.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:5d873c7de42dea355d73f170be0f23788cf3fa9f7bed718fd2830eefedce01b4"}, - {file = "websockets-12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3f61726cae9f65b872502ff3c1496abc93ffbe31b278455c418492016e2afc8f"}, - {file = "websockets-12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ed2fcf7a07334c77fc8a230755c2209223a7cc44fc27597729b8ef5425aa61a3"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e332c210b14b57904869ca9f9bf4ca32f5427a03eeb625da9b616c85a3a506c"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5693ef74233122f8ebab026817b1b37fe25c411ecfca084b29bc7d6efc548f45"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e9e7db18b4539a29cc5ad8c8b252738a30e2b13f033c2d6e9d0549b45841c04"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6e2df67b8014767d0f785baa98393725739287684b9f8d8a1001eb2839031447"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bea88d71630c5900690fcb03161ab18f8f244805c59e2e0dc4ffadae0a7ee0ca"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:dff6cdf35e31d1315790149fee351f9e52978130cef6c87c4b6c9b3baf78bc53"}, - {file = "websockets-12.0-cp311-cp311-win32.whl", hash = "sha256:3e3aa8c468af01d70332a382350ee95f6986db479ce7af14d5e81ec52aa2b402"}, - {file = "websockets-12.0-cp311-cp311-win_amd64.whl", hash = "sha256:25eb766c8ad27da0f79420b2af4b85d29914ba0edf69f547cc4f06ca6f1d403b"}, - {file = "websockets-12.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0e6e2711d5a8e6e482cacb927a49a3d432345dfe7dea8ace7b5790df5932e4df"}, - {file = "websockets-12.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:dbcf72a37f0b3316e993e13ecf32f10c0e1259c28ffd0a85cee26e8549595fbc"}, - {file = "websockets-12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12743ab88ab2af1d17dd4acb4645677cb7063ef4db93abffbf164218a5d54c6b"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b645f491f3c48d3f8a00d1fce07445fab7347fec54a3e65f0725d730d5b99cb"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9893d1aa45a7f8b3bc4510f6ccf8db8c3b62120917af15e3de247f0780294b92"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f38a7b376117ef7aff996e737583172bdf535932c9ca021746573bce40165ed"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:f764ba54e33daf20e167915edc443b6f88956f37fb606449b4a5b10ba42235a5"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:1e4b3f8ea6a9cfa8be8484c9221ec0257508e3a1ec43c36acdefb2a9c3b00aa2"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:9fdf06fd06c32205a07e47328ab49c40fc1407cdec801d698a7c41167ea45113"}, - {file = "websockets-12.0-cp312-cp312-win32.whl", hash = "sha256:baa386875b70cbd81798fa9f71be689c1bf484f65fd6fb08d051a0ee4e79924d"}, - {file = "websockets-12.0-cp312-cp312-win_amd64.whl", hash = "sha256:ae0a5da8f35a5be197f328d4727dbcfafa53d1824fac3d96cdd3a642fe09394f"}, - {file = "websockets-12.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5f6ffe2c6598f7f7207eef9a1228b6f5c818f9f4d53ee920aacd35cec8110438"}, - {file = "websockets-12.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9edf3fc590cc2ec20dc9d7a45108b5bbaf21c0d89f9fd3fd1685e223771dc0b2"}, - {file = "websockets-12.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:8572132c7be52632201a35f5e08348137f658e5ffd21f51f94572ca6c05ea81d"}, - {file = "websockets-12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:604428d1b87edbf02b233e2c207d7d528460fa978f9e391bd8aaf9c8311de137"}, - {file = "websockets-12.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1a9d160fd080c6285e202327aba140fc9a0d910b09e423afff4ae5cbbf1c7205"}, - {file = "websockets-12.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87b4aafed34653e465eb77b7c93ef058516cb5acf3eb21e42f33928616172def"}, - {file = "websockets-12.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b2ee7288b85959797970114deae81ab41b731f19ebcd3bd499ae9ca0e3f1d2c8"}, - {file = "websockets-12.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:7fa3d25e81bfe6a89718e9791128398a50dec6d57faf23770787ff441d851967"}, - {file = "websockets-12.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:a571f035a47212288e3b3519944f6bf4ac7bc7553243e41eac50dd48552b6df7"}, - {file = "websockets-12.0-cp38-cp38-win32.whl", hash = "sha256:3c6cc1360c10c17463aadd29dd3af332d4a1adaa8796f6b0e9f9df1fdb0bad62"}, - {file = "websockets-12.0-cp38-cp38-win_amd64.whl", hash = "sha256:1bf386089178ea69d720f8db6199a0504a406209a0fc23e603b27b300fdd6892"}, - {file = "websockets-12.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:ab3d732ad50a4fbd04a4490ef08acd0517b6ae6b77eb967251f4c263011a990d"}, - {file = "websockets-12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a1d9697f3337a89691e3bd8dc56dea45a6f6d975f92e7d5f773bc715c15dde28"}, - {file = "websockets-12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1df2fbd2c8a98d38a66f5238484405b8d1d16f929bb7a33ed73e4801222a6f53"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:23509452b3bc38e3a057382c2e941d5ac2e01e251acce7adc74011d7d8de434c"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e5fc14ec6ea568200ea4ef46545073da81900a2b67b3e666f04adf53ad452ec"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46e71dbbd12850224243f5d2aeec90f0aaa0f2dde5aeeb8fc8df21e04d99eff9"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b81f90dcc6c85a9b7f29873beb56c94c85d6f0dac2ea8b60d995bd18bf3e2aae"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:a02413bc474feda2849c59ed2dfb2cddb4cd3d2f03a2fedec51d6e959d9b608b"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bbe6013f9f791944ed31ca08b077e26249309639313fff132bfbf3ba105673b9"}, - {file = "websockets-12.0-cp39-cp39-win32.whl", hash = "sha256:cbe83a6bbdf207ff0541de01e11904827540aa069293696dd528a6640bd6a5f6"}, - {file = "websockets-12.0-cp39-cp39-win_amd64.whl", hash = "sha256:fc4e7fa5414512b481a2483775a8e8be7803a35b30ca805afa4998a84f9fd9e8"}, - {file = "websockets-12.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:248d8e2446e13c1d4326e0a6a4e9629cb13a11195051a73acf414812700badbd"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f44069528d45a933997a6fef143030d8ca8042f0dfaad753e2906398290e2870"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c4e37d36f0d19f0a4413d3e18c0d03d0c268ada2061868c1e6f5ab1a6d575077"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d829f975fc2e527a3ef2f9c8f25e553eb7bc779c6665e8e1d52aa22800bb38b"}, - {file = "websockets-12.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:2c71bd45a777433dd9113847af751aae36e448bc6b8c361a566cb043eda6ec30"}, - {file = "websockets-12.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0bee75f400895aef54157b36ed6d3b308fcab62e5260703add87f44cee9c82a6"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:423fc1ed29f7512fceb727e2d2aecb952c46aa34895e9ed96071821309951123"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:27a5e9964ef509016759f2ef3f2c1e13f403725a5e6a1775555994966a66e931"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3181df4583c4d3994d31fb235dc681d2aaad744fbdbf94c4802485ececdecf2"}, - {file = "websockets-12.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:b067cb952ce8bf40115f6c19f478dc71c5e719b7fbaa511359795dfd9d1a6468"}, - {file = "websockets-12.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:00700340c6c7ab788f176d118775202aadea7602c5cc6be6ae127761c16d6b0b"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e469d01137942849cff40517c97a30a93ae79917752b34029f0ec72df6b46399"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffefa1374cd508d633646d51a8e9277763a9b78ae71324183693959cf94635a7"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba0cab91b3956dfa9f512147860783a1829a8d905ee218a9837c18f683239611"}, - {file = "websockets-12.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2cb388a5bfb56df4d9a406783b7f9dbefb888c09b71629351cc6b036e9259370"}, - {file = "websockets-12.0-py3-none-any.whl", hash = "sha256:dc284bbc8d7c78a6c69e0c7325ab46ee5e40bb4d50e494d8131a07ef47500e9e"}, - {file = "websockets-12.0.tar.gz", hash = "sha256:81df9cbcbb6c260de1e007e58c011bfebe2dafc8435107b0537f393dd38c8b1b"}, + {file = "websockets-13.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f48c749857f8fb598fb890a75f540e3221d0976ed0bf879cf3c7eef34151acee"}, + {file = "websockets-13.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c7e72ce6bda6fb9409cc1e8164dd41d7c91466fb599eb047cfda72fe758a34a7"}, + {file = "websockets-13.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f779498eeec470295a2b1a5d97aa1bc9814ecd25e1eb637bd9d1c73a327387f6"}, + {file = "websockets-13.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4676df3fe46956fbb0437d8800cd5f2b6d41143b6e7e842e60554398432cf29b"}, + {file = "websockets-13.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7affedeb43a70351bb811dadf49493c9cfd1ed94c9c70095fd177e9cc1541fa"}, + {file = "websockets-13.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1971e62d2caa443e57588e1d82d15f663b29ff9dfe7446d9964a4b6f12c1e700"}, + {file = "websockets-13.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:5f2e75431f8dc4a47f31565a6e1355fb4f2ecaa99d6b89737527ea917066e26c"}, + {file = "websockets-13.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:58cf7e75dbf7e566088b07e36ea2e3e2bd5676e22216e4cad108d4df4a7402a0"}, + {file = "websockets-13.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c90d6dec6be2c7d03378a574de87af9b1efea77d0c52a8301dd831ece938452f"}, + {file = "websockets-13.1-cp310-cp310-win32.whl", hash = "sha256:730f42125ccb14602f455155084f978bd9e8e57e89b569b4d7f0f0c17a448ffe"}, + {file = "websockets-13.1-cp310-cp310-win_amd64.whl", hash = "sha256:5993260f483d05a9737073be197371940c01b257cc45ae3f1d5d7adb371b266a"}, + {file = "websockets-13.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:61fc0dfcda609cda0fc9fe7977694c0c59cf9d749fbb17f4e9483929e3c48a19"}, + {file = "websockets-13.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ceec59f59d092c5007e815def4ebb80c2de330e9588e101cf8bd94c143ec78a5"}, + {file = "websockets-13.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c1dca61c6db1166c48b95198c0b7d9c990b30c756fc2923cc66f68d17dc558fd"}, + {file = "websockets-13.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:308e20f22c2c77f3f39caca508e765f8725020b84aa963474e18c59accbf4c02"}, + {file = "websockets-13.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62d516c325e6540e8a57b94abefc3459d7dab8ce52ac75c96cad5549e187e3a7"}, + {file = "websockets-13.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87c6e35319b46b99e168eb98472d6c7d8634ee37750d7693656dc766395df096"}, + {file = "websockets-13.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5f9fee94ebafbc3117c30be1844ed01a3b177bb6e39088bc6b2fa1dc15572084"}, + {file = "websockets-13.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:7c1e90228c2f5cdde263253fa5db63e6653f1c00e7ec64108065a0b9713fa1b3"}, + {file = "websockets-13.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:6548f29b0e401eea2b967b2fdc1c7c7b5ebb3eeb470ed23a54cd45ef078a0db9"}, + {file = "websockets-13.1-cp311-cp311-win32.whl", hash = "sha256:c11d4d16e133f6df8916cc5b7e3e96ee4c44c936717d684a94f48f82edb7c92f"}, + {file = "websockets-13.1-cp311-cp311-win_amd64.whl", hash = "sha256:d04f13a1d75cb2b8382bdc16ae6fa58c97337253826dfe136195b7f89f661557"}, + {file = "websockets-13.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:9d75baf00138f80b48f1eac72ad1535aac0b6461265a0bcad391fc5aba875cfc"}, + {file = "websockets-13.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:9b6f347deb3dcfbfde1c20baa21c2ac0751afaa73e64e5b693bb2b848efeaa49"}, + {file = "websockets-13.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:de58647e3f9c42f13f90ac7e5f58900c80a39019848c5547bc691693098ae1bd"}, + {file = "websockets-13.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a1b54689e38d1279a51d11e3467dd2f3a50f5f2e879012ce8f2d6943f00e83f0"}, + {file = "websockets-13.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cf1781ef73c073e6b0f90af841aaf98501f975d306bbf6221683dd594ccc52b6"}, + {file = "websockets-13.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d23b88b9388ed85c6faf0e74d8dec4f4d3baf3ecf20a65a47b836d56260d4b9"}, + {file = "websockets-13.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3c78383585f47ccb0fcf186dcb8a43f5438bd7d8f47d69e0b56f71bf431a0a68"}, + {file = "websockets-13.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:d6d300f8ec35c24025ceb9b9019ae9040c1ab2f01cddc2bcc0b518af31c75c14"}, + {file = "websockets-13.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:a9dcaf8b0cc72a392760bb8755922c03e17a5a54e08cca58e8b74f6902b433cf"}, + {file = "websockets-13.1-cp312-cp312-win32.whl", hash = "sha256:2f85cf4f2a1ba8f602298a853cec8526c2ca42a9a4b947ec236eaedb8f2dc80c"}, + {file = "websockets-13.1-cp312-cp312-win_amd64.whl", hash = "sha256:38377f8b0cdeee97c552d20cf1865695fcd56aba155ad1b4ca8779a5b6ef4ac3"}, + {file = "websockets-13.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:a9ab1e71d3d2e54a0aa646ab6d4eebfaa5f416fe78dfe4da2839525dc5d765c6"}, + {file = "websockets-13.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b9d7439d7fab4dce00570bb906875734df13d9faa4b48e261c440a5fec6d9708"}, + {file = "websockets-13.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:327b74e915cf13c5931334c61e1a41040e365d380f812513a255aa804b183418"}, + {file = "websockets-13.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:325b1ccdbf5e5725fdcb1b0e9ad4d2545056479d0eee392c291c1bf76206435a"}, + {file = "websockets-13.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:346bee67a65f189e0e33f520f253d5147ab76ae42493804319b5716e46dddf0f"}, + {file = "websockets-13.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91a0fa841646320ec0d3accdff5b757b06e2e5c86ba32af2e0815c96c7a603c5"}, + {file = "websockets-13.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:18503d2c5f3943e93819238bf20df71982d193f73dcecd26c94514f417f6b135"}, + {file = "websockets-13.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:a9cd1af7e18e5221d2878378fbc287a14cd527fdd5939ed56a18df8a31136bb2"}, + {file = "websockets-13.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:70c5be9f416aa72aab7a2a76c90ae0a4fe2755c1816c153c1a2bcc3333ce4ce6"}, + {file = "websockets-13.1-cp313-cp313-win32.whl", hash = "sha256:624459daabeb310d3815b276c1adef475b3e6804abaf2d9d2c061c319f7f187d"}, + {file = "websockets-13.1-cp313-cp313-win_amd64.whl", hash = "sha256:c518e84bb59c2baae725accd355c8dc517b4a3ed8db88b4bc93c78dae2974bf2"}, + {file = "websockets-13.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:c7934fd0e920e70468e676fe7f1b7261c1efa0d6c037c6722278ca0228ad9d0d"}, + {file = "websockets-13.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:149e622dc48c10ccc3d2760e5f36753db9cacf3ad7bc7bbbfd7d9c819e286f23"}, + {file = "websockets-13.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a569eb1b05d72f9bce2ebd28a1ce2054311b66677fcd46cf36204ad23acead8c"}, + {file = "websockets-13.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:95df24ca1e1bd93bbca51d94dd049a984609687cb2fb08a7f2c56ac84e9816ea"}, + {file = "websockets-13.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d8dbb1bf0c0a4ae8b40bdc9be7f644e2f3fb4e8a9aca7145bfa510d4a374eeb7"}, + {file = "websockets-13.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:035233b7531fb92a76beefcbf479504db8c72eb3bff41da55aecce3a0f729e54"}, + {file = "websockets-13.1-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:e4450fc83a3df53dec45922b576e91e94f5578d06436871dce3a6be38e40f5db"}, + {file = "websockets-13.1-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:463e1c6ec853202dd3657f156123d6b4dad0c546ea2e2e38be2b3f7c5b8e7295"}, + {file = "websockets-13.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:6d6855bbe70119872c05107e38fbc7f96b1d8cb047d95c2c50869a46c65a8e96"}, + {file = "websockets-13.1-cp38-cp38-win32.whl", hash = "sha256:204e5107f43095012b00f1451374693267adbb832d29966a01ecc4ce1db26faf"}, + {file = "websockets-13.1-cp38-cp38-win_amd64.whl", hash = "sha256:485307243237328c022bc908b90e4457d0daa8b5cf4b3723fd3c4a8012fce4c6"}, + {file = "websockets-13.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9b37c184f8b976f0c0a231a5f3d6efe10807d41ccbe4488df8c74174805eea7d"}, + {file = "websockets-13.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:163e7277e1a0bd9fb3c8842a71661ad19c6aa7bb3d6678dc7f89b17fbcc4aeb7"}, + {file = "websockets-13.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4b889dbd1342820cc210ba44307cf75ae5f2f96226c0038094455a96e64fb07a"}, + {file = "websockets-13.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:586a356928692c1fed0eca68b4d1c2cbbd1ca2acf2ac7e7ebd3b9052582deefa"}, + {file = "websockets-13.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7bd6abf1e070a6b72bfeb71049d6ad286852e285f146682bf30d0296f5fbadfa"}, + {file = "websockets-13.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2aad13a200e5934f5a6767492fb07151e1de1d6079c003ab31e1823733ae79"}, + {file = "websockets-13.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:df01aea34b6e9e33572c35cd16bae5a47785e7d5c8cb2b54b2acdb9678315a17"}, + {file = "websockets-13.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:e54affdeb21026329fb0744ad187cf812f7d3c2aa702a5edb562b325191fcab6"}, + {file = "websockets-13.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:9ef8aa8bdbac47f4968a5d66462a2a0935d044bf35c0e5a8af152d58516dbeb5"}, + {file = "websockets-13.1-cp39-cp39-win32.whl", hash = "sha256:deeb929efe52bed518f6eb2ddc00cc496366a14c726005726ad62c2dd9017a3c"}, + {file = "websockets-13.1-cp39-cp39-win_amd64.whl", hash = "sha256:7c65ffa900e7cc958cd088b9a9157a8141c991f8c53d11087e6fb7277a03f81d"}, + {file = "websockets-13.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:5dd6da9bec02735931fccec99d97c29f47cc61f644264eb995ad6c0c27667238"}, + {file = "websockets-13.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:2510c09d8e8df777177ee3d40cd35450dc169a81e747455cc4197e63f7e7bfe5"}, + {file = "websockets-13.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1c3cf67185543730888b20682fb186fc8d0fa6f07ccc3ef4390831ab4b388d9"}, + {file = "websockets-13.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bcc03c8b72267e97b49149e4863d57c2d77f13fae12066622dc78fe322490fe6"}, + {file = "websockets-13.1-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:004280a140f220c812e65f36944a9ca92d766b6cc4560be652a0a3883a79ed8a"}, + {file = "websockets-13.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:e2620453c075abeb0daa949a292e19f56de518988e079c36478bacf9546ced23"}, + {file = "websockets-13.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:9156c45750b37337f7b0b00e6248991a047be4aa44554c9886fe6bdd605aab3b"}, + {file = "websockets-13.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:80c421e07973a89fbdd93e6f2003c17d20b69010458d3a8e37fb47874bd67d51"}, + {file = "websockets-13.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:82d0ba76371769d6a4e56f7e83bb8e81846d17a6190971e38b5de108bde9b0d7"}, + {file = "websockets-13.1-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e9875a0143f07d74dc5e1ded1c4581f0d9f7ab86c78994e2ed9e95050073c94d"}, + {file = "websockets-13.1-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a11e38ad8922c7961447f35c7b17bffa15de4d17c70abd07bfbe12d6faa3e027"}, + {file = "websockets-13.1-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:4059f790b6ae8768471cddb65d3c4fe4792b0ab48e154c9f0a04cefaabcd5978"}, + {file = "websockets-13.1-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:25c35bf84bf7c7369d247f0b8cfa157f989862c49104c5cf85cb5436a641d93e"}, + {file = "websockets-13.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:83f91d8a9bb404b8c2c41a707ac7f7f75b9442a0a876df295de27251a856ad09"}, + {file = "websockets-13.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7a43cfdcddd07f4ca2b1afb459824dd3c6d53a51410636a2c7fc97b9a8cf4842"}, + {file = "websockets-13.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:48a2ef1381632a2f0cb4efeff34efa97901c9fbc118e01951ad7cfc10601a9bb"}, + {file = "websockets-13.1-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:459bf774c754c35dbb487360b12c5727adab887f1622b8aed5755880a21c4a20"}, + {file = "websockets-13.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:95858ca14a9f6fa8413d29e0a585b31b278388aa775b8a81fa24830123874678"}, + {file = "websockets-13.1-py3-none-any.whl", hash = "sha256:a9a396a6ad26130cdae92ae10c36af09d9bfe6cafe69670fd3b6da9b07b4044f"}, + {file = "websockets-13.1.tar.gz", hash = "sha256:a3b3366087c1bc0a2795111edcadddb8b3b59509d5db5d7ea3fdd69f954a8878"}, ] [[package]] name = "wheel" -version = "0.43.0" +version = "0.44.0" description = "A built-package format for Python" optional = false python-versions = ">=3.8" files = [ - {file = "wheel-0.43.0-py3-none-any.whl", hash = "sha256:55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81"}, - {file = "wheel-0.43.0.tar.gz", hash = "sha256:465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85"}, + {file = "wheel-0.44.0-py3-none-any.whl", hash = "sha256:2376a90c98cc337d18623527a97c31797bd02bad0033d41547043a1cbfbe448f"}, + {file = "wheel-0.44.0.tar.gz", hash = "sha256:a29c3f2817e95ab89aa4660681ad547c0e9547f20e75b0562fe7723c9a2a9d49"}, ] [package.extras] @@ -3287,123 +3493,123 @@ h11 = ">=0.9.0,<1" [[package]] name = "yarl" -version = "1.9.4" +version = "1.17.1" description = "Yet another URL library" -optional = false -python-versions = ">=3.7" +optional = true +python-versions = ">=3.9" files = [ - {file = "yarl-1.9.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a8c1df72eb746f4136fe9a2e72b0c9dc1da1cbd23b5372f94b5820ff8ae30e0e"}, - {file = "yarl-1.9.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a3a6ed1d525bfb91b3fc9b690c5a21bb52de28c018530ad85093cc488bee2dd2"}, - {file = "yarl-1.9.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c38c9ddb6103ceae4e4498f9c08fac9b590c5c71b0370f98714768e22ac6fa66"}, - {file = "yarl-1.9.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d9e09c9d74f4566e905a0b8fa668c58109f7624db96a2171f21747abc7524234"}, - {file = "yarl-1.9.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b8477c1ee4bd47c57d49621a062121c3023609f7a13b8a46953eb6c9716ca392"}, - {file = "yarl-1.9.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d5ff2c858f5f6a42c2a8e751100f237c5e869cbde669a724f2062d4c4ef93551"}, - {file = "yarl-1.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:357495293086c5b6d34ca9616a43d329317feab7917518bc97a08f9e55648455"}, - {file = "yarl-1.9.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54525ae423d7b7a8ee81ba189f131054defdb122cde31ff17477951464c1691c"}, - {file = "yarl-1.9.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:801e9264d19643548651b9db361ce3287176671fb0117f96b5ac0ee1c3530d53"}, - {file = "yarl-1.9.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e516dc8baf7b380e6c1c26792610230f37147bb754d6426462ab115a02944385"}, - {file = "yarl-1.9.4-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:7d5aaac37d19b2904bb9dfe12cdb08c8443e7ba7d2852894ad448d4b8f442863"}, - {file = "yarl-1.9.4-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:54beabb809ffcacbd9d28ac57b0db46e42a6e341a030293fb3185c409e626b8b"}, - {file = "yarl-1.9.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bac8d525a8dbc2a1507ec731d2867025d11ceadcb4dd421423a5d42c56818541"}, - {file = "yarl-1.9.4-cp310-cp310-win32.whl", hash = "sha256:7855426dfbddac81896b6e533ebefc0af2f132d4a47340cee6d22cac7190022d"}, - {file = "yarl-1.9.4-cp310-cp310-win_amd64.whl", hash = "sha256:848cd2a1df56ddbffeb375535fb62c9d1645dde33ca4d51341378b3f5954429b"}, - {file = "yarl-1.9.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:35a2b9396879ce32754bd457d31a51ff0a9d426fd9e0e3c33394bf4b9036b099"}, - {file = "yarl-1.9.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c7d56b293cc071e82532f70adcbd8b61909eec973ae9d2d1f9b233f3d943f2c"}, - {file = "yarl-1.9.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d8a1c6c0be645c745a081c192e747c5de06e944a0d21245f4cf7c05e457c36e0"}, - {file = "yarl-1.9.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4b3c1ffe10069f655ea2d731808e76e0f452fc6c749bea04781daf18e6039525"}, - {file = "yarl-1.9.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:549d19c84c55d11687ddbd47eeb348a89df9cb30e1993f1b128f4685cd0ebbf8"}, - {file = "yarl-1.9.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a7409f968456111140c1c95301cadf071bd30a81cbd7ab829169fb9e3d72eae9"}, - {file = "yarl-1.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e23a6d84d9d1738dbc6e38167776107e63307dfc8ad108e580548d1f2c587f42"}, - {file = "yarl-1.9.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d8b889777de69897406c9fb0b76cdf2fd0f31267861ae7501d93003d55f54fbe"}, - {file = "yarl-1.9.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:03caa9507d3d3c83bca08650678e25364e1843b484f19986a527630ca376ecce"}, - {file = "yarl-1.9.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:4e9035df8d0880b2f1c7f5031f33f69e071dfe72ee9310cfc76f7b605958ceb9"}, - {file = "yarl-1.9.4-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:c0ec0ed476f77db9fb29bca17f0a8fcc7bc97ad4c6c1d8959c507decb22e8572"}, - {file = "yarl-1.9.4-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:ee04010f26d5102399bd17f8df8bc38dc7ccd7701dc77f4a68c5b8d733406958"}, - {file = "yarl-1.9.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:49a180c2e0743d5d6e0b4d1a9e5f633c62eca3f8a86ba5dd3c471060e352ca98"}, - {file = "yarl-1.9.4-cp311-cp311-win32.whl", hash = "sha256:81eb57278deb6098a5b62e88ad8281b2ba09f2f1147c4767522353eaa6260b31"}, - {file = "yarl-1.9.4-cp311-cp311-win_amd64.whl", hash = "sha256:d1d2532b340b692880261c15aee4dc94dd22ca5d61b9db9a8a361953d36410b1"}, - {file = "yarl-1.9.4-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0d2454f0aef65ea81037759be5ca9947539667eecebca092733b2eb43c965a81"}, - {file = "yarl-1.9.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:44d8ffbb9c06e5a7f529f38f53eda23e50d1ed33c6c869e01481d3fafa6b8142"}, - {file = "yarl-1.9.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:aaaea1e536f98754a6e5c56091baa1b6ce2f2700cc4a00b0d49eca8dea471074"}, - {file = "yarl-1.9.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3777ce5536d17989c91696db1d459574e9a9bd37660ea7ee4d3344579bb6f129"}, - {file = "yarl-1.9.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9fc5fc1eeb029757349ad26bbc5880557389a03fa6ada41703db5e068881e5f2"}, - {file = "yarl-1.9.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ea65804b5dc88dacd4a40279af0cdadcfe74b3e5b4c897aa0d81cf86927fee78"}, - {file = "yarl-1.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa102d6d280a5455ad6a0f9e6d769989638718e938a6a0a2ff3f4a7ff8c62cc4"}, - {file = "yarl-1.9.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:09efe4615ada057ba2d30df871d2f668af661e971dfeedf0c159927d48bbeff0"}, - {file = "yarl-1.9.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:008d3e808d03ef28542372d01057fd09168419cdc8f848efe2804f894ae03e51"}, - {file = "yarl-1.9.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:6f5cb257bc2ec58f437da2b37a8cd48f666db96d47b8a3115c29f316313654ff"}, - {file = "yarl-1.9.4-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:992f18e0ea248ee03b5a6e8b3b4738850ae7dbb172cc41c966462801cbf62cf7"}, - {file = "yarl-1.9.4-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:0e9d124c191d5b881060a9e5060627694c3bdd1fe24c5eecc8d5d7d0eb6faabc"}, - {file = "yarl-1.9.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:3986b6f41ad22988e53d5778f91855dc0399b043fc8946d4f2e68af22ee9ff10"}, - {file = "yarl-1.9.4-cp312-cp312-win32.whl", hash = "sha256:4b21516d181cd77ebd06ce160ef8cc2a5e9ad35fb1c5930882baff5ac865eee7"}, - {file = "yarl-1.9.4-cp312-cp312-win_amd64.whl", hash = "sha256:a9bd00dc3bc395a662900f33f74feb3e757429e545d831eef5bb280252631984"}, - {file = "yarl-1.9.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:63b20738b5aac74e239622d2fe30df4fca4942a86e31bf47a81a0e94c14df94f"}, - {file = "yarl-1.9.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7d7f7de27b8944f1fee2c26a88b4dabc2409d2fea7a9ed3df79b67277644e17"}, - {file = "yarl-1.9.4-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c74018551e31269d56fab81a728f683667e7c28c04e807ba08f8c9e3bba32f14"}, - {file = "yarl-1.9.4-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ca06675212f94e7a610e85ca36948bb8fc023e458dd6c63ef71abfd482481aa5"}, - {file = "yarl-1.9.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5aef935237d60a51a62b86249839b51345f47564208c6ee615ed2a40878dccdd"}, - {file = "yarl-1.9.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2b134fd795e2322b7684155b7855cc99409d10b2e408056db2b93b51a52accc7"}, - {file = "yarl-1.9.4-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d25039a474c4c72a5ad4b52495056f843a7ff07b632c1b92ea9043a3d9950f6e"}, - {file = "yarl-1.9.4-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f7d6b36dd2e029b6bcb8a13cf19664c7b8e19ab3a58e0fefbb5b8461447ed5ec"}, - {file = "yarl-1.9.4-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:957b4774373cf6f709359e5c8c4a0af9f6d7875db657adb0feaf8d6cb3c3964c"}, - {file = "yarl-1.9.4-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:d7eeb6d22331e2fd42fce928a81c697c9ee2d51400bd1a28803965883e13cead"}, - {file = "yarl-1.9.4-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:6a962e04b8f91f8c4e5917e518d17958e3bdee71fd1d8b88cdce74dd0ebbf434"}, - {file = "yarl-1.9.4-cp37-cp37m-win32.whl", hash = "sha256:f3bc6af6e2b8f92eced34ef6a96ffb248e863af20ef4fde9448cc8c9b858b749"}, - {file = "yarl-1.9.4-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4d7a90a92e528aadf4965d685c17dacff3df282db1121136c382dc0b6014d2"}, - {file = "yarl-1.9.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ec61d826d80fc293ed46c9dd26995921e3a82146feacd952ef0757236fc137be"}, - {file = "yarl-1.9.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8be9e837ea9113676e5754b43b940b50cce76d9ed7d2461df1af39a8ee674d9f"}, - {file = "yarl-1.9.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:bef596fdaa8f26e3d66af846bbe77057237cb6e8efff8cd7cc8dff9a62278bbf"}, - {file = "yarl-1.9.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d47552b6e52c3319fede1b60b3de120fe83bde9b7bddad11a69fb0af7db32f1"}, - {file = "yarl-1.9.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:84fc30f71689d7fc9168b92788abc977dc8cefa806909565fc2951d02f6b7d57"}, - {file = "yarl-1.9.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4aa9741085f635934f3a2583e16fcf62ba835719a8b2b28fb2917bb0537c1dfa"}, - {file = "yarl-1.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:206a55215e6d05dbc6c98ce598a59e6fbd0c493e2de4ea6cc2f4934d5a18d130"}, - {file = "yarl-1.9.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07574b007ee20e5c375a8fe4a0789fad26db905f9813be0f9fef5a68080de559"}, - {file = "yarl-1.9.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:5a2e2433eb9344a163aced6a5f6c9222c0786e5a9e9cac2c89f0b28433f56e23"}, - {file = "yarl-1.9.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:6ad6d10ed9b67a382b45f29ea028f92d25bc0bc1daf6c5b801b90b5aa70fb9ec"}, - {file = "yarl-1.9.4-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:6fe79f998a4052d79e1c30eeb7d6c1c1056ad33300f682465e1b4e9b5a188b78"}, - {file = "yarl-1.9.4-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:a825ec844298c791fd28ed14ed1bffc56a98d15b8c58a20e0e08c1f5f2bea1be"}, - {file = "yarl-1.9.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8619d6915b3b0b34420cf9b2bb6d81ef59d984cb0fde7544e9ece32b4b3043c3"}, - {file = "yarl-1.9.4-cp38-cp38-win32.whl", hash = "sha256:686a0c2f85f83463272ddffd4deb5e591c98aac1897d65e92319f729c320eece"}, - {file = "yarl-1.9.4-cp38-cp38-win_amd64.whl", hash = "sha256:a00862fb23195b6b8322f7d781b0dc1d82cb3bcac346d1e38689370cc1cc398b"}, - {file = "yarl-1.9.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:604f31d97fa493083ea21bd9b92c419012531c4e17ea6da0f65cacdcf5d0bd27"}, - {file = "yarl-1.9.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8a854227cf581330ffa2c4824d96e52ee621dd571078a252c25e3a3b3d94a1b1"}, - {file = "yarl-1.9.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ba6f52cbc7809cd8d74604cce9c14868306ae4aa0282016b641c661f981a6e91"}, - {file = "yarl-1.9.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6327976c7c2f4ee6816eff196e25385ccc02cb81427952414a64811037bbc8b"}, - {file = "yarl-1.9.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8397a3817d7dcdd14bb266283cd1d6fc7264a48c186b986f32e86d86d35fbac5"}, - {file = "yarl-1.9.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e0381b4ce23ff92f8170080c97678040fc5b08da85e9e292292aba67fdac6c34"}, - {file = "yarl-1.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23d32a2594cb5d565d358a92e151315d1b2268bc10f4610d098f96b147370136"}, - {file = "yarl-1.9.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ddb2a5c08a4eaaba605340fdee8fc08e406c56617566d9643ad8bf6852778fc7"}, - {file = "yarl-1.9.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:26a1dc6285e03f3cc9e839a2da83bcbf31dcb0d004c72d0730e755b33466c30e"}, - {file = "yarl-1.9.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:18580f672e44ce1238b82f7fb87d727c4a131f3a9d33a5e0e82b793362bf18b4"}, - {file = "yarl-1.9.4-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:29e0f83f37610f173eb7e7b5562dd71467993495e568e708d99e9d1944f561ec"}, - {file = "yarl-1.9.4-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:1f23e4fe1e8794f74b6027d7cf19dc25f8b63af1483d91d595d4a07eca1fb26c"}, - {file = "yarl-1.9.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:db8e58b9d79200c76956cefd14d5c90af54416ff5353c5bfd7cbe58818e26ef0"}, - {file = "yarl-1.9.4-cp39-cp39-win32.whl", hash = "sha256:c7224cab95645c7ab53791022ae77a4509472613e839dab722a72abe5a684575"}, - {file = "yarl-1.9.4-cp39-cp39-win_amd64.whl", hash = "sha256:824d6c50492add5da9374875ce72db7a0733b29c2394890aef23d533106e2b15"}, - {file = "yarl-1.9.4-py3-none-any.whl", hash = "sha256:928cecb0ef9d5a7946eb6ff58417ad2fe9375762382f1bf5c55e61645f2c43ad"}, - {file = "yarl-1.9.4.tar.gz", hash = "sha256:566db86717cf8080b99b58b083b773a908ae40f06681e87e589a976faf8246bf"}, + {file = "yarl-1.17.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b1794853124e2f663f0ea54efb0340b457f08d40a1cef78edfa086576179c91"}, + {file = "yarl-1.17.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:fbea1751729afe607d84acfd01efd95e3b31db148a181a441984ce9b3d3469da"}, + {file = "yarl-1.17.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8ee427208c675f1b6e344a1f89376a9613fc30b52646a04ac0c1f6587c7e46ec"}, + {file = "yarl-1.17.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b74ff4767d3ef47ffe0cd1d89379dc4d828d4873e5528976ced3b44fe5b0a21"}, + {file = "yarl-1.17.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:62a91aefff3d11bf60e5956d340eb507a983a7ec802b19072bb989ce120cd948"}, + {file = "yarl-1.17.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:846dd2e1243407133d3195d2d7e4ceefcaa5f5bf7278f0a9bda00967e6326b04"}, + {file = "yarl-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3e844be8d536afa129366d9af76ed7cb8dfefec99f5f1c9e4f8ae542279a6dc3"}, + {file = "yarl-1.17.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cc7c92c1baa629cb03ecb0c3d12564f172218fb1739f54bf5f3881844daadc6d"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ae3476e934b9d714aa8000d2e4c01eb2590eee10b9d8cd03e7983ad65dfbfcba"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:c7e177c619342e407415d4f35dec63d2d134d951e24b5166afcdfd1362828e17"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:64cc6e97f14cf8a275d79c5002281f3040c12e2e4220623b5759ea7f9868d6a5"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:84c063af19ef5130084db70ada40ce63a84f6c1ef4d3dbc34e5e8c4febb20822"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:482c122b72e3c5ec98f11457aeb436ae4aecca75de19b3d1de7cf88bc40db82f"}, + {file = "yarl-1.17.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:380e6c38ef692b8fd5a0f6d1fa8774d81ebc08cfbd624b1bca62a4d4af2f9931"}, + {file = "yarl-1.17.1-cp310-cp310-win32.whl", hash = "sha256:16bca6678a83657dd48df84b51bd56a6c6bd401853aef6d09dc2506a78484c7b"}, + {file = "yarl-1.17.1-cp310-cp310-win_amd64.whl", hash = "sha256:561c87fea99545ef7d692403c110b2f99dced6dff93056d6e04384ad3bc46243"}, + {file = "yarl-1.17.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:cbad927ea8ed814622305d842c93412cb47bd39a496ed0f96bfd42b922b4a217"}, + {file = "yarl-1.17.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fca4b4307ebe9c3ec77a084da3a9d1999d164693d16492ca2b64594340999988"}, + {file = "yarl-1.17.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ff5c6771c7e3511a06555afa317879b7db8d640137ba55d6ab0d0c50425cab75"}, + {file = "yarl-1.17.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b29beab10211a746f9846baa39275e80034e065460d99eb51e45c9a9495bcca"}, + {file = "yarl-1.17.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1a52a1ffdd824fb1835272e125385c32fd8b17fbdefeedcb4d543cc23b332d74"}, + {file = "yarl-1.17.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:58c8e9620eb82a189c6c40cb6b59b4e35b2ee68b1f2afa6597732a2b467d7e8f"}, + {file = "yarl-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d216e5d9b8749563c7f2c6f7a0831057ec844c68b4c11cb10fc62d4fd373c26d"}, + {file = "yarl-1.17.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:881764d610e3269964fc4bb3c19bb6fce55422828e152b885609ec176b41cf11"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8c79e9d7e3d8a32d4824250a9c6401194fb4c2ad9a0cec8f6a96e09a582c2cc0"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:299f11b44d8d3a588234adbe01112126010bd96d9139c3ba7b3badd9829261c3"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:cc7d768260f4ba4ea01741c1b5fe3d3a6c70eb91c87f4c8761bbcce5181beafe"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:de599af166970d6a61accde358ec9ded821234cbbc8c6413acfec06056b8e860"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:2b24ec55fad43e476905eceaf14f41f6478780b870eda5d08b4d6de9a60b65b4"}, + {file = "yarl-1.17.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9fb815155aac6bfa8d86184079652c9715c812d506b22cfa369196ef4e99d1b4"}, + {file = "yarl-1.17.1-cp311-cp311-win32.whl", hash = "sha256:7615058aabad54416ddac99ade09a5510cf77039a3b903e94e8922f25ed203d7"}, + {file = "yarl-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:14bc88baa44e1f84164a392827b5defb4fa8e56b93fecac3d15315e7c8e5d8b3"}, + {file = "yarl-1.17.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:327828786da2006085a4d1feb2594de6f6d26f8af48b81eb1ae950c788d97f61"}, + {file = "yarl-1.17.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cc353841428d56b683a123a813e6a686e07026d6b1c5757970a877195f880c2d"}, + {file = "yarl-1.17.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c73df5b6e8fabe2ddb74876fb82d9dd44cbace0ca12e8861ce9155ad3c886139"}, + {file = "yarl-1.17.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0bdff5e0995522706c53078f531fb586f56de9c4c81c243865dd5c66c132c3b5"}, + {file = "yarl-1.17.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:06157fb3c58f2736a5e47c8fcbe1afc8b5de6fb28b14d25574af9e62150fcaac"}, + {file = "yarl-1.17.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1654ec814b18be1af2c857aa9000de7a601400bd4c9ca24629b18486c2e35463"}, + {file = "yarl-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f6595c852ca544aaeeb32d357e62c9c780eac69dcd34e40cae7b55bc4fb1147"}, + {file = "yarl-1.17.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:459e81c2fb920b5f5df744262d1498ec2c8081acdcfe18181da44c50f51312f7"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:7e48cdb8226644e2fbd0bdb0a0f87906a3db07087f4de77a1b1b1ccfd9e93685"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:d9b6b28a57feb51605d6ae5e61a9044a31742db557a3b851a74c13bc61de5172"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e594b22688d5747b06e957f1ef822060cb5cb35b493066e33ceac0cf882188b7"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5f236cb5999ccd23a0ab1bd219cfe0ee3e1c1b65aaf6dd3320e972f7ec3a39da"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:a2a64e62c7a0edd07c1c917b0586655f3362d2c2d37d474db1a509efb96fea1c"}, + {file = "yarl-1.17.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d0eea830b591dbc68e030c86a9569826145df485b2b4554874b07fea1275a199"}, + {file = "yarl-1.17.1-cp312-cp312-win32.whl", hash = "sha256:46ddf6e0b975cd680eb83318aa1d321cb2bf8d288d50f1754526230fcf59ba96"}, + {file = "yarl-1.17.1-cp312-cp312-win_amd64.whl", hash = "sha256:117ed8b3732528a1e41af3aa6d4e08483c2f0f2e3d3d7dca7cf538b3516d93df"}, + {file = "yarl-1.17.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:5d1d42556b063d579cae59e37a38c61f4402b47d70c29f0ef15cee1acaa64488"}, + {file = "yarl-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c0167540094838ee9093ef6cc2c69d0074bbf84a432b4995835e8e5a0d984374"}, + {file = "yarl-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2f0a6423295a0d282d00e8701fe763eeefba8037e984ad5de44aa349002562ac"}, + {file = "yarl-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e5b078134f48552c4d9527db2f7da0b5359abd49393cdf9794017baec7506170"}, + {file = "yarl-1.17.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d401f07261dc5aa36c2e4efc308548f6ae943bfff20fcadb0a07517a26b196d8"}, + {file = "yarl-1.17.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b5f1ac7359e17efe0b6e5fec21de34145caef22b260e978336f325d5c84e6938"}, + {file = "yarl-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f63d176a81555984e91f2c84c2a574a61cab7111cc907e176f0f01538e9ff6e"}, + {file = "yarl-1.17.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9e275792097c9f7e80741c36de3b61917aebecc08a67ae62899b074566ff8556"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:81713b70bea5c1386dc2f32a8f0dab4148a2928c7495c808c541ee0aae614d67"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:aa46dce75078fceaf7cecac5817422febb4355fbdda440db55206e3bd288cfb8"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1ce36ded585f45b1e9bb36d0ae94765c6608b43bd2e7f5f88079f7a85c61a4d3"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:2d374d70fdc36f5863b84e54775452f68639bc862918602d028f89310a034ab0"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:2d9f0606baaec5dd54cb99667fcf85183a7477f3766fbddbe3f385e7fc253299"}, + {file = "yarl-1.17.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b0341e6d9a0c0e3cdc65857ef518bb05b410dbd70d749a0d33ac0f39e81a4258"}, + {file = "yarl-1.17.1-cp313-cp313-win32.whl", hash = "sha256:2e7ba4c9377e48fb7b20dedbd473cbcbc13e72e1826917c185157a137dac9df2"}, + {file = "yarl-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:949681f68e0e3c25377462be4b658500e85ca24323d9619fdc41f68d46a1ffda"}, + {file = "yarl-1.17.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8994b29c462de9a8fce2d591028b986dbbe1b32f3ad600b2d3e1c482c93abad6"}, + {file = "yarl-1.17.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f9cbfbc5faca235fbdf531b93aa0f9f005ec7d267d9d738761a4d42b744ea159"}, + {file = "yarl-1.17.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b40d1bf6e6f74f7c0a567a9e5e778bbd4699d1d3d2c0fe46f4b717eef9e96b95"}, + {file = "yarl-1.17.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f5efe0661b9fcd6246f27957f6ae1c0eb29bc60552820f01e970b4996e016004"}, + {file = "yarl-1.17.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b5c4804e4039f487e942c13381e6c27b4b4e66066d94ef1fae3f6ba8b953f383"}, + {file = "yarl-1.17.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b5d6a6c9602fd4598fa07e0389e19fe199ae96449008d8304bf5d47cb745462e"}, + {file = "yarl-1.17.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f4c9156c4d1eb490fe374fb294deeb7bc7eaccda50e23775b2354b6a6739934"}, + {file = "yarl-1.17.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6324274b4e0e2fa1b3eccb25997b1c9ed134ff61d296448ab8269f5ac068c4c"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:d8a8b74d843c2638f3864a17d97a4acda58e40d3e44b6303b8cc3d3c44ae2d29"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:7fac95714b09da9278a0b52e492466f773cfe37651cf467a83a1b659be24bf71"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:c180ac742a083e109c1a18151f4dd8675f32679985a1c750d2ff806796165b55"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:578d00c9b7fccfa1745a44f4eddfdc99d723d157dad26764538fbdda37209857"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:1a3b91c44efa29e6c8ef8a9a2b583347998e2ba52c5d8280dbd5919c02dfc3b5"}, + {file = "yarl-1.17.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:a7ac5b4984c468ce4f4a553df281450df0a34aefae02e58d77a0847be8d1e11f"}, + {file = "yarl-1.17.1-cp39-cp39-win32.whl", hash = "sha256:7294e38f9aa2e9f05f765b28ffdc5d81378508ce6dadbe93f6d464a8c9594473"}, + {file = "yarl-1.17.1-cp39-cp39-win_amd64.whl", hash = "sha256:eb6dce402734575e1a8cc0bb1509afca508a400a57ce13d306ea2c663bad1138"}, + {file = "yarl-1.17.1-py3-none-any.whl", hash = "sha256:f1790a4b1e8e8e028c391175433b9c8122c39b46e1663228158e61e6f915bf06"}, + {file = "yarl-1.17.1.tar.gz", hash = "sha256:067a63fcfda82da6b198fa73079b1ca40b7c9b7994995b6ee38acda728b64d47"}, ] [package.dependencies] idna = ">=2.0" multidict = ">=4.0" +propcache = ">=0.2.0" [[package]] name = "zipp" -version = "3.18.1" +version = "3.20.2" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.8" files = [ - {file = "zipp-3.18.1-py3-none-any.whl", hash = "sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b"}, - {file = "zipp-3.18.1.tar.gz", hash = "sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715"}, + {file = "zipp-3.20.2-py3-none-any.whl", hash = "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350"}, + {file = "zipp-3.20.2.tar.gz", hash = "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +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 = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] +type = ["pytest-mypy"] + +[extras] +proxy = ["asgiproxy"] [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "c602c46c760b8c791a85db72622f1e39bcfa2ae7db6fc5a0d499701251e51508" +python-versions = "^3.9" +content-hash = "633eb484eb18b3151d1e7432e44717c6ee72c10fef0852f3213168604e43c271" diff --git a/pyproject.toml b/pyproject.toml index ba742e107..6381f800b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "reflex" -version = "0.5.0" +version = "0.6.5dev1" description = "Web apps in pure Python." license = "Apache-2.0" authors = [ @@ -26,12 +26,11 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.8" -dill = ">=0.3.8,<0.4" -fastapi = ">=0.96.0,<1.0" -gunicorn = ">=20.1.0,<23.0" +python = "^3.9" +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,<6.0" +psutil = ">=5.9.4,<7.0" pydantic = ">=1.10.2,<3.0" python-multipart = ">=0.0.5,<0.1" python-socketio = ">=5.7.0,<6.0" @@ -39,12 +38,7 @@ redis = ">=4.3.5,<6.0" rich = ">=13.0.0,<14.0" sqlmodel = ">=0.0.14,<0.1" typer = ">=0.4.2,<1.0" -uvicorn = [ - {version = "^0.24.0", python = ">=3.12"}, - {version = "^0.20.0", python = "<3.12"}, -] -watchdog = ">=2.3.1,<5.0" -watchfiles = ">=0.19.0,<1.0" +uvicorn = ">=0.20.0" starlette-admin = ">=0.11.0,<1.0" alembic = ">=1.11.1,<2.0" platformdirs = ">=3.10.0,<5.0" @@ -59,34 +53,33 @@ reflex-hosting-cli = ">=0.1.2,<2.0" charset-normalizer = ">=3.3.2,<4.0" wheel = ">=0.42.0,<1.0" build = ">=1.0.3,<2.0" -setuptools = ">=69.1.1,<70.0" +setuptools = ">=75.0" httpx = ">=0.25.1,<1.0" twine = ">=4.0.0,<6.0" tomlkit = ">=0.12.4,<1.0" asgiproxy = { version = "==0.1.1", optional = true } +lazy_loader = ">=0.4" +reflex-chakra = ">=0.6.0" [tool.poetry.group.dev.dependencies] -pytest = ">=7.1.2,<8.0" +pytest = ">=7.1.2,<9.0" pytest-mock = ">=3.10.0,<4.0" pyright = ">=1.1.229,<1.1.335" darglint = ">=1.8.1,<2.0" +dill = ">=0.3.8" 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" -black = "^22.10.0,<23.0" -ruff = "0.1.0" -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"} -] +pytest-asyncio = ">=0.24.0" +pytest-cov = ">=4.0.0,<6.0" +ruff = "0.7.1" +pandas = ">=2.1.1,<3.0" +pillow = ">=10.0.0,<12.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" +playwright = ">=1.46.0" +pytest-playwright = ">=0.5.1" [tool.poetry.scripts] reflex = "reflex.reflex:cli" @@ -101,13 +94,18 @@ build-backend = "poetry.core.masonry.api" [tool.pyright] [tool.ruff] -exclude = ["*.pyi"] -target-version = "py37" +target-version = "py39" lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] -lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541"] +lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541", "SIM115"] +lint.pydocstyle.convention = "google" + [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "tests/*.py" = ["D100", "D103", "D104", "B018"] "reflex/.templates/*.py" = ["D100", "D103", "D104"] -"*.pyi" = ["ALL"] +"*.pyi" = ["D301", "D415", "D417", "D418", "E742"] "*/blank.py" = ["I001"] + +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "function" +asyncio_mode = "auto" 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 2774ec579..000000000 --- a/reflex/.templates/apps/demo/code/demo.py +++ /dev/null @@ -1,126 +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 7f319d25c..000000000 --- a/reflex/.templates/apps/demo/code/pages/__init__.py +++ /dev/null @@ -1,6 +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 3747d5994..000000000 --- a/reflex/.templates/apps/demo/code/pages/datatable.py +++ /dev/null @@ -1,359 +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 c494573de..000000000 --- a/reflex/.templates/apps/demo/code/pages/forms.py +++ /dev/null @@ -1,256 +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 3eeef92c1..000000000 --- a/reflex/.templates/apps/demo/code/pages/graphing.py +++ /dev/null @@ -1,252 +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 d1a667783..000000000 --- a/reflex/.templates/apps/demo/code/pages/home.py +++ /dev/null @@ -1,55 +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 e31913194..000000000 --- a/reflex/.templates/apps/demo/code/styles.py +++ /dev/null @@ -1,67 +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/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 2678e8fa9..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/loading_icon.py +++ /dev/null @@ -1,26 +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] - - def get_event_triggers(self) -> dict: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return {"on_change": 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 4956e6f59..000000000 --- a/reflex/.templates/apps/demo/code/webui/state.py +++ /dev/null @@ -1,145 +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 - self.current_chat = list(self.chats.keys())[0] - 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 list(self.chats.keys()) - - 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..a5239f33b 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.9" 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 832bb61fb..21cfd921a 100644 --- a/reflex/.templates/jinja/web/pages/_app.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/_app.js.jinja2 @@ -1,13 +1,15 @@ {% extends "web/pages/base_page.js.jinja2" %} {% block early_imports %} -import '/styles/styles.css' +import '$/styles/styles.css' {% endblock %} {% block declaration %} -import { EventLoopProvider, StateProvider, defaultColorMode } from "/utils/context.js"; +import { EventLoopProvider, StateProvider, defaultColorMode } from "$/utils/context.js"; import { ThemeProvider } from 'next-themes' - +{% for library_alias, library_path in window_libraries %} +import * as {{library_alias}} from "{{library_path}}"; +{% endfor %} {% for custom_code in custom_codes %} {{custom_code}} @@ -27,8 +29,17 @@ 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 = { +{% for library_alias, library_path in window_libraries %} + "{{library_path}}": {{library_alias}}, +{% endfor %} + }; + 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..624e3bee8 100644 --- a/reflex/.templates/jinja/web/pages/utils.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/utils.js.jinja2 @@ -36,14 +36,10 @@ {# component: component dictionary #} {% macro render_tag(component) %} <{{component.name}} {{- render_props(component.props) }}> -{%- if component.args is not none -%} - {{- render_arg_content(component) }} -{%- else -%} - {{ component.contents }} - {% for child in component.children %} - {{ render(child) }} - {% endfor %} -{%- endif -%} +{{ component.contents }} +{% for child in component.children %} +{{ render(child) }} +{% endfor %} {%- endmacro %} @@ -64,11 +60,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 +81,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/context.js.jinja2 b/reflex/.templates/jinja/web/utils/context.js.jinja2 index 95e9fb3ab..2428cfa9d 100644 --- a/reflex/.templates/jinja/web/utils/context.js.jinja2 +++ b/reflex/.templates/jinja/web/utils/context.js.jinja2 @@ -1,5 +1,5 @@ import { createContext, useContext, useMemo, useReducer, useState } from "react" -import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "/utils/state.js" +import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "$/utils/state.js" {% if initial_state %} export const initialState = {{ initial_state|json_dumps }} @@ -7,7 +7,7 @@ export const initialState = {{ initial_state|json_dumps }} export const initialState = {} {% endif %} -export const defaultColorMode = "{{ default_color_mode }}" +export const defaultColorMode = {{ default_color_mode }} export const ColorModeContext = createContext(null); export const UploadFilesContext = createContext(null); export const DispatchContext = createContext(null); @@ -26,6 +26,8 @@ export const clientStorage = {} {% if state_name %} export const state_name = "{{state_name}}" +export const exception_state_name = "{{const.frontend_exception_state}}" + // Theses events are triggered on initial load and each page navigation. export const onLoadInternalEvent = () => { const internal_events = []; @@ -57,6 +59,8 @@ export const initialEvents = () => [ {% else %} export const state_name = undefined +export const exception_state_name = undefined + export const onLoadInternalEvent = () => [] export const initialEvents = () => [] @@ -64,6 +68,8 @@ export const initialEvents = () => [] export const isDevMode = {{ is_dev_mode|json_dumps }} +export const lastCompiledTimeStamp = {{ last_compiled_time|json_dumps }} + export function UploadFilesProvider({ children }) { const [filesById, setFilesById] = useState({}) refs["__clear_selected_files"] = (id) => setFilesById(filesById => { 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 f897522dd..000000000 --- a/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +++ /dev/null @@ -1,21 +0,0 @@ -import { useColorMode as chakraUseColorMode } from "@chakra-ui/react" -import { useTheme } from "next-themes" -import { useEffect } from "react" -import { ColorModeContext } from "/utils/context.js" - -export default function ChakraColorModeProvider({ children }) { - const {colorMode, toggleColorMode} = chakraUseColorMode() - const {theme, setTheme} = useTheme() - - useEffect(() => { - if (colorMode != theme) { - toggleColorMode() - } - }, [theme]) - - return ( - - {children} - - ) -} \ No newline at end of file diff --git a/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js b/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js index e2dd563e0..dd7886c89 100644 --- a/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +++ b/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js @@ -1,22 +1,53 @@ -import { useTheme } from "next-themes" -import { useEffect, useState } from "react" -import { ColorModeContext, defaultColorMode } from "/utils/context.js" - +import { useTheme } from "next-themes"; +import { useEffect, useState } from "react"; +import { + ColorModeContext, + defaultColorMode, + isDevMode, + lastCompiledTimeStamp, +} from "$/utils/context.js"; export default function RadixThemesColorModeProvider({ children }) { - const {theme, setTheme} = useTheme() - const [colorMode, setColorMode] = useState(defaultColorMode) - - useEffect(() => { - setColorMode(theme) - }, [theme]) - - const toggleColorMode = () => { - setTheme(theme === "light" ? "dark" : "light") + const { theme, resolvedTheme, setTheme } = useTheme(); + const [rawColorMode, setRawColorMode] = useState(defaultColorMode); + const [resolvedColorMode, setResolvedColorMode] = useState("dark"); + + useEffect(() => { + if (isDevMode) { + const lastCompiledTimeInLocalStorage = + localStorage.getItem("last_compiled_time"); + if ( + lastCompiledTimeInLocalStorage && + lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp + ) { + // on app startup, make sure the application color mode is persisted correctly. + setTheme(defaultColorMode); + localStorage.setItem("last_compiled_time", lastCompiledTimeStamp); + return; + } } - return ( - - {children} - - ) - } \ No newline at end of file + setRawColorMode(theme); + setResolvedColorMode(resolvedTheme); + }, [theme, resolvedTheme]); + + const toggleColorMode = () => { + setTheme(resolvedTheme === "light" ? "dark" : "light"); + }; + 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/components/shiki/code.js b/reflex/.templates/web/components/shiki/code.js new file mode 100644 index 000000000..22b3693b4 --- /dev/null +++ b/reflex/.templates/web/components/shiki/code.js @@ -0,0 +1,34 @@ +import { useEffect, useState } from "react" +import { codeToHtml} from "shiki" + +/** + * Code component that uses Shiki to convert code to HTML and render it. + * + * @param code - The code to be highlighted. + * @param theme - The theme to be used for highlighting. + * @param language - The language of the code. + * @param transformers - The transformers to be applied to the code. + * @param decorations - The decorations to be applied to the code. + * @param divProps - Additional properties to be passed to the div element. + * @returns The rendered code block. + */ +export function Code ({code, theme, language, transformers, decorations, ...divProps}) { + const [codeResult, setCodeResult] = useState("") + useEffect(() => { + async function fetchCode() { + const result = await codeToHtml(code, { + lang: language, + theme, + transformers, + decorations + }); + setCodeResult(result); + } + fetchCode(); + }, [code, language, theme, transformers, decorations] + + ) + return ( +
+ ) +} diff --git a/reflex/.templates/web/jsconfig.json b/reflex/.templates/web/jsconfig.json index 3c8a3257f..3fcb35ba6 100644 --- a/reflex/.templates/web/jsconfig.json +++ b/reflex/.templates/web/jsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "baseUrl": ".", "paths": { + "$/*": ["*"], "@/*": ["public/*"] } } -} \ No newline at end of file +} diff --git a/reflex/.templates/web/postcss.config.js b/reflex/.templates/web/postcss.config.js index 33ad091d2..1e7129835 100644 --- a/reflex/.templates/web/postcss.config.js +++ b/reflex/.templates/web/postcss.config.js @@ -1,5 +1,6 @@ module.exports = { plugins: { + "postcss-import": {}, tailwindcss: {}, autoprefixer: {}, }, diff --git a/reflex/.templates/web/styles/tailwind.css b/reflex/.templates/web/styles/tailwind.css index b5c61c956..e1c383749 100644 --- a/reflex/.templates/web/styles/tailwind.css +++ b/reflex/.templates/web/styles/tailwind.css @@ -1,3 +1,6 @@ -@tailwind base; +@import "tailwindcss/base"; + +@import "@radix-ui/themes/styles.css"; + @tailwind components; @tailwind utilities; diff --git a/reflex/.templates/web/utils/client_side_routing.js b/reflex/.templates/web/utils/client_side_routing.js index 75fb581c8..1718c8e61 100644 --- a/reflex/.templates/web/utils/client_side_routing.js +++ b/reflex/.templates/web/utils/client_side_routing.js @@ -23,7 +23,12 @@ export const useClientSideRouting = () => { router.replace({ pathname: window.location.pathname, query: window.location.search.slice(1), - }) + }).then(()=>{ + // Check if the current route is /404 + if (router.pathname === '/404') { + setRouteNotFound(true); // Mark as an actual 404 + } + }) .catch((e) => { setRouteNotFound(true) // navigation failed, so this is a real 404 }) diff --git a/reflex/.templates/web/utils/helpers/paste.js b/reflex/.templates/web/utils/helpers/paste.js new file mode 100644 index 000000000..f30fe9499 --- /dev/null +++ b/reflex/.templates/web/utils/helpers/paste.js @@ -0,0 +1,59 @@ +import { useEffect } from "react"; + +const handle_paste_data = (clipboardData) => + new Promise((resolve, reject) => { + const pasted_data = []; + const n_items = clipboardData.items.length; + const extract_data = (item) => { + const type = item.type; + if (item.kind === "string") { + item.getAsString((data) => { + pasted_data.push([type, data]); + if (pasted_data.length === n_items) { + resolve(pasted_data); + } + }); + } else if (item.kind === "file") { + const file = item.getAsFile(); + const reader = new FileReader(); + reader.onload = (e) => { + pasted_data.push([type, e.target.result]); + if (pasted_data.length === n_items) { + resolve(pasted_data); + } + }; + if (type.indexOf("text/") === 0) { + reader.readAsText(file); + } else { + reader.readAsDataURL(file); + } + } + }; + for (const item of clipboardData.items) { + extract_data(item); + } + }); + +export default function usePasteHandler(target_ids, event_actions, on_paste) { + return useEffect(() => { + const handle_paste = (_ev) => { + event_actions.preventDefault && _ev.preventDefault(); + event_actions.stopPropagation && _ev.stopPropagation(); + handle_paste_data(_ev.clipboardData).then(on_paste); + }; + const targets = target_ids + .map((id) => document.getElementById(id)) + .filter((element) => !!element); + if (target_ids.length === 0) { + targets.push(document); + } + targets.forEach((target) => + target.addEventListener("paste", handle_paste, false), + ); + return () => { + targets.forEach((target) => + target.removeEventListener("paste", handle_paste, false), + ); + }; + }); +} diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 5bc6b8b8b..7d76b080a 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -2,18 +2,19 @@ import axios from "axios"; import io from "socket.io-client"; import JSON5 from "json5"; -import env from "/env.json"; +import env from "$/env.json"; import Cookies from "universal-cookie"; -import { useEffect, useReducer, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import Router, { useRouter } from "next/router"; import { initialEvents, initialState, onLoadInternalEvent, state_name, -} from "utils/context.js"; -import debounce from "/utils/helpers/debounce"; -import throttle from "/utils/helpers/throttle"; + exception_state_name, +} from "$/utils/context.js"; +import debounce from "$/utils/helpers/debounce"; +import throttle from "$/utils/helpers/throttle"; // Endpoint URLs. const EVENTURL = env.EVENT; @@ -107,6 +108,18 @@ export const getBackendURL = (url_str) => { return endpoint; }; +/** + * Determine if any event in the event queue is stateful. + * + * @returns True if there's any event that requires state and False if none of them do. + */ +export const isStateful = () => { + if (event_queue.length === 0) { + return false; + } + return event_queue.some((event) => event.name.startsWith("reflex___state")); +}; + /** * Apply a delta to the state. * @param state The state to apply the delta to. @@ -116,6 +129,35 @@ 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 encodedJs = encodeURIComponent(component); + 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. + * @param socket The socket object to send the event on. + * + * @returns Adds event to queue and processes it if websocket exits, does nothing otherwise. + */ +export const queueEventIfSocketExists = async (events, socket) => { + if (!socket) { + return; + } + await queueEvents(events, socket); +}; + /** * Handle frontend event or send the event to the backend via Websocket. * @param event The event to send. @@ -126,8 +168,13 @@ export const applyDelta = (state, delta) => { export const applyEvent = async (event, socket) => { // Handle special events if (event.name == "_redirect") { - if (event.payload.external) window.open(event.payload.path, "_blank"); - else Router.push(event.payload.path); + if (event.payload.external) { + window.open(event.payload.path, "_blank"); + } else if (event.payload.replace) { + Router.replace(event.payload.path); + } else { + Router.push(event.payload.path); + } return false; } @@ -138,18 +185,30 @@ export const applyEvent = async (event, socket) => { if (event.name == "_remove_cookie") { cookies.remove(event.payload.key, { ...event.payload.options }); - queueEvents(initialEvents(), socket); + queueEventIfSocketExists(initialEvents(), socket); return false; } if (event.name == "_clear_local_storage") { localStorage.clear(); - queueEvents(initialEvents(), socket); + queueEventIfSocketExists(initialEvents(), socket); return false; } if (event.name == "_remove_local_storage") { localStorage.removeItem(event.payload.key); + queueEventIfSocketExists(initialEvents(), socket); + return false; + } + + if (event.name == "_clear_session_storage") { + sessionStorage.clear(); + queueEvents(initialEvents(), socket); + return false; + } + + if (event.name == "_remove_session_storage") { + sessionStorage.removeItem(event.payload.key); queueEvents(initialEvents(), socket); return false; } @@ -164,7 +223,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(); @@ -204,6 +266,9 @@ 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); + } } return false; } @@ -243,10 +308,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){ + 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. @@ -277,8 +341,8 @@ export const queueEvents = async (events, socket) => { * @param socket The socket object to send the event on. */ export const processEvent = async (socket) => { - // Only proceed if the socket is up, otherwise we throw the event into the void - if (!socket) { + // Only proceed if the socket is up and no event in the queue uses state, otherwise we throw the event into the void + if (!socket && isStateful()) { return; } @@ -345,16 +409,31 @@ export const connect = async ( } } + const pagehideHandler = (event) => { + if (event.persisted && socket.current?.connected) { + console.log("Disconnect backend before bfcache on navigation"); + socket.current.disconnect(); + } + }; + // Once the socket is open, hydrate the page. socket.current.on("connect", () => { setConnectErrors([]); + window.addEventListener("pagehide", pagehideHandler); }); socket.current.on("connect_error", (error) => { setConnectErrors((connectErrors) => [connectErrors.slice(-9), error]); }); + + // When the socket disconnects reset the event_processing flag + socket.current.on("disconnect", () => { + event_processing = false; + window.removeEventListener("pagehide", pagehideHandler); + }); + // 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]); @@ -463,13 +542,19 @@ export const uploadFiles = async ( /** * Create an event object. - * @param name The name of the event. - * @param payload The payload of the event. - * @param handler The client handler to process event. + * @param {string} name The name of the event. + * @param {Object.} payload The payload of the event. + * @param {Object.} event_actions The actions to take on the event. + * @param {string} handler The client handler to process event. * @returns The event object. */ -export const Event = (name, payload = {}, handler = null) => { - return { name, payload, handler }; +export const Event = ( + name, + payload = {}, + event_actions = {}, + handler = null +) => { + return { name, payload, handler, event_actions }; }; /** @@ -501,7 +586,22 @@ export const hydrateClientStorage = (client_storage) => { } } } - if (client_storage.cookies || client_storage.local_storage) { + if (client_storage.session_storage && typeof window != "undefined") { + for (const state_key in client_storage.session_storage) { + const session_options = client_storage.session_storage[state_key]; + const session_storage_value = sessionStorage.getItem( + session_options.name || state_key + ); + if (session_storage_value != null) { + client_storage_values[state_key] = session_storage_value; + } + } + } + if ( + client_storage.cookies || + client_storage.local_storage || + client_storage.session_storage + ) { return client_storage_values; } return {}; @@ -541,6 +641,16 @@ const applyClientStorageDelta = (client_storage, delta) => { ) { const options = client_storage.local_storage[state_key]; localStorage.setItem(options.name || state_key, delta[substate][key]); + } 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] + ); } } } @@ -566,7 +676,18 @@ export const useEventLoop = ( const [connectErrors, setConnectErrors] = useState([]); // Function to add new events to the event queue. - const addEvents = (events, _e, event_actions) => { + const addEvents = (events, args, event_actions) => { + if (!(args instanceof Array)) { + args = [args]; + } + + event_actions = events.reduce( + (acc, e) => ({ ...acc, ...e.event_actions }), + event_actions ?? {} + ); + + const _e = args.filter((o) => o?.preventDefault !== undefined)[0]; + if (event_actions?.preventDefault && _e?.preventDefault) { _e.preventDefault(); } @@ -585,7 +706,7 @@ export const useEventLoop = ( debounce( combined_name, () => queueEvents(events, socket), - event_actions.debounce, + event_actions.debounce ); } else { queueEvents(events, socket); @@ -610,6 +731,35 @@ 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, + component_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, + component_stack: "", + }), + ]); + return false; + }; + }, []); + // Main event loop. useEffect(() => { // Skip if the router is not ready. @@ -657,7 +807,7 @@ export const useEventLoop = ( const vars = {}; vars[storage_to_state_map[e.key]] = e.newValue; const event = Event( - `${state_name}.update_vars_internal_state.update_vars_internal`, + `${state_name}.reflex___state____update_vars_internal_state.update_vars_internal`, { vars: vars } ); addEvents([event], e); @@ -671,11 +821,11 @@ export const useEventLoop = ( // Route after the initial page hydration. useEffect(() => { const change_start = () => { - const main_state_dispatch = dispatch["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); @@ -694,7 +844,9 @@ export const useEventLoop = ( * @returns True if the value is truthy, false otherwise. */ export const isTrue = (val) => { - return Array.isArray(val) ? val.length > 0 : !!val; + if (Array.isArray(val)) return val.length > 0; + if (val === Object(val)) return Object.keys(val).length > 0; + return Boolean(val); }; /** diff --git a/reflex/__init__.py b/reflex/__init__.py index b67208ec9..ffc4426f9 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -1,152 +1,317 @@ """Import all classes and functions the end user will need to make an app. Anything imported here will be available in the default Reflex import as `rx.*`. -To signal to typecheckers that something should be reexported, -we use the Flask "import name as name" syntax. + +Dynamic Imports +--------------- +Reflex utilizes dynamic imports, or lazy loading, to reduce startup/import times. +With this approach, imports are delayed until they are actually needed. We use +the `lazy_loader` library(https://github.com/scientific-python/lazy_loader) to achieve this. + +How it works +-------------- +`lazy_loader.attach` takes two optional arguments: `submodules` and `submod_attrs`. +- `submodules` typically points to directories or files to be accessed. +- `submod_attrs` defines a mapping of directory or file names as keys with a list + of attributes or modules to access. + +Example directory structure: + +reflex/ + |_ components/ + |_ radix/ + |_ themes/ + |_ components/ + |_ box.py + +To add `box` under the `rx` namespace (`rx.box`), add the relative path to `submod_attrs` in +`reflex/__init__.py` (this file): + +```python +lazy_loader.attach( + submodules={"components"}, + submod_attrs={ + "components.radix.themes.components.box": ["box"] + } +) +``` + +This implies that `box` will be imported from `reflex/components/radix/themes/components/box.py`. + +To add box under the `rx.radix` namespace (`rx.radix.box`), add the relative path to the +submod_attrs argument in `reflex/components/radix/__init__.py`: + +```python +lazy_loader.attach( + submodules = {"themes"}, + submod_attrs = { + "themes.components.box": ["box"] + } +) +``` + +Note: It is important to specify the immediate submodules of a directory in the submodules +argument to ensure they are registered at runtime. For example, 'components' for reflex, +'radix' for components, 'themes' for radix, etc. + + +Pyi_generator +-------------- +To generate `.pyi` files for `__init__.py` files, we read the `_SUBMODULES` and `_SUBMOD_ATTRS` +attributes to generate the import statements. It is highly recommended to define these with +the provided annotations to facilitate their generation. + + +Aliases +------------ +This is a special case to specify an alias for a component. +As an example, we use this typically for `rx.list` where defining `list` attribute in the list.py +overshadows python's list object which messes up the pyi generation for `list.pyi`. As a result, aliases +should be used for similar cases like this. Note that this logic is employed to fix the pyi generation and alias +should still be defined or accessible. Check out the __getattr__ logic in `reflex/components/radix/themes/layouts/list.py` + +```python +lazy_loader.attach( + submodules={"components"}, + submod_attrs={ + "components.radix.themes.layouts": [("list_ns", "list")] + } +) +``` + +In the example above, you will be able to do `rx.list` """ from __future__ import annotations -import importlib -from typing import Type +from reflex.utils import ( + compat, # for side-effects + lazy_loader, +) -from reflex.page import page as page -from reflex.utils import console -from reflex.utils.format import to_snake_case +from .event import event as event -_ALL_COMPONENTS = [ - # Core - "color", - "cond", - "foreach", - "html", - "match", - "color_mode_cond", - "connection_banner", - "connection_modal", - "debounce_input", - # Base - "fragment", - "Fragment", - "image", - "script", - # Responsive - "desktop_only", - "mobile_and_tablet", - "mobile_only", - "tablet_and_desktop", - "tablet_only", - # Upload - "cancel_upload", - "clear_selected_files", - "get_upload_dir", - "get_upload_url", - "selected_files", - "upload", - # Radix - "accordion", - "alert_dialog", - "aspect_ratio", - "avatar", - "badge", - "blockquote", - "box", - "button", - "callout", - "card", - "center", - "checkbox", - "code", - "container", - "context_menu", - "data_list", - "dialog", - "divider", - "drawer", - "flex", - "form", - "grid", - "heading", - "hover_card", - "hstack", - "icon_button", - "inset", - "input", - "link", - "menu", - "popover", - "progress", - "radio", - "scroll_area", - "section", - "select", - "skeleton", - "slider", - "spacer", - "spinner", - "stack", - "switch", - "table", - "tabs", - "text", - "text_area", - "theme", - "theme_panel", - "tooltip", - "vstack", - # Other - "code_block", - "data_editor", - "data_editor_theme", - "data_table", - "plotly", - "audio", - "video", - "editor", - "EditorButtonList", - "EditorOptions", - "icon", - "markdown", - "list", - "list_item", - "unordered_list", - "ordered_list", - "moment", - "logo", - # Toast is in experimental namespace initially - # "toast", -] +# import this here explicitly to avoid returning the page module since page attr has the +# same name as page module(page.py) +from .page import page as page -_MAPPING = { - "reflex.experimental": ["_x"], - "reflex.admin": ["admin", "AdminDash"], - "reflex.app": ["app", "App", "UploadFile"], - "reflex.base": ["base", "Base"], - "reflex.compiler": ["compiler"], - "reflex.components": _ALL_COMPONENTS, - "reflex.components.component": ["Component", "NoSSRComponent", "memo"], - "reflex.components.chakra": ["chakra"], - "reflex.components.el": ["el"], - "reflex.components.lucide": ["lucide"], - "reflex.components.next": ["next"], - "reflex.components.radix": ["radix", "color_mode"], - "reflex.components.recharts": ["recharts"], - "reflex.components.moment.moment": ["MomentDelta"], - "reflex.config": ["config", "Config", "DBConfig"], - "reflex.constants": ["constants", "Env"], - "reflex.event": [ - "event", +# Remove the `compat` name from the namespace, it was imported for side-effects only. +del compat + +RADIX_THEMES_MAPPING: dict = { + "components.radix.themes.base": ["color_mode", "theme", "theme_panel"], + "components.radix.themes.color_mode": ["color_mode"], +} +RADIX_THEMES_COMPONENTS_MAPPING: dict = { + **{ + f"components.radix.themes.components.{mod}": [mod] + for mod in [ + "alert_dialog", + "aspect_ratio", + "avatar", + "badge", + "button", + "callout", + "card", + "checkbox", + "context_menu", + "data_list", + "dialog", + "hover_card", + "icon_button", + "input", + "inset", + "popover", + "scroll_area", + "select", + "skeleton", + "slider", + "spinner", + "switch", + "table", + "tabs", + "text_area", + "tooltip", + "segmented_control", + "radio_cards", + "checkbox_cards", + "checkbox_group", + ] + }, + "components.radix.themes.components.text_field": ["text_field", "input"], + "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 = { + "components.radix.themes.layout.box": [ + "box", + ], + "components.radix.themes.layout.center": [ + "center", + ], + "components.radix.themes.layout.container": [ + "container", + ], + "components.radix.themes.layout.flex": [ + "flex", + ], + "components.radix.themes.layout.grid": [ + "grid", + ], + "components.radix.themes.layout.section": [ + "section", + ], + "components.radix.themes.layout.spacer": [ + "spacer", + ], + "components.radix.themes.layout.stack": [ + "stack", + "hstack", + "vstack", + ], + "components.radix.themes.layout.list": [ + ("list_ns", "list"), + "list_item", + "ordered_list", + "unordered_list", + ], +} + +RADIX_THEMES_TYPOGRAPHY_MAPPING: dict = { + "components.radix.themes.typography.blockquote": [ + "blockquote", + ], + "components.radix.themes.typography.code": [ + "code", + ], + "components.radix.themes.typography.heading": [ + "heading", + ], + "components.radix.themes.typography.link": [ + "link", + ], + "components.radix.themes.typography.text": [ + "text", + ], +} + +RADIX_PRIMITIVES_MAPPING: dict = { + "components.radix.primitives.accordion": [ + "accordion", + ], + "components.radix.primitives.drawer": [ + "drawer", + ], + "components.radix.primitives.form": [ + "form", + ], + "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 = { + "components.core.banner": [ + "connection_banner", + "connection_modal", + ], + "components.core.cond": ["cond", "color_mode_cond"], + "components.core.foreach": ["foreach"], + "components.core.debounce": ["debounce_input"], + "components.core.html": ["html"], + "components.core.match": ["match"], + "components.core.clipboard": ["clipboard"], + "components.core.colors": ["color"], + "components.core.breakpoints": ["breakpoints"], + "components.core.responsive": [ + "desktop_only", + "mobile_and_tablet", + "mobile_only", + "tablet_and_desktop", + "tablet_only", + ], + "components.core.upload": [ + "cancel_upload", + "clear_selected_files", + "get_upload_dir", + "get_upload_url", + "selected_files", + "upload", + ], +} + +COMPONENTS_BASE_MAPPING: dict = { + "components.base.fragment": ["fragment", "Fragment"], + "components.base.script": ["script", "Script"], +} + +RADIX_MAPPING: dict = { + **RADIX_THEMES_MAPPING, + **RADIX_THEMES_COMPONENTS_MAPPING, + **RADIX_THEMES_TYPOGRAPHY_MAPPING, + **RADIX_THEMES_LAYOUT_MAPPING, + **RADIX_PRIMITIVES_SHORTCUT_MAPPING, +} + +_MAPPING: dict = { + "experimental": ["_x"], + "admin": ["AdminDash"], + "app": ["App", "UploadFile"], + "base": ["Base"], + "components.component": [ + "Component", + "NoSSRComponent", + "memo", + "ComponentNamespace", + ], + "components.el.elements.media": ["image"], + "components.lucide": ["icon"], + **COMPONENTS_BASE_MAPPING, + "components.suneditor": [ + "editor", + "EditorButtonList", + "EditorOptions", + ], + "components": ["el", "radix", "lucide", "recharts", "next"], + "components.markdown": ["markdown"], + **RADIX_MAPPING, + "components.plotly": ["plotly"], + "components.react_player": ["audio", "video"], + **COMPONENTS_CORE_MAPPING, + "components.datadisplay.code": [ + "code_block", + ], + "components.datadisplay.dataeditor": [ + "data_editor", + "data_editor_theme", + ], + "components.sonner.toast": ["toast"], + "components.datadisplay.logo": ["logo"], + "components.gridjs": ["data_table"], + "components.moment": ["MomentDelta", "moment"], + "config": ["Config", "DBConfig"], + "constants": ["Env"], + "event": [ "EventChain", "EventHandler", "background", "call_script", "clear_local_storage", + "clear_session_storage", "console_log", "download", "prevent_default", "redirect", "remove_cookie", "remove_local_storage", + "remove_session_storage", "set_clipboard", "set_focus", "scroll_to", @@ -155,84 +320,60 @@ _MAPPING = { "upload_files", "window_alert", ], - "reflex.middleware": ["middleware", "Middleware"], - "reflex.model": ["model", "session", "Model"], - "reflex.page": ["page"], - "reflex.route": ["route"], - "reflex.state": [ - "state", - "var", + "istate.storage": [ "Cookie", "LocalStorage", + "SessionStorage", + ], + "middleware": ["middleware", "Middleware"], + "model": ["session", "Model"], + "state": [ + "var", "ComponentState", "State", + "dynamic", ], - "reflex.style": ["style", "toggle_color_mode"], - "reflex.testing": ["testing"], - "reflex.utils": ["utils"], - "reflex.utils.imports": ["ImportVar"], - "reflex.vars": ["vars", "cached_var", "Var"], + "style": ["Style", "toggle_color_mode"], + "utils.imports": ["ImportVar"], + "utils.serializers": ["serializer"], + "vars": ["Var", "field", "Field"], } - -def _reverse_mapping(mapping: dict[str, list]) -> dict[str, str]: - """Reverse the mapping used to lazy loading, and check for conflicting name. - - Args: - mapping: The mapping to reverse. - - Returns: - The reversed mapping. - """ - reversed_mapping = {} - for key, values in mapping.items(): - for value in values: - if value not in reversed_mapping: - reversed_mapping[value] = key - else: - console.warn( - f"Key {value} is present multiple times in the imports _MAPPING: {key} / {reversed_mapping[value]}" - ) - return reversed_mapping +_SUBMODULES: set[str] = { + "components", + "app", + "style", + "admin", + "base", + "model", + "testing", + "utils", + "vars", + "config", + "compiler", +} +_SUBMOD_ATTRS: dict = _MAPPING +getattr, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) -# _MAPPING = {value: key for key, values in _MAPPING.items() for value in values} -_MAPPING = _reverse_mapping(_MAPPING) +def __getattr__(name): + if name == "chakra": + from reflex.utils import console - -def _removeprefix(text, prefix): - return text[text.startswith(prefix) and len(prefix) :] - - -__all__ = (_removeprefix(mod, "reflex.") for mod in _MAPPING) - - -def __getattr__(name: str) -> Type: - """Lazy load all modules. - - Args: - name: name of the module to load. - - Returns: - The module or the attribute of the module. - - Raises: - AttributeError: If the module or the attribute does not exist. - """ - try: - # Check for import of a module that is not in the mapping. - if name not in _MAPPING: - # If the name does not start with reflex, add it. - if not name.startswith("reflex") and name != "__all__": - name = f"reflex.{name}" - return importlib.import_module(name) - - # Import the module. - module = importlib.import_module(_MAPPING[name]) - - # Get the attribute from the module if the name is not the module itself. - return ( - getattr(module, name) if name != _MAPPING[name].rsplit(".")[-1] else module + console.deprecate( + "rx.chakra", + reason="and moved to a separate package. " + "To continue using Chakra UI components, install the `reflex-chakra` package via `pip install " + "reflex-chakra`.", + deprecation_version="0.6.0", + removal_version="0.7.0", + dedupe=True, ) - except ModuleNotFoundError: - raise AttributeError(f"module 'reflex' has no attribute {name}") from None + import reflex_chakra as rc + + return rc + return getattr(name) diff --git a/reflex/__init__.pyi b/reflex/__init__.pyi index f919220a8..aa1c92b72 100644 --- a/reflex/__init__.pyi +++ b/reflex/__init__.pyi @@ -1,157 +1,206 @@ -from reflex.experimental import _x as _x -from reflex import admin as admin -from reflex.admin import AdminDash as AdminDash -from reflex import app as app -from reflex.app import App as App -from reflex.app import UploadFile as UploadFile -from reflex import base as base -from reflex.base import Base as Base -from reflex import compiler as compiler -from reflex.components import color as color -from reflex.components import cond as cond -from reflex.components import foreach as foreach -from reflex.components import html as html -from reflex.components import match as match -from reflex.components import color_mode_cond as color_mode_cond -from reflex.components import connection_banner as connection_banner -from reflex.components import connection_modal as connection_modal -from reflex.components import debounce_input as debounce_input -from reflex.components import fragment as fragment -from reflex.components import Fragment as Fragment -from reflex.components import image as image -from reflex.components import script as script -from reflex.components import desktop_only as desktop_only -from reflex.components import mobile_and_tablet as mobile_and_tablet -from reflex.components import mobile_only as mobile_only -from reflex.components import tablet_and_desktop as tablet_and_desktop -from reflex.components import tablet_only as tablet_only -from reflex.components import cancel_upload as cancel_upload -from reflex.components import clear_selected_files as clear_selected_files -from reflex.components import get_upload_dir as get_upload_dir -from reflex.components import get_upload_url as get_upload_url -from reflex.components import selected_files as selected_files -from reflex.components import upload as upload -from reflex.components import accordion as accordion -from reflex.components import alert_dialog as alert_dialog -from reflex.components import aspect_ratio as aspect_ratio -from reflex.components import avatar as avatar -from reflex.components import badge as badge -from reflex.components import blockquote as blockquote -from reflex.components import box as box -from reflex.components import button as button -from reflex.components import callout as callout -from reflex.components import card as card -from reflex.components import center as center -from reflex.components import checkbox as checkbox -from reflex.components import code as code -from reflex.components import container as container -from reflex.components import context_menu as context_menu -from reflex.components import data_list as data_list -from reflex.components import dialog as dialog -from reflex.components import divider as divider -from reflex.components import drawer as drawer -from reflex.components import flex as flex -from reflex.components import form as form -from reflex.components import grid as grid -from reflex.components import heading as heading -from reflex.components import hover_card as hover_card -from reflex.components import hstack as hstack -from reflex.components import icon_button as icon_button -from reflex.components import inset as inset -from reflex.components import input as input -from reflex.components import link as link -from reflex.components import menu as menu -from reflex.components import popover as popover -from reflex.components import progress as progress -from reflex.components import radio as radio -from reflex.components import scroll_area as scroll_area -from reflex.components import section as section -from reflex.components import select as select -from reflex.components import skeleton as skeleton -from reflex.components import slider as slider -from reflex.components import spacer as spacer -from reflex.components import spinner as spinner -from reflex.components import stack as stack -from reflex.components import switch as switch -from reflex.components import table as table -from reflex.components import tabs as tabs -from reflex.components import text as text -from reflex.components import text_area as text_area -from reflex.components import theme as theme -from reflex.components import theme_panel as theme_panel -from reflex.components import tooltip as tooltip -from reflex.components import vstack as vstack -from reflex.components import code_block as code_block -from reflex.components import data_editor as data_editor -from reflex.components import data_editor_theme as data_editor_theme -from reflex.components import data_table as data_table -from reflex.components import plotly as plotly -from reflex.components import audio as audio -from reflex.components import video as video -from reflex.components import editor as editor -from reflex.components import EditorButtonList as EditorButtonList -from reflex.components import EditorOptions as EditorOptions -from reflex.components import icon as icon -from reflex.components import markdown as markdown -from reflex.components import list as list -from reflex.components import list_item as list_item -from reflex.components import unordered_list as unordered_list -from reflex.components import ordered_list as ordered_list -from reflex.components import moment as moment -from reflex.components import logo as logo -from reflex.components.component import Component as Component -from reflex.components.component import NoSSRComponent as NoSSRComponent -from reflex.components.component import memo as memo -from reflex.components import chakra as chakra -from reflex.components import el as el -from reflex.components import lucide as lucide -from reflex.components import next as next -from reflex.components import radix as radix -from reflex.components.radix import color_mode as color_mode -from reflex.components import recharts as recharts -from reflex.components.moment.moment import MomentDelta as MomentDelta -from reflex import config as config -from reflex.config import Config as Config -from reflex.config import DBConfig as DBConfig -from reflex import constants as constants -from reflex.constants import Env as Env -from reflex import event as event -from reflex.event import EventChain as EventChain -from reflex.event import EventHandler as EventHandler -from reflex.event import background as background -from reflex.event import call_script as call_script -from reflex.event import clear_local_storage as clear_local_storage -from reflex.event import console_log as console_log -from reflex.event import download as download -from reflex.event import prevent_default as prevent_default -from reflex.event import redirect as redirect -from reflex.event import remove_cookie as remove_cookie -from reflex.event import remove_local_storage as remove_local_storage -from reflex.event import set_clipboard as set_clipboard -from reflex.event import set_focus as set_focus -from reflex.event import scroll_to as scroll_to -from reflex.event import set_value as set_value -from reflex.event import stop_propagation as stop_propagation -from reflex.event import upload_files as upload_files -from reflex.event import window_alert as window_alert -from reflex import middleware as middleware -from reflex.middleware import Middleware as Middleware -from reflex import model as model -from reflex.model import session as session -from reflex.model import Model as Model -from reflex.page import page as page -from reflex import route as route -from reflex import state as state -from reflex.state import var as var -from reflex.state import Cookie as Cookie -from reflex.state import LocalStorage as LocalStorage -from reflex.state import ComponentState as ComponentState -from reflex.state import State as State -from reflex import style as style -from reflex.style import toggle_color_mode as toggle_color_mode -from reflex import testing as testing -from reflex import utils as utils -from reflex.utils.imports import ImportVar as ImportVar -from reflex import vars as vars -from reflex.vars import cached_var as cached_var -from reflex.vars import Var as Var +"""Stub file for reflex/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from reflex.utils import compat + +from . import admin as admin +from . import app as app +from . import base as base +from . import compiler as compiler +from . import components as components +from . import config as config +from . import model as model +from . import style as style +from . import testing as testing +from . import utils as utils +from . import vars as vars +from .admin import AdminDash as AdminDash +from .app import App as App +from .app import UploadFile as UploadFile +from .base import Base as Base +from .components import el as el +from .components import lucide as lucide +from .components import next as next +from .components import radix as radix +from .components import recharts as recharts +from .components.base.fragment import Fragment as Fragment +from .components.base.fragment import fragment as fragment +from .components.base.script import Script as Script +from .components.base.script import script as script +from .components.component import Component as Component +from .components.component import ComponentNamespace as ComponentNamespace +from .components.component import NoSSRComponent as NoSSRComponent +from .components.component import memo as memo +from .components.core.banner import connection_banner as connection_banner +from .components.core.banner import connection_modal as connection_modal +from .components.core.breakpoints import breakpoints as breakpoints +from .components.core.clipboard import clipboard as clipboard +from .components.core.colors import color as color +from .components.core.cond import color_mode_cond as color_mode_cond +from .components.core.cond import cond as cond +from .components.core.debounce import debounce_input as debounce_input +from .components.core.foreach import foreach as foreach +from .components.core.html import html as html +from .components.core.match import match as match +from .components.core.responsive import desktop_only as desktop_only +from .components.core.responsive import mobile_and_tablet as mobile_and_tablet +from .components.core.responsive import mobile_only as mobile_only +from .components.core.responsive import tablet_and_desktop as tablet_and_desktop +from .components.core.responsive import tablet_only as tablet_only +from .components.core.upload import cancel_upload as cancel_upload +from .components.core.upload import clear_selected_files as clear_selected_files +from .components.core.upload import get_upload_dir as get_upload_dir +from .components.core.upload import get_upload_url as get_upload_url +from .components.core.upload import selected_files as selected_files +from .components.core.upload import upload as upload +from .components.datadisplay.code import code_block as code_block +from .components.datadisplay.dataeditor import data_editor as data_editor +from .components.datadisplay.dataeditor import data_editor_theme as data_editor_theme +from .components.datadisplay.logo import logo as logo +from .components.el.elements.media import image as image +from .components.gridjs import data_table as data_table +from .components.lucide import icon as icon +from .components.markdown import markdown as markdown +from .components.moment import MomentDelta as MomentDelta +from .components.moment import moment as moment +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.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 +from .components.radix.themes.components.alert_dialog import ( + alert_dialog as alert_dialog, +) +from .components.radix.themes.components.aspect_ratio import ( + aspect_ratio as aspect_ratio, +) +from .components.radix.themes.components.avatar import avatar as avatar +from .components.radix.themes.components.badge import badge as badge +from .components.radix.themes.components.button import button as button +from .components.radix.themes.components.callout import callout as callout +from .components.radix.themes.components.card import card as card +from .components.radix.themes.components.checkbox import checkbox as checkbox +from .components.radix.themes.components.checkbox_cards import ( + checkbox_cards as checkbox_cards, +) +from .components.radix.themes.components.checkbox_group import ( + checkbox_group as checkbox_group, +) +from .components.radix.themes.components.context_menu import ( + context_menu as context_menu, +) +from .components.radix.themes.components.data_list import data_list as data_list +from .components.radix.themes.components.dialog import dialog as dialog +from .components.radix.themes.components.dropdown_menu import ( + dropdown_menu as dropdown_menu, +) +from .components.radix.themes.components.dropdown_menu import menu as menu +from .components.radix.themes.components.hover_card import hover_card as hover_card +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 +from .components.radix.themes.components.scroll_area import scroll_area as scroll_area +from .components.radix.themes.components.segmented_control import ( + segmented_control as segmented_control, +) +from .components.radix.themes.components.select import select as select +from .components.radix.themes.components.separator import divider as divider +from .components.radix.themes.components.separator import separator as separator +from .components.radix.themes.components.skeleton import skeleton as skeleton +from .components.radix.themes.components.slider import slider as slider +from .components.radix.themes.components.spinner import spinner as spinner +from .components.radix.themes.components.switch import switch as switch +from .components.radix.themes.components.table import table as table +from .components.radix.themes.components.tabs import tabs as tabs +from .components.radix.themes.components.text_area import text_area as text_area +from .components.radix.themes.components.text_field import input as input +from .components.radix.themes.components.text_field import text_field as text_field +from .components.radix.themes.components.tooltip import tooltip as tooltip +from .components.radix.themes.layout.box import box as box +from .components.radix.themes.layout.center import center as center +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 +from .components.radix.themes.layout.spacer import spacer as spacer +from .components.radix.themes.layout.stack import hstack as hstack +from .components.radix.themes.layout.stack import stack as stack +from .components.radix.themes.layout.stack import vstack as vstack +from .components.radix.themes.typography.blockquote import blockquote as blockquote +from .components.radix.themes.typography.code import code as code +from .components.radix.themes.typography.heading import heading as heading +from .components.radix.themes.typography.link import link as link +from .components.radix.themes.typography.text import text as text +from .components.react_player import audio as audio +from .components.react_player import video as video +from .components.sonner.toast import toast as toast +from .components.suneditor import EditorButtonList as EditorButtonList +from .components.suneditor import EditorOptions as EditorOptions +from .components.suneditor import editor as editor +from .config import Config as Config +from .config import DBConfig as DBConfig +from .constants import Env as Env +from .event import EventChain as EventChain +from .event import EventHandler as EventHandler +from .event import background as background +from .event import call_script as call_script +from .event import clear_local_storage as clear_local_storage +from .event import clear_session_storage as clear_session_storage +from .event import console_log as console_log +from .event import download as download +from .event import event as event +from .event import prevent_default as prevent_default +from .event import redirect as redirect +from .event import remove_cookie as remove_cookie +from .event import remove_local_storage as remove_local_storage +from .event import remove_session_storage as remove_session_storage +from .event import scroll_to as scroll_to +from .event import set_clipboard as set_clipboard +from .event import set_focus as set_focus +from .event import set_value as set_value +from .event import stop_propagation as stop_propagation +from .event import upload_files as upload_files +from .event import window_alert as window_alert +from .experimental import _x as _x +from .istate.storage import Cookie as Cookie +from .istate.storage import LocalStorage as LocalStorage +from .istate.storage import SessionStorage as SessionStorage +from .middleware import Middleware as Middleware +from .middleware import middleware as middleware +from .model import Model as Model +from .model import session as session +from .page import page as page +from .state import ComponentState as ComponentState +from .state import State as State +from .state import dynamic as dynamic +from .state import var as var +from .style import Style as Style +from .style import toggle_color_mode as toggle_color_mode +from .utils.imports import ImportVar as ImportVar +from .utils.serializers import serializer as serializer +from .vars import Field as Field +from .vars import Var as Var +from .vars import field as field + +del compat +RADIX_THEMES_MAPPING: dict +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/admin.py b/reflex/admin.py index 44193daab..eba5dbe0f 100644 --- a/reflex/admin.py +++ b/reflex/admin.py @@ -1,4 +1,5 @@ """The Reflex Admin Dashboard.""" + from dataclasses import dataclass, field from typing import Optional diff --git a/reflex/app.py b/reflex/app.py index bd2dc771f..aaf75cc8a 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -6,12 +6,20 @@ import asyncio import concurrent.futures import contextlib import copy +import dataclasses import functools +import inspect import io +import json import multiprocessing import os import platform +import sys +import traceback +from datetime import datetime +from pathlib import Path from typing import ( + TYPE_CHECKING, Any, AsyncGenerator, AsyncIterator, @@ -29,7 +37,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 @@ -38,28 +46,39 @@ from starlette_admin.contrib.sqla.view import ModelView from reflex import constants from reflex.admin import AdminDash -from reflex.base import Base +from reflex.app_mixins import AppMixin, LifespanMixin, MiddlewareMixin from reflex.compiler import compiler from reflex.compiler import utils as compiler_utils -from reflex.compiler.compiler import ExecutorSafeFunctions -from reflex.components import connection_modal, connection_pulser +from reflex.compiler.compiler import ( + ExecutorSafeFunctions, + compile_theme, +) from reflex.components.base.app_wrap import AppWrap +from reflex.components.base.error_boundary import ErrorBoundary from reflex.components.base.fragment import Fragment from reflex.components.component import ( Component, ComponentStyle, evaluate_style_namespaces, ) +from reflex.components.core.banner import connection_pulser, connection_toaster +from reflex.components.core.breakpoints import set_breakpoints from reflex.components.core.client_side_routing import ( Default404Page, wait_for_client_redirect, ) 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 -from reflex.middleware import HydrateMiddleware, Middleware -from reflex.model import Model +from reflex.config import environment, get_config +from reflex.event import ( + Event, + EventHandler, + EventSpec, + EventType, + IndividualEventType, + window_alert, +) +from reflex.model import Model, get_db_status from reflex.page import ( DECORATED_PAGES, ) @@ -77,39 +96,87 @@ from reflex.state import ( _substate_key, code_uses_state_contexts, ) -from reflex.utils import console, exceptions, format, prerequisites, types -from reflex.utils.exec import is_testing_env, should_skip_compile +from reflex.utils import codespaces, console, exceptions, format, prerequisites, types +from reflex.utils.exec import is_backend_only, is_prod_mode, is_testing_env, should_skip_compile from reflex.utils.imports import ImportVar +if TYPE_CHECKING: + from reflex.vars import Var + # Define custom types. ComponentCallable = Callable[[], Component] Reducer = Callable[[Event], Coroutine[Any, Any, StateUpdate]] +def default_frontend_exception_handler(exception: Exception) -> None: + """Default frontend exception handler function. + + Args: + exception: The exception. + + """ + console.error(f"[Reflex Frontend Exception]\n {exception}\n") + + +def default_backend_exception_handler(exception: Exception) -> EventSpec: + """Default backend exception handler function. + + Args: + exception: The exception. + + Returns: + EventSpec: The window alert event. + + """ + from reflex.components.sonner.toast import Toaster, toast + + error = traceback.format_exc() + + console.error(f"[Reflex Backend Exception]\n {error}\n") + + error_message = ( + ["Contact the website administrator."] + if is_prod_mode() + else [f"{type(exception).__name__}: {exception}.", "See logs for details."] + ) + if Toaster.is_used: + return toast( + "An error occurred.", + level="error", + description="
".join(error_message), + position="top-center", + id="backend_error", + style={"width": "500px"}, + ) # type: ignore + else: + error_message.insert(0, "An error occurred.") + return window_alert("\n".join(error_message)) + + def default_overlay_component() -> Component: """Default overlay_component attribute for App. Returns: The default overlay_component, which is a connection_modal. """ - return Fragment.create(connection_pulser(), connection_modal()) + return Fragment.create( + connection_pulser(), + connection_toaster(), + *codespaces.codespaces_auto_redirect(), + ) -@contextlib.asynccontextmanager -async def lifespan(api: FastAPI) -> AsyncGenerator[None, None]: - """Context manager to handle the lifespan of the app. +def default_error_boundary(*children: Component) -> Component: + """Default error_boundary attribute for App. Args: - api: The FastAPI instance. + *children: The children to render in the error boundary. + + Returns: + The default error_boundary, which is an ErrorBoundary. - Yields: - None """ - # try to set up proxying if its enabled - from .proxy import proxy_middleware - - async with proxy_middleware(api): - yield + return ErrorBoundary.create(*children) class OverlayFragment(Fragment): @@ -118,7 +185,23 @@ class OverlayFragment(Fragment): pass -class App(Base): +@dataclasses.dataclass( + frozen=True, +) +class UnevaluatedPage: + """An uncompiled page.""" + + component: Union[Component, ComponentCallable] + route: str + title: Union[Var, str, None] + description: Union[Var, str, None] + image: str + on_load: Union[EventType[[]], None] + meta: List[Dict[str, str]] + + +@dataclasses.dataclass() +class App(MiddlewareMixin, LifespanMixin): """The main Reflex app that encapsulates the backend and frontend. Every Reflex app needs an app defined in its main module. @@ -140,21 +223,26 @@ class App(Base): """ # The global [theme](https://reflex.dev/docs/styling/theming/#theme) for the entire app. - theme: Optional[Component] = themes.theme(accent_color="blue") + theme: Optional[Component] = dataclasses.field( + default_factory=lambda: themes.theme(accent_color="blue") + ) # The [global style](https://reflex.dev/docs/styling/overview/#global-styles}) for the app. - style: ComponentStyle = {} + style: ComponentStyle = dataclasses.field(default_factory=dict) # A list of URLs to [stylesheets](https://reflex.dev/docs/styling/custom-stylesheets/) to include in the app. - stylesheets: List[str] = [] + stylesheets: List[str] = dataclasses.field(default_factory=list) # A component that is present on every page (defaults to the Connection Error banner). - overlay_component: Optional[ - Union[Component, ComponentCallable] - ] = default_overlay_component + overlay_component: Optional[Union[Component, ComponentCallable]] = ( + dataclasses.field(default_factory=default_overlay_component) + ) + + # Error boundary component to wrap the app with. + error_boundary: Optional[ComponentCallable] = default_error_boundary # Components to add to the head of every page. - head_components: List[Component] = [] + head_components: List[Component] = dataclasses.field(default_factory=list) # The Socket.IO AsyncServer instance. sio: Optional[AsyncServer] = None @@ -165,8 +253,13 @@ class App(Base): # Attributes to add to the html root tag of every page. html_custom_attrs: Optional[Dict[str, str]] = None + # A map from a route to an unevaluated page. PRIVATE. + unevaluated_pages: Dict[str, UnevaluatedPage] = dataclasses.field( + default_factory=dict + ) + # A map from a page route to the component to render. Users should use `add_page`. PRIVATE. - pages: Dict[str, Component] = {} + pages: Dict[str, Component] = dataclasses.field(default_factory=dict) # The backend API object. PRIVATE. api: FastAPI = None # type: ignore @@ -177,11 +270,10 @@ class App(Base): # Class to manage many client states. _state_manager: Optional[StateManager] = None - # Middleware to add to the app. Users should use `add_middleware`. PRIVATE. - middleware: List[Middleware] = [] - # Mapping from a route to event handlers to trigger when the page loads. PRIVATE. - load_events: Dict[str, List[Union[EventHandler, EventSpec]]] = {} + load_events: Dict[str, List[IndividualEventType[[]]]] = dataclasses.field( + default_factory=dict + ) # Admin dashboard to view and manage the database. PRIVATE. admin_dash: Optional[AdminDash] = None @@ -190,46 +282,64 @@ class App(Base): event_namespace: Optional[EventNamespace] = None # Background tasks that are currently running. PRIVATE. - background_tasks: Set[asyncio.Task] = set() + background_tasks: Set[asyncio.Task] = dataclasses.field(default_factory=set) - def __init__(self, **kwargs): + # Frontend Error Handler Function + frontend_exception_handler: Callable[[Exception], None] = ( + default_frontend_exception_handler + ) + + # Backend Error Handler Function + backend_exception_handler: Callable[ + [Exception], Union[EventSpec, List[EventSpec], None] + ] = default_backend_exception_handler + + def __post_init__(self): """Initialize the app. - Args: - **kwargs: Kwargs to initialize the app with. - Raises: ValueError: If the event namespace is not provided in the config. Also, if there are multiple client subclasses of rx.BaseState(Subclasses of rx.BaseState should consist of the DefaultState and the client app state). """ - if "connect_error_component" in kwargs: - raise ValueError( - "`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" ) - # Add middleware. - self.middleware.append(HydrateMiddleware()) + if "breakpoints" in self.style: + set_breakpoints(self.style.pop("breakpoints")) # Set up the API. - self.api = FastAPI(lifespan=lifespan) + self.api = FastAPI(lifespan=self._run_lifespan_tasks) self._add_cors() self._add_default_endpoints() + for clz in App.__mro__: + if clz == App: + continue + if issubclass(clz, AppMixin): + clz._init_mixin(self) + self._setup_state() # Set up the admin dash. self._setup_admin_dash() + if sys.platform == "win32" and not is_prod_mode(): + # Hack to fix Windows hot reload issue. + from reflex.utils.compat import windows_hot_reload_lifespan_hack + + self.register_lifespan_task(windows_hot_reload_lifespan_hack) + + # Enable proxying to frontend server. + if not is_backend_only(): + from reflex.proxy import proxy_middleware + + self.register_lifespan_task(proxy_middleware) + def _enable_state(self) -> None: """Enable state for the app.""" if not self.state: @@ -281,6 +391,9 @@ class App(Base): # Mount the socket app with the API. self.api.mount(str(constants.Endpoint.EVENT), socket_app) + # Check the exception handlers + self._validate_exception_handlers() + def __repr__(self) -> str: """Get the string representation of the app. @@ -301,11 +414,12 @@ class App(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).""" - # To upload files. if Upload.is_used: + # To upload files. self.api.post(str(constants.Endpoint.UPLOAD))(upload(self)) # To access uploaded files. @@ -314,6 +428,10 @@ class App(Base): StaticFiles(directory=get_upload_dir()), name="uploaded_files", ) + if codespaces.is_running_in_codespaces(): + self.api.get(str(constants.Endpoint.AUTH_CODESPACE))( + codespaces.auth_codespace + ) def _add_cors(self): """Add CORS middleware to the app.""" @@ -339,77 +457,6 @@ class App(Base): raise ValueError("The state manager has not been initialized.") return self._state_manager - async def _preprocess(self, state: BaseState, event: Event) -> StateUpdate | None: - """Preprocess the event. - - This is where middleware can modify the event before it is processed. - Each middleware is called in the order it was added to the app. - - If a middleware returns an update, the event is not processed and the - update is returned. - - Args: - state: The state to preprocess. - event: The event to preprocess. - - Returns: - An optional state to return. - """ - for middleware in self.middleware: - if asyncio.iscoroutinefunction(middleware.preprocess): - out = await middleware.preprocess(app=self, state=state, event=event) # type: ignore - else: - out = middleware.preprocess(app=self, state=state, event=event) # type: ignore - if out is not None: - return out # type: ignore - - async def _postprocess( - self, state: BaseState, event: Event, update: StateUpdate - ) -> StateUpdate: - """Postprocess the event. - - This is where middleware can modify the delta after it is processed. - Each middleware is called in the order it was added to the app. - - Args: - state: The state to postprocess. - event: The event to postprocess. - update: The current state update. - - Returns: - The state update to return. - """ - for middleware in self.middleware: - if asyncio.iscoroutinefunction(middleware.postprocess): - out = await middleware.postprocess( - app=self, # type: ignore - state=state, - event=event, - update=update, - ) - else: - out = middleware.postprocess( - app=self, # type: ignore - state=state, - event=event, - update=update, - ) - if out is not None: - return out # type: ignore - return update - - def add_middleware(self, middleware: Middleware, index: int | None = None): - """Add middleware to the app. - - Args: - middleware: The middleware to add. - index: The index to add the middleware at. - """ - if index is None: - self.middleware.append(middleware) - else: - self.middleware.insert(index, middleware) - @staticmethod def _generate_component(component: Component | ComponentCallable) -> Component: """Generate a component from a callable. @@ -421,36 +468,21 @@ class App(Base): The generated component. Raises: - VarOperationTypeError: When an invalid component var related function is passed. - TypeError: When an invalid component function is passed. exceptions.MatchTypeError: If the return types of match cases in rx.match are different. """ - from reflex.utils.exceptions import VarOperationTypeError - try: return component if isinstance(component, Component) else component() except exceptions.MatchTypeError: raise - except TypeError as e: - message = str(e) - if "BaseVar" in message or "ComputedVar" in message: - raise VarOperationTypeError( - "You may be trying to use an invalid Python function on a state var. " - "When referencing a var inside your render code, only limited var operations are supported. " - "See the var operation docs here: https://reflex.dev/docs/vars/var-operations/" - ) from e - raise e def add_page( self, component: Component | ComponentCallable, route: str | None = None, - title: str | None = None, - description: str | None = None, + title: str | Var | None = None, + description: str | Var | None = None, image: str = constants.DefaultPage.IMAGE, - on_load: ( - EventHandler | EventSpec | list[EventHandler | EventSpec] | None - ) = None, + on_load: EventType[[]] | None = None, meta: list[dict[str, str]] = constants.DefaultPage.META_LIST, ): """Add a page to the app. @@ -472,9 +504,8 @@ class App(Base): """ # If the route is not set, get it from the callable. if route is None: - assert isinstance( - component, Callable - ), "Route must be set if component is not a callable." + if not isinstance(component, Callable): + raise ValueError("Route must be set if component is not a callable.") # Format the route. route = format.format_route(component.__name__) else: @@ -483,13 +514,13 @@ class App(Base): # Check if the route given is valid verify_route_validity(route) - if route in self.pages and os.getenv(constants.RELOAD_CONFIG): + if route in self.unevaluated_pages and os.getenv(constants.RELOAD_CONFIG): # when the app is reloaded(typically for app harness tests), we should maintain # the latest render function of a route.This applies typically to decorated pages # since they are only added when app._compile is called. - self.pages.pop(route) + self.unevaluated_pages.pop(route) - if route in self.pages: + if route in self.unevaluated_pages: route_name = ( f"`{route}` or `/`" if route == constants.PageNames.INDEX_ROUTE @@ -505,58 +536,39 @@ class App(Base): state = self.state if self.state else State state.setup_dynamic_args(get_route_args(route)) - # Generate the component if it is a callable. - component = self._generate_component(component) + if on_load: + self.load_events[route] = ( + on_load if isinstance(on_load, list) else [on_load] + ) - # unpack components that return tuples in an rx.fragment. - if isinstance(component, tuple): - component = Fragment.create(*component) - - # Ensure state is enabled if this page uses state. - if self.state is None: - if on_load or component._has_event_triggers(): - self._enable_state() - else: - for var in component._get_vars(include_children=True): - if not var._var_data: - continue - if not var._var_data.state: - continue - self._enable_state() - break - - component = OverlayFragment.create(component) - - meta_args = { - "title": ( - title - if title is not None - else format.make_default_page_title(get_config().app_name, route) - ), - "image": image, - "meta": meta, - } - - if description is not None: - meta_args["description"] = description - - # Add meta information to the component. - compiler_utils.add_meta( - component, - **meta_args, + self.unevaluated_pages[route] = UnevaluatedPage( + component=component, + route=route, + title=title, + description=description, + image=image, + on_load=on_load, + meta=meta, ) + def _compile_page(self, route: str): + """Compile a page. + + Args: + route: The route of the page to compile. + """ + component, enable_state = compiler.compile_unevaluated_page( + route, self.unevaluated_pages[route], self.state, self.style, self.theme + ) + + if enable_state: + self._enable_state() + # Add the page. self._check_routes_conflict(route) self.pages[route] = component - # Add the load events. - if on_load: - if not isinstance(on_load, list): - on_load = [on_load] - self.load_events[route] = on_load - - def get_load_events(self, route: str) -> list[EventHandler | EventSpec]: + def get_load_events(self, route: str) -> list[IndividualEventType[[]]]: """Get the load events for a route. Args: @@ -615,9 +627,7 @@ class App(Base): title: str = constants.Page404.TITLE, image: str = constants.Page404.IMAGE, description: str = constants.Page404.DESCRIPTION, - on_load: ( - EventHandler | EventSpec | list[EventHandler | EventSpec] | None - ) = None, + on_load: EventType[[]] | None = None, meta: list[dict[str, str]] = constants.DefaultPage.META_LIST, ): """Define a custom 404 page for any url having no match. @@ -680,12 +690,9 @@ class App(Base): page_imports = { i for i, tags in imports.items() - if i - not in [ - *constants.PackageJson.DEPENDENCIES.keys(), - *constants.PackageJson.DEV_DEPENDENCIES.keys(), - ] - and not any(i.startswith(prefix) for prefix in ["/", ".", "next/"]) + if i not in constants.PackageJson.DEPENDENCIES + and i not in constants.PackageJson.DEV_DEPENDENCIES + and not any(i.startswith(prefix) for prefix in ["/", "$/", ".", "next/"]) and i != "" and any(tag.install for tag in tags) } @@ -727,10 +734,12 @@ class App(Base): if should_skip_compile(): return False + nocompile = prerequisites.get_web_dir() / constants.NOCOMPILE_FILE + # Check the nocompile file. - if os.path.exists(constants.NOCOMPILE_FILE): + if nocompile.exists(): # Delete the nocompile file - os.remove(constants.NOCOMPILE_FILE) + nocompile.unlink() return False # By default, compile the app. @@ -758,6 +767,25 @@ class App(Base): for k, component in self.pages.items(): self.pages[k] = self._add_overlay_to_component(component) + def _add_error_boundary_to_component(self, component: Component) -> Component: + if self.error_boundary is None: + return component + + component = self.error_boundary(*component.children) + + return component + + def _setup_error_boundary(self): + """If a State is not used and no error_boundary is specified, do not render the error boundary.""" + if self.state is None and self.error_boundary is default_error_boundary: + self.error_boundary = None + + for k, component in self.pages.items(): + # Skip the 404 page + if k == constants.Page404.SLUG: + continue + self.pages[k] = self._add_error_boundary_to_component(component) + def _apply_decorated_pages(self): """Add @rx.page decorated pages to the app. @@ -771,6 +799,36 @@ class App(Base): for render, kwargs in DECORATED_PAGES[get_config().app_name]: self.add_page(render, **kwargs) + def _validate_var_dependencies( + self, state: Optional[Type[BaseState]] = None + ) -> None: + """Validate the dependencies of the vars in the app. + + Args: + state: The state to validate the dependencies for. + + Raises: + VarDependencyError: When a computed var has an invalid dependency. + """ + if not self.state: + return + + if not state: + state = self.state + + for var in state.computed_vars.values(): + if not var._cache: + continue + deps = var._deps(objclass=state) + for dep in deps: + if dep not in state.vars and dep not in state.backend_vars: + raise exceptions.VarDependencyError( + f"ComputedVar {var._js_expr} on state {state.__name__} has an invalid dependency {dep}" + ) + + for substate in state.class_subclasses: + self._validate_var_dependencies(substate) + def _compile(self, export: bool = False): """Compile the app and output it to the pages folder. @@ -782,17 +840,42 @@ class App(Base): """ from reflex.utils.exceptions import ReflexRuntimeError + self.pages = {} + + def get_compilation_time() -> str: + return str(datetime.now().time()).split(".")[0] + # Render a default 404 page if the user didn't supply one - if constants.Page404.SLUG not in self.pages: + if constants.Page404.SLUG not in self.unevaluated_pages: self.add_custom_404_page() + # Fix up the style. + self.style = evaluate_style_namespaces(self.style) + + # Add the app wrappers. + app_wrappers: Dict[tuple[int, str], Component] = { + # Default app wrap component renders {children} + (0, "AppWrap"): AppWrap.create() + } + + if self.theme is not None: + # If a theme component was provided, wrap the app with it + app_wrappers[(20, "Theme")] = self.theme + # Fix #2992 by removing the top-level appearance prop + self.theme.appearance = None + + for route in self.unevaluated_pages: + self._compile_page(route) + # Add the optional endpoints (_upload) self._add_optional_endpoints() if not self._should_compile(): return + self._validate_var_dependencies() self._setup_overlay_component() + self._setup_error_boundary() # Create a progress bar. progress = Progress( @@ -806,7 +889,7 @@ class App(Base): fixed_pages_within_executor = 5 progress.start() task = progress.add_task( - "Compiling:", + f"[{get_compilation_time()}] Compiling:", total=len(self.pages) + fixed_pages_within_executor + adhoc_steps_without_executor, @@ -818,28 +901,15 @@ class App(Base): # Store the compile results. compile_results = [] - # Add the app wrappers. - app_wrappers: Dict[tuple[int, str], Component] = { - # Default app wrap component renders {children} - (0, "AppWrap"): AppWrap.create() - } - if self.theme is not None: - # If a theme component was provided, wrap the app with it - app_wrappers[(20, "Theme")] = self.theme - progress.advance(task) - # Fix up the style. - self.style = evaluate_style_namespaces(self.style) - # Track imports and custom components found. all_imports = {} custom_components = set() - for _route, component in self.pages.items(): - # Merge the component style with the app style. - component._add_style_recursive(self.style, self.theme) - + # This has to happen before compiling stateful components as that + # prevents recursive functions from reaching all components. + for component in self.pages.values(): # Add component._get_all_imports() to all_imports. all_imports.update(component._get_all_imports()) @@ -849,8 +919,6 @@ class App(Base): # Add the custom components from the page to the set. custom_components |= component._get_all_custom_components() - progress.advance(task) - # Perform auto-memoization of stateful components. ( stateful_components_path, @@ -868,6 +936,8 @@ class App(Base): ) compile_results.append((stateful_components_path, stateful_components_code)) + progress.advance(task) + # Compile the root document before fork. compile_results.append( compiler.compile_document_root( @@ -877,77 +947,50 @@ class App(Base): ) ) - # Compile the contexts before fork. - compile_results.append( - compiler.compile_contexts(self.state, self.theme), - ) - # Fix #2992 by removing the top-level appearance prop - if self.theme is not None: - self.theme.appearance = None - - app_root = self._app_root(app_wrappers=app_wrappers) - progress.advance(task) - # Prepopulate the global ExecutorSafeFunctions class with input data required by the compile functions. - # This is required for multiprocessing to work, in presence of non-picklable inputs. - for route, component in zip(self.pages, page_components): - ExecutorSafeFunctions.COMPILE_PAGE_ARGS_BY_ROUTE[route] = ( - route, - component, - self.state, - ) - - ExecutorSafeFunctions.COMPILE_APP_APP_ROOT = app_root - ExecutorSafeFunctions.CUSTOM_COMPONENTS = custom_components - ExecutorSafeFunctions.STYLE = self.style - # Use a forking process pool, if possible. Much faster, especially for large sites. # Fallback to ThreadPoolExecutor as something that will always work. executor = None if ( platform.system() in ("Linux", "Darwin") - and os.environ.get("REFLEX_COMPILE_PROCESSES") is not None + and (number_of_processes := environment.REFLEX_COMPILE_PROCESSES) + is not None ): executor = concurrent.futures.ProcessPoolExecutor( - max_workers=int(os.environ.get("REFLEX_COMPILE_PROCESSES", 0)) or None, + max_workers=number_of_processes, mp_context=multiprocessing.get_context("fork"), ) else: executor = concurrent.futures.ThreadPoolExecutor( - max_workers=int(os.environ.get("REFLEX_COMPILE_THREADS", 0)) or None, + max_workers=environment.REFLEX_COMPILE_THREADS ) + for route, component in zip(self.pages, page_components): + ExecutorSafeFunctions.COMPONENTS[route] = component + + ExecutorSafeFunctions.STATE = self.state + with executor: result_futures = [] - custom_components_future = None - - def _mark_complete(_=None): - progress.advance(task) def _submit_work(fn, *args, **kwargs): f = executor.submit(fn, *args, **kwargs) - f.add_done_callback(_mark_complete) + # f = executor.apipe(fn, *args, **kwargs) result_futures.append(f) - # Compile all page components. + # Compile the pre-compiled pages. for route in self.pages: - _submit_work(ExecutorSafeFunctions.compile_page, route) - - # Compile the app wrapper. - _submit_work(ExecutorSafeFunctions.compile_app) - - # Compile the custom components. - custom_components_future = executor.submit( - ExecutorSafeFunctions.compile_custom_components, - ) - custom_components_future.add_done_callback(_mark_complete) + _submit_work( + ExecutorSafeFunctions.compile_page, + route, + ) # Compile the root stylesheet with base styles. _submit_work(compiler.compile_root_stylesheet, self.stylesheets) # Compile the theme. - _submit_work(ExecutorSafeFunctions.compile_theme) + _submit_work(compile_theme, self.style) # Compile the Tailwind config. if config.tailwind is not None: @@ -961,23 +1004,33 @@ class App(Base): # Wait for all compilation tasks to complete. for future in concurrent.futures.as_completed(result_futures): compile_results.append(future.result()) + progress.advance(task) - # Special case for custom_components, since we need the compiled imports - # to install proper frontend packages. - ( - *custom_components_result, - custom_components_imports, - ) = custom_components_future.result() - compile_results.append(custom_components_result) - all_imports.update(custom_components_imports) + app_root = self._app_root(app_wrappers=app_wrappers) # Get imports from AppWrap components. all_imports.update(app_root._get_all_imports()) progress.advance(task) - # Empty the .web pages directory. - compiler.purge_web_pages_dir() + # Compile the contexts. + compile_results.append( + compiler.compile_contexts(self.state, self.theme), + ) + progress.advance(task) + + # Compile the app root. + compile_results.append( + compiler.compile_app(app_root), + ) + progress.advance(task) + + # Compile custom components. + *custom_components_result, custom_components_imports = ( + compiler.compile_components(custom_components) + ) + compile_results.append(custom_components_result) + all_imports.update(custom_components_imports) progress.advance(task) progress.stop() @@ -996,6 +1049,19 @@ class App(Base): transpile_packages=transpile_packages, ) + if is_prod_mode(): + # Empty the .web pages directory. + compiler.purge_web_pages_dir() + else: + # In dev mode, delete removed pages and update existing pages. + keep_files = [Path(output_path) for output_path, _ in compile_results] + for p in Path(prerequisites.get_web_dir() / constants.Dirs.PAGES).rglob( + "*" + ): + if p.is_file() and p not in keep_files: + # Remove pages that are no longer in the app. + p.unlink() + for output_path, code in compile_results: compiler_utils.write_page(output_path, code) @@ -1041,6 +1107,7 @@ class App(Base): Task if the event was backgroundable, otherwise None """ substate, handler = state._get_event_handler(event) + if not handler.is_background: return None @@ -1072,6 +1139,100 @@ class App(Base): task.add_done_callback(self.background_tasks.discard) return task + def _validate_exception_handlers(self): + """Validate the custom event exception handlers for front- and backend. + + Raises: + ValueError: If the custom exception handlers are invalid. + + """ + FRONTEND_ARG_SPEC = { + "exception": Exception, + } + + BACKEND_ARG_SPEC = { + "exception": Exception, + } + + for handler_domain, handler_fn, handler_spec in zip( + ["frontend", "backend"], + [self.frontend_exception_handler, self.backend_exception_handler], + [ + FRONTEND_ARG_SPEC, + BACKEND_ARG_SPEC, + ], + ): + if hasattr(handler_fn, "__name__"): + _fn_name = handler_fn.__name__ + else: + _fn_name = handler_fn.__class__.__name__ + + if isinstance(handler_fn, functools.partial): + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` is a partial function. Please provide a named function instead." + ) + + if not callable(handler_fn): + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` is not a function." + ) + + # Allow named functions only as lambda functions cannot be introspected + if _fn_name == "": + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` is a lambda function. Please use a named function instead." + ) + + # Check if the function has the necessary annotations and types in the right order + argspec = inspect.getfullargspec(handler_fn) + arg_annotations = { + k: eval(v) if isinstance(v, str) else v + for k, v in argspec.annotations.items() + if k not in ["args", "kwargs", "return"] + } + + for required_arg_index, required_arg in enumerate(handler_spec): + if required_arg not in arg_annotations: + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` does not take the required argument `{required_arg}`" + ) + elif ( + not list(arg_annotations.keys())[required_arg_index] == required_arg + ): + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong argument order." + f"Expected `{required_arg}` as the {required_arg_index+1} argument but got `{list(arg_annotations.keys())[required_arg_index]}`" + ) + + if not issubclass(arg_annotations[required_arg], Exception): + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong type for {required_arg} argument." + f"Expected to be `Exception` but got `{arg_annotations[required_arg]}`" + ) + + # Check if the return type is valid for backend exception handler + if handler_domain == "backend": + sig = inspect.signature(self.backend_exception_handler) + return_type = ( + eval(sig.return_annotation) + if isinstance(sig.return_annotation, str) + else sig.return_annotation + ) + + valid = bool( + return_type == EventSpec + or return_type == Optional[EventSpec] + or return_type == List[EventSpec] + or return_type == inspect.Signature.empty + or return_type is None + ) + + if not valid: + raise ValueError( + f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong return type." + f"Expected `Union[EventSpec, List[EventSpec], None]` but got `{return_type}`" + ) + async def process( app: App, event: Event, sid: str, headers: Dict, client_ip: str @@ -1086,13 +1247,12 @@ async def process( client_ip: The client_ip. Raises: - ReflexError: If a reflex specific error occurs during processing the event. + Exception: If a reflex specific error occurs during processing the event. Yields: The state updates after processing the event. """ from reflex.utils import telemetry - from reflex.utils.exceptions import ReflexError try: # Add request data to the state. @@ -1136,8 +1296,10 @@ async def process( # Yield the update. yield update - except ReflexError as ex: - telemetry.send("error", context="backend", detail=str(ex)) + except Exception as ex: + telemetry.send_error(ex, context="backend") + + app.backend_exception_handler(ex) raise @@ -1150,6 +1312,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. @@ -1204,7 +1398,7 @@ def upload(app: App): if isinstance(func, EventHandler): if func.is_background: raise UploadTypeError( - f"@rx.background is not supported for upload handler `{handler}`.", + f"@rx.event(background=True) is not supported for upload handler `{handler}`.", ) func = func.fn if isinstance(func, functools.partial): @@ -1276,6 +1470,12 @@ class EventNamespace(AsyncNamespace): # The application object. app: App + # Keep a mapping between socket ID and client token. + token_to_sid: dict[str, str] = {} + + # Keep a mapping between client token and socket ID. + sid_to_token: dict[str, str] = {} + def __init__(self, namespace: str, app: App): """Initialize the event namespace. @@ -1301,7 +1501,9 @@ class EventNamespace(AsyncNamespace): Args: sid: The Socket.IO session id. """ - pass + disconnect_token = self.sid_to_token.pop(sid, None) + if disconnect_token: + self.token_to_sid.pop(disconnect_token, None) async def emit_update(self, update: StateUpdate, sid: str) -> None: """Emit an update to the client. @@ -1318,17 +1520,28 @@ class EventNamespace(AsyncNamespace): async def on_event(self, sid, data): """Event for receiving front-end websocket events. + Raises: + RuntimeError: If the Socket.IO is badly initialized. + Args: 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 not in ("handler", "event_actions")} + ) + + self.token_to_sid[event.token] = sid + self.sid_to_token[sid] = event.token # Get the event environment. - assert self.app.sio is not None + if self.app.sio is None: + raise RuntimeError("Socket.IO is not initialized.") environ = self.app.sio.get_environ(sid, self.namespace) - assert environ is not None + if environ is None: + raise RuntimeError("Socket.IO environ is not initialized.") # Get the client headers. headers = { diff --git a/reflex/app_mixins/__init__.py b/reflex/app_mixins/__init__.py new file mode 100644 index 000000000..86c0aa2bd --- /dev/null +++ b/reflex/app_mixins/__init__.py @@ -0,0 +1,5 @@ +"""Reflex AppMixins package.""" + +from .lifespan import LifespanMixin +from .middleware import MiddlewareMixin +from .mixin import AppMixin diff --git a/reflex/app_mixins/lifespan.py b/reflex/app_mixins/lifespan.py new file mode 100644 index 000000000..52bf0be1d --- /dev/null +++ b/reflex/app_mixins/lifespan.py @@ -0,0 +1,79 @@ +"""Mixin that allow tasks to run during the whole app lifespan.""" + +from __future__ import annotations + +import asyncio +import contextlib +import dataclasses +import functools +import inspect +from typing import Callable, Coroutine, Set, Union + +from fastapi import FastAPI + +from reflex.utils import console +from reflex.utils.exceptions import InvalidLifespanTaskType + +from .mixin import AppMixin + + +@dataclasses.dataclass +class LifespanMixin(AppMixin): + """A Mixin that allow tasks to run during the whole app lifespan.""" + + # Lifespan tasks that are planned to run. + lifespan_tasks: Set[Union[asyncio.Task, Callable]] = dataclasses.field( + default_factory=set + ) + + @contextlib.asynccontextmanager + async def _run_lifespan_tasks(self, app: FastAPI): + running_tasks = [] + try: + async with contextlib.AsyncExitStack() as stack: + for task in self.lifespan_tasks: + run_msg = f"Started lifespan task: {task.__name__} as {{type}}" # type: ignore + if isinstance(task, asyncio.Task): + running_tasks.append(task) + else: + signature = inspect.signature(task) + if "app" in signature.parameters: + task = functools.partial(task, app=app) + _t = task() + if isinstance(_t, contextlib._AsyncGeneratorContextManager): + await stack.enter_async_context(_t) + console.debug(run_msg.format(type="asynccontextmanager")) + elif isinstance(_t, Coroutine): + task_ = asyncio.create_task(_t) + task_.add_done_callback(lambda t: t.result()) + running_tasks.append(task_) + console.debug(run_msg.format(type="coroutine")) + else: + console.debug(run_msg.format(type="function")) + yield + finally: + for task in running_tasks: + console.debug(f"Canceling lifespan task: {task}") + task.cancel(msg="lifespan_cleanup") + + def register_lifespan_task(self, task: Callable | asyncio.Task, **task_kwargs): + """Register a task to run during the lifespan of the app. + + Args: + task: The task to register. + task_kwargs: The kwargs of the task. + + Raises: + InvalidLifespanTaskType: If the task is a generator function. + """ + if inspect.isgeneratorfunction(task) or inspect.isasyncgenfunction(task): + raise InvalidLifespanTaskType( + f"Task {task.__name__} of type generator must be decorated with contextlib.asynccontextmanager." + ) + + if task_kwargs: + original_task = task + task = functools.partial(task, **task_kwargs) # type: ignore + functools.update_wrapper(task, original_task) # type: ignore + self.lifespan_tasks.add(task) # type: ignore + console.debug(f"Registered lifespan task: {task.__name__}") # type: ignore diff --git a/reflex/app_mixins/middleware.py b/reflex/app_mixins/middleware.py new file mode 100644 index 000000000..30593d9ae --- /dev/null +++ b/reflex/app_mixins/middleware.py @@ -0,0 +1,95 @@ +"""Middleware Mixin that allow to add middleware to the app.""" + +from __future__ import annotations + +import asyncio +import dataclasses +from typing import List + +from reflex.event import Event +from reflex.middleware import HydrateMiddleware, Middleware +from reflex.state import BaseState, StateUpdate + +from .mixin import AppMixin + + +@dataclasses.dataclass +class MiddlewareMixin(AppMixin): + """Middleware Mixin that allow to add middleware to the app.""" + + # Middleware to add to the app. Users should use `add_middleware`. PRIVATE. + middleware: List[Middleware] = dataclasses.field(default_factory=list) + + def _init_mixin(self): + self.middleware.append(HydrateMiddleware()) + + def add_middleware(self, middleware: Middleware, index: int | None = None): + """Add middleware to the app. + + Args: + middleware: The middleware to add. + index: The index to add the middleware at. + """ + if index is None: + self.middleware.append(middleware) + else: + self.middleware.insert(index, middleware) + + async def _preprocess(self, state: BaseState, event: Event) -> StateUpdate | None: + """Preprocess the event. + + This is where middleware can modify the event before it is processed. + Each middleware is called in the order it was added to the app. + + If a middleware returns an update, the event is not processed and the + update is returned. + + Args: + state: The state to preprocess. + event: The event to preprocess. + + Returns: + An optional state to return. + """ + for middleware in self.middleware: + if asyncio.iscoroutinefunction(middleware.preprocess): + out = await middleware.preprocess(app=self, state=state, event=event) # type: ignore + else: + out = middleware.preprocess(app=self, state=state, event=event) # type: ignore + if out is not None: + return out # type: ignore + + async def _postprocess( + self, state: BaseState, event: Event, update: StateUpdate + ) -> StateUpdate: + """Postprocess the event. + + This is where middleware can modify the delta after it is processed. + Each middleware is called in the order it was added to the app. + + Args: + state: The state to postprocess. + event: The event to postprocess. + update: The current state update. + + Returns: + The state update to return. + """ + for middleware in self.middleware: + if asyncio.iscoroutinefunction(middleware.postprocess): + out = await middleware.postprocess( + app=self, # type: ignore + state=state, + event=event, + update=update, + ) + else: + out = middleware.postprocess( + app=self, # type: ignore + state=state, + event=event, + update=update, + ) + if out is not None: + return out # type: ignore + return update diff --git a/reflex/app_mixins/mixin.py b/reflex/app_mixins/mixin.py new file mode 100644 index 000000000..23207a462 --- /dev/null +++ b/reflex/app_mixins/mixin.py @@ -0,0 +1,15 @@ +"""Default mixin for all app mixins.""" + +import dataclasses + + +@dataclasses.dataclass +class AppMixin: + """Define the base class for all app mixins.""" + + def _init_mixin(self): + """Initialize the mixin. + + Any App mixin can override this method to perform any initialization. + """ + ... diff --git a/reflex/app_module_for_backend.py b/reflex/app_module_for_backend.py index 8d97725f9..8109fc3d6 100644 --- a/reflex/app_module_for_backend.py +++ b/reflex/app_module_for_backend.py @@ -1,18 +1,21 @@ """Shims the real reflex app module for running backend server (uvicorn or gunicorn). Only the app attribute is explicitly exposed. """ + from concurrent.futures import ThreadPoolExecutor from reflex import constants +from reflex.utils import telemetry from reflex.utils.exec import is_prod_mode from reflex.utils.prerequisites import get_app -if "app" != constants.CompileVars.APP: +if constants.CompileVars.APP != "app": raise AssertionError("unexpected variable name for 'app'") +telemetry.send("compile") app_module = get_app(reload=False) app = getattr(app_module, constants.CompileVars.APP) -# For py3.8 and py3.9 compatibility when redis is used, we MUST add any decorator pages +# For py3.9 compatibility when redis is used, we MUST add any decorator pages # before compiling the app in a thread to avoid event loop error (REF-2172). app._apply_decorated_pages() compile_future = ThreadPoolExecutor(max_workers=1).submit(app._compile) @@ -29,5 +32,6 @@ del app_module del compile_future del get_app del is_prod_mode +del telemetry del constants del ThreadPoolExecutor diff --git a/reflex/base.py b/reflex/base.py index d15a7bedc..c334ddf56 100644 --- a/reflex/base.py +++ b/reflex/base.py @@ -6,12 +6,12 @@ import os from typing import TYPE_CHECKING, Any, List, Type try: - import pydantic.v1 as pydantic + import pydantic.v1.main as pydantic_main from pydantic.v1 import BaseModel from pydantic.v1.fields import ModelField except ModuleNotFoundError: if not TYPE_CHECKING: - import pydantic + import pydantic.main as pydantic_main from pydantic import BaseModel from pydantic.fields import ModelField # type: ignore @@ -45,10 +45,13 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None # monkeypatch pydantic validate_field_name method to skip validating # shadowed state vars when reloading app via utils.prerequisites.get_app(reload=True) -pydantic.main.validate_field_name = validate_field_name # type: ignore +pydantic_main.validate_field_name = validate_field_name # type: ignore + +if TYPE_CHECKING: + from reflex.vars import Var -class Base(pydantic.BaseModel): # pyright: ignore [reportUnboundVariable] +class Base(BaseModel): # pyright: ignore [reportUnboundVariable] """The base class subclassed by all Reflex classes. This class wraps Pydantic and provides common methods such as @@ -92,7 +95,7 @@ class Base(pydantic.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(pydantic.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,14 +113,15 @@ class Base(pydantic.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_field_name new_field = ModelField.infer( - name=var._var_name, + name=var_name, value=default_value, annotation=var._var_type, class_validators=None, config=cls.__config__, # type: ignore ) - cls.__fields__.update({var._var_name: new_field}) + cls.__fields__.update({var_name: new_field}) def get_value(self, key: str) -> Any: """Get the value of a field. @@ -132,13 +136,4 @@ class Base(pydantic.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 3f4f9a4be..e9d56b7e7 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -2,12 +2,13 @@ from __future__ import annotations -import os +from datetime import datetime from pathlib import Path -from typing import Dict, Iterable, Optional, Type, Union +from typing import TYPE_CHECKING, Dict, Iterable, Optional, Tuple, Type, Union from reflex import constants from reflex.compiler import templates, utils +from reflex.components.base.fragment import Fragment from reflex.components.component import ( BaseComponent, Component, @@ -15,12 +16,13 @@ from reflex.components.component import ( CustomComponent, StatefulComponent, ) -from reflex.config import get_config +from reflex.config import environment, get_config from reflex.state import BaseState -from reflex.style import LIGHT_COLOR_MODE +from reflex.style import SYSTEM_COLOR_MODE from reflex.utils.exec import is_prod_mode from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.utils.prerequisites import get_web_dir +from reflex.vars.base import LiteralVar, Var def _compile_document_root(root: Component) -> str: @@ -38,6 +40,20 @@ def _compile_document_root(root: Component) -> str: ) +def _normalize_library_name(lib: str) -> str: + """Normalize the library name. + + Args: + lib: The library name to normalize. + + Returns: + The normalized library name. + """ + if lib == "react": + return "React" + return lib.replace("@", "").replace("/", "_").replace("-", "_") + + def _compile_app(app_root: Component) -> str: """Compile the app template component. @@ -47,15 +63,25 @@ def _compile_app(app_root: Component) -> str: Returns: The compiled app. """ + from reflex.components.dynamic import bundled_libraries + + window_libraries = [ + (_normalize_library_name(name), name) for name in bundled_libraries + ] + [ + ("utils_context", f"$/{constants.Dirs.UTILS}/context"), + ("utils_state", f"$/{constants.Dirs.UTILS}/state"), + ] + return templates.APP_ROOT.render( imports=utils.compile_imports(app_root._get_all_imports()), custom_codes=app_root._get_all_custom_code(), hooks={**app_root._get_all_hooks_internal(), **app_root._get_all_hooks()}, + window_libraries=window_libraries, render=app_root.render(), ) -def _compile_theme(theme: dict) -> str: +def _compile_theme(theme: str) -> str: """Compile the theme. Args: @@ -78,27 +104,31 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None) The compiled context file. """ appearance = getattr(theme, "appearance", None) - if appearance is None: - appearance = LIGHT_COLOR_MODE + if appearance is None or str(LiteralVar.create(appearance)) == '"inherit"': + appearance = LiteralVar.create(SYSTEM_COLOR_MODE) + + last_compiled_time = str(datetime.now()) return ( templates.CONTEXT.render( initial_state=utils.compile_state(state), state_name=state.get_name(), client_storage=utils.compile_client_storage(state), is_dev_mode=not is_prod_mode(), + last_compiled_time=last_compiled_time, default_color_mode=appearance, ) if state else templates.CONTEXT.render( is_dev_mode=not is_prod_mode(), default_color_mode=appearance, + last_compiled_time=last_compiled_time, ) ) def _compile_page( - component: Component, - state: Type[BaseState], + component: BaseComponent, + state: Type[BaseState] | None, ) -> str: """Compile the component given the app state. @@ -113,7 +143,7 @@ def _compile_page( imports = utils.compile_imports(imports) # Compile the code to render the component. - kwargs = {"state_name": state.get_name()} if state else {} + kwargs = {"state_name": state.get_name()} if state is not None else {} return templates.PAGE.render( imports=imports, @@ -165,11 +195,11 @@ def _compile_root_stylesheet(stylesheets: list[str]) -> str: stylesheet_full_path = ( Path.cwd() / constants.Dirs.APP_ASSETS / stylesheet.strip("/") ) - if not os.path.exists(stylesheet_full_path): + if not stylesheet_full_path.exists(): raise FileNotFoundError( f"The stylesheet file {stylesheet_full_path} does not exist." ) - stylesheet = f"@/{stylesheet.strip('/')}" + stylesheet = f"../{constants.Dirs.PUBLIC}/{stylesheet.strip('/')}" sheets.append(stylesheet) if stylesheet not in sheets else None return templates.STYLE.render(stylesheets=sheets) @@ -199,7 +229,7 @@ def _compile_components( """ imports = { "react": [ImportVar(tag="memo")], - f"/{constants.Dirs.STATE_PATH}": [ImportVar(tag="E"), ImportVar(tag="isTrue")], + f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="E"), ImportVar(tag="isTrue")], } component_renders = [] @@ -286,7 +316,7 @@ def _compile_stateful_components( # Don't import from the file that we're about to create. all_imports = utils.merge_imports(*all_import_dicts) all_imports.pop( - f"/{constants.Dirs.UTILS}/{constants.PageNames.STATEFUL_COMPONENTS}", None + f"$/{constants.Dirs.UTILS}/{constants.PageNames.STATEFUL_COMPONENTS}", None ) return templates.STATEFUL_COMPONENTS.render( @@ -371,7 +401,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 @@ -395,7 +425,7 @@ def compile_contexts( def compile_page( - path: str, component: Component, state: Type[BaseState] + path: str, component: BaseComponent, state: Type[BaseState] | None ) -> tuple[str, str]: """Compile a single page. @@ -469,7 +499,7 @@ def compile_tailwind( The compiled Tailwind config. """ # Get the path for the output file. - output_path = constants.Tailwind.CONFIG + output_path = get_web_dir() / constants.Tailwind.CONFIG # Compile the config. code = _compile_tailwind(config) @@ -483,7 +513,7 @@ def remove_tailwind_from_postcss() -> tuple[str, str]: The path and code of the compiled postcss.config.js. """ # Get the path for the output file. - output_path = constants.Dirs.POSTCSS_JS + output_path = str(get_web_dir() / constants.Dirs.POSTCSS_JS) code = [ line @@ -497,12 +527,87 @@ def remove_tailwind_from_postcss() -> tuple[str, str]: def purge_web_pages_dir(): """Empty out .web/pages directory.""" - if not is_prod_mode() and os.environ.get("REFLEX_PERSIST_WEB_DIR"): + if not is_prod_mode() and environment.REFLEX_PERSIST_WEB_DIR: # Skip purging the web directory in dev mode if REFLEX_PERSIST_WEB_DIR is set. return # Empty out the web pages directory. - utils.empty_dir(constants.Dirs.WEB_PAGES, keep_files=["_app.js"]) + utils.empty_dir(get_web_dir() / constants.Dirs.PAGES, keep_files=["_app.js"]) + + +if TYPE_CHECKING: + from reflex.app import UnevaluatedPage + + +def compile_unevaluated_page( + route: str, + page: UnevaluatedPage, + state: Type[BaseState] | None = None, + style: ComponentStyle | None = None, + theme: Component | None = None, +) -> Tuple[Component, bool]: + """Compiles an uncompiled page into a component and adds meta information. + + Args: + route: The route of the page. + page: The uncompiled page object. + state: The state of the app. + style: The style of the page. + theme: The theme of the page. + + Returns: + The compiled component and whether state should be enabled. + """ + # Generate the component if it is a callable. + component = page.component + component = component if isinstance(component, Component) else component() + + # unpack components that return tuples in an rx.fragment. + if isinstance(component, tuple): + component = Fragment.create(*component) + + component._add_style_recursive(style or {}, theme) + + enable_state = False + # Ensure state is enabled if this page uses state. + if state is None: + if page.on_load or component._has_stateful_event_triggers(): + enable_state = True + else: + for var in component._get_vars(include_children=True): + var_data = var._get_all_var_data() + if not var_data: + continue + if not var_data.state: + continue + enable_state = True + break + + from reflex.app import OverlayFragment + from reflex.utils.format import make_default_page_title + + component = OverlayFragment.create(component) + + meta_args = { + "title": ( + page.title + if page.title is not None + else make_default_page_title(get_config().app_name, route) + ), + "image": page.image, + "meta": page.meta, + } + + if page.description is not None: + meta_args["description"] = page.description + + # Add meta information to the component. + utils.add_meta( + component, + **meta_args, + ) + + return component, enable_state class ExecutorSafeFunctions: @@ -530,13 +635,12 @@ class ExecutorSafeFunctions: """ - COMPILE_PAGE_ARGS_BY_ROUTE = {} - COMPILE_APP_APP_ROOT: Component | None = None - CUSTOM_COMPONENTS: set[CustomComponent] | None = None - STYLE: ComponentStyle | None = None + COMPONENTS: Dict[str, BaseComponent] = {} + UNCOMPILED_PAGES: Dict[str, UnevaluatedPage] = {} + STATE: Optional[Type[BaseState]] = None @classmethod - def compile_page(cls, route: str): + def compile_page(cls, route: str) -> tuple[str, str]: """Compile a page. Args: @@ -545,46 +649,45 @@ class ExecutorSafeFunctions: Returns: The path and code of the compiled page. """ - return compile_page(*cls.COMPILE_PAGE_ARGS_BY_ROUTE[route]) + return compile_page(route, cls.COMPONENTS[route], cls.STATE) @classmethod - def compile_app(cls): - """Compile the app. + def compile_unevaluated_page( + cls, + route: str, + style: ComponentStyle, + theme: Component | None, + ) -> tuple[str, Component, tuple[str, str]]: + """Compile an unevaluated page. + + Args: + route: The route of the page to compile. + style: The style of the page. + theme: The theme of the page. Returns: - The path and code of the compiled app. - - Raises: - ValueError: If the app root is not set. + The route, compiled component, and compiled page. """ - if cls.COMPILE_APP_APP_ROOT is None: - raise ValueError("COMPILE_APP_APP_ROOT should be set") - return compile_app(cls.COMPILE_APP_APP_ROOT) + component, enable_state = compile_unevaluated_page( + route, cls.UNCOMPILED_PAGES[route] + ) + component = component if isinstance(component, Component) else component() + component._add_style_recursive(style, theme) + return route, component, compile_page(route, component, cls.STATE) @classmethod - def compile_custom_components(cls): - """Compile the custom components. - - Returns: - The path and code of the compiled custom components. - - Raises: - ValueError: If the custom components are not set. - """ - if cls.CUSTOM_COMPONENTS is None: - raise ValueError("CUSTOM_COMPONENTS should be set") - return compile_components(cls.CUSTOM_COMPONENTS) - - @classmethod - def compile_theme(cls): + def compile_theme(cls, style: ComponentStyle | None) -> tuple[str, str]: """Compile the theme. + Args: + style: The style to compile. + Returns: The path and code of the compiled theme. Raises: ValueError: If the style is not set. """ - if cls.STYLE is None: + if style is None: raise ValueError("STYLE should be set") - return compile_theme(cls.STYLE) + return compile_theme(style) diff --git a/reflex/compiler/templates.py b/reflex/compiler/templates.py index eb2a3d6fa..c868a0cbb 100644 --- a/reflex/compiler/templates.py +++ b/reflex/compiler/templates.py @@ -37,11 +37,14 @@ class ReflexJinjaEnvironment(Environment): constants.CompileVars.PROCESSING: False, }, "color_mode": constants.ColorMode.NAME, + "resolved_color_mode": constants.ColorMode.RESOLVED_NAME, "toggle_color_mode": constants.ColorMode.TOGGLE, + "set_color_mode": constants.ColorMode.SET, "use_color_mode": constants.ColorMode.USE, "hydrate": constants.CompileVars.HYDRATE, "on_load_internal": constants.CompileVars.ON_LOAD_INTERNAL, "update_vars_internal": constants.CompileVars.UPDATE_VARS_INTERNAL, + "frontend_exception_state": constants.CompileVars.FRONTEND_EXCEPTION_STATE_FULL, } diff --git a/reflex/compiler/utils.py b/reflex/compiler/utils.py index 9f389d811..29398da87 100644 --- a/reflex/compiler/utils.py +++ b/reflex/compiler/utils.py @@ -2,10 +2,13 @@ from __future__ import annotations -import os +from pathlib import Path 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 except ModuleNotFoundError: @@ -25,21 +28,25 @@ from reflex.components.base import ( Title, ) from reflex.components.component import Component, ComponentStyle, CustomComponent -from reflex.state import BaseState, Cookie, LocalStorage +from reflex.istate.storage import Cookie, LocalStorage, SessionStorage +from reflex.state import BaseState from reflex.style import Style from reflex.utils import console, format, imports, path_ops -from reflex.vars import Var +from reflex.utils.imports import ImportVar, ParsedImportDict # To re-export this function. merge_imports = imports.merge_imports -def compile_import_statement(fields: list[imports.ImportVar]) -> tuple[str, list[str]]: +def compile_import_statement(fields: list[ImportVar]) -> tuple[str, list[str]]: """Compile an import statement. Args: fields: The set of fields to import from the library. + Raises: + ValueError: If there is more than one default import. + Returns: The libraries for default and rest. default: default library. When install "import def from library". @@ -50,7 +57,8 @@ def compile_import_statement(fields: list[imports.ImportVar]) -> tuple[str, list # Check for default imports. defaults = {field for field in fields_set if field.is_default} - assert len(defaults) < 2 + if len(defaults) >= 2: + raise ValueError("Only one default import is allowed.") # Get the default import, and the specific imports. default = next(iter({field.name for field in defaults}), "") @@ -59,7 +67,7 @@ def compile_import_statement(fields: list[imports.ImportVar]) -> tuple[str, list return default, list(rest) -def validate_imports(import_dict: imports.ImportDict): +def validate_imports(import_dict: ParsedImportDict): """Verify that the same Tag is not used in multiple import. Args: @@ -75,6 +83,12 @@ def validate_imports(import_dict: imports.ImportDict): f"{_import.tag}/{_import.alias}" if _import.alias else _import.tag ) if import_name in used_tags: + already_imported = used_tags[import_name] + if (already_imported[0] == "$" and already_imported[1:] == lib) or ( + lib[0] == "$" and lib[1:] == already_imported + ): + used_tags[import_name] = lib if lib[0] == "$" else already_imported + continue raise ValueError( f"Can not compile, the tag {import_name} is used multiple time from {lib} and {used_tags[import_name]}" ) @@ -82,16 +96,19 @@ def validate_imports(import_dict: imports.ImportDict): used_tags[import_name] = lib -def compile_imports(import_dict: imports.ImportDict) -> list[dict]: +def compile_imports(import_dict: ParsedImportDict) -> list[dict]: """Compile an import dict. Args: import_dict: The import dict to compile. + Raises: + ValueError: If an import in the dict is invalid. + Returns: The list of import dict. """ - collapsed_import_dict = imports.collapse_imports(import_dict) + collapsed_import_dict: ParsedImportDict = imports.collapse_imports(import_dict) validate_imports(collapsed_import_dict) import_dicts = [] for lib, fields in collapsed_import_dict.items(): @@ -102,8 +119,10 @@ def compile_imports(import_dict: imports.ImportDict) -> list[dict]: continue if not lib: - assert not default, "No default field allowed for empty library." - assert rest is not None and len(rest) > 0, "No fields to import." + if default: + raise ValueError("No default field allowed for empty library.") + if rest is None or len(rest) == 0: + raise ValueError("No fields to import.") for module in sorted(rest): import_dicts.append(get_import_dict(module)) continue @@ -148,14 +167,19 @@ 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) - return format.format_state(initial_state) + initial_state = state(_reflex_internal_init=True).dict( + initial=True, include_computed=False + ) + return initial_state def _compile_client_storage_field( field: ModelField, -) -> tuple[Type[Cookie] | Type[LocalStorage] | None, dict[str, Any] | None]: - """Compile the given cookie or local_storage field. +) -> tuple[ + Type[Cookie] | Type[LocalStorage] | Type[SessionStorage] | None, + dict[str, Any] | None, +]: + """Compile the given cookie, local_storage or session_storage field. Args: field: The possible cookie field to compile. @@ -163,7 +187,7 @@ def _compile_client_storage_field( Returns: A dictionary of the compiled cookie or None if the field is not cookie-like. """ - for field_type in (Cookie, LocalStorage): + for field_type in (Cookie, LocalStorage, SessionStorage): if isinstance(field.default, field_type): cs_obj = field.default elif isinstance(field.type_, type) and issubclass(field.type_, field_type): @@ -176,7 +200,7 @@ def _compile_client_storage_field( def _compile_client_storage_recursive( state: Type[BaseState], -) -> tuple[dict[str, dict], dict[str, dict[str, str]]]: +) -> tuple[dict[str, dict], dict[str, dict], dict[str, dict]]: """Compile the client-side storage for the given state recursively. Args: @@ -187,10 +211,12 @@ def _compile_client_storage_recursive( ( cookies: dict[str, dict], local_storage: dict[str, dict[str, str]] - ) + session_storage: dict[str, dict[str, str]] + ). """ cookies = {} local_storage = {} + session_storage = {} state_name = state.get_full_name() for name, field in state.__fields__.items(): if name in state.inherited_vars: @@ -202,15 +228,20 @@ def _compile_client_storage_recursive( cookies[state_key] = options elif field_type is LocalStorage: local_storage[state_key] = options + elif field_type is SessionStorage: + session_storage[state_key] = options else: continue for substate in state.get_substates(): - substate_cookies, substate_local_storage = _compile_client_storage_recursive( - substate - ) + ( + substate_cookies, + substate_local_storage, + substate_session_storage, + ) = _compile_client_storage_recursive(substate) cookies.update(substate_cookies) local_storage.update(substate_local_storage) - return cookies, local_storage + session_storage.update(substate_session_storage) + return cookies, local_storage, session_storage def compile_client_storage(state: Type[BaseState]) -> dict[str, dict]: @@ -222,16 +253,17 @@ def compile_client_storage(state: Type[BaseState]) -> dict[str, dict]: Returns: A dictionary of the compiled client-side storage info. """ - cookies, local_storage = _compile_client_storage_recursive(state) + cookies, local_storage, session_storage = _compile_client_storage_recursive(state) return { constants.COOKIES: cookies, constants.LOCAL_STORAGE: local_storage, + constants.SESSION_STORAGE: session_storage, } def compile_custom_component( component: CustomComponent, -) -> tuple[dict, imports.ImportDict]: +) -> tuple[dict, ParsedImportDict]: """Compile a custom component. Args: @@ -244,14 +276,14 @@ def compile_custom_component( render = component.get_component(component) # Get the imports. - imports = { + imports: ParsedImportDict = { lib: fields for lib, fields in render._get_all_imports().items() if lib != component.library } # 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 ( @@ -329,7 +361,7 @@ def get_page_path(path: str) -> str: Returns: The path of the compiled JS file. """ - return os.path.join(constants.Dirs.WEB_PAGES, path + constants.Ext.JS) + return str(get_web_dir() / constants.Dirs.PAGES / (path + constants.Ext.JS)) def get_theme_path() -> str: @@ -338,8 +370,10 @@ def get_theme_path() -> str: Returns: The path of the theme style. """ - return os.path.join( - constants.Dirs.WEB_UTILS, constants.PageNames.THEME + constants.Ext.JS + return str( + get_web_dir() + / constants.Dirs.UTILS + / (constants.PageNames.THEME + constants.Ext.JS) ) @@ -349,8 +383,10 @@ def get_root_stylesheet_path() -> str: Returns: The path of the app root file. """ - return os.path.join( - constants.STYLES_DIR, constants.PageNames.STYLESHEET_ROOT + constants.Ext.CSS + return str( + get_web_dir() + / constants.Dirs.STYLES + / (constants.PageNames.STYLESHEET_ROOT + constants.Ext.CSS) ) @@ -360,9 +396,7 @@ def get_context_path() -> str: Returns: The path of the context module. """ - return os.path.join( - constants.Dirs.WEB, constants.Dirs.CONTEXTS_PATH + constants.Ext.JS - ) + return str(get_web_dir() / (constants.Dirs.CONTEXTS_PATH + constants.Ext.JS)) def get_components_path() -> str: @@ -371,7 +405,11 @@ def get_components_path() -> str: Returns: The path of the compiled components. """ - return os.path.join(constants.Dirs.WEB_UTILS, "components" + constants.Ext.JS) + return str( + get_web_dir() + / constants.Dirs.UTILS + / (constants.PageNames.COMPONENTS + constants.Ext.JS), + ) def get_stateful_components_path() -> str: @@ -380,9 +418,10 @@ def get_stateful_components_path() -> str: Returns: The path of the compiled stateful components. """ - return os.path.join( - constants.Dirs.WEB_UTILS, - constants.PageNames.STATEFUL_COMPONENTS + constants.Ext.JS, + return str( + get_web_dir() + / constants.Dirs.UTILS + / (constants.PageNames.STATEFUL_COMPONENTS + constants.Ext.JS) ) @@ -405,11 +444,11 @@ def add_meta( Returns: The component with the metadata added. """ - meta_tags = [Meta.create(**item) for item in meta] - - children: list[Any] = [ - Title.create(title), + meta_tags = [ + item if isinstance(item, Component) else Meta.create(**item) for item in meta ] + + children: list[Any] = [Title.create(title)] if description: children.append(Description.create(content=description)) children.append(Image.create(content=image)) @@ -424,35 +463,36 @@ def add_meta( return page -def write_page(path: str, code: str): +def write_page(path: str | Path, code: str): """Write the given code to the given path. Args: path: The path to write the code to. code: The code to write. """ - path_ops.mkdir(os.path.dirname(path)) - with open(path, "w", encoding="utf-8") as f: - f.write(code) + path = Path(path) + path_ops.mkdir(path.parent) + path.write_text(code, encoding="utf-8") -def empty_dir(path: str, keep_files: list[str] | None = None): +def empty_dir(path: str | Path, keep_files: list[str] | None = None): """Remove all files and folders in a directory except for the keep_files. Args: path: The path to the directory that will be emptied keep_files: List of filenames or foldernames that will not be deleted. """ + path = Path(path) + # If the directory does not exist, return. - if not os.path.exists(path): + if not path.exists(): return # Remove all files and folders in the directory. keep_files = keep_files or [] - directory_contents = os.listdir(path) - for element in directory_contents: - if element not in keep_files: - path_ops.rm(os.path.join(path, element)) + for element in path.iterdir(): + if element.name not in keep_files: + path_ops.rm(element) def is_valid_url(url) -> bool: diff --git a/reflex/components/__init__.py b/reflex/components/__init__.py index a5a7fa5d0..250df4e71 100644 --- a/reflex/components/__init__.py +++ b/reflex/components/__init__.py @@ -1,21 +1,35 @@ """Import all the components.""" + from __future__ import annotations -from . import lucide -from .base import Fragment, Script, fragment, script -from .component import Component -from .component import NoSSRComponent as NoSSRComponent -from .core import * -from .datadisplay import * -from .el import img as image -from .gridjs import * -from .markdown import * -from .moment import * -from .next import NextLink, next_link -from .plotly import * -from .radix import * -from .react_player import * -from .sonner import * -from .suneditor import * +from reflex.utils import lazy_loader -icon = lucide.icon +_SUBMODULES: set[str] = { + "lucide", + "core", + "datadisplay", + "gridjs", + "markdown", + "moment", + "plotly", + "radix", + "react_player", + "sonner", + "suneditor", + "el", + "base", + "recharts", +} + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "component": [ + "Component", + "NoSSRComponent", + ], + "next": ["NextLink", "next_link"], +} +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/__init__.pyi b/reflex/components/__init__.pyi new file mode 100644 index 000000000..781e75eb0 --- /dev/null +++ b/reflex/components/__init__.pyi @@ -0,0 +1,23 @@ +"""Stub file for reflex/components/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import base as base +from . import core as core +from . import datadisplay as datadisplay +from . import el as el +from . import gridjs as gridjs +from . import lucide as lucide +from . import markdown as markdown +from . import moment as moment +from . import plotly as plotly +from . import radix as radix +from . import react_player as react_player +from . import recharts as recharts +from . import sonner as sonner +from . import suneditor as suneditor +from .component import Component as Component +from .component import NoSSRComponent as NoSSRComponent +from .next import NextLink as NextLink +from .next import next_link as next_link diff --git a/reflex/components/base/__init__.py b/reflex/components/base/__init__.py index 58a0f6a55..51c369bb9 100644 --- a/reflex/components/base/__init__.py +++ b/reflex/components/base/__init__.py @@ -1,12 +1,33 @@ """Base components.""" -from .body import Body -from .document import DocumentHead, Html, Main, NextScript -from .fragment import Fragment -from .head import Head -from .link import RawLink, ScriptTag -from .meta import Description, Image, Meta, Title -from .script import Script +from __future__ import annotations -fragment = Fragment.create -script = Script.create +from reflex.utils import lazy_loader + +_SUBMODULES: set[str] = {"app_wrap", "bare"} + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "body": ["Body"], + "document": ["DocumentHead", "Html", "Main", "NextScript"], + "fragment": [ + "Fragment", + "fragment", + ], + "error_boundary": [ + "ErrorBoundary", + "error_boundary", + ], + "head": [ + "head", + "Head", + ], + "link": ["RawLink", "ScriptTag"], + "meta": ["Description", "Image", "Meta", "Title"], + "script": ["Script", "script"], +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/base/__init__.pyi b/reflex/components/base/__init__.pyi new file mode 100644 index 000000000..d312caa9d --- /dev/null +++ b/reflex/components/base/__init__.pyi @@ -0,0 +1,26 @@ +"""Stub file for reflex/components/base/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import app_wrap as app_wrap +from . import bare as bare +from .body import Body as Body +from .document import DocumentHead as DocumentHead +from .document import Html as Html +from .document import Main as Main +from .document import NextScript as NextScript +from .error_boundary import ErrorBoundary as ErrorBoundary +from .error_boundary import error_boundary as error_boundary +from .fragment import Fragment as Fragment +from .fragment import fragment as fragment +from .head import Head as Head +from .head import head as head +from .link import RawLink as RawLink +from .link import ScriptTag as ScriptTag +from .meta import Description as Description +from .meta import Image as Image +from .meta import Meta as Meta +from .meta import Title as Title +from .script import Script as Script +from .script import script as script diff --git a/reflex/components/base/app_wrap.py b/reflex/components/base/app_wrap.py index 32f9f3522..c7cfe6505 100644 --- a/reflex/components/base/app_wrap.py +++ b/reflex/components/base/app_wrap.py @@ -1,7 +1,8 @@ """Top-level component that wraps the entire app.""" + from reflex.components.base.fragment import Fragment from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var class AppWrap(Fragment): @@ -14,6 +15,4 @@ class AppWrap(Fragment): Returns: A new AppWrap component containing {children}. """ - return super().create( - Var.create("{children}", _var_is_local=False, _var_is_string=False) - ) + return super().create(Var(_js_expr="children")) diff --git a/reflex/components/base/app_wrap.pyi b/reflex/components/base/app_wrap.pyi index f394225df..c4cb45469 100644 --- a/reflex/components/base/app_wrap.pyi +++ b/reflex/components/base/app_wrap.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/base/app_wrap.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.base.fragment import Fragment -from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class AppWrap(Fragment): @overload @@ -23,52 +22,22 @@ class AppWrap(Fragment): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AppWrap": """Create a new AppWrap component. diff --git a/reflex/components/base/bare.py b/reflex/components/base/bare.py index 0de7307db..c70b4c844 100644 --- a/reflex/components/base/bare.py +++ b/reflex/components/base/bare.py @@ -4,16 +4,17 @@ from __future__ import annotations from typing import Any, Iterator -from reflex.components.component import Component +from reflex.components.component import Component, LiteralComponentVar from reflex.components.tags import Tag from reflex.components.tags.tagless import Tagless -from reflex.vars import Var +from reflex.utils.imports import ParsedImportDict +from reflex.vars import BooleanVar, ObjectVar, Var class Bare(Component): """A component with no tag.""" - contents: Var[str] + contents: Var[Any] @classmethod def create(cls, contents: Any) -> Component: @@ -25,13 +26,85 @@ class Bare(Component): Returns: The component. """ - if isinstance(contents, Var) and contents._var_data: - contents = contents.to(str) + if isinstance(contents, Var): + return cls(contents=contents) else: contents = str(contents) if contents is not None else "" return cls(contents=contents) # type: ignore + def _get_all_hooks_internal(self) -> dict[str, None]: + """Include the hooks for the component. + + Returns: + The hooks for the component. + """ + hooks = super()._get_all_hooks_internal() + if isinstance(self.contents, LiteralComponentVar): + hooks |= self.contents._var_value._get_all_hooks_internal() + return hooks + + def _get_all_hooks(self) -> dict[str, None]: + """Include the hooks for the component. + + Returns: + The hooks for the component. + """ + hooks = super()._get_all_hooks() + if isinstance(self.contents, LiteralComponentVar): + hooks |= self.contents._var_value._get_all_hooks() + return hooks + + def _get_all_imports(self) -> ParsedImportDict: + """Include the imports for the component. + + Returns: + The imports for the component. + """ + imports = super()._get_all_imports() + if isinstance(self.contents, LiteralComponentVar): + var_data = self.contents._get_all_var_data() + if var_data: + imports |= {k: list(v) for k, v in var_data.imports} + return imports + + def _get_all_dynamic_imports(self) -> set[str]: + """Get dynamic imports for the component. + + Returns: + The dynamic imports. + """ + dynamic_imports = super()._get_all_dynamic_imports() + if isinstance(self.contents, LiteralComponentVar): + dynamic_imports |= self.contents._var_value._get_all_dynamic_imports() + return dynamic_imports + + def _get_all_custom_code(self) -> set[str]: + """Get custom code for the component. + + Returns: + The custom code. + """ + custom_code = super()._get_all_custom_code() + if isinstance(self.contents, LiteralComponentVar): + custom_code |= self.contents._var_value._get_all_custom_code() + return custom_code + + def _get_all_refs(self) -> set[str]: + """Get the refs for the children of the component. + + Returns: + The refs for the children. + """ + refs = super()._get_all_refs() + if isinstance(self.contents, LiteralComponentVar): + refs |= self.contents._var_value._get_all_refs() + return refs + def _render(self) -> Tag: + if isinstance(self.contents, Var): + if isinstance(self.contents, (BooleanVar, ObjectVar)): + return Tagless(contents=f"{{{str(self.contents.to_string())}}}") + return Tagless(contents=f"{{{str(self.contents)}}}") return Tagless(contents=str(self.contents)) def _get_vars(self, include_children: bool = False) -> Iterator[Var]: diff --git a/reflex/components/base/body.pyi b/reflex/components/base/body.pyi index 9f51e39bb..74f3333e5 100644 --- a/reflex/components/base/body.pyi +++ b/reflex/components/base/body.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/base/body.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Body(Component): @overload @@ -21,52 +22,22 @@ class Body(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Body": """Create the component. diff --git a/reflex/components/base/document.pyi b/reflex/components/base/document.pyi index 7a3cc6b13..a4a956369 100644 --- a/reflex/components/base/document.pyi +++ b/reflex/components/base/document.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/base/document.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class NextDocumentLib(Component): @overload @@ -22,52 +22,22 @@ class NextDocumentLib(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "NextDocumentLib": """Create the component. @@ -99,52 +69,22 @@ class Html(NextDocumentLib): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Html": """Create the component. @@ -175,52 +115,22 @@ class DocumentHead(NextDocumentLib): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DocumentHead": """Create the component. @@ -251,52 +161,22 @@ class Main(NextDocumentLib): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Main": """Create the component. @@ -327,52 +207,22 @@ class NextScript(NextDocumentLib): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "NextScript": """Create the component. diff --git a/reflex/components/base/error_boundary.py b/reflex/components/base/error_boundary.py new file mode 100644 index 000000000..83becc034 --- /dev/null +++ b/reflex/components/base/error_boundary.py @@ -0,0 +1,92 @@ +"""A React Error Boundary component that catches unhandled frontend exceptions.""" + +from __future__ import annotations + +from typing import Dict, List, Tuple + +from reflex.compiler.compiler import _compile_component +from reflex.components.component import Component +from reflex.components.el import div, p +from reflex.event import EventHandler +from reflex.state import FrontendEventExceptionState +from reflex.vars.base import Var + + +def on_error_spec( + error: Var[Dict[str, str]], info: Var[Dict[str, str]] +) -> Tuple[Var[str], Var[str]]: + """The spec for the on_error event handler. + + Args: + error: The error message. + info: Additional information about the error. + + Returns: + The arguments for the event handler. + """ + return ( + error.stack, + info.componentStack, + ) + + +class ErrorBoundary(Component): + """A React Error Boundary component that catches unhandled frontend exceptions.""" + + library = "react-error-boundary" + tag = "ErrorBoundary" + + # Fired when the boundary catches an error. + on_error: EventHandler[on_error_spec] + + # Rendered instead of the children when an error is caught. + Fallback_component: Var[Component] = Var(_js_expr="Fallback")._replace( + _var_type=Component + ) + + def add_custom_code(self) -> List[str]: + """Add custom Javascript code into the page that contains this component. + + Custom code is inserted at module level, after any imports. + + Returns: + The custom code to add. + """ + fallback_container = div( + p("Ooops...Unknown Reflex error has occured:"), + p( + Var(_js_expr="error.message"), + color="red", + ), + p("Please contact the support."), + ) + + compiled_fallback = _compile_component(fallback_container) + + return [ + f""" + function Fallback({{ error, resetErrorBoundary }}) {{ + return ( + {compiled_fallback} + ); + }} + """ + ] + + @classmethod + def create(cls, *children, **props): + """Create an ErrorBoundary component. + + Args: + *children: The children of the component. + **props: The props of the component. + + Returns: + The ErrorBoundary component. + """ + if "on_error" not in props: + props["on_error"] = FrontendEventExceptionState.handle_frontend_exception + return super().create(*children, **props) + + +error_boundary = ErrorBoundary.create diff --git a/reflex/components/base/error_boundary.pyi b/reflex/components/base/error_boundary.pyi new file mode 100644 index 000000000..154ec0d13 --- /dev/null +++ b/reflex/components/base/error_boundary.pyi @@ -0,0 +1,68 @@ +"""Stub file for reflex/components/base/error_boundary.py""" + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from typing import Any, Dict, List, Optional, Tuple, Union, overload + +from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +def on_error_spec( + error: Var[Dict[str, str]], info: Var[Dict[str, str]] +) -> Tuple[Var[str], Var[str]]: ... + +class ErrorBoundary(Component): + def add_custom_code(self) -> List[str]: ... + @overload + @classmethod + def create( # type: ignore + cls, + *children, + Fallback_component: Optional[Union[Component, Var[Component]]] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_error: Optional[EventType[str, str]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "ErrorBoundary": + """Create an ErrorBoundary component. + + Args: + *children: The children of the component. + on_error: Fired when the boundary catches an error. + Fallback_component: Rendered instead of the children when an error is caught. + 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 of the component. + + Returns: + The ErrorBoundary component. + """ + ... + +error_boundary = ErrorBoundary.create diff --git a/reflex/components/base/fragment.py b/reflex/components/base/fragment.py index 99554ede9..84ec86145 100644 --- a/reflex/components/base/fragment.py +++ b/reflex/components/base/fragment.py @@ -1,4 +1,5 @@ """React fragments to enable bare returns of component trees from functions.""" + from reflex.components.component import Component @@ -7,3 +8,6 @@ class Fragment(Component): library = "react" tag = "Fragment" + + +fragment = Fragment.create diff --git a/reflex/components/base/fragment.pyi b/reflex/components/base/fragment.pyi index 9d9754d37..b49bf4cad 100644 --- a/reflex/components/base/fragment.pyi +++ b/reflex/components/base/fragment.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/base/fragment.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Fragment(Component): @overload @@ -21,52 +22,22 @@ class Fragment(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Fragment": """Create the component. @@ -84,3 +55,5 @@ class Fragment(Component): The component. """ ... + +fragment = Fragment.create diff --git a/reflex/components/base/head.py b/reflex/components/base/head.py index c8a63e7b4..b130ed22f 100644 --- a/reflex/components/base/head.py +++ b/reflex/components/base/head.py @@ -15,3 +15,6 @@ class Head(NextHeadLib, MemoizationLeaf): tag = "NextHead" is_default = True + + +head = Head.create diff --git a/reflex/components/base/head.pyi b/reflex/components/base/head.pyi index eb5112d55..148dbe486 100644 --- a/reflex/components/base/head.pyi +++ b/reflex/components/base/head.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/base/head.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component, MemoizationLeaf +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class NextHeadLib(Component): @overload @@ -21,52 +22,22 @@ class NextHeadLib(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "NextHeadLib": """Create the component. @@ -97,52 +68,22 @@ class Head(NextHeadLib, MemoizationLeaf): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Head": """Create a new memoization leaf component. @@ -160,3 +101,5 @@ class Head(NextHeadLib, MemoizationLeaf): The memoization leaf """ ... + +head = Head.create diff --git a/reflex/components/base/link.py b/reflex/components/base/link.py index 04d109e51..3ea34f212 100644 --- a/reflex/components/base/link.py +++ b/reflex/components/base/link.py @@ -1,8 +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 2e0c63a12..61ff66029 100644 --- a/reflex/components/base/link.pyi +++ b/reflex/components/base/link.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/base/link.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class RawLink(Component): @overload @@ -24,52 +24,22 @@ class RawLink(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RawLink": """Create the component. @@ -109,52 +79,22 @@ class ScriptTag(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ScriptTag": """Create the component. diff --git a/reflex/components/base/meta.py b/reflex/components/base/meta.py index 55cb42f0a..526233c8b 100644 --- a/reflex/components/base/meta.py +++ b/reflex/components/base/meta.py @@ -16,13 +16,15 @@ class Title(Component): def render(self) -> dict: """Render the title component. + Raises: + ValueError: If the title is not a single string. + Returns: The rendered title component. """ # Make sure the title is a single string. - assert len(self.children) == 1 and isinstance( - self.children[0], Bare - ), "Title must be a single string." + if len(self.children) != 1 or not isinstance(self.children[0], Bare): + raise ValueError("Title must be a single string.") return super().render() diff --git a/reflex/components/base/meta.pyi b/reflex/components/base/meta.pyi index 87752e264..e91626cde 100644 --- a/reflex/components/base/meta.pyi +++ b/reflex/components/base/meta.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/base/meta.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.base.bare import Bare from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Title(Component): def render(self) -> dict: ... @@ -24,52 +23,22 @@ class Title(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Title": """Create the component. @@ -105,52 +74,22 @@ class Meta(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Meta": """Create the component. @@ -191,52 +130,22 @@ class Description(Meta): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Description": """Create the component. @@ -277,52 +186,22 @@ class Image(Meta): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Image": """Create the component. diff --git a/reflex/components/base/script.py b/reflex/components/base/script.py index e379a1824..eb37d53e7 100644 --- a/reflex/components/base/script.py +++ b/reflex/components/base/script.py @@ -2,12 +2,14 @@ https://nextjs.org/docs/app/api-reference/components/script """ + from __future__ import annotations -from typing import Any, Union +from typing import Literal from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventHandler, empty_event +from reflex.vars.base import LiteralVar, Var class Script(Component): @@ -27,8 +29,19 @@ class Script(Component): # Required unless inline script is used src: Var[str] - # When the script will execute: afterInteractive | beforeInteractive | lazyOnload - strategy: Var[str] = "afterInteractive" # type: ignore + # When the script will execute: afterInteractive (defer-like behavior) | beforeInteractive | lazyOnload (async-like behavior) + strategy: Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]] = ( + LiteralVar.create("afterInteractive") + ) + + # Triggered when the script is loading + on_load: EventHandler[empty_event] + + # Triggered when the script has loaded + on_ready: EventHandler[empty_event] + + # Triggered when the script has errored + on_error: EventHandler[empty_event] @classmethod def create(cls, *children, **props) -> Component: @@ -58,15 +71,5 @@ class Script(Component): raise ValueError("Must provide inline script or `src` prop.") return super().create(*children, **props) - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_load": lambda: [], - "on_ready": lambda: [], - "on_error": lambda: [], - } +script = Script.create diff --git a/reflex/components/base/script.pyi b/reflex/components/base/script.pyi index 3bd824122..be4517f44 100644 --- a/reflex/components/base/script.pyi +++ b/reflex/components/base/script.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/base/script.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union + from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Script(Component): @overload @@ -18,68 +17,37 @@ class Script(Component): cls, *children, src: Optional[Union[Var[str], str]] = None, - strategy: Optional[Union[Var[str], str]] = None, + strategy: Optional[ + Union[ + Literal["afterInteractive", "beforeInteractive", "lazyOnload"], + Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]], + ] + ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_ready: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_error: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_load: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_ready: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Script": """Create an inline or user-defined script. @@ -96,7 +64,10 @@ class Script(Component): Args: *children: The children of the component. src: Required unless inline script is used - strategy: When the script will execute: afterInteractive | beforeInteractive | lazyOnload + strategy: When the script will execute: afterInteractive (defer-like behavior) | beforeInteractive | lazyOnload (async-like behavior) + on_load: Triggered when the script is loading + on_ready: Triggered when the script has loaded + on_error: Triggered when the script has errored style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -112,4 +83,5 @@ class Script(Component): ValueError: when neither children nor `src` are specified. """ ... - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... + +script = Script.create diff --git a/reflex/components/chakra/__init__.py b/reflex/components/chakra/__init__.py deleted file mode 100644 index ea0976f8c..000000000 --- a/reflex/components/chakra/__init__.py +++ /dev/null @@ -1,204 +0,0 @@ -"""Chakra components.""" - -from .base import * -from .datadisplay import * -from .disclosure import * -from .feedback import * -from .forms import * -from .layout import * -from .media import * -from .navigation import * -from .overlay import * -from .typography import * - -accordion = Accordion.create -accordion_button = AccordionButton.create -accordion_icon = AccordionIcon.create -accordion_item = AccordionItem.create -accordion_panel = AccordionPanel.create -alert = Alert.create -alert_description = AlertDescription.create -alert_dialog = AlertDialog.create -alert_dialog_body = AlertDialogBody.create -alert_dialog_content = AlertDialogContent.create -alert_dialog_footer = AlertDialogFooter.create -alert_dialog_header = AlertDialogHeader.create -alert_dialog_overlay = AlertDialogOverlay.create -alert_icon = AlertIcon.create -alert_title = AlertTitle.create -aspect_ratio = AspectRatio.create -avatar = Avatar.create -avatar_badge = AvatarBadge.create -avatar_group = AvatarGroup.create -badge = Badge.create -box = Box.create -breadcrumb = Breadcrumb.create -breadcrumb_item = BreadcrumbItem.create -breadcrumb_link = BreadcrumbLink.create -breadcrumb_separator = BreadcrumbSeparator.create -button = Button.create -button_group = ButtonGroup.create -card = Card.create -card_body = CardBody.create -card_footer = CardFooter.create -card_header = CardHeader.create -center = Center.create -checkbox = Checkbox.create -checkbox_group = CheckboxGroup.create -circle = Circle.create -circular_progress = CircularProgress.create -circular_progress_label = CircularProgressLabel.create -code = Code.create -collapse = Collapse.create -color_mode_button = ColorModeButton.create -color_mode_icon = ColorModeIcon.create -color_mode_switch = ColorModeSwitch.create -component = Component.create -container = Container.create -date_picker = DatePicker.create -date_time_picker = DateTimePicker.create -divider = Divider.create -drawer = Drawer.create -drawer_body = DrawerBody.create -drawer_close_button = DrawerCloseButton.create -drawer_content = DrawerContent.create -drawer_footer = DrawerFooter.create -drawer_header = DrawerHeader.create -drawer_overlay = DrawerOverlay.create -editable = Editable.create -editable_input = EditableInput.create -editable_preview = EditablePreview.create -editable_textarea = EditableTextarea.create -email = Email.create -fade = Fade.create -flex = Flex.create -form = Form.create -form_control = FormControl.create -form_error_message = FormErrorMessage.create -form_helper_text = FormHelperText.create -form_label = FormLabel.create -grid = Grid.create -grid_item = GridItem.create -heading = Heading.create -highlight = Highlight.create -hstack = Hstack.create -icon = Icon.create -icon_button = IconButton.create -image = Image.create -input = Input.create -input_group = InputGroup.create -input_left_addon = InputLeftAddon.create -input_left_element = InputLeftElement.create -input_right_addon = InputRightAddon.create -input_right_element = InputRightElement.create -kbd = Kbd.create -link = Link.create -link_box = LinkBox.create -link_overlay = LinkOverlay.create -list = List.create -list_item = ListItem.create -menu = Menu.create -menu_button = MenuButton.create -menu_divider = MenuDivider.create -menu_group = MenuGroup.create -menu_item = MenuItem.create -menu_item_option = MenuItemOption.create -menu_list = MenuList.create -menu_option_group = MenuOptionGroup.create -modal = Modal.create -modal_body = ModalBody.create -modal_close_button = ModalCloseButton.create -modal_content = ModalContent.create -modal_footer = ModalFooter.create -modal_header = ModalHeader.create -modal_overlay = ModalOverlay.create -multi_select = MultiSelect.create -multi_select_option = MultiSelectOption -number_decrement_stepper = NumberDecrementStepper.create -number_increment_stepper = NumberIncrementStepper.create -number_input = NumberInput.create -number_input_field = NumberInputField.create -number_input_stepper = NumberInputStepper.create -option = Option.create -ordered_list = OrderedList.create -password = Password.create -pin_input = PinInput.create -pin_input_field = PinInputField.create -popover = Popover.create -popover_anchor = PopoverAnchor.create -popover_arrow = PopoverArrow.create -popover_body = PopoverBody.create -popover_close_button = PopoverCloseButton.create -popover_content = PopoverContent.create -popover_footer = PopoverFooter.create -popover_header = PopoverHeader.create -popover_trigger = PopoverTrigger.create -progress = Progress.create -radio = Radio.create -radio_group = RadioGroup.create -range_slider = RangeSlider.create -range_slider_filled_track = RangeSliderFilledTrack.create -range_slider_thumb = RangeSliderThumb.create -range_slider_track = RangeSliderTrack.create -responsive_grid = ResponsiveGrid.create -scale_fade = ScaleFade.create -select = Select.create -skeleton = Skeleton.create -skeleton_circle = SkeletonCircle.create -skeleton_text = SkeletonText.create -slide = Slide.create -slide_fade = SlideFade.create -slider = Slider.create -slider_filled_track = SliderFilledTrack.create -slider_mark = SliderMark.create -slider_thumb = SliderThumb.create -slider_track = SliderTrack.create -spacer = Spacer.create -span = Span.create -spinner = Spinner.create -square = Square.create -stack = Stack.create -stat = Stat.create -stat_arrow = StatArrow.create -stat_group = StatGroup.create -stat_help_text = StatHelpText.create -stat_label = StatLabel.create -stat_number = StatNumber.create -step = Step.create -step_description = StepDescription.create -step_icon = StepIcon.create -step_indicator = StepIndicator.create -step_number = StepNumber.create -step_separator = StepSeparator.create -step_status = StepStatus.create -step_title = StepTitle.create -stepper = Stepper.create -switch = Switch.create -tab = Tab.create -tab_list = TabList.create -tab_panel = TabPanel.create -tab_panels = TabPanels.create -table = Table.create -table_caption = TableCaption.create -table_container = TableContainer.create -tabs = Tabs.create -tag = Tag.create -tag_close_button = TagCloseButton.create -tag_label = TagLabel.create -tag_left_icon = TagLeftIcon.create -tag_right_icon = TagRightIcon.create -tbody = Tbody.create -td = Td.create -text = Text.create -text_area = TextArea.create -tfoot = Tfoot.create -th = Th.create -thead = Thead.create -time_picker = TimePicker.create -tooltip = Tooltip.create -tr = Tr.create -unordered_list = UnorderedList.create -visually_hidden = VisuallyHidden.create -vstack = Vstack.create -wrap = Wrap.create -wrap_item = WrapItem.create diff --git a/reflex/components/chakra/base.py b/reflex/components/chakra/base.py deleted file mode 100644 index 9e1f3f698..000000000 --- a/reflex/components/chakra/base.py +++ /dev/null @@ -1,206 +0,0 @@ -"""Components that are based on Chakra-UI.""" -from __future__ import annotations - -from functools import lru_cache -from typing import List, Literal - -from reflex.components.component import Component -from reflex.utils import imports -from reflex.vars import Var - - -class ChakraComponent(Component): - """A component that wraps a Chakra component.""" - - library = "@chakra-ui/react@2.6.1" - lib_dependencies: List[str] = [ - "@chakra-ui/system@2.5.7", - "framer-motion@10.16.4", - ] - - @staticmethod - @lru_cache(maxsize=None) - def _get_app_wrap_components() -> dict[tuple[int, str], Component]: - return { - (60, "ChakraProvider"): chakra_provider, - } - - def _get_style(self) -> dict: - """Get the style for the component. - - Returns: - The dictionary of the component style as value and the style notation as key. - """ - return {"sx": self.style} - - @classmethod - @lru_cache(maxsize=None) - def _get_dependencies_imports(cls) -> imports.ImportDict: - """Get the imports from lib_dependencies for installing. - - Returns: - The dependencies imports of the component. - """ - return { - dep: [imports.ImportVar(tag=None, render=False)] - for dep in [ - "@chakra-ui/system@2.5.7", - "framer-motion@10.16.4", - ] - } - - -class ChakraProvider(ChakraComponent): - """Top level Chakra provider must be included in any app using chakra components.""" - - tag = "ChakraProvider" - - theme: Var[str] - - @classmethod - def create(cls) -> Component: - """Create a new ChakraProvider component. - - Returns: - A new ChakraProvider component. - """ - return super().create( - theme=Var.create("extendTheme(theme)", _var_is_local=False), - ) - - def _get_imports(self) -> imports.ImportDict: - _imports = super()._get_imports() - _imports.setdefault(self.__fields__["library"].default, []).append( - imports.ImportVar(tag="extendTheme", is_default=False), - ) - _imports.setdefault("/utils/theme.js", []).append( - imports.ImportVar(tag="theme", is_default=True), - ) - return _imports - - @staticmethod - @lru_cache(maxsize=None) - def _get_app_wrap_components() -> dict[tuple[int, str], Component]: - return { - (50, "ChakraColorModeProvider"): chakra_color_mode_provider, - } - - -chakra_provider = ChakraProvider.create() - - -class ChakraColorModeProvider(Component): - """Next-themes integration for chakra colorModeProvider.""" - - library = "/components/reflex/chakra_color_mode_provider.js" - tag = "ChakraColorModeProvider" - is_default = True - - -chakra_color_mode_provider = ChakraColorModeProvider.create() - - -LiteralColorScheme = Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", -] - - -LiteralVariant = Literal["solid", "subtle", "outline"] -LiteralDividerVariant = Literal["solid", "dashed"] -LiteralTheme = Literal["light", "dark"] - - -LiteralTagColorScheme = Literal[ - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", -] -LiteralTagAlign = Literal["center", "end", "start"] -LiteralTabsVariant = Literal[ - "line", - "enclosed", - "enclosed-colored", - "soft-rounded", - "solid-rounded", - "unstyled", -] - -LiteralStatus = Literal["success", "info", "warning", "error"] -LiteralAlertVariant = Literal["subtle", "left-accent", "top-accent", "solid"] -LiteralButtonVariant = Literal["ghost", "outline", "solid", "link", "unstyled"] -LiteralSpinnerPlacement = Literal["start", "end"] -LiteralLanguage = Literal[ - "en", - "da", - "de", - "es", - "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", - "he", - "it", -] -LiteralInputVariant = Literal["outline", "filled", "flushed", "unstyled"] -LiteralInputNumberMode = [ - "text", - "search", - "none", - "tel", - "url", - "email", - "numeric", - "decimal", -] -LiteralChakraDirection = Literal["ltr", "rtl"] -LiteralCardVariant = Literal["outline", "filled", "elevated", "unstyled"] -LiteralStackDirection = Literal["row", "column"] -LiteralImageLoading = Literal["eager", "lazy"] -LiteralTagSize = Literal["sm", "md", "lg"] -LiteralSpinnerSize = Literal[Literal[LiteralTagSize], "xs", "xl"] -LiteralAvatarSize = Literal[Literal[LiteralTagSize], "xl", "xs", "2xl", "full", "2xs"] -LiteralButtonSize = Literal["sm", "md", "lg", "xs"] -# Applies to AlertDialog and Modal -LiteralAlertDialogSize = Literal[ - "sm", "md", "lg", "xs", "2xl", "full", "3xl", "4xl", "5xl", "6xl" -] -LiteralDrawerSize = Literal[Literal[LiteralSpinnerSize], "xl", "full"] - -LiteralMenuStrategy = Literal["fixed", "absolute"] -LiteralMenuOption = Literal["checkbox", "radio"] -LiteralPopOverTrigger = Literal["click", "hover"] - -LiteralHeadingSize = Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"] diff --git a/reflex/components/chakra/base.pyi b/reflex/components/chakra/base.pyi deleted file mode 100644 index be99b2f90..000000000 --- a/reflex/components/chakra/base.pyi +++ /dev/null @@ -1,319 +0,0 @@ -"""Stub file for reflex/components/chakra/base.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from functools import lru_cache -from typing import List, Literal -from reflex.components.component import Component -from reflex.utils import imports -from reflex.vars import Var - -class ChakraComponent(Component): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ChakraComponent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ChakraProvider(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - theme: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ChakraProvider": - """Create a new ChakraProvider component. - - Returns: - A new ChakraProvider component. - """ - ... - -chakra_provider = ChakraProvider.create() - -class ChakraColorModeProvider(Component): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ChakraColorModeProvider": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -chakra_color_mode_provider = ChakraColorModeProvider.create() -LiteralColorScheme = Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", -] -LiteralVariant = Literal["solid", "subtle", "outline"] -LiteralDividerVariant = Literal["solid", "dashed"] -LiteralTheme = Literal["light", "dark"] -LiteralTagColorScheme = Literal[ - "gray", "red", "orange", "yellow", "green", "teal", "blue", "cyan", "purple", "pink" -] -LiteralTagAlign = Literal["center", "end", "start"] -LiteralTabsVariant = Literal[ - "line", "enclosed", "enclosed-colored", "soft-rounded", "solid-rounded", "unstyled" -] -LiteralStatus = Literal["success", "info", "warning", "error"] -LiteralAlertVariant = Literal["subtle", "left-accent", "top-accent", "solid"] -LiteralButtonVariant = Literal["ghost", "outline", "solid", "link", "unstyled"] -LiteralSpinnerPlacement = Literal["start", "end"] -LiteralLanguage = Literal[ - "en", - "da", - "de", - "es", - "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", - "he", - "it", -] -LiteralInputVariant = Literal["outline", "filled", "flushed", "unstyled"] -LiteralInputNumberMode = [ - "text", - "search", - "none", - "tel", - "url", - "email", - "numeric", - "decimal", -] -LiteralChakraDirection = Literal["ltr", "rtl"] -LiteralCardVariant = Literal["outline", "filled", "elevated", "unstyled"] -LiteralStackDirection = Literal["row", "column"] -LiteralImageLoading = Literal["eager", "lazy"] -LiteralTagSize = Literal["sm", "md", "lg"] -LiteralSpinnerSize = Literal[Literal[LiteralTagSize], "xs", "xl"] -LiteralAvatarSize = Literal[Literal[LiteralTagSize], "xl", "xs", "2xl", "full", "2xs"] -LiteralButtonSize = Literal["sm", "md", "lg", "xs"] -LiteralAlertDialogSize = Literal[ - "sm", "md", "lg", "xs", "2xl", "full", "3xl", "4xl", "5xl", "6xl" -] -LiteralDrawerSize = Literal[Literal[LiteralSpinnerSize], "xl", "full"] -LiteralMenuStrategy = Literal["fixed", "absolute"] -LiteralMenuOption = Literal["checkbox", "radio"] -LiteralPopOverTrigger = Literal["click", "hover"] -LiteralHeadingSize = Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"] diff --git a/reflex/components/chakra/datadisplay/__init__.py b/reflex/components/chakra/datadisplay/__init__.py deleted file mode 100644 index b20d17248..000000000 --- a/reflex/components/chakra/datadisplay/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Data display components.""" - -from .badge import Badge -from .code import Code -from .divider import Divider -from .keyboard_key import KeyboardKey as Kbd -from .list import List, ListItem, OrderedList, UnorderedList -from .stat import Stat, StatArrow, StatGroup, StatHelpText, StatLabel, StatNumber -from .table import Table, TableCaption, TableContainer, Tbody, Td, Tfoot, Th, Thead, Tr -from .tag import Tag, TagCloseButton, TagLabel, TagLeftIcon, TagRightIcon diff --git a/reflex/components/chakra/datadisplay/badge.py b/reflex/components/chakra/datadisplay/badge.py deleted file mode 100644 index 52d36fe7c..000000000 --- a/reflex/components/chakra/datadisplay/badge.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Badge component.""" - -from reflex.components.chakra import ChakraComponent, LiteralVariant -from reflex.vars import Var - - -class Badge(ChakraComponent): - """A badge component.""" - - tag = "Badge" - - # Variant of the badge ("solid" | "subtle" | "outline") - variant: Var[LiteralVariant] - - # The color of the badge - color_scheme: Var[str] diff --git a/reflex/components/chakra/datadisplay/badge.pyi b/reflex/components/chakra/datadisplay/badge.pyi deleted file mode 100644 index 646952b50..000000000 --- a/reflex/components/chakra/datadisplay/badge.pyi +++ /dev/null @@ -1,96 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/badge.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent, LiteralVariant -from reflex.vars import Var - -class Badge(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - variant: Optional[ - Union[ - Var[Literal["solid", "subtle", "outline"]], - Literal["solid", "subtle", "outline"], - ] - ] = None, - color_scheme: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Badge": - """Create the component. - - Args: - *children: The children of the component. - variant: Variant of the badge ("solid" | "subtle" | "outline") - color_scheme: The color of the badge - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/code.py b/reflex/components/chakra/datadisplay/code.py deleted file mode 100644 index fe1016b7a..000000000 --- a/reflex/components/chakra/datadisplay/code.py +++ /dev/null @@ -1,10 +0,0 @@ -"""A code component.""" -from reflex.components.chakra import ( - ChakraComponent, -) - - -class Code(ChakraComponent): - """Used to display inline code.""" - - tag = "Code" diff --git a/reflex/components/chakra/datadisplay/code.pyi b/reflex/components/chakra/datadisplay/code.pyi deleted file mode 100644 index 751a7b689..000000000 --- a/reflex/components/chakra/datadisplay/code.pyi +++ /dev/null @@ -1,86 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/code.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent - -class Code(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Code": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/divider.py b/reflex/components/chakra/datadisplay/divider.py deleted file mode 100644 index de33e4ec0..000000000 --- a/reflex/components/chakra/datadisplay/divider.py +++ /dev/null @@ -1,19 +0,0 @@ -"""A line to divide parts of the layout.""" -from typing import Literal - -from reflex.components.chakra import ChakraComponent, LiteralDividerVariant -from reflex.vars import Var - -LiteralLayout = Literal["horizontal", "vertical"] - - -class Divider(ChakraComponent): - """Dividers are used to visually separate content in a list or group.""" - - tag = "Divider" - - # Pass the orientation prop and set it to either horizontal or vertical. If the vertical orientation is used, make sure that the parent element is assigned a height. - orientation: Var[LiteralLayout] - - # Variant of the divider ("solid" | "dashed") - variant: Var[LiteralDividerVariant] diff --git a/reflex/components/chakra/datadisplay/divider.pyi b/reflex/components/chakra/datadisplay/divider.pyi deleted file mode 100644 index 8f78c741c..000000000 --- a/reflex/components/chakra/datadisplay/divider.pyi +++ /dev/null @@ -1,101 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/divider.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal -from reflex.components.chakra import ChakraComponent, LiteralDividerVariant -from reflex.vars import Var - -LiteralLayout = Literal["horizontal", "vertical"] - -class Divider(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - orientation: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - variant: Optional[ - Union[Var[Literal["solid", "dashed"]], Literal["solid", "dashed"]] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Divider": - """Create the component. - - Args: - *children: The children of the component. - orientation: Pass the orientation prop and set it to either horizontal or vertical. If the vertical orientation is used, make sure that the parent element is assigned a height. - variant: Variant of the divider ("solid" | "dashed") - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/keyboard_key.py b/reflex/components/chakra/datadisplay/keyboard_key.py deleted file mode 100644 index f9068284d..000000000 --- a/reflex/components/chakra/datadisplay/keyboard_key.py +++ /dev/null @@ -1,9 +0,0 @@ -"""A Keyboard Key Component.""" - -from reflex.components.chakra import ChakraComponent - - -class KeyboardKey(ChakraComponent): - """Display a keyboard key text.""" - - tag = "Kbd" diff --git a/reflex/components/chakra/datadisplay/keyboard_key.pyi b/reflex/components/chakra/datadisplay/keyboard_key.pyi deleted file mode 100644 index c0c2ff746..000000000 --- a/reflex/components/chakra/datadisplay/keyboard_key.pyi +++ /dev/null @@ -1,86 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/keyboard_key.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent - -class KeyboardKey(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "KeyboardKey": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/list.py b/reflex/components/chakra/datadisplay/list.py deleted file mode 100644 index 0bfe155fa..000000000 --- a/reflex/components/chakra/datadisplay/list.py +++ /dev/null @@ -1,60 +0,0 @@ -"""List components.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.vars import Var - - -class List(ChakraComponent): - """Display a list of items.""" - - tag = "List" - - # The space between each list item - spacing: Var[str] - - # Shorthand prop for listStylePosition - style_position: Var[str] - - # Shorthand prop for listStyleType - style_type: Var[str] - - @classmethod - def create(cls, *children, items: Var[list] | None = None, **props) -> Component: - """Create a list component. - - Args: - *children: The children of the component. - items: A list of items to add to the list. - **props: The properties of the component. - - Returns: - The list component. - """ - if len(children) == 0: - if isinstance(items, Var): - children = [Foreach.create(items, ListItem.create)] - else: - children = [ListItem.create(item) for item in items or []] - return super().create(*children, **props) - - -class ListItem(ChakraComponent): - """A single list item.""" - - tag = "ListItem" - - -class OrderedList(List): - """An ordered list component with numbers.""" - - tag = "OrderedList" - - -class UnorderedList(List): - """An unordered list component with bullets.""" - - tag = "UnorderedList" diff --git a/reflex/components/chakra/datadisplay/list.pyi b/reflex/components/chakra/datadisplay/list.pyi deleted file mode 100644 index 344a64688..000000000 --- a/reflex/components/chakra/datadisplay/list.pyi +++ /dev/null @@ -1,341 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/list.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.vars import Var - -class List(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[Union[Var[list], list]] = None, - spacing: Optional[Union[Var[str], str]] = None, - style_position: Optional[Union[Var[str], str]] = None, - style_type: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "List": - """Create a list component. - - Args: - *children: The children of the component. - items: A list of items to add to the list. - spacing: The space between each list item - style_position: Shorthand prop for listStylePosition - style_type: Shorthand prop for listStyleType - 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 properties of the component. - - Returns: - The list component. - """ - ... - -class ListItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ListItem": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class OrderedList(List): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[Union[Var[list], list]] = None, - spacing: Optional[Union[Var[str], str]] = None, - style_position: Optional[Union[Var[str], str]] = None, - style_type: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "OrderedList": - """Create a list component. - - Args: - *children: The children of the component. - items: A list of items to add to the list. - spacing: The space between each list item - style_position: Shorthand prop for listStylePosition - style_type: Shorthand prop for listStyleType - 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 properties of the component. - - Returns: - The list component. - """ - ... - -class UnorderedList(List): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[Union[Var[list], list]] = None, - spacing: Optional[Union[Var[str], str]] = None, - style_position: Optional[Union[Var[str], str]] = None, - style_type: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "UnorderedList": - """Create a list component. - - Args: - *children: The children of the component. - items: A list of items to add to the list. - spacing: The space between each list item - style_position: Shorthand prop for listStylePosition - style_type: Shorthand prop for listStyleType - 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 properties of the component. - - Returns: - The list component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/stat.py b/reflex/components/chakra/datadisplay/stat.py deleted file mode 100644 index b9fe7f332..000000000 --- a/reflex/components/chakra/datadisplay/stat.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Statistics components.""" - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - - -class Stat(ChakraComponent): - """The Stat component is used to display some statistics. It can take in a label, a number and a help text.""" - - tag = "Stat" - - @classmethod - def create( - cls, *children, label=None, number=0, help_text=None, arrow_type=None, **props - ) -> Component: - """Create a stat component. - - Args: - *children: The children of the component. - label: A label for the stat component. - number: The value of the stat component. - help_text: A text added to the stat component. - arrow_type: The type of the arrow ("increase", "decrease", None) - **props: The properties of the component. - - Returns: - The stat component. - """ - if len(children) == 0: - children = [] - if label: - children.append(StatLabel.create(label)) - - children.append(StatNumber.create(number)) - - if help_text: - if arrow_type: - children.append( - StatHelpText.create( - help_text, StatArrow.create(type_=arrow_type) - ) - ) - else: - children.append(StatHelpText.create(help_text)) - - return super().create(*children, **props) - - -class StatLabel(ChakraComponent): - """A stat label component.""" - - tag = "StatLabel" - - -class StatNumber(ChakraComponent): - """The stat to display.""" - - tag = "StatNumber" - - -class StatHelpText(ChakraComponent): - """A helper text to display under the stat.""" - - tag = "StatHelpText" - - -class StatArrow(ChakraComponent): - """A stat arrow component indicating the direction of change.""" - - tag = "StatArrow" - - # The type of arrow, either increase or decrease. - type_: Var[str] - - -class StatGroup(ChakraComponent): - """A stat group component to evenly space out the stats.""" - - tag = "StatGroup" diff --git a/reflex/components/chakra/datadisplay/stat.pyi b/reflex/components/chakra/datadisplay/stat.pyi deleted file mode 100644 index 1201b65d1..000000000 --- a/reflex/components/chakra/datadisplay/stat.pyi +++ /dev/null @@ -1,478 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/stat.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - -class Stat(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - label=None, - number=0, - help_text=None, - arrow_type=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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Stat": - """Create a stat component. - - Args: - *children: The children of the component. - label: A label for the stat component. - number: The value of the stat component. - help_text: A text added to the stat component. - arrow_type: The type of the arrow ("increase", "decrease", None) - 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 properties of the component. - - Returns: - The stat component. - """ - ... - -class StatLabel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StatLabel": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StatNumber(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StatNumber": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StatHelpText(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StatHelpText": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StatArrow(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StatArrow": - """Create the component. - - Args: - *children: The children of the component. - type_: The type of arrow, either increase or decrease. - 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 of the component. - - Returns: - The component. - """ - ... - -class StatGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StatGroup": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/table.py b/reflex/components/chakra/datadisplay/table.py deleted file mode 100644 index cdc5c1fea..000000000 --- a/reflex/components/chakra/datadisplay/table.py +++ /dev/null @@ -1,304 +0,0 @@ -"""Table components.""" -from typing import List, Tuple - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.utils import types -from reflex.vars import Var - - -class Table(ChakraComponent): - """A table component.""" - - tag = "Table" - - # The color scheme of the table - color_scheme: Var[str] - - # The variant of the table style to use - variant: Var[str] - - # The size of the table - size: Var[str] - - # The placement of the table caption. - placement: Var[str] - - @classmethod - def create( - cls, *children, caption=None, headers=None, rows=None, footers=None, **props - ) -> Component: - """Create a table component. - - Args: - *children: The children of the component. - caption: The caption of the table component. - headers: The headers of the table component. - rows: The rows of the table component. - footers: The footers of the table component. - **props: The properties of the component. - - Returns: - The table component. - """ - if len(children) == 0: - children = [] - - if caption is not None: - children.append(TableCaption.create(caption)) - - if headers is not None: - children.append(Thead.create(headers=headers)) - - if rows is not None: - children.append(Tbody.create(rows=rows)) - - if footers is not None: - children.append(Tfoot.create(footers=footers)) - return super().create(*children, **props) - - -class Thead(ChakraComponent): - """A table header component.""" - - tag = "Thead" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead", "Tfoot"] - - @classmethod - def create(cls, *children, headers=None, **props) -> Component: - """Create a table header component. - - Args: - *children: The children of the component. - headers (list, optional): List of headers. Defaults to None. - **props: The properties of the component. - - Returns: - The table header component. - - """ - if len(children) == 0: - cls.validate_headers(headers) - - children = [Tr.create(cell_type="header", cells=headers)] - return super().create(*children, **props) - - @staticmethod - def validate_headers(headers): - """Type checking for table headers. - - Args: - headers: The table headers. - - Raises: - TypeError: If headers are not of type list or type tuple. - - """ - allowed_types = (list, tuple) - if ( - ( - isinstance(headers, Var) - and not types.check_type_in_allowed_types( - headers._var_type, allowed_types - ) - ) - or not isinstance(headers, Var) - and not types.check_type_in_allowed_types(type(headers), allowed_types) - ): - raise TypeError("table headers should be a list or tuple") - - -class Tbody(ChakraComponent): - """A table body component.""" - - tag = "Tbody" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead", "Tfoot", "Td", "Th"] - - @classmethod - def create(cls, *children, rows=None, **props) -> Component: - """Create a table body component. - - Args: - *children: The children of the component. - rows (list[list], optional): The rows of the table body. Defaults to None. - **props: The properties of the component. - - Returns: - Component: The table body component - """ - if len(children) == 0: - cls.validate_rows(rows) if rows is not None else None - - if isinstance(rows, Var): - children = [ - Foreach.create( - rows, lambda row: Tr.create(cell_type="data", cells=row) - ) - ] - else: - children = [ - Tr.create(cell_type="data", cells=row) for row in rows or [] - ] - return super().create(*children, **props) - - @staticmethod - def validate_rows(rows): - """Type checking for table rows. - - Args: - rows: Table rows. - - Raises: - TypeError: If rows are not lists or tuples containing inner lists or tuples. - """ - allowed_subclasses = (List, Tuple) - if isinstance(rows, Var): - outer_type = rows._var_type - inner_type = ( - outer_type.__args__[0] if hasattr(outer_type, "__args__") else None - ) - - # check that the outer container and inner container types are lists or tuples. - if not ( - types._issubclass(types.get_base_class(outer_type), allowed_subclasses) - and ( - inner_type is None - or types._issubclass( - types.get_base_class(inner_type), allowed_subclasses - ) - ) - ): - raise TypeError( - f"table rows should be a list or tuple containing inner lists or tuples. Got {outer_type} instead" - ) - elif not ( - types._issubclass(type(rows), allowed_subclasses) - and (not rows or types._issubclass(type(rows[0]), allowed_subclasses)) - ): - raise TypeError( - "table rows should be a list or tuple containing inner lists or tuples." - ) - - -class Tfoot(ChakraComponent): - """A table footer component.""" - - tag = "Tfoot" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead", "Td", "Th", "Tfoot"] - - @classmethod - def create(cls, *children, footers=None, **props) -> Component: - """Create a table footer component. - - Args: - *children: The children of the component. - footers (list, optional): List of footers. Defaults to None. - **props: The properties of the component. - - Returns: - The table footer component. - """ - if len(children) == 0: - cls.validate_footers(footers) - children = [Tr.create(cell_type="header", cells=footers)] - return super().create(*children, **props) - - @staticmethod - def validate_footers(footers): - """Type checking for table footers. - - Args: - footers: Table rows. - - Raises: - TypeError: If footers are not of type list. - """ - allowed_types = (list, tuple) - if ( - ( - isinstance(footers, Var) - and not types.check_type_in_allowed_types( - footers._var_type, allowed_types - ) - ) - or not isinstance(footers, Var) - and not types.check_type_in_allowed_types(type(footers), allowed_types) - ): - raise TypeError("table headers should be a list or tuple") - - -class Tr(ChakraComponent): - """A table row component.""" - - tag = "Tr" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead", "Tfoot", "Tr"] - - @classmethod - def create(cls, *children, cell_type: str = "", cells=None, **props) -> Component: - """Create a table row component. - - Args: - *children: The children of the component. - cell_type: the type of cells in this table row. "header" or "data". Defaults to None. - cells: The cells value to add in the table row. Defaults to None. - **props: The properties of the component. - - Returns: - The table row component - """ - types = {"header": Th, "data": Td} - cell_cls = types.get(cell_type) - if len(children) == 0 and cell_cls: - if isinstance(cells, Var): - children = [Foreach.create(cells, cell_cls.create)] - else: - children = [cell_cls.create(cell) for cell in cells or []] - return super().create(*children, **props) - - -class Th(ChakraComponent): - """A table header cell component.""" - - tag = "Th" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead", "Tr", "Td", "Th"] - - # Aligns the cell content to the right. - is_numeric: Var[bool] - - -class Td(ChakraComponent): - """A table data cell component.""" - - tag = "Td" - - # invalid children components - _invalid_children: List[str] = ["Tbody", "Thead"] - - # Aligns the cell content to the right. - is_numeric: Var[bool] - - -class TableCaption(ChakraComponent): - """A table caption component.""" - - tag = "TableCaption" - - # The placement of the table caption. This sets the `caption-side` CSS attribute. - placement: Var[str] - - -class TableContainer(ChakraComponent): - """The table container component renders a div that wraps the table component.""" - - tag = "TableContainer" diff --git a/reflex/components/chakra/datadisplay/table.pyi b/reflex/components/chakra/datadisplay/table.pyi deleted file mode 100644 index 5a271d259..000000000 --- a/reflex/components/chakra/datadisplay/table.pyi +++ /dev/null @@ -1,738 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/table.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Tuple -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.utils import types -from reflex.vars import Var - -class Table(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - caption=None, - headers=None, - rows=None, - footers=None, - color_scheme: Optional[Union[Var[str], str]] = None, - variant: Optional[Union[Var[str], str]] = None, - size: Optional[Union[Var[str], str]] = None, - placement: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Table": - """Create a table component. - - Args: - *children: The children of the component. - caption: The caption of the table component. - headers: The headers of the table component. - rows: The rows of the table component. - footers: The footers of the table component. - color_scheme: The color scheme of the table - variant: The variant of the table style to use - size: The size of the table - placement: The placement of the table caption. - 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 properties of the component. - - Returns: - The table component. - """ - ... - -class Thead(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - headers=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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Thead": - """Create a table header component. - - Args: - *children: The children of the component. - headers (list, optional): List of headers. Defaults to None. - 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 properties of the component. - - Returns: - The table header component. - - """ - ... - @staticmethod - def validate_headers(headers): ... - -class Tbody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - rows=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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tbody": - """Create a table body component. - - Args: - *children: The children of the component. - rows (list[list], optional): The rows of the table body. Defaults to None. - 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 properties of the component. - - Returns: - Component: The table body component - """ - ... - @staticmethod - def validate_rows(rows): ... - -class Tfoot(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - footers=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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tfoot": - """Create a table footer component. - - Args: - *children: The children of the component. - footers (list, optional): List of footers. Defaults to None. - 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 properties of the component. - - Returns: - The table footer component. - """ - ... - @staticmethod - def validate_footers(footers): ... - -class Tr(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - cell_type: Optional[str] = "", - cells=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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tr": - """Create a table row component. - - Args: - *children: The children of the component. - cell_type: the type of cells in this table row. "header" or "data". Defaults to None. - cells: The cells value to add in the table row. Defaults to None. - 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 properties of the component. - - Returns: - The table row component - """ - ... - -class Th(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_numeric: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Th": - """Create the component. - - Args: - *children: The children of the component. - is_numeric: Aligns the cell content to the right. - 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 of the component. - - Returns: - The component. - """ - ... - -class Td(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_numeric: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Td": - """Create the component. - - Args: - *children: The children of the component. - is_numeric: Aligns the cell content to the right. - 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 of the component. - - Returns: - The component. - """ - ... - -class TableCaption(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - placement: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TableCaption": - """Create the component. - - Args: - *children: The children of the component. - placement: The placement of the table caption. This sets the `caption-side` CSS attribute. - 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 of the component. - - Returns: - The component. - """ - ... - -class TableContainer(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TableContainer": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/datadisplay/tag.py b/reflex/components/chakra/datadisplay/tag.py deleted file mode 100644 index 4a02d22d9..000000000 --- a/reflex/components/chakra/datadisplay/tag.py +++ /dev/null @@ -1,84 +0,0 @@ -"""Chakra Tag Component.""" -from typing import Optional - -from reflex.components.chakra import ( - ChakraComponent, - LiteralTagColorScheme, - LiteralTagSize, - LiteralVariant, -) -from reflex.components.component import Component -from reflex.vars import Var - - -class TagLabel(ChakraComponent): - """The label of the tag.""" - - tag = "TagLabel" - - -class TagLeftIcon(ChakraComponent): - """The left icon of the tag.""" - - tag = "TagLeftIcon" - - -class TagRightIcon(ChakraComponent): - """The right icon of the tag.""" - - tag = "TagRightIcon" - - -class TagCloseButton(ChakraComponent): - """The close button of the tag.""" - - tag = "TagCloseButton" - - -class Tag(ChakraComponent): - """The parent wrapper that provides context for its children.""" - - tag = "Tag" - - # The visual color appearance of the tag. - # options: "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | - # "cyan" | "purple" | "pink" - # default: "gray" - color_scheme: Var[LiteralTagColorScheme] - - # The size of the tag - # options: "sm" | "md" | "lg" - # default: "md" - size: Var[LiteralTagSize] - - # The variant of the tag - # options: "solid" | "subtle" | "outline" - # default: "solid" - variant: Var[LiteralVariant] - - @classmethod - def create( - cls, - label: Component, - *, - left_icon: Optional[Component] = None, - right_icon: Optional[Component] = None, - close_button: Optional[Component] = None, - **props, - ) -> Component: - """Creates a Chakra Tag with a label and optionally left_icon, right_icon, and close_button, and returns it. - - Args: - label (Component): The label of the Tag that will be created. - left_icon (Optional[Component]): Should be a rx.TagLeftIcon instance. - right_icon (Optional[Component]): Should be a rx.TagRightIcon instance. - close_button (Optional[Component]): Should be a rx.TagCloseButton instance. - props: The properties to be passed to the component. - - Returns: - The `create()` method returns a Tag object. - """ - children = [ - x for x in (left_icon, label, right_icon, close_button) if x is not None - ] - return super().create(*children, **props) diff --git a/reflex/components/chakra/datadisplay/tag.pyi b/reflex/components/chakra/datadisplay/tag.pyi deleted file mode 100644 index de6e5b390..000000000 --- a/reflex/components/chakra/datadisplay/tag.pyi +++ /dev/null @@ -1,437 +0,0 @@ -"""Stub file for reflex/components/chakra/datadisplay/tag.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.chakra import ( - ChakraComponent, - LiteralTagColorScheme, - LiteralTagSize, - LiteralVariant, -) -from reflex.components.component import Component -from reflex.vars import Var - -class TagLabel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TagLabel": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class TagLeftIcon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TagLeftIcon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class TagRightIcon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TagRightIcon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class TagCloseButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TagCloseButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Tag(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - left_icon: Optional[Component] = None, - right_icon: Optional[Component] = None, - close_button: Optional[Component] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - ] - ], - Literal[ - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - ], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg"]], Literal["sm", "md", "lg"]] - ] = None, - variant: Optional[ - Union[ - Var[Literal["solid", "subtle", "outline"]], - Literal["solid", "subtle", "outline"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tag": - """Creates a Chakra Tag with a label and optionally left_icon, right_icon, and close_button, and returns it. - - Args: - label (Component): The label of the Tag that will be created. - left_icon (Optional[Component]): Should be a rx.TagLeftIcon instance. - right_icon (Optional[Component]): Should be a rx.TagRightIcon instance. - close_button (Optional[Component]): Should be a rx.TagCloseButton instance. - props: The properties to be passed to the component. - - Returns: - The `create()` method returns a Tag object. - """ - ... diff --git a/reflex/components/chakra/disclosure/__init__.py b/reflex/components/chakra/disclosure/__init__.py deleted file mode 100644 index 7a756c603..000000000 --- a/reflex/components/chakra/disclosure/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -"""Disclosure components.""" - -from .accordion import ( - Accordion, - AccordionButton, - AccordionIcon, - AccordionItem, - AccordionPanel, -) -from .tabs import Tab, TabList, TabPanel, TabPanels, Tabs -from .transition import Collapse, Fade, ScaleFade, Slide, SlideFade -from .visuallyhidden import VisuallyHidden - -__all__ = [f for f in dir() if f[0].isupper()] # type: ignore diff --git a/reflex/components/chakra/disclosure/accordion.py b/reflex/components/chakra/disclosure/accordion.py deleted file mode 100644 index f92bc3ad9..000000000 --- a/reflex/components/chakra/disclosure/accordion.py +++ /dev/null @@ -1,110 +0,0 @@ -"""Container to stack elements with spacing.""" - -from typing import List, Optional, Union - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - - -class Accordion(ChakraComponent): - """The wrapper that uses cloneElement to pass props to AccordionItem children.""" - - tag = "Accordion" - - # If true, multiple accordion items can be expanded at once. - allow_multiple: Var[bool] - - # If true, any expanded accordion item can be collapsed again. - allow_toggle: Var[bool] - - # The initial index(es) of the expanded accordion item(s). - default_index: Var[Optional[List[int]]] - - # The index(es) of the expanded accordion item - index: Var[Union[int, List[int]]] - - # If true, height animation and transitions will be disabled. - reduce_motion: Var[bool] - - @classmethod - def create( - cls, - *children, - items=None, - icon_pos="right", - allow_multiple: Optional[Var[bool]] = None, - allow_toggle: Optional[Var[bool]] = None, - **props, - ) -> Component: - """Create an accordion component. - - Args: - *children: The children of the component. - items: The items of the accordion component: list of tuples (label,panel) - icon_pos: The position of the arrow icon of the accordion. "right", "left" or None - allow_multiple: The allow_multiple property of the accordion. (True or False) - allow_toggle: The allow_toggle property of the accordion. (True or False) - **props: The properties of the component. - - Returns: - The accordion component - """ - if len(children) == 0: - children = [] - if not items: - items = [] - for label, panel in items: - if icon_pos == "right": - button = AccordionButton.create(label, AccordionIcon.create()) - elif icon_pos == "left": - button = AccordionButton.create(AccordionIcon.create(), label) - else: - button = AccordionButton.create(label) - - children.append( - AccordionItem.create( - button, - AccordionPanel.create(panel), - ) - ) - - # if allow_multiple is True, allow_toggle is implicitely used and does not need to be defined - if allow_multiple: - props.update({"allow_multiple": allow_multiple}) - elif allow_toggle: - props.update({"allow_toggle": allow_toggle}) - return super().create(*children, **props) - - -class AccordionItem(ChakraComponent): - """A single accordion item.""" - - tag = "AccordionItem" - - # A unique id for the accordion item. - id_: Var[str] - - # If true, the accordion item will be disabled. - is_disabled: Var[bool] - - # If true, the accordion item will be focusable. - is_focusable: Var[bool] - - -class AccordionButton(ChakraComponent): - """The button that toggles the expand/collapse state of the accordion item. This button must be wrapped in an element with role heading.""" - - tag = "AccordionButton" - - -class AccordionPanel(ChakraComponent): - """The container for the details to be revealed.""" - - tag = "AccordionPanel" - - -class AccordionIcon(ChakraComponent): - """A chevron-down icon that rotates based on the expanded/collapsed state.""" - - tag = "AccordionIcon" diff --git a/reflex/components/chakra/disclosure/accordion.pyi b/reflex/components/chakra/disclosure/accordion.pyi deleted file mode 100644 index 812b5f9ce..000000000 --- a/reflex/components/chakra/disclosure/accordion.pyi +++ /dev/null @@ -1,417 +0,0 @@ -"""Stub file for reflex/components/chakra/disclosure/accordion.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Optional, Union -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - -class Accordion(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items=None, - icon_pos="right", - allow_multiple: Optional[Union[Var[bool], bool]] = None, - allow_toggle: Optional[Union[Var[bool], bool]] = None, - default_index: Optional[ - Union[Var[Optional[List[int]]], Optional[List[int]]] - ] = None, - index: Optional[ - Union[Var[Union[int, List[int]]], Union[int, List[int]]] - ] = None, - reduce_motion: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Accordion": - """Create an accordion component. - - Args: - *children: The children of the component. - items: The items of the accordion component: list of tuples (label,panel) - icon_pos: The position of the arrow icon of the accordion. "right", "left" or None - allow_multiple: The allow_multiple property of the accordion. (True or False) - allow_toggle: The allow_toggle property of the accordion. (True or False) - default_index: The initial index(es) of the expanded accordion item(s). - index: The index(es) of the expanded accordion item - reduce_motion: If true, height animation and transitions will be disabled. - 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 properties of the component. - - Returns: - The accordion component - """ - ... - -class AccordionItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - id_: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AccordionItem": - """Create the component. - - Args: - *children: The children of the component. - id_: A unique id for the accordion item. - is_disabled: If true, the accordion item will be disabled. - is_focusable: If true, the accordion item will be focusable. - 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 of the component. - - Returns: - The component. - """ - ... - -class AccordionButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AccordionButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AccordionPanel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AccordionPanel": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AccordionIcon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AccordionIcon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/disclosure/tabs.py b/reflex/components/chakra/disclosure/tabs.py deleted file mode 100644 index 4600384b4..000000000 --- a/reflex/components/chakra/disclosure/tabs.py +++ /dev/null @@ -1,117 +0,0 @@ -"""Tab components.""" - -from typing import List, Optional, Tuple - -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralTabsVariant, - LiteralTagAlign, -) -from reflex.components.component import Component -from reflex.vars import Var - - -class Tabs(ChakraComponent): - """An accessible tabs component that provides keyboard interactions and ARIA attributes described in the WAI-ARIA Tabs Design Pattern. Tabs, provides context and state for all components.""" - - tag = "Tabs" - - # The alignment of the tabs ("center" | "end" | "start"). - align: Var[LiteralTagAlign] - - # The initial index of the selected tab (in uncontrolled mode). - default_index: Var[int] - - # The id of the tab. - id_: Var[str] - - # If true, tabs will stretch to width of the tablist. - is_fitted: Var[bool] - - # Performance booster. If true, rendering of the tab panel's will be deferred until it is selected. - is_lazy: Var[bool] - - # If true, the tabs will be manually activated and display its panel by pressing Space or Enter. If false, the tabs will be automatically activated and their panel is displayed when they receive focus. - is_manual: Var[bool] - - # The orientation of the tab list. - orientation: Var[str] - - # "line" | "enclosed" | "enclosed-colored" | "soft-rounded" | "solid-rounded" | "unstyled" - variant: Var[LiteralTabsVariant] - - # The color scheme of the tabs. - color_scheme: Var[LiteralColorScheme] - - # Index of the selected tab (in controlled mode). - index: Var[int] - - @classmethod - def create( - cls, *children, items: Optional[List[Tuple[str, str]]] = None, **props - ) -> Component: - """Create a tab component. - - Args: - *children: The children of the component. - items: The items for the tabs component, a list of tuple (label, panel) - **props: The properties of the component. - - Returns: - The tab component - """ - if len(children) == 0: - tabs = [] - panels = [] - if not items: - items = [] - for label, panel in items: - tabs.append(Tab.create(label)) - panels.append(TabPanel.create(panel)) - children = [TabList.create(*tabs), TabPanels.create(*panels)] # type: ignore - return super().create(*children, **props) - - -class Tab(ChakraComponent): - """An element that serves as a label for one of the tab panels and can be activated to display that panel..""" - - tag = "Tab" - - # If true, the Tab won't be toggleable. - is_disabled: Var[bool] - - # If true, the Tab will be selected. - is_selected: Var[bool] - - # The id of the tab. - id_: Var[str] - - # The id of the panel. - panel_id: Var[str] - - _valid_parents: List[str] = ["TabList"] - - -class TabList(ChakraComponent): - """Wrapper for the Tab components.""" - - tag = "TabList" - - _valid_parents: List[str] = ["Tabs"] - - -class TabPanels(ChakraComponent): - """Wrapper for the Tab components.""" - - tag = "TabPanels" - - _valid_parents: List[str] = ["Tabs"] - - -class TabPanel(ChakraComponent): - """An element that contains the content associated with a tab.""" - - tag = "TabPanel" - - _valid_parents: List[str] = ["TabPanels"] diff --git a/reflex/components/chakra/disclosure/tabs.pyi b/reflex/components/chakra/disclosure/tabs.pyi deleted file mode 100644 index 4de06ddcf..000000000 --- a/reflex/components/chakra/disclosure/tabs.pyi +++ /dev/null @@ -1,501 +0,0 @@ -"""Stub file for reflex/components/chakra/disclosure/tabs.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Optional, Tuple -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralTabsVariant, - LiteralTagAlign, -) -from reflex.components.component import Component -from reflex.vars import Var - -class Tabs(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[List[Tuple[str, str]]] = None, - align: Optional[ - Union[ - Var[Literal["center", "end", "start"]], - Literal["center", "end", "start"], - ] - ] = None, - default_index: Optional[Union[Var[int], int]] = None, - id_: Optional[Union[Var[str], str]] = None, - is_fitted: Optional[Union[Var[bool], bool]] = None, - is_lazy: Optional[Union[Var[bool], bool]] = None, - is_manual: Optional[Union[Var[bool], bool]] = None, - orientation: Optional[Union[Var[str], str]] = None, - variant: Optional[ - Union[ - Var[ - Literal[ - "line", - "enclosed", - "enclosed-colored", - "soft-rounded", - "solid-rounded", - "unstyled", - ] - ], - Literal[ - "line", - "enclosed", - "enclosed-colored", - "soft-rounded", - "solid-rounded", - "unstyled", - ], - ] - ] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - index: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tabs": - """Create a tab component. - - Args: - *children: The children of the component. - items: The items for the tabs component, a list of tuple (label, panel) - align: The alignment of the tabs ("center" | "end" | "start"). - default_index: The initial index of the selected tab (in uncontrolled mode). - id_: The id of the tab. - is_fitted: If true, tabs will stretch to width of the tablist. - is_lazy: Performance booster. If true, rendering of the tab panel's will be deferred until it is selected. - is_manual: If true, the tabs will be manually activated and display its panel by pressing Space or Enter. If false, the tabs will be automatically activated and their panel is displayed when they receive focus. - orientation: The orientation of the tab list. - variant: "line" | "enclosed" | "enclosed-colored" | "soft-rounded" | "solid-rounded" | "unstyled" - color_scheme: The color scheme of the tabs. - index: Index of the selected tab (in controlled mode). - 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 properties of the component. - - Returns: - The tab component - """ - ... - -class Tab(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_selected: Optional[Union[Var[bool], bool]] = None, - id_: Optional[Union[Var[str], str]] = None, - panel_id: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tab": - """Create the component. - - Args: - *children: The children of the component. - is_disabled: If true, the Tab won't be toggleable. - is_selected: If true, the Tab will be selected. - id_: The id of the tab. - panel_id: The id of the panel. - 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 of the component. - - Returns: - The component. - """ - ... - -class TabList(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TabList": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class TabPanels(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TabPanels": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class TabPanel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TabPanel": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/disclosure/transition.py b/reflex/components/chakra/disclosure/transition.py deleted file mode 100644 index f24afa827..000000000 --- a/reflex/components/chakra/disclosure/transition.py +++ /dev/null @@ -1,72 +0,0 @@ -"""A transition Component.""" -from typing import Union - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Transition(ChakraComponent): - """Base componemt of all transitions.""" - - # Show the component; triggers when enter or exit states - in_: Var[bool] - - # If true, the element will unmount when `in={false}` and animation is done - unmount_on_exit: Var[bool] - - -class Fade(Transition): - """Fade component cab be used show and hide content of your app.""" - - tag = "Fade" - - -class ScaleFade(Transition): - """Fade component can be scaled and reverse your app.""" - - tag = "ScaleFade" - - # The initial scale of the element - initial_scale: Var[float] - - # If true, the element will transition back to exit state - reverse: Var[bool] - - -class Slide(Transition): - """Side can be used show content below your app.""" - - tag = "Slide" - - # The direction to slide from - direction: Var[str] - - -class SlideFade(Transition): - """SlideFade component.""" - - tag = "SlideFade" - - # The offset on the horizontal or x axis - offsetX: Var[Union[str, int]] - - # The offset on the vertical or y axis - offsetY: Var[Union[str, int]] - - # If true, the element will be transitioned back to the offset when it leaves. Otherwise, it'll only fade out - reverse: Var[bool] - - -class Collapse(Transition): - """Collapse component can collapse some content.""" - - tag = "Collapse" - - # If true, the opacity of the content will be animated - animateOpacity: Var[bool] - - # The height you want the content in its expanded state. - endingHeight: Var[str] - - # The height you want the content in its collapsed state. - startingHeight: Var[Union[str, int]] diff --git a/reflex/components/chakra/disclosure/transition.pyi b/reflex/components/chakra/disclosure/transition.pyi deleted file mode 100644 index 368af2d3f..000000000 --- a/reflex/components/chakra/disclosure/transition.pyi +++ /dev/null @@ -1,510 +0,0 @@ -"""Stub file for reflex/components/chakra/disclosure/transition.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Union -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Transition(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Transition": - """Create the component. - - Args: - *children: The children of the component. - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... - -class Fade(Transition): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Fade": - """Create the component. - - Args: - *children: The children of the component. - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... - -class ScaleFade(Transition): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - initial_scale: Optional[Union[Var[float], float]] = None, - reverse: Optional[Union[Var[bool], bool]] = None, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ScaleFade": - """Create the component. - - Args: - *children: The children of the component. - initial_scale: The initial scale of the element - reverse: If true, the element will transition back to exit state - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... - -class Slide(Transition): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - direction: Optional[Union[Var[str], str]] = None, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Slide": - """Create the component. - - Args: - *children: The children of the component. - direction: The direction to slide from - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... - -class SlideFade(Transition): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - offsetX: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - offsetY: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - reverse: Optional[Union[Var[bool], bool]] = None, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SlideFade": - """Create the component. - - Args: - *children: The children of the component. - offsetX: The offset on the horizontal or x axis - offsetY: The offset on the vertical or y axis - reverse: If true, the element will be transitioned back to the offset when it leaves. Otherwise, it'll only fade out - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... - -class Collapse(Transition): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - animateOpacity: Optional[Union[Var[bool], bool]] = None, - endingHeight: Optional[Union[Var[str], str]] = None, - startingHeight: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - in_: Optional[Union[Var[bool], bool]] = None, - unmount_on_exit: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Collapse": - """Create the component. - - Args: - *children: The children of the component. - animateOpacity: If true, the opacity of the content will be animated - endingHeight: The height you want the content in its expanded state. - startingHeight: The height you want the content in its collapsed state. - in_: Show the component; triggers when enter or exit states - unmount_on_exit: If true, the element will unmount when `in={false}` and animation is done - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/disclosure/visuallyhidden.py b/reflex/components/chakra/disclosure/visuallyhidden.py deleted file mode 100644 index 161b130b2..000000000 --- a/reflex/components/chakra/disclosure/visuallyhidden.py +++ /dev/null @@ -1,9 +0,0 @@ -"""A component to display visually hidden text.""" - -from reflex.components.chakra import ChakraComponent - - -class VisuallyHidden(ChakraComponent): - """A component that visually hides content while still allowing it to be read by screen readers.""" - - tag = "VisuallyHidden" diff --git a/reflex/components/chakra/disclosure/visuallyhidden.pyi b/reflex/components/chakra/disclosure/visuallyhidden.pyi deleted file mode 100644 index e8e519e63..000000000 --- a/reflex/components/chakra/disclosure/visuallyhidden.pyi +++ /dev/null @@ -1,86 +0,0 @@ -"""Stub file for reflex/components/chakra/disclosure/visuallyhidden.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent - -class VisuallyHidden(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "VisuallyHidden": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/feedback/__init__.py b/reflex/components/chakra/feedback/__init__.py deleted file mode 100644 index 8037e366a..000000000 --- a/reflex/components/chakra/feedback/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Convenience functions to define core components.""" - -from .alert import Alert, AlertDescription, AlertIcon, AlertTitle -from .circularprogress import CircularProgress, CircularProgressLabel -from .progress import Progress -from .skeleton import Skeleton, SkeletonCircle, SkeletonText -from .spinner import Spinner diff --git a/reflex/components/chakra/feedback/alert.py b/reflex/components/chakra/feedback/alert.py deleted file mode 100644 index 57f99817f..000000000 --- a/reflex/components/chakra/feedback/alert.py +++ /dev/null @@ -1,68 +0,0 @@ -"""Alert components.""" - -from reflex.components.chakra import ( - ChakraComponent, - LiteralAlertVariant, - LiteralStatus, -) -from reflex.components.component import Component -from reflex.vars import Var - - -class Alert(ChakraComponent): - """An alert feedback box.""" - - tag = "Alert" - - # The status of the alert ("success" | "info" | "warning" | "error") - status: Var[LiteralStatus] - - # "subtle" | "left-accent" | "top-accent" | "solid" - variant: Var[LiteralAlertVariant] - - @classmethod - def create( - cls, *children, icon=True, title="Alert title", desc=None, **props - ) -> Component: - """Create an alert component. - - Args: - *children: The children of the component. - icon: The icon of the alert. - title: The title of the alert. - desc: The description of the alert - **props: The properties of the component. - - Returns: - The alert component. - """ - if len(children) == 0: - children = [] - - if icon: - children.append(AlertIcon.create()) - - children.append(AlertTitle.create(title)) - - if desc: - children.append(AlertDescription.create(desc)) - - return super().create(*children, **props) - - -class AlertIcon(ChakraComponent): - """An icon displayed in the alert.""" - - tag = "AlertIcon" - - -class AlertTitle(ChakraComponent): - """The title of the alert.""" - - tag = "AlertTitle" - - -class AlertDescription(ChakraComponent): - """AlertDescription composes the Box component.""" - - tag = "AlertDescription" diff --git a/reflex/components/chakra/feedback/alert.pyi b/reflex/components/chakra/feedback/alert.pyi deleted file mode 100644 index a27074a42..000000000 --- a/reflex/components/chakra/feedback/alert.pyi +++ /dev/null @@ -1,336 +0,0 @@ -"""Stub file for reflex/components/chakra/feedback/alert.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent, LiteralAlertVariant, LiteralStatus -from reflex.components.component import Component -from reflex.vars import Var - -class Alert(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - icon=True, - title="Alert title", - desc=None, - status: Optional[ - Union[ - Var[Literal["success", "info", "warning", "error"]], - Literal["success", "info", "warning", "error"], - ] - ] = None, - variant: Optional[ - Union[ - Var[Literal["subtle", "left-accent", "top-accent", "solid"]], - Literal["subtle", "left-accent", "top-accent", "solid"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Alert": - """Create an alert component. - - Args: - *children: The children of the component. - icon: The icon of the alert. - title: The title of the alert. - desc: The description of the alert - status: The status of the alert ("success" | "info" | "warning" | "error") - variant: "subtle" | "left-accent" | "top-accent" | "solid" - 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 properties of the component. - - Returns: - The alert component. - """ - ... - -class AlertIcon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertIcon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertTitle(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertTitle": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDescription(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDescription": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/feedback/circularprogress.py b/reflex/components/chakra/feedback/circularprogress.py deleted file mode 100644 index 45a0877eb..000000000 --- a/reflex/components/chakra/feedback/circularprogress.py +++ /dev/null @@ -1,67 +0,0 @@ -"""Container to stack elements with spacing.""" -from typing import Union - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - - -class CircularProgress(ChakraComponent): - """The CircularProgress component is used to indicate the progress for determinate and indeterminate processes.""" - - tag = "CircularProgress" - - # If true, the cap of the progress indicator will be rounded. - cap_is_round: Var[bool] - - # If true, the progress will be indeterminate and the value prop will be ignored - is_indeterminate: Var[bool] - - # Maximum value defining 100% progress made (must be higher than 'min') - max_: Var[int] - - # Minimum value defining 'no progress' (must be lower than 'max') - min_: Var[int] - - # This defines the stroke width of the svg circle. - thickness: Var[Union[str, int]] - - # The color name of the progress track. Use a color key in the theme object - track_color: Var[str] - - # Current progress (must be between min/max). - value: Var[int] - - # The desired valueText to use in place of the value. - value_text: Var[str] - - # The color name of the progress bar - color: Var[str] - - # The size of the circular progress - size: Var[str] - - @classmethod - def create(cls, *children, label=None, **props) -> Component: - """Create a circular progress component. - - Args: - *children: the children of the component. - label: A label to add in the circular progress. Defaults to None. - **props: the props of the component. - - Returns: - The circular progress component. - """ - if len(children) == 0: - children = [] - - if label is not None: - children.append(CircularProgressLabel.create(label)) - return super().create(*children, **props) - - -class CircularProgressLabel(ChakraComponent): - """Label of CircularProcess.""" - - tag = "CircularProgressLabel" diff --git a/reflex/components/chakra/feedback/circularprogress.pyi b/reflex/components/chakra/feedback/circularprogress.pyi deleted file mode 100644 index de349e47d..000000000 --- a/reflex/components/chakra/feedback/circularprogress.pyi +++ /dev/null @@ -1,187 +0,0 @@ -"""Stub file for reflex/components/chakra/feedback/circularprogress.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Union -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - -class CircularProgress(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - label=None, - cap_is_round: Optional[Union[Var[bool], bool]] = None, - is_indeterminate: Optional[Union[Var[bool], bool]] = None, - max_: Optional[Union[Var[int], int]] = None, - min_: Optional[Union[Var[int], int]] = None, - thickness: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - track_color: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[int], int]] = None, - value_text: Optional[Union[Var[str], str]] = None, - color: Optional[Union[Var[str], str]] = None, - size: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CircularProgress": - """Create a circular progress component. - - Args: - *children: the children of the component. - label: A label to add in the circular progress. Defaults to None. - cap_is_round: If true, the cap of the progress indicator will be rounded. - is_indeterminate: If true, the progress will be indeterminate and the value prop will be ignored - max_: Maximum value defining 100% progress made (must be higher than 'min') - min_: Minimum value defining 'no progress' (must be lower than 'max') - thickness: This defines the stroke width of the svg circle. - track_color: The color name of the progress track. Use a color key in the theme object - value: Current progress (must be between min/max). - value_text: The desired valueText to use in place of the value. - color: The color name of the progress bar - size: The size of the circular progress - 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 of the component. - - Returns: - The circular progress component. - """ - ... - -class CircularProgressLabel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CircularProgressLabel": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/feedback/progress.py b/reflex/components/chakra/feedback/progress.py deleted file mode 100644 index 6dbaf1e94..000000000 --- a/reflex/components/chakra/feedback/progress.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Container to stack elements with spacing.""" - -from typing import Union - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Progress(ChakraComponent): - """A bar to display progress.""" - - tag = "Progress" - - # If true, the progress bar will show stripe - has_stripe: Var[bool] - - # If true, and has_stripe is true, the stripes will be animated - is_animated: Var[bool] - - # If true, the progress will be indeterminate and the value prop will be ignored - is_indeterminate: Var[bool] - - # The maximum value of the progress - max_: Var[int] - - # The minimum value of the progress - min_: Var[int] - - # The value of the progress indicator. If undefined the progress bar will be in indeterminate state - value: Var[Union[int, float]] - - # The color scheme of the progress bar. - color_scheme: Var[str] diff --git a/reflex/components/chakra/feedback/progress.pyi b/reflex/components/chakra/feedback/progress.pyi deleted file mode 100644 index aae921ff4..000000000 --- a/reflex/components/chakra/feedback/progress.pyi +++ /dev/null @@ -1,102 +0,0 @@ -"""Stub file for reflex/components/chakra/feedback/progress.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Union -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Progress(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - has_stripe: Optional[Union[Var[bool], bool]] = None, - is_animated: Optional[Union[Var[bool], bool]] = None, - is_indeterminate: Optional[Union[Var[bool], bool]] = None, - max_: Optional[Union[Var[int], int]] = None, - min_: Optional[Union[Var[int], int]] = None, - value: Optional[Union[Var[Union[int, float]], Union[int, float]]] = None, - color_scheme: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Progress": - """Create the component. - - Args: - *children: The children of the component. - has_stripe: If true, the progress bar will show stripe - is_animated: If true, and has_stripe is true, the stripes will be animated - is_indeterminate: If true, the progress will be indeterminate and the value prop will be ignored - max_: The maximum value of the progress - min_: The minimum value of the progress - value: The value of the progress indicator. If undefined the progress bar will be in indeterminate state - color_scheme: The color scheme of the progress bar. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/feedback/skeleton.py b/reflex/components/chakra/feedback/skeleton.py deleted file mode 100644 index ef71cd514..000000000 --- a/reflex/components/chakra/feedback/skeleton.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Container to stack elements with spacing.""" - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Skeleton(ChakraComponent): - """Skeleton is used to display the loading state of some components. You can use it as a standalone component. Or to wrap another component to take the same height and width.""" - - tag = "Skeleton" - - # The color at the animation end - end_color: Var[str] - - # The fadeIn duration in seconds - fade_duration: Var[float] - - # If true, it'll render its children with a nice fade transition - is_loaded: Var[bool] - - # The animation speed in seconds - speed: Var[float] - - # The color at the animation start - start_color: Var[str] - - -class SkeletonCircle(ChakraComponent): - """SkeletonCircle is used to display the loading state of some components.""" - - tag = "SkeletonCircle" - - # The color at the animation end - end_color: Var[str] - - # The fadeIn duration in seconds - fade_duration: Var[float] - - # If true, it'll render its children with a nice fade transition - is_loaded: Var[bool] - - # The animation speed in seconds - speed: Var[float] - - # The color at the animation start - start_color: Var[str] - - -class SkeletonText(ChakraComponent): - """SkeletonText is used to display the loading state of some components.""" - - tag = "SkeletonText" - - # The color at the animation end - end_color: Var[str] - - # The fadeIn duration in seconds - fade_duration: Var[float] - - # If true, it'll render its children with a nice fade transition - is_loaded: Var[bool] - - # The animation speed in seconds - speed: Var[float] - - # The color at the animation start - start_color: Var[str] - - # Number is lines of text. - no_of_lines: Var[int] diff --git a/reflex/components/chakra/feedback/skeleton.pyi b/reflex/components/chakra/feedback/skeleton.pyi deleted file mode 100644 index c0a964407..000000000 --- a/reflex/components/chakra/feedback/skeleton.pyi +++ /dev/null @@ -1,271 +0,0 @@ -"""Stub file for reflex/components/chakra/feedback/skeleton.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Skeleton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - end_color: Optional[Union[Var[str], str]] = None, - fade_duration: Optional[Union[Var[float], float]] = None, - is_loaded: Optional[Union[Var[bool], bool]] = None, - speed: Optional[Union[Var[float], float]] = None, - start_color: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Skeleton": - """Create the component. - - Args: - *children: The children of the component. - end_color: The color at the animation end - fade_duration: The fadeIn duration in seconds - is_loaded: If true, it'll render its children with a nice fade transition - speed: The animation speed in seconds - start_color: The color at the animation start - 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 of the component. - - Returns: - The component. - """ - ... - -class SkeletonCircle(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - end_color: Optional[Union[Var[str], str]] = None, - fade_duration: Optional[Union[Var[float], float]] = None, - is_loaded: Optional[Union[Var[bool], bool]] = None, - speed: Optional[Union[Var[float], float]] = None, - start_color: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SkeletonCircle": - """Create the component. - - Args: - *children: The children of the component. - end_color: The color at the animation end - fade_duration: The fadeIn duration in seconds - is_loaded: If true, it'll render its children with a nice fade transition - speed: The animation speed in seconds - start_color: The color at the animation start - 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 of the component. - - Returns: - The component. - """ - ... - -class SkeletonText(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - end_color: Optional[Union[Var[str], str]] = None, - fade_duration: Optional[Union[Var[float], float]] = None, - is_loaded: Optional[Union[Var[bool], bool]] = None, - speed: Optional[Union[Var[float], float]] = None, - start_color: Optional[Union[Var[str], str]] = None, - no_of_lines: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SkeletonText": - """Create the component. - - Args: - *children: The children of the component. - end_color: The color at the animation end - fade_duration: The fadeIn duration in seconds - is_loaded: If true, it'll render its children with a nice fade transition - speed: The animation speed in seconds - start_color: The color at the animation start - no_of_lines: Number is lines of text. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/feedback/spinner.py b/reflex/components/chakra/feedback/spinner.py deleted file mode 100644 index eed335ce1..000000000 --- a/reflex/components/chakra/feedback/spinner.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Container to stack elements with spacing.""" - -from reflex.components.chakra import ChakraComponent, LiteralSpinnerSize -from reflex.vars import Var - - -class Spinner(ChakraComponent): - """The component that spins.""" - - tag = "Spinner" - - # The color of the empty area in the spinner - empty_color: Var[str] - - # For accessibility, it is important to add a fallback loading text. This text will be visible to screen readers. - label: Var[str] - - # The speed of the spinner must be as a string and in seconds '1s'. Default is '0.45s'. - speed: Var[str] - - # The thickness of the spinner. - thickness: Var[int] - - # "xs" | "sm" | "md" | "lg" | "xl" - size: Var[LiteralSpinnerSize] diff --git a/reflex/components/chakra/feedback/spinner.pyi b/reflex/components/chakra/feedback/spinner.pyi deleted file mode 100644 index 55ea26d72..000000000 --- a/reflex/components/chakra/feedback/spinner.pyi +++ /dev/null @@ -1,102 +0,0 @@ -"""Stub file for reflex/components/chakra/feedback/spinner.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent, LiteralSpinnerSize -from reflex.vars import Var - -class Spinner(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - empty_color: Optional[Union[Var[str], str]] = None, - label: Optional[Union[Var[str], str]] = None, - speed: Optional[Union[Var[str], str]] = None, - thickness: Optional[Union[Var[int], int]] = None, - size: Optional[ - Union[ - Var[Literal["sm", "md", "lg", "xs", "xl"]], - Literal["sm", "md", "lg", "xs", "xl"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Spinner": - """Create the component. - - Args: - *children: The children of the component. - empty_color: The color of the empty area in the spinner - label: For accessibility, it is important to add a fallback loading text. This text will be visible to screen readers. - speed: The speed of the spinner must be as a string and in seconds '1s'. Default is '0.45s'. - thickness: The thickness of the spinner. - size: "xs" | "sm" | "md" | "lg" | "xl" - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/__init__.py b/reflex/components/chakra/forms/__init__.py deleted file mode 100644 index 7bf225e35..000000000 --- a/reflex/components/chakra/forms/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -"""Convenience functions to define core components.""" - -from .button import Button, ButtonGroup -from .checkbox import Checkbox, CheckboxGroup -from .colormodeswitch import ( - ColorModeButton, - ColorModeIcon, - ColorModeScript, - ColorModeSwitch, -) -from .date_picker import DatePicker -from .date_time_picker import DateTimePicker -from .editable import Editable, EditableInput, EditablePreview, EditableTextarea -from .email import Email -from .form import Form, FormControl, FormErrorMessage, FormHelperText, FormLabel -from .iconbutton import IconButton -from .input import ( - Input, - InputGroup, - InputLeftAddon, - InputLeftElement, - InputRightAddon, - InputRightElement, -) -from .multiselect import Option as MultiSelectOption -from .multiselect import Select as MultiSelect -from .numberinput import ( - NumberDecrementStepper, - NumberIncrementStepper, - NumberInput, - NumberInputField, - NumberInputStepper, -) -from .password import Password -from .pininput import PinInput, PinInputField -from .radio import Radio, RadioGroup -from .rangeslider import ( - RangeSlider, - RangeSliderFilledTrack, - RangeSliderThumb, - RangeSliderTrack, -) -from .select import Option, Select -from .slider import Slider, SliderFilledTrack, SliderMark, SliderThumb, SliderTrack -from .switch import Switch -from .textarea import TextArea -from .time_picker import TimePicker - -__all__ = [f for f in dir() if f[0].isupper()] # type: ignore diff --git a/reflex/components/chakra/forms/button.py b/reflex/components/chakra/forms/button.py deleted file mode 100644 index bbadbf73d..000000000 --- a/reflex/components/chakra/forms/button.py +++ /dev/null @@ -1,82 +0,0 @@ -"""A button component.""" -from typing import List - -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralButtonVariant, - LiteralColorScheme, - LiteralSpinnerPlacement, -) -from reflex.vars import Var - - -class Button(ChakraComponent): - """The Button component is used to trigger an event or event, such as submitting a form, opening a dialog, canceling an event, or performing a delete operation.""" - - tag = "Button" - - # The space between the button icon and label. - icon_spacing: Var[int] - - # If true, the button will be styled in its active state. - is_active: Var[bool] - - # If true, the button will be styled in its disabled state. - is_disabled: Var[bool] - - # If true, the button will take up the full width of its container. - is_full_width: Var[bool] - - # If true, the button will show a spinner. - is_loading: Var[bool] - - # The label to show in the button when isLoading is true If no text is passed, it only shows the spinner. - loading_text: Var[str] - - # "lg" | "md" | "sm" | "xs" - size: Var[LiteralButtonSize] - - # "ghost" | "outline" | "solid" | "link" | "unstyled" - variant: Var[LiteralButtonVariant] - - # Built in color scheme for ease of use. - # Options: - # "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" - # | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - color_scheme: Var[LiteralColorScheme] - - # Position of the loading spinner. - # Options: - # "start" | "end" - spinner_placement: Var[LiteralSpinnerPlacement] - - # The type of button. - type_: Var[str] - - # Components that are not allowed as children. - _invalid_children: List[str] = ["Button", "MenuButton"] - - # The name of the form field - name: Var[str] - - -class ButtonGroup(ChakraComponent): - """A group of buttons.""" - - tag = "ButtonGroup" - - # If true, the borderRadius of button that are direct children will be altered to look flushed together. - is_attached: Var[bool] - - # If true, all wrapped button will be disabled. - is_disabled: Var[bool] - - # The spacing between the buttons. - spacing: Var[int] - - # "lg" | "md" | "sm" | "xs" - size: Var[LiteralButtonSize] - - # "ghost" | "outline" | "solid" | "link" | "unstyled" - variant: Var[LiteralButtonVariant] diff --git a/reflex/components/chakra/forms/button.pyi b/reflex/components/chakra/forms/button.pyi deleted file mode 100644 index 72a1f280e..000000000 --- a/reflex/components/chakra/forms/button.pyi +++ /dev/null @@ -1,267 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/button.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralButtonVariant, - LiteralColorScheme, - LiteralSpinnerPlacement, -) -from reflex.vars import Var - -class Button(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - icon_spacing: Optional[Union[Var[int], int]] = None, - is_active: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_full_width: Optional[Union[Var[bool], bool]] = None, - is_loading: Optional[Union[Var[bool], bool]] = None, - loading_text: Optional[Union[Var[str], str]] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - variant: Optional[ - Union[ - Var[Literal["ghost", "outline", "solid", "link", "unstyled"]], - Literal["ghost", "outline", "solid", "link", "unstyled"], - ] - ] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - spinner_placement: Optional[ - Union[Var[Literal["start", "end"]], Literal["start", "end"]] - ] = None, - type_: Optional[Union[Var[str], str]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Button": - """Create the component. - - Args: - *children: The children of the component. - icon_spacing: The space between the button icon and label. - is_active: If true, the button will be styled in its active state. - is_disabled: If true, the button will be styled in its disabled state. - is_full_width: If true, the button will take up the full width of its container. - is_loading: If true, the button will show a spinner. - loading_text: The label to show in the button when isLoading is true If no text is passed, it only shows the spinner. - size: "lg" | "md" | "sm" | "xs" - variant: "ghost" | "outline" | "solid" | "link" | "unstyled" - color_scheme: Built in color scheme for ease of use. Options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - spinner_placement: Position of the loading spinner. Options: "start" | "end" - type_: The type of button. - name: The name of the form field - 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 of the component. - - Returns: - The component. - """ - ... - -class ButtonGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_attached: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - spacing: Optional[Union[Var[int], int]] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - variant: Optional[ - Union[ - Var[Literal["ghost", "outline", "solid", "link", "unstyled"]], - Literal["ghost", "outline", "solid", "link", "unstyled"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ButtonGroup": - """Create the component. - - Args: - *children: The children of the component. - is_attached: If true, the borderRadius of button that are direct children will be altered to look flushed together. - is_disabled: If true, all wrapped button will be disabled. - spacing: The spacing between the buttons. - size: "lg" | "md" | "sm" | "xs" - variant: "ghost" | "outline" | "solid" | "link" | "unstyled" - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/checkbox.py b/reflex/components/chakra/forms/checkbox.py deleted file mode 100644 index b0e29ea16..000000000 --- a/reflex/components/chakra/forms/checkbox.py +++ /dev/null @@ -1,86 +0,0 @@ -"""A checkbox component.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralTagSize, -) -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class Checkbox(ChakraComponent): - """The Checkbox component is used in forms when a user needs to select multiple values from several options.""" - - tag = "Checkbox" - - # Color scheme for checkbox. - # Options: - # "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" - # | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - color_scheme: Var[LiteralColorScheme] - - # "sm" | "md" | "lg" - size: Var[LiteralTagSize] - - # If true, the checkbox will be checked. - is_checked: Var[bool] - - # If true, the checkbox will be disabled - is_disabled: Var[bool] - - # If true and is_disabled is passed, the checkbox will remain tabbable but not interactive - is_focusable: Var[bool] - - # If true, the checkbox will be indeterminate. This only affects the icon shown inside checkbox and does not modify the is_checked var. - is_indeterminate: Var[bool] - - # If true, the checkbox is marked as invalid. Changes style of unchecked state. - is_invalid: Var[bool] - - # If true, the checkbox will be readonly - is_read_only: Var[bool] - - # If true, the checkbox input is marked as required, and required attribute will be added - is_required: Var[bool] - - # The name of the input field in a checkbox (Useful for form submission). - name: Var[str] - - # The value of the input field when checked (use is_checked prop for a bool) - value: Var[str] = Var.create("true") # type: ignore - - # The spacing between the checkbox and its label text (0.5rem) - spacing: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.checked], - } - - -class CheckboxGroup(ChakraComponent): - """A group of checkboxes.""" - - tag = "CheckboxGroup" - - # The value of the checkbox group - value: Var[str] - - # The initial value of the checkbox group - default_value: Var[str] - - # If true, all wrapped checkbox inputs will be disabled - is_disabled: Var[bool] - - # If true, input elements will receive checked attribute instead of isChecked. This assumes, you're using native radio inputs - is_native: Var[bool] diff --git a/reflex/components/chakra/forms/checkbox.pyi b/reflex/components/chakra/forms/checkbox.pyi deleted file mode 100644 index abb17a2dd..000000000 --- a/reflex/components/chakra/forms/checkbox.pyi +++ /dev/null @@ -1,250 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/checkbox.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralColorScheme, LiteralTagSize -from reflex.constants import EventTriggers -from reflex.vars import Var - -class Checkbox(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg"]], Literal["sm", "md", "lg"]] - ] = None, - is_checked: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = None, - is_indeterminate: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - name: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - spacing: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Checkbox": - """Create the component. - - Args: - *children: The children of the component. - color_scheme: Color scheme for checkbox. Options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - size: "sm" | "md" | "lg" - is_checked: If true, the checkbox will be checked. - is_disabled: If true, the checkbox will be disabled - is_focusable: If true and is_disabled is passed, the checkbox will remain tabbable but not interactive - is_indeterminate: If true, the checkbox will be indeterminate. This only affects the icon shown inside checkbox and does not modify the is_checked var. - is_invalid: If true, the checkbox is marked as invalid. Changes style of unchecked state. - is_read_only: If true, the checkbox will be readonly - is_required: If true, the checkbox input is marked as required, and required attribute will be added - name: The name of the input field in a checkbox (Useful for form submission). - value: The value of the input field when checked (use is_checked prop for a bool) - spacing: The spacing between the checkbox and its label text (0.5rem) - 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 of the component. - - Returns: - The component. - """ - ... - -class CheckboxGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_native: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CheckboxGroup": - """Create the component. - - Args: - *children: The children of the component. - value: The value of the checkbox group - default_value: The initial value of the checkbox group - is_disabled: If true, all wrapped checkbox inputs will be disabled - is_native: If true, input elements will receive checked attribute instead of isChecked. This assumes, you're using native radio inputs - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/colormodeswitch.py b/reflex/components/chakra/forms/colormodeswitch.py deleted file mode 100644 index b88e5895b..000000000 --- a/reflex/components/chakra/forms/colormodeswitch.py +++ /dev/null @@ -1,103 +0,0 @@ -"""A switch component for toggling color_mode. - -To style components based on color mode, use style props with `color_mode_cond`: - -``` -rx.text( - "Hover over me", - _hover={ - "background": rx.color_mode_cond( - light="var(--chakra-colors-gray-200)", - dark="var(--chakra-colors-gray-700)", - ), - }, -) -``` -""" -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import BaseComponent -from reflex.components.core.cond import Cond, color_mode_cond -from reflex.style import LIGHT_COLOR_MODE, color_mode, toggle_color_mode - -from .button import Button -from .switch import Switch - -DEFAULT_LIGHT_ICON: Icon = Icon.create(tag="sun") -DEFAULT_DARK_ICON: Icon = Icon.create(tag="moon") - - -class ColorModeIcon(Cond): - """Displays the current color mode as an icon.""" - - @classmethod - def create( - cls, - light_component: BaseComponent | None = None, - dark_component: BaseComponent | None = None, - ): - """Create an icon component based on color_mode. - - Args: - light_component: the component to display when color mode is default - dark_component: the component to display when color mode is dark (non-default) - - Returns: - The conditionally rendered component - """ - return color_mode_cond( - light=light_component or DEFAULT_LIGHT_ICON, - dark=dark_component or DEFAULT_DARK_ICON, - ) - - -class ColorModeSwitch(Switch): - """Switch for toggling chakra light / dark mode via toggle_color_mode.""" - - @classmethod - def create(cls, *children, **props): - """Create a switch component bound to color_mode. - - Args: - *children: The children of the component. - **props: The props to pass to the component. - - Returns: - The switch component. - """ - return Switch.create( - *children, - is_checked=color_mode != LIGHT_COLOR_MODE, - on_change=toggle_color_mode, - **props, - ) - - -class ColorModeButton(Button): - """Button for toggling chakra light / dark mode via toggle_color_mode.""" - - @classmethod - def create(cls, *children, **props): - """Create a button component that calls toggle_color_mode on click. - - Args: - *children: The children of the component. - **props: The props to pass to the component. - - Returns: - The switch component. - """ - return Button.create( - *children, - on_click=toggle_color_mode, - **props, - ) - - -class ColorModeScript(ChakraComponent): - """Chakra color mode script.""" - - tag = "ColorModeScript" - initialColorMode = LIGHT_COLOR_MODE diff --git a/reflex/components/chakra/forms/colormodeswitch.pyi b/reflex/components/chakra/forms/colormodeswitch.pyi deleted file mode 100644 index 63ca2ffb6..000000000 --- a/reflex/components/chakra/forms/colormodeswitch.pyi +++ /dev/null @@ -1,472 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/colormodeswitch.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import BaseComponent -from reflex.components.core.cond import Cond, color_mode_cond -from reflex.style import LIGHT_COLOR_MODE, color_mode, toggle_color_mode -from .button import Button -from .switch import Switch - -DEFAULT_LIGHT_ICON: Icon -DEFAULT_DARK_ICON: Icon - -class ColorModeIcon(Cond): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - cond: Optional[Union[Var[Any], Any]] = None, - comp1: Optional[BaseComponent] = None, - comp2: Optional[BaseComponent] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ColorModeIcon": - """Create an icon component based on color_mode. - - Args: - light_component: the component to display when color mode is default - dark_component: the component to display when color mode is dark (non-default) - - Returns: - The conditionally rendered component - """ - ... - -class ColorModeSwitch(Switch): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_checked: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - name: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - spacing: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ColorModeSwitch": - """Create a switch component bound to color_mode. - - Args: - *children: The children of the component. - is_checked: If true, the switch will be checked. You'll need to set an on_change event handler to update its value (since it is now controlled) - is_disabled: If true, the switch will be disabled - is_focusable: If true and is_disabled prop is set, the switch will remain tabbable but not interactive. - is_invalid: If true, the switch is marked as invalid. Changes style of unchecked state. - is_read_only: If true, the switch will be readonly - is_required: If true, the switch will be required - name: The name of the input field in a switch (Useful for form submission). - value: The value of the input field when checked (use is_checked prop for a bool) - spacing: The spacing between the switch and its label text (0.5rem) - placeholder: The placeholder text. - color_scheme: The color scheme of the switch (e.g. "blue", "green", "red", etc.) - 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 switch component. - """ - ... - -class ColorModeButton(Button): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - icon_spacing: Optional[Union[Var[int], int]] = None, - is_active: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_full_width: Optional[Union[Var[bool], bool]] = None, - is_loading: Optional[Union[Var[bool], bool]] = None, - loading_text: Optional[Union[Var[str], str]] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - variant: Optional[ - Union[ - Var[Literal["ghost", "outline", "solid", "link", "unstyled"]], - Literal["ghost", "outline", "solid", "link", "unstyled"], - ] - ] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - spinner_placement: Optional[ - Union[Var[Literal["start", "end"]], Literal["start", "end"]] - ] = None, - type_: Optional[Union[Var[str], str]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ColorModeButton": - """Create a button component that calls toggle_color_mode on click. - - Args: - *children: The children of the component. - icon_spacing: The space between the button icon and label. - is_active: If true, the button will be styled in its active state. - is_disabled: If true, the button will be styled in its disabled state. - is_full_width: If true, the button will take up the full width of its container. - is_loading: If true, the button will show a spinner. - loading_text: The label to show in the button when isLoading is true If no text is passed, it only shows the spinner. - size: "lg" | "md" | "sm" | "xs" - variant: "ghost" | "outline" | "solid" | "link" | "unstyled" - color_scheme: Built in color scheme for ease of use. Options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - spinner_placement: Position of the loading spinner. Options: "start" | "end" - type_: The type of button. - name: The name of the form field - 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 switch component. - """ - ... - -class ColorModeScript(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ColorModeScript": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/date_picker.py b/reflex/components/chakra/forms/date_picker.py deleted file mode 100644 index 350e700b6..000000000 --- a/reflex/components/chakra/forms/date_picker.py +++ /dev/null @@ -1,11 +0,0 @@ -"""A date input component.""" - -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - - -class DatePicker(Input): - """A date input component.""" - - # The type of input. - type_: Var[str] = "date" # type: ignore diff --git a/reflex/components/chakra/forms/date_picker.pyi b/reflex/components/chakra/forms/date_picker.pyi deleted file mode 100644 index 0fdbbaafa..000000000 --- a/reflex/components/chakra/forms/date_picker.pyi +++ /dev/null @@ -1,129 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/date_picker.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - -class DatePicker(Input): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DatePicker": - """Create an Input component. - - Args: - *children: The children of the component. - type_: The type of input. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/date_time_picker.py b/reflex/components/chakra/forms/date_time_picker.py deleted file mode 100644 index ae245a907..000000000 --- a/reflex/components/chakra/forms/date_time_picker.py +++ /dev/null @@ -1,11 +0,0 @@ -"""A datetime-local input component.""" - -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - - -class DateTimePicker(Input): - """A datetime-local input component.""" - - # The type of input. - type_: Var[str] = "datetime-local" # type: ignore diff --git a/reflex/components/chakra/forms/date_time_picker.pyi b/reflex/components/chakra/forms/date_time_picker.pyi deleted file mode 100644 index 73ddea1af..000000000 --- a/reflex/components/chakra/forms/date_time_picker.pyi +++ /dev/null @@ -1,129 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/date_time_picker.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - -class DateTimePicker(Input): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DateTimePicker": - """Create an Input component. - - Args: - *children: The children of the component. - type_: The type of input. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/editable.py b/reflex/components/chakra/forms/editable.py deleted file mode 100644 index d09a90a3f..000000000 --- a/reflex/components/chakra/forms/editable.py +++ /dev/null @@ -1,70 +0,0 @@ -"""An editable component.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class Editable(ChakraComponent): - """The wrapper component that provides context value.""" - - tag = "Editable" - - # If true, the Editable will be disabled. - is_disabled: Var[bool] - - # If true, the read only view, has a tabIndex set to 0 so it can receive focus via the keyboard or click. - is_preview_focusable: Var[bool] - - # The placeholder text when the value is empty. - placeholder: Var[str] - - # If true, the input's text will be highlighted on focus. - select_all_on_focus: Var[bool] - - # If true, the Editable will start with edit mode by default. - start_with_edit_view: Var[bool] - - # If true, it'll update the value onBlur and turn off the edit mode. - submit_on_blur: Var[bool] - - # The value of the Editable in both edit & preview mode - value: Var[str] - - # The initial value of the Editable in both edit and preview mode. - default_value: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - EventTriggers.ON_EDIT: lambda e0: [e0], - EventTriggers.ON_SUBMIT: lambda e0: [e0], - EventTriggers.ON_CANCEL: lambda e0: [e0], - } - - -class EditableInput(ChakraComponent): - """The edit view of the component. It shows when you click or focus on the text.""" - - tag = "EditableInput" - - -class EditableTextarea(ChakraComponent): - """Use the textarea element to handle multi line text input in an editable context.""" - - tag = "EditableTextarea" - - -class EditablePreview(ChakraComponent): - """The read-only view of the component.""" - - tag = "EditablePreview" diff --git a/reflex/components/chakra/forms/editable.pyi b/reflex/components/chakra/forms/editable.pyi deleted file mode 100644 index aa1395d4a..000000000 --- a/reflex/components/chakra/forms/editable.pyi +++ /dev/null @@ -1,346 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/editable.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent -from reflex.constants import EventTriggers -from reflex.vars import Var - -class Editable(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_preview_focusable: Optional[Union[Var[bool], bool]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - select_all_on_focus: Optional[Union[Var[bool], bool]] = None, - start_with_edit_view: Optional[Union[Var[bool], bool]] = None, - submit_on_blur: Optional[Union[Var[bool], bool]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_cancel: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_edit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Editable": - """Create the component. - - Args: - *children: The children of the component. - is_disabled: If true, the Editable will be disabled. - is_preview_focusable: If true, the read only view, has a tabIndex set to 0 so it can receive focus via the keyboard or click. - placeholder: The placeholder text when the value is empty. - select_all_on_focus: If true, the input's text will be highlighted on focus. - start_with_edit_view: If true, the Editable will start with edit mode by default. - submit_on_blur: If true, it'll update the value onBlur and turn off the edit mode. - value: The value of the Editable in both edit & preview mode - default_value: The initial value of the Editable in both edit and preview mode. - 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 of the component. - - Returns: - The component. - """ - ... - -class EditableInput(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "EditableInput": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class EditableTextarea(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "EditableTextarea": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class EditablePreview(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "EditablePreview": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/email.py b/reflex/components/chakra/forms/email.py deleted file mode 100644 index 18fadef2d..000000000 --- a/reflex/components/chakra/forms/email.py +++ /dev/null @@ -1,11 +0,0 @@ -"""An email input component.""" - -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - - -class Email(Input): - """An email input component.""" - - # The type of input. - type_: Var[str] = "email" # type: ignore diff --git a/reflex/components/chakra/forms/email.pyi b/reflex/components/chakra/forms/email.pyi deleted file mode 100644 index c616049b7..000000000 --- a/reflex/components/chakra/forms/email.pyi +++ /dev/null @@ -1,129 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/email.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - -class Email(Input): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Email": - """Create an Input component. - - Args: - *children: The children of the component. - type_: The type of input. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/form.py b/reflex/components/chakra/forms/form.py deleted file mode 100644 index f9c9df856..000000000 --- a/reflex/components/chakra/forms/form.py +++ /dev/null @@ -1,102 +0,0 @@ -"""Form components.""" -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.el.elements.forms import Form as HTMLForm -from reflex.vars import Var - - -class Form(ChakraComponent, HTMLForm): - """A form component.""" - - tag = "Box" - - # What the form renders to. - as_: Var[str] = "form" # type: ignore - - -class FormControl(ChakraComponent): - """Provide context to form components.""" - - tag = "FormControl" - - # If true, the form control will be disabled. - is_disabled: Var[bool] - - # If true, the form control will be invalid. - is_invalid: Var[bool] - - # If true, the form control will be readonly - is_read_only: Var[bool] - - # If true, the form control will be required. - is_required: Var[bool] - - # The label text used to inform users as to what information is requested for a text field. - label: Var[str] - - @classmethod - def create( - cls, - *children, - label=None, - input=None, - help_text=None, - error_message=None, - **props, - ) -> Component: - """Create a form control component. - - Args: - *children: The children of the form control. - label: The label of the form control. - input: The input of the form control. - help_text: The help text of the form control. - error_message: The error message of the form control. - **props: The properties of the form control. - - Raises: - AttributeError: raise an error if missing required kwargs. - - Returns: - The form control component. - """ - if len(children) == 0: - children = [] - - if label: - children.append(FormLabel.create(*label)) - - if not input: - raise AttributeError("input keyword argument is required") - children.append(input) - - if help_text: - children.append(FormHelperText.create(*help_text)) - - if error_message: - children.append(FormErrorMessage.create(*error_message)) - - return super().create(*children, **props) - - -class FormHelperText(ChakraComponent): - """A form helper text component.""" - - tag = "FormHelperText" - - -class FormLabel(ChakraComponent): - """A form label component.""" - - tag = "FormLabel" - - # Link - html_for: Var[str] - - -class FormErrorMessage(ChakraComponent): - """A form error message component.""" - - tag = "FormErrorMessage" diff --git a/reflex/components/chakra/forms/form.pyi b/reflex/components/chakra/forms/form.pyi deleted file mode 100644 index 28a9ca4e8..000000000 --- a/reflex/components/chakra/forms/form.pyi +++ /dev/null @@ -1,513 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/form.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.el.elements.forms import Form as HTMLForm -from reflex.vars import Var - -class Form(ChakraComponent, HTMLForm): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - as_: Optional[Union[Var[str], str]] = None, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - accept_charset: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - action: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enc_type: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enter_key_hint: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Form": - """Create a form component. - - Args: - *children: The children of the form. - as_: What the form renders to. - accept: MIME types the server accepts for file upload - accept_charset: Character encodings to be used for form submission - action: URL where the form's data should be submitted - auto_complete: Whether the form should have autocomplete enabled - enc_type: Encoding type for the form data when submitted - method: HTTP method to use for form submission - name: Name of the form - no_validate: Indicates that the form should not be validated on submit - target: Where to display the response after submitting the form - reset_on_submit: If true, the form will be cleared after submit. - handle_submit_unique_name: The name used to make this form's submit handler function unique. - access_key: Provides a hint for generating a keyboard shortcut for the current element. - auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. - content_editable: Indicates whether the element's content is editable. - context_menu: Defines the ID of a element which will serve as the element's context menu. - dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) - draggable: Defines whether the element can be dragged. - enter_key_hint: Hints what media types the media element is able to play. - hidden: Defines whether the element is hidden. - input_mode: Defines the type of the element. - item_prop: Defines the name of the element for metadata purposes. - lang: Defines the language used in the element. - role: Defines the role of the element. - slot: Assigns a slot in a shadow DOM shadow tree to an element. - spell_check: Defines whether the element may be checked for spelling errors. - tab_index: Defines the position of the current element in the tabbing order. - title: Defines a tooltip for the element. - 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 properties of the form. - - Returns: - The form component. - """ - ... - -class FormControl(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - label=None, - input=None, - help_text=None, - error_message=None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "FormControl": - """Create a form control component. - - Args: - *children: The children of the form control. - label: The label of the form control. - input: The input of the form control. - help_text: The help text of the form control. - error_message: The error message of the form control. - is_disabled: If true, the form control will be disabled. - is_invalid: If true, the form control will be invalid. - is_read_only: If true, the form control will be readonly - is_required: If true, the form control will be required. - 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 properties of the form control. - - Raises: - AttributeError: raise an error if missing required kwargs. - - Returns: - The form control component. - """ - ... - -class FormHelperText(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "FormHelperText": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class FormLabel(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - html_for: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "FormLabel": - """Create the component. - - Args: - *children: The children of the component. - html_for: Link - 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 of the component. - - Returns: - The component. - """ - ... - -class FormErrorMessage(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "FormErrorMessage": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/iconbutton.py b/reflex/components/chakra/forms/iconbutton.py deleted file mode 100644 index 10e3d3a6f..000000000 --- a/reflex/components/chakra/forms/iconbutton.py +++ /dev/null @@ -1,38 +0,0 @@ -"""An icon button component.""" - -from typing import Optional - -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.vars import Var - - -class IconButton(Text): - """A button with an icon.""" - - tag = "IconButton" - library = "@chakra-ui/button@2.1.0" - - # The type of button. - type: Var[str] - - # A label that describes the button - aria_label: Var[str] - - # The icon to be used in the button. - icon: Optional[Component] - - # If true, the button will be styled in its active state. - is_active: Var[bool] - - # If true, the button will be disabled. - is_disabled: Var[bool] - - # If true, the button will show a spinner. - is_loading: Var[bool] - - # If true, the button will be perfectly round. Else, it'll be slightly round - is_round: Var[bool] - - # Replace the spinner component when isLoading is set to true - spinner: Var[str] diff --git a/reflex/components/chakra/forms/iconbutton.pyi b/reflex/components/chakra/forms/iconbutton.pyi deleted file mode 100644 index 8356bf1e1..000000000 --- a/reflex/components/chakra/forms/iconbutton.pyi +++ /dev/null @@ -1,109 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/iconbutton.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.vars import Var - -class IconButton(Text): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type: Optional[Union[Var[str], str]] = None, - aria_label: Optional[Union[Var[str], str]] = None, - icon: Optional[Component] = None, - is_active: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_loading: Optional[Union[Var[bool], bool]] = None, - is_round: Optional[Union[Var[bool], bool]] = None, - spinner: Optional[Union[Var[str], str]] = None, - as_: Optional[Union[Var[str], str]] = None, - no_of_lines: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "IconButton": - """Create the component. - - Args: - *children: The children of the component. - type: The type of button. - aria_label: A label that describes the button - icon: The icon to be used in the button. - is_active: If true, the button will be styled in its active state. - is_disabled: If true, the button will be disabled. - is_loading: If true, the button will show a spinner. - is_round: If true, the button will be perfectly round. Else, it'll be slightly round - spinner: Replace the spinner component when isLoading is set to true - as_: Override the tag. The default tag is `

`. - no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/input.py b/reflex/components/chakra/forms/input.py deleted file mode 100644 index 4512a4f48..000000000 --- a/reflex/components/chakra/forms/input.py +++ /dev/null @@ -1,129 +0,0 @@ -"""An input component.""" - -from typing import Any, Dict - -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralInputVariant, -) -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.components.literals import LiteralInputType -from reflex.constants import EventTriggers, MemoizationMode -from reflex.utils import imports -from reflex.vars import Var - - -class Input(ChakraComponent): - """The Input component is a component that is used to get user input in a text field.""" - - tag = "Input" - - # State var to bind the input. - value: Var[str] - - # The default value of the input. - default_value: Var[str] - - # The placeholder text. - placeholder: Var[str] - - # The type of input. - type_: Var[LiteralInputType] - - # The border color when the input is invalid. - error_border_color: Var[str] - - # The border color when the input is focused. - focus_border_color: Var[str] - - # If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_disabled: Var[bool] - - # If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_invalid: Var[bool] - - # If true, the form control will be readonly. - is_read_only: Var[bool] - - # If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - is_required: Var[bool] - - # "outline" | "filled" | "flushed" | "unstyled" - variant: Var[LiteralInputVariant] - - # "lg" | "md" | "sm" | "xs" - size: Var[LiteralButtonSize] - - # The name of the form field - name: Var[str] - - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - {"/utils/state": {imports.ImportVar(tag="set_val")}}, - ) - - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create an Input component. - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The component. - """ - if props.get("value") is not None and props.get("on_change"): - # create a debounced input if the user requests full control to avoid typing jank - return DebounceInput.create(super().create(*children, **props)) - return super().create(*children, **props) - - -class InputGroup(ChakraComponent): - """The InputGroup component is a component that is used to group a set of inputs.""" - - tag = "InputGroup" - - _memoization_mode = MemoizationMode(recursive=False) - - -class InputLeftAddon(ChakraComponent): - """The InputLeftAddon component is a component that is used to add an addon to the left of an input.""" - - tag = "InputLeftAddon" - - -class InputRightAddon(ChakraComponent): - """The InputRightAddon component is a component that is used to add an addon to the right of an input.""" - - tag = "InputRightAddon" - - -class InputLeftElement(ChakraComponent): - """The InputLeftElement component is a component that is used to add an element to the left of an input.""" - - tag = "InputLeftElement" - - -class InputRightElement(ChakraComponent): - """The InputRightElement component is a component that is used to add an element to the right of an input.""" - - tag = "InputRightElement" diff --git a/reflex/components/chakra/forms/input.pyi b/reflex/components/chakra/forms/input.pyi deleted file mode 100644 index 475ab8ae4..000000000 --- a/reflex/components/chakra/forms/input.pyi +++ /dev/null @@ -1,573 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/input.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralInputVariant, -) -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.components.literals import LiteralInputType -from reflex.constants import EventTriggers, MemoizationMode -from reflex.utils import imports -from reflex.vars import Var - -class Input(ChakraComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - type_: Optional[ - Union[ - Var[ - Literal[ - "button", - "checkbox", - "color", - "date", - "datetime-local", - "email", - "file", - "hidden", - "image", - "month", - "number", - "password", - "radio", - "range", - "reset", - "search", - "submit", - "tel", - "text", - "time", - "url", - "week", - ] - ], - Literal[ - "button", - "checkbox", - "color", - "date", - "datetime-local", - "email", - "file", - "hidden", - "image", - "month", - "number", - "password", - "radio", - "range", - "reset", - "search", - "submit", - "tel", - "text", - "time", - "url", - "week", - ], - ] - ] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Input": - """Create an Input component. - - Args: - *children: The children of the component. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - type_: The type of input. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... - -class InputGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "InputGroup": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class InputLeftAddon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "InputLeftAddon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class InputRightAddon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "InputRightAddon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class InputLeftElement(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "InputLeftElement": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class InputRightElement(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "InputRightElement": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/multiselect.py b/reflex/components/chakra/forms/multiselect.py deleted file mode 100644 index d9af42c3b..000000000 --- a/reflex/components/chakra/forms/multiselect.py +++ /dev/null @@ -1,354 +0,0 @@ -"""Provides a feature-rich Select and some (not all) related components.""" -from __future__ import annotations - -from typing import Any, Dict, List, Optional, Set, Union - -from reflex.base import Base -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class Option(Base): - """An option component for the chakra-react-select Select.""" - - # What is displayed to the user - label: str - - # The value of the option, must be serializable - value: Any - - # the variant of the option tag - variant: Optional[str] = None - - # [not working yet] - # Whether the option is disabled - # is_disabled: Optional[bool] = None - - # [not working yet] - # The visual color appearance of the component - # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | - # "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | - # "purple" | "pink" | "linkedin" | "facebook" | "messenger" | - # "whatsapp" | "twitter" | "telegram" - # default: "gray" - # color_scheme: Optional[str] = None - - # [not working yet] - # The icon of the option tag - # icon: Optional[str] = None - - -class Select(Component): - """The default chakra-react-select Select component. - Not every available prop is listed here, - for a complete overview check the react-select/chakra-react-select docs. - Props added by chakra-react-select are marked with "[chakra]". - """ - - library = "chakra-react-select@4.7.5" - tag = "Select" - alias = "MultiSelect" - - # Focus the control when it is mounted - auto_focus: Var[bool] - - # Remove the currently focused option when the user presses backspace - # when Select isClearable or isMulti - backspace_removes_value: Var[bool] - - # Remove focus from the input when the user selects an option - # (handy for dismissing the keyboard on touch devices) - blur_input_on_select: Var[bool] - - # When the user reaches the top/bottom of the menu, - # prevent scroll on the scroll-parent - capture_menu_scroll: Var[bool] - - # [chakra] - # To use the chakraStyles prop, first, - # check the documentation for the original styles prop from the react-select docs. - # This package offers an identical API for the chakraStyles prop, however, - # the provided and output style objects use Chakra's sx prop - # instead of the default emotion styles the original package offers. - # This allows you to both use the shorthand styling props you'd normally use - # to style Chakra components, as well as tokens from your theme such as named colors. - # All of the style keys offered in the original package can be used in the chakraStyles prop - # except for menuPortal. Along with some other caveats, this is explained below. - # Most of the components rendered by this package use the basic Chakra component with a few exceptions. - # Here are the style keys offered and the corresponding Chakra component that is rendered: - # - clearIndicator - Box (uses theme styles for Chakra's CloseButton) - # - container - Box - # - control - Box (uses theme styles for Chakra's Input) - # - dropdownIndicator - Box (uses theme styles for Chrakra's InputRightAddon) - # - downChevron - Icon - # - crossIcon - Icon - # - group - Box - # - groupHeading - Box (uses theme styles for Chakra's Menu group title) - # - indicatorsContainer - Box - # - indicatorSeparator - Divider - # - input - chakra.input (wrapped in a Box) - # - inputContainer - Box - # - loadingIndicator - Spinner - # - loadingMessage - Box - # - menu - Box - # - menuList - Box (uses theme styles for Chakra's Menu) - # - multiValue - chakra.span (uses theme styles for Chakra's Tag) - # - multiValueLabel - chakra.span (uses theme styles for Chakra's TagLabel) - # - multiValueRemove - Box (uses theme styles for Chakra's TagCloseButton) - # - noOptionsMessage - Box - # - option - Box (uses theme styles for Chakra's MenuItem) - # - placeholder - Box - # - singleValue - Box - # - valueContainer - Box - chakra_styles: Var[str] - - # Close the select menu when the user selects an option - close_menu_on_select: Var[bool] - - # If true, close the select menu when the user scrolls the document/body. - close_menu_on_scroll: Var[bool] - - # [chakra] - # The visual color appearance of the component - # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | - # "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | - # "purple" | "pink" | "linkedin" | "facebook" | "messenger" | - # "whatsapp" | "twitter" | "telegram" - # default: "gray" - color_scheme: Var[str] - - # This complex object includes all the compositional components - # that are used in react-select. If you wish to overwrite a component, - # pass in an object with the appropriate namespace. - # If you only wish to restyle a component, - # we recommend using the styles prop instead. - components: Var[Dict[str, Component]] - - # Whether the value of the select, e.g. SingleValue, - # should be displayed in the control. - control_should_render_value: Var[bool] - - # Delimiter used to join multiple values into a single HTML Input value - delimiter: Var[str] - - # [chakra] - # Colors the component border with the given chakra color string on error state - # default: "red.500" - error_border_color: Var[str] - - # Clear all values when the user presses escape AND the menu is closed - escape_clears_value: Var[bool] - - # [chakra] - # Colors the component border with the given chakra color string on focus - # default: "blue.500" - focus_border_color: Var[str] - - # Sets the form attribute on the input - form: Var[str] - - # Hide the selected option from the menu - hide_selected_options: Var[bool] - - # The id to set on the SelectContainer component. - # id: Var[str] - - # The value of the search input - input_value: Var[str] - - # The id of the search input - input_id: Var[str] - - # Is the select value clearable - is_clearable: Var[bool] - - # Is the select disabled - is_disabled: Var[bool] - - # [chakra] - # Style component in the chakra invalid style - # default: False - is_invalid: Var[bool] - - # Support multiple selected options - is_multi: Var[bool] - - # [chakra] - # Style component as disabled (chakra style) - # default: False - is_read_only: Var[bool] - - # Is the select direction right-to-left - is_rtl: Var[bool] - - # Whether to enable search functionality - is_searchable: Var[bool] - - # Minimum height of the menu before flipping - min_menu_height: Var[int] - - # Maximum height of the menu before scrolling - max_menu_height: Var[int] - - # Default placement of the menu in relation to the control. - # 'auto' will flip when there isn't enough space below the control. - # options: "bottom" | "auto" | "top" - menu_placement: Var[str] - - # The CSS position value of the menu, - # when "fixed" extra layout management is required - # options: "absolute" | "fixed" - menu_position: Var[str] - - # Whether to block scroll events when the menu is open - menu_should_block_scroll: Var[bool] - - # Whether the menu should be scrolled into view when it opens - menu_should_scroll_into_view: Var[bool] - - # Name of the HTML Input (optional - without this, no input will be rendered) - name: Var[str] - - # Allows control of whether the menu is opened when the Select is focused - open_menu_on_focus: Var[bool] - - # Allows control of whether the menu is opened when the Select is clicked - open_menu_on_click: Var[bool] - - # Array of options that populate the select menu - options: Var[List[Dict]] - - # Number of options to jump in menu when page{up|down} keys are used - page_size: Var[int] - - # Placeholder for the select value - placeholder: Var[Optional[str]] - - # Marks the value-holding input as required for form validation - required: Var[bool] - - # [chakra] - # If you choose to stick with the default selectedOptionStyle="color", - # you have one additional styling option. - # If you do not like the default of blue for the highlight color, - # you can pass the selectedOptionColorScheme prop to change it. - # This prop will accept any named color from your theme's color palette, - # and it will use the 500 value in light mode or the 300 value in dark mode. - # This prop can only be used for named colors from your theme, not arbitrary hex/rgb colors. - # If you would like to use a specific color for the background that's not a part of your theme, - # use the chakraStyles prop to customize it. - # default: "blue" - selected_option_color_scheme: Var[str] - - # [chakra] - # The default option "color" will style a selected option - # similar to how react-select does it, - # by highlighting the selected option in the color blue. - # Alternatively, if you pass "check" for the value, - # the selected option will be styled like the Chakra UI Menu component - # and include a check icon next to the selected option(s). - # If is_multi and selected_option_style="check" are passed, - # space will only be added for the check marks - # if hide_selected_options=False is also passed. - # options: "color" | "check" - # default: "color" - selected_option_style: Var[str] - - # [chakra] - # The size of the component. - # options: "sm" | "md" | "lg" - # default: "md" - size: Var[str] - - # Sets the tabIndex attribute on the input - tab_index: Var[int] - - # Select the currently focused option when the user presses tab - tab_selects_value: Var[bool] - - # [chakra] - # Variant of multi-select tags - # options: "subtle" | "solid" | "outline" - # default: "subtle" - tag_variant: Var[str] - - # Remove all non-essential styles - unstyled: Var[bool] - - # [chakra] - # If this prop is passed, - # the dropdown indicator at the right of the component will be styled - # in the same way the original Chakra Select component is styled, - # instead of being styled as an InputRightAddon. - # The original purpose of styling it as an addon - # was to create a visual separation between the dropdown indicator - # and the button for clearing the selected options. - # However, as this button only appears when isMulti is passed, - # using this style could make more sense for a single select. - # default: False - use_basic_style: Var[bool] - - # [chakra] - # The variant of the Select. If no variant is passed, - # it will default to defaultProps.variant from the theme for Chakra's Input component. - # If your component theme for Input is not modified, it will be outline. - # options: "outline" | "filled" | "flushed" | "unstyled" - # default: "outline" - variant: Var[str] - - # How the options should be displayed in the menu. - menu_position: Var[str] = "fixed" # type: ignore - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: ( - lambda e0: [ - Var.create_safe(f"{e0}.map(e => e.value)", _var_is_local=True) - ] - if self.is_multi.equals(Var.create_safe(True)) - else lambda e0: [e0] - ), - } - - @classmethod - def get_initial_props(cls) -> Set[str]: - """Get the initial props to set for the component. - - Returns: - The initial props to set. - """ - return super().get_initial_props() | {"is_multi"} - - @classmethod - def create( - cls, options: List[Union[Option, str, int, float, bool]], **props - ) -> Component: - """Takes a list of options and additional properties, checks if each option is an - instance of Option, and returns a Select component with the given options and - properties. No children allowed. - - Args: - options (List[Option | str | int | float | bool]): A list of values. - **props: Additional properties to be passed to the Select component. - - Returns: - The `create` method is returning an instance of the `Select` class. - """ - converted_options: List[Option] = [] - if not isinstance(options, Var): - for option in options: - if not isinstance(option, Option): - converted_options.append(Option(label=str(option), value=option)) - else: - converted_options.append(option) - props["options"] = [o.dict() for o in converted_options] - else: - props["options"] = options - return super().create(*[], **props) diff --git a/reflex/components/chakra/forms/numberinput.py b/reflex/components/chakra/forms/numberinput.py deleted file mode 100644 index c6ed8df6d..000000000 --- a/reflex/components/chakra/forms/numberinput.py +++ /dev/null @@ -1,137 +0,0 @@ -"""A number input component.""" - -from numbers import Number -from typing import Any, Dict - -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralInputVariant, -) -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class NumberInput(ChakraComponent): - """The wrapper that provides context and logic to the components.""" - - tag = "NumberInput" - - # State var to bind the input. - value: Var[Number] - - # If true, the input's value will change based on mouse wheel. - allow_mouse_wheel: Var[bool] - - # This controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same. - clamped_value_on_blur: Var[bool] - - # The initial value of the counter. Should be less than max and greater than min - default_value: Var[Number] - - # The border color when the input is invalid. - error_border_color: Var[str] - - # The border color when the input is focused. - focus_border_color: Var[str] - - # If true, the input will be focused as you increment or decrement the value with the stepper - focus_input_on_change: Var[bool] - - # Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices ("text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal") - # input_mode: Var[LiteralInputNumberMode] - - # Whether the input should be disabled. - is_disabled: Var[bool] - - # If true, the input will have `aria-invalid` set to true - is_invalid: Var[bool] - - # If true, the input will be in readonly mode - is_read_only: Var[bool] - - # Whether the input is required - is_required: Var[bool] - - # Whether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\-.]$/ - is_valid_character: Var[str] - - # This controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range. - keep_within_range: Var[bool] - - # The maximum value of the counter - max_: Var[Number] - - # The minimum value of the counter - min_: Var[Number] - - # "outline" | "filled" | "flushed" | "unstyled" - variant: Var[LiteralInputVariant] - - # "lg" | "md" | "sm" | "xs" - size: Var[LiteralButtonSize] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a number input component. - - If no children are provided, a default stepper will be used. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The component. - """ - if len(children) == 0: - _id = props.pop("id", None) - children = [ - NumberInputField.create(id=_id) - if _id is not None - else NumberInputField.create(), - NumberInputStepper.create( - NumberIncrementStepper.create(), - NumberDecrementStepper.create(), - ), - ] - return super().create(*children, **props) - - -class NumberInputField(ChakraComponent): - """The input field itself.""" - - tag = "NumberInputField" - - -class NumberInputStepper(ChakraComponent): - """The wrapper for the input's stepper buttons.""" - - tag = "NumberInputStepper" - - -class NumberIncrementStepper(ChakraComponent): - """The button to increment the value of the input.""" - - tag = "NumberIncrementStepper" - - -class NumberDecrementStepper(ChakraComponent): - """The button to decrement the value of the input.""" - - tag = "NumberDecrementStepper" diff --git a/reflex/components/chakra/forms/numberinput.pyi b/reflex/components/chakra/forms/numberinput.pyi deleted file mode 100644 index 079490757..000000000 --- a/reflex/components/chakra/forms/numberinput.pyi +++ /dev/null @@ -1,448 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/numberinput.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from numbers import Number -from typing import Any, Dict -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralInputVariant, -) -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var - -class NumberInput(ChakraComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[Number], Number]] = None, - allow_mouse_wheel: Optional[Union[Var[bool], bool]] = None, - clamped_value_on_blur: Optional[Union[Var[bool], bool]] = None, - default_value: Optional[Union[Var[Number], Number]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - focus_input_on_change: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - is_valid_character: Optional[Union[Var[str], str]] = None, - keep_within_range: Optional[Union[Var[bool], bool]] = None, - max_: Optional[Union[Var[Number], Number]] = None, - min_: Optional[Union[Var[Number], Number]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "NumberInput": - """Create a number input component. - - If no children are provided, a default stepper will be used. - - Args: - *children: The children of the component. - value: State var to bind the input. - allow_mouse_wheel: If true, the input's value will change based on mouse wheel. - clamped_value_on_blur: This controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same. - default_value: The initial value of the counter. Should be less than max and greater than min - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - focus_input_on_change: If true, the input will be focused as you increment or decrement the value with the stepper - is_disabled: Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices ("text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal") input_mode: Var[LiteralInputNumberMode] Whether the input should be disabled. - is_invalid: If true, the input will have `aria-invalid` set to true - is_read_only: If true, the input will be in readonly mode - is_required: Whether the input is required - is_valid_character: Whether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\\-.]$/ - keep_within_range: This controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range. - max_: The maximum value of the counter - min_: The minimum value of the counter - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 of the component. - - Returns: - The component. - """ - ... - -class NumberInputField(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "NumberInputField": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class NumberInputStepper(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "NumberInputStepper": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class NumberIncrementStepper(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "NumberIncrementStepper": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class NumberDecrementStepper(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "NumberDecrementStepper": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/password.py b/reflex/components/chakra/forms/password.py deleted file mode 100644 index 100bb6151..000000000 --- a/reflex/components/chakra/forms/password.py +++ /dev/null @@ -1,11 +0,0 @@ -"""A password input component.""" - -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - - -class Password(Input): - """A password input component.""" - - # The type of input. - type_: Var[str] = "password" # type: ignore diff --git a/reflex/components/chakra/forms/password.pyi b/reflex/components/chakra/forms/password.pyi deleted file mode 100644 index 3f08d1ef0..000000000 --- a/reflex/components/chakra/forms/password.pyi +++ /dev/null @@ -1,129 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/password.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - -class Password(Input): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Password": - """Create an Input component. - - Args: - *children: The children of the component. - type_: The type of input. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/pininput.py b/reflex/components/chakra/forms/pininput.py deleted file mode 100644 index 653bfb90a..000000000 --- a/reflex/components/chakra/forms/pininput.py +++ /dev/null @@ -1,207 +0,0 @@ -"""A pin input component.""" - -from __future__ import annotations - -from typing import Any, Optional, Union - -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.tags.tag import Tag -from reflex.constants import EventTriggers -from reflex.utils import format -from reflex.utils.imports import ImportDict, merge_imports -from reflex.vars import Var - - -class PinInput(ChakraComponent): - """The component that provides context to all the pin-input fields.""" - - tag = "PinInput" - - # State var to bind the input. - value: Var[str] - - # If true, the pin input receives focus on mount - auto_focus: Var[bool] - - # The default value of the pin input - default_value: Var[str] - - # The border color when the input is invalid. - error_border_color: Var[str] - - # The border color when the input is focused. - focus_border_color: Var[str] - - # The top-level id string that will be applied to the input fields. The index of the input will be appended to this top-level id. - id_: Var[str] - - # The length of the number input. - length: Var[int] - - # If true, the pin input component is put in the disabled state - is_disabled: Var[bool] - - # If true, the pin input component is put in the invalid state - is_invalid: Var[bool] - - # If true, focus will move automatically to the next input once filled - manage_focus: Var[bool] - - # If true, the input's value will be masked just like `type=password` - mask: Var[bool] - - # The placeholder for the pin input - placeholder: Var[str] - - # The type of values the pin-input should allow ("number" | "alphanumeric"). - type_: Var[str] - - # "outline" | "flushed" | "filled" | "unstyled" - variant: Var[LiteralInputVariant] - - # The name of the form field - name: Var[str] - - def _get_imports(self) -> ImportDict: - """Include PinInputField explicitly because it may not be a child component at compile time. - - Returns: - The merged import dict. - """ - range_var = Var.range(0) - return merge_imports( - super()._get_imports(), - PinInputField()._get_all_imports(), # type: ignore - range_var._var_data.imports if range_var._var_data is not None else {}, - ) - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - EventTriggers.ON_COMPLETE: lambda e0: [e0], - } - - def get_ref(self) -> str | None: - """Override ref handling to handle array refs. - - PinInputFields may be created dynamically, so it's not possible - to compute their ref at compile time, so we return a cheating - guess if the id is specified. - - The `ref` for this outer component will always be stripped off, so what - is returned here only matters for form ref collection purposes. - - Returns: - None. - """ - if any(isinstance(c, PinInputField) for c in self.children): - return None - if self.id: - return format.format_array_ref(self.id, idx=self.length) - return super().get_ref() - - def _get_ref_hook(self) -> Optional[str]: - """Override the base _get_ref_hook to handle array refs. - - Returns: - The overrided hooks. - """ - if self.id: - ref = format.format_array_ref(self.id, None) - refs_declaration = Var.range(self.length).foreach( - lambda: Var.create_safe("useRef(null)", _var_is_string=False), - ) - refs_declaration._var_is_local = True - if ref: - return ( - f"const {ref} = {str(refs_declaration)}; " - f"{str(Var.create_safe(ref).as_ref())} = {ref}" - ) - return super()._get_ref_hook() - - def _render(self) -> Tag: - """Override the base _render to remove the fake get_ref. - - Returns: - The rendered component. - """ - return super()._render().remove_props("ref") - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a pin input component. - - If no children are passed in, the component will create a default pin input - based on the length prop. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The pin input component. - """ - if children: - props.pop("length", None) - elif "length" in props: - field_props = {} - if "id" in props: - field_props["id"] = props["id"] - if "name" in props: - field_props["name"] = props["name"] - children = [ - PinInputField.for_length(props["length"], **field_props), - ] - return super().create(*children, **props) - - -class PinInputField(ChakraComponent): - """The text field that user types in - must be a direct child of PinInput.""" - - tag = "PinInputField" - - # the position of the PinInputField inside the PinInput. - # Default to None because it is assigned by PinInput when created. - index: Optional[Var[int]] = None - - # The name of the form field - name: Var[str] - - @classmethod - def for_length(cls, length: Var | int, **props) -> Var: - """Create a PinInputField for a PinInput with a given length. - - Args: - length: The length of the PinInput. - props: The props of each PinInputField (name will become indexed). - - Returns: - The PinInputField. - """ - name = props.get("name") - - def _create(i): - if name is not None: - props["name"] = f"{name}-{i}" - return PinInputField.create(**props, index=i, key=i) - - return Var.range(length).foreach(_create) # type: ignore - - def _get_ref_hook(self) -> Optional[str]: - return None - - def get_ref(self): - """Get the array ref for the pin input. - - Returns: - The array ref. - """ - if self.id: - return format.format_array_ref(self.id, self.index) diff --git a/reflex/components/chakra/forms/pininput.pyi b/reflex/components/chakra/forms/pininput.pyi deleted file mode 100644 index a3f76c8ab..000000000 --- a/reflex/components/chakra/forms/pininput.pyi +++ /dev/null @@ -1,222 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/pininput.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Optional, Union -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.tags.tag import Tag -from reflex.constants import EventTriggers -from reflex.utils import format -from reflex.utils.imports import ImportDict, merge_imports -from reflex.vars import Var - -class PinInput(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - def get_ref(self) -> str | None: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[str], str]] = None, - auto_focus: Optional[Union[Var[bool], bool]] = None, - default_value: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - id_: Optional[Union[Var[str], str]] = None, - length: Optional[Union[Var[int], int]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - manage_focus: Optional[Union[Var[bool], bool]] = None, - mask: Optional[Union[Var[bool], bool]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - type_: Optional[Union[Var[str], str]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_complete: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PinInput": - """Create a pin input component. - - If no children are passed in, the component will create a default pin input - based on the length prop. - - Args: - *children: The children of the component. - value: State var to bind the input. - auto_focus: If true, the pin input receives focus on mount - default_value: The default value of the pin input - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - id_: The top-level id string that will be applied to the input fields. The index of the input will be appended to this top-level id. - length: The length of the number input. - is_disabled: If true, the pin input component is put in the disabled state - is_invalid: If true, the pin input component is put in the invalid state - manage_focus: If true, focus will move automatically to the next input once filled - mask: If true, the input's value will be masked just like `type=password` - placeholder: The placeholder for the pin input - type_: The type of values the pin-input should allow ("number" | "alphanumeric"). - variant: "outline" | "flushed" | "filled" | "unstyled" - name: The name of the form field - 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 of the component. - - Returns: - The pin input component. - """ - ... - -class PinInputField(ChakraComponent): - @classmethod - def for_length(cls, length: Var | int, **props) -> Var: ... - def get_ref(self): ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - index: Optional[Union[Var[int], int]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PinInputField": - """Create the component. - - Args: - *children: The children of the component. - index: the position of the PinInputField inside the PinInput. Default to None because it is assigned by PinInput when created. - name: The name of the form field - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/radio.py b/reflex/components/chakra/forms/radio.py deleted file mode 100644 index f864fed69..000000000 --- a/reflex/components/chakra/forms/radio.py +++ /dev/null @@ -1,110 +0,0 @@ -"""A radio component.""" - - -from typing import Any, Dict, List, Union - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.constants import EventTriggers -from reflex.utils.types import _issubclass -from reflex.vars import Var - - -class RadioGroup(ChakraComponent): - """A grouping of individual radio options.""" - - tag = "RadioGroup" - - # State var to bind the input. - value: Var[Any] - - # The default value. - default_value: Var[Any] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> Dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a radio group component. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The component. - """ - if len(children) == 1 and isinstance(children[0], list): - children = [Radio.create(child) for child in children[0]] - if ( - len(children) == 1 - and isinstance(children[0], Var) - and _issubclass(children[0]._var_type, List) - ): - children = [Foreach.create(children[0], lambda item: Radio.create(item))] - return super().create(*children, **props) - - -class Radio(Text): - """Radios are used when only one choice may be selected in a series of options.""" - - tag = "Radio" - - # Value of radio. - value: Var[Any] - - # The default value. - default_value: Var[Any] - - # The color scheme. - color_scheme: Var[str] - - # If true, the radio will be initially checked. - default_checked: Var[bool] - - # If true, the radio will be checked. You'll need to pass onChange to update its value (since it is now controlled) - is_checked: Var[bool] - - # If true, the radio will be disabled. - is_disabled: Var[bool] - - # If true, the radio button will be invalid. This also sets `aria-invalid` to true. - is_invalid: Var[bool] - - # If true, the radio will be read-only - is_read_only: Var[bool] - - # If true, the radio button will be required. This also sets `aria-required` to true. - is_required: Var[bool] - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a radio component. - - By default, the value is bound to the first child. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The radio component. - """ - if "value" not in props: - assert len(children) == 1 - props["value"] = children[0] - return super().create(*children, **props) diff --git a/reflex/components/chakra/forms/radio.pyi b/reflex/components/chakra/forms/radio.pyi deleted file mode 100644 index e8389ed51..000000000 --- a/reflex/components/chakra/forms/radio.pyi +++ /dev/null @@ -1,203 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/radio.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Union -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.constants import EventTriggers -from reflex.utils.types import _issubclass -from reflex.vars import Var - -class RadioGroup(ChakraComponent): - def get_event_triggers(self) -> Dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[Any], Any]] = None, - default_value: Optional[Union[Var[Any], Any]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "RadioGroup": - """Create a radio group component. - - Args: - *children: The children of the component. - value: State var to bind the input. - default_value: The default value. - name: The name of the form field - 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 of the component. - - Returns: - The component. - """ - ... - -class Radio(Text): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[Any], Any]] = None, - default_value: Optional[Union[Var[Any], Any]] = None, - color_scheme: Optional[Union[Var[str], str]] = None, - default_checked: Optional[Union[Var[bool], bool]] = None, - is_checked: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - as_: Optional[Union[Var[str], str]] = None, - no_of_lines: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Radio": - """Create a radio component. - - By default, the value is bound to the first child. - - Args: - *children: The children of the component. - value: Value of radio. - default_value: The default value. - color_scheme: The color scheme. - default_checked: If true, the radio will be initially checked. - is_checked: If true, the radio will be checked. You'll need to pass onChange to update its value (since it is now controlled) - is_disabled: If true, the radio will be disabled. - is_invalid: If true, the radio button will be invalid. This also sets `aria-invalid` to true. - is_read_only: If true, the radio will be read-only - is_required: If true, the radio button will be required. This also sets `aria-required` to true. - as_: Override the tag. The default tag is `

`. - no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. - 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 of the component. - - Returns: - The radio component. - """ - ... diff --git a/reflex/components/chakra/forms/rangeslider.py b/reflex/components/chakra/forms/rangeslider.py deleted file mode 100644 index 0b42ad6a5..000000000 --- a/reflex/components/chakra/forms/rangeslider.py +++ /dev/null @@ -1,152 +0,0 @@ -"""A range slider component.""" -from __future__ import annotations - -from typing import Any, List, Optional, Union - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.utils import format -from reflex.vars import Var - - -class RangeSlider(ChakraComponent): - """The RangeSlider is a multi thumb slider used to select a range of related values. A common use-case of this component is a price range picker that allows a user to set the minimum and maximum price.""" - - tag = "RangeSlider" - - # State var to bind the input. - value: Var[List[int]] - - # The default values. - default_value: Var[List[int]] - - # The writing mode ("ltr" | "rtl") - direction: Var[LiteralChakraDirection] - - # If false, the slider handle will not capture focus when value changes. - focus_thumb_on_change: Var[bool] - - # If true, the slider will be disabled - is_disabled: Var[bool] - - # If true, the slider will be in `read-only` state. - is_read_only: Var[bool] - - # If true, the value will be incremented or decremented in reverse. - is_reversed: Var[bool] - - # The minimum value of the slider. - min_: Var[int] - - # The maximum value of the slider. - max_: Var[int] - - # The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together. - min_steps_between_thumbs: Var[int] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - EventTriggers.ON_CHANGE_END: lambda e0: [e0], - EventTriggers.ON_CHANGE_START: lambda e0: [e0], - } - - def get_ref(self): - """Get the ref of the component. - - Returns: - The ref of the component. - """ - return None - - def _get_ref_hook(self) -> Optional[str]: - """Override the base _get_ref_hook to handle array refs. - - Returns: - The overrided hooks. - """ - if self.id: - ref = format.format_array_ref(self.id, None) - if ref: - return ( - f"const {ref} = Array.from({{length:2}}, () => useRef(null)); " - f"{str(Var.create_safe(ref).as_ref())} = {ref}" - ) - return super()._get_ref_hook() - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a RangeSlider component. - - If no children are provided, a default RangeSlider will be created. - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The RangeSlider component. - """ - if len(children) == 0: - _id = props.get("id", None) - if _id: - children = [ - RangeSliderTrack.create( - RangeSliderFilledTrack.create(), - ), - RangeSliderThumb.create(index=0, id=_id), - RangeSliderThumb.create(index=1, id=_id), - ] - else: - children = [ - RangeSliderTrack.create( - RangeSliderFilledTrack.create(), - ), - RangeSliderThumb.create(index=0), - RangeSliderThumb.create(index=1), - ] - return super().create(*children, **props) - - -class RangeSliderTrack(ChakraComponent): - """A range slider track.""" - - tag = "RangeSliderTrack" - - -class RangeSliderFilledTrack(ChakraComponent): - """A filled range slider track.""" - - tag = "RangeSliderFilledTrack" - - -class RangeSliderThumb(ChakraComponent): - """A range slider thumb.""" - - tag = "RangeSliderThumb" - - # The position of the thumb. - index: Var[int] - - def _get_ref_hook(self) -> Optional[str]: - # hook is None because RangeSlider is handling it. - return None - - def get_ref(self): - """Get an array ref for the range slider thumb. - - Returns: - The array ref. - """ - if self.id: - return format.format_array_ref(self.id, self.index) diff --git a/reflex/components/chakra/forms/rangeslider.pyi b/reflex/components/chakra/forms/rangeslider.pyi deleted file mode 100644 index abd016184..000000000 --- a/reflex/components/chakra/forms/rangeslider.pyi +++ /dev/null @@ -1,359 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/rangeslider.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, List, Optional, Union -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.utils import format -from reflex.vars import Var - -class RangeSlider(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - def get_ref(self): ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[List[int]], List[int]]] = None, - default_value: Optional[Union[Var[List[int]], List[int]]] = None, - direction: Optional[ - Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]] - ] = None, - focus_thumb_on_change: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_reversed: Optional[Union[Var[bool], bool]] = None, - min_: Optional[Union[Var[int], int]] = None, - max_: Optional[Union[Var[int], int]] = None, - min_steps_between_thumbs: Optional[Union[Var[int], int]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_change_end: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_change_start: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "RangeSlider": - """Create a RangeSlider component. - - If no children are provided, a default RangeSlider will be created. - - Args: - *children: The children of the component. - value: State var to bind the input. - default_value: The default values. - direction: The writing mode ("ltr" | "rtl") - focus_thumb_on_change: If false, the slider handle will not capture focus when value changes. - is_disabled: If true, the slider will be disabled - is_read_only: If true, the slider will be in `read-only` state. - is_reversed: If true, the value will be incremented or decremented in reverse. - min_: The minimum value of the slider. - max_: The maximum value of the slider. - min_steps_between_thumbs: The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together. - name: The name of the form field - 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 properties of the component. - - Returns: - The RangeSlider component. - """ - ... - -class RangeSliderTrack(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "RangeSliderTrack": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class RangeSliderFilledTrack(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "RangeSliderFilledTrack": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class RangeSliderThumb(ChakraComponent): - def get_ref(self): ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - index: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "RangeSliderThumb": - """Create the component. - - Args: - *children: The children of the component. - index: The position of the thumb. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/select.py b/reflex/components/chakra/forms/select.py deleted file mode 100644 index c898f40d9..000000000 --- a/reflex/components/chakra/forms/select.py +++ /dev/null @@ -1,111 +0,0 @@ -"""A select component.""" - -from typing import Any, Dict, List, Union - -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.constants import EventTriggers -from reflex.utils.types import _issubclass -from reflex.vars import Var - - -class Select(ChakraComponent): - """Select component is a component that allows users pick a value from predefined options. Ideally, it should be used when there are more than 5 options, otherwise you might consider using a radio group instead.""" - - tag = "Select" - - # State var to bind the select. - value: Var[str] - - # The default value of the select. - default_value: Var[str] - - # The placeholder text. - placeholder: Var[str] - - # The border color when the select is invalid. - error_border_color: Var[str] - - # The border color when the select is focused. - focus_border_color: Var[str] - - # If true, the select will be disabled. - is_disabled: Var[bool] - - # If true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_invalid: Var[bool] - - # If true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - is_required: Var[bool] - - # "outline" | "filled" | "flushed" | "unstyled" - variant: Var[LiteralInputVariant] - - # The size of the select. - size: Var[str] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> Dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a select component. - - If a list is provided as the first children, a default component - will be created for each item in the list. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The component. - """ - if len(children) == 1 and isinstance(children[0], list): - children = [Option.create(child) for child in children[0]] - if ( - len(children) == 1 - and isinstance(children[0], Var) - and _issubclass(children[0]._var_type, List) - ): - children = [Foreach.create(children[0], lambda item: Option.create(item))] - return super().create(*children, **props) - - -class Option(Text): - """A select option.""" - - tag = "option" - - value: Var[Any] - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a select option component. - - By default, the value of the option is the text of the option. - - Args: - *children: The children of the component. - **props: The props of the component. - - Returns: - The component. - """ - if "value" not in props: - assert len(children) == 1 - props["value"] = children[0] - return super().create(*children, **props) diff --git a/reflex/components/chakra/forms/select.pyi b/reflex/components/chakra/forms/select.pyi deleted file mode 100644 index 64f0f0fc0..000000000 --- a/reflex/components/chakra/forms/select.pyi +++ /dev/null @@ -1,210 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/select.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Union -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.constants import EventTriggers -from reflex.utils.types import _issubclass -from reflex.vars import Var - -class Select(ChakraComponent): - def get_event_triggers(self) -> Dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[Union[Var[str], str]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Select": - """Create a select component. - - If a list is provided as the first children, a default component - will be created for each item in the list. - - Args: - *children: The children of the component. - value: State var to bind the select. - default_value: The default value of the select. - placeholder: The placeholder text. - error_border_color: The border color when the select is invalid. - focus_border_color: The border color when the select is focused. - is_disabled: If true, the select will be disabled. - is_invalid: If true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_required: If true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: The size of the select. - name: The name of the form field - 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 of the component. - - Returns: - The component. - """ - ... - -class Option(Text): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[Any], Any]] = None, - as_: Optional[Union[Var[str], str]] = None, - no_of_lines: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Option": - """Create a select option component. - - By default, the value of the option is the text of the option. - - Args: - *children: The children of the component. - as_: Override the tag. The default tag is `

`. - no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/slider.py b/reflex/components/chakra/forms/slider.py deleted file mode 100644 index 69eb6ac9f..000000000 --- a/reflex/components/chakra/forms/slider.py +++ /dev/null @@ -1,133 +0,0 @@ -"""A slider component.""" -from __future__ import annotations - -from typing import Any, Literal, Union - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var - -LiteralLayout = Literal["horizontal", "vertical"] - - -class Slider(ChakraComponent): - """The wrapper that provides context and functionality for all children.""" - - tag = "Slider" - - # State var to bind the input. - value: Var[int] - - # The color scheme. - color_scheme: Var[str] - - # The placeholder text. - default_value: Var[int] - - # The writing mode ("ltr" | "rtl") - direction: Var[LiteralChakraDirection] - - # If false, the slider handle will not capture focus when value changes. - focus_thumb_on_change: Var[bool] - - # If true, the slider will be disabled - is_disabled: Var[bool] - - # If true, the slider will be in `read-only` state. - is_read_only: Var[bool] - - # If true, the value will be incremented or decremented in reverse. - is_reversed: Var[bool] - - # The minimum value of the slider. - min_: Var[int] - - # The maximum value of the slider. - max_: Var[int] - - # The step in which increments/decrements have to be made - step: Var[int] - - # The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together. - min_steps_between_thumbs: Var[int] - - # Oreintation of the slider vertical | horizontal. - orientation: Var[LiteralLayout] - - # Minimum height of the slider. - min_h: Var[str] - - # Minimum width of the slider. - min_w: Var[str] - - # Maximum height of the slider. - max_h: Var[str] - - # Maximum width of the slider. - max_w: Var[str] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - EventTriggers.ON_CHANGE_END: lambda e0: [e0], - EventTriggers.ON_CHANGE_START: lambda e0: [e0], - } # type: ignore - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a slider component. - - If no children are provided, a default slider will be created. - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The slider component. - """ - if len(children) == 0: - children = [ - SliderTrack.create( - SliderFilledTrack.create(), - ), - SliderThumb.create(), - ] - return super().create(*children, **props) - - -class SliderTrack(ChakraComponent): - """The empty part of the slider that shows the track.""" - - tag = "SliderTrack" - - -class SliderFilledTrack(ChakraComponent): - """The filled part of the slider.""" - - tag = "SliderFilledTrack" - - -class SliderThumb(ChakraComponent): - """The handle that's used to change the slider value.""" - - tag = "SliderThumb" - - # The size of the thumb. - box_size: Var[str] - - -class SliderMark(ChakraComponent): - """The label or mark that shows names for specific slider values.""" - - tag = "SliderMark" diff --git a/reflex/components/chakra/forms/slider.pyi b/reflex/components/chakra/forms/slider.pyi deleted file mode 100644 index dc8ae2fa8..000000000 --- a/reflex/components/chakra/forms/slider.pyi +++ /dev/null @@ -1,453 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/slider.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Literal, Union -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var - -LiteralLayout = Literal["horizontal", "vertical"] - -class Slider(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[int], int]] = None, - color_scheme: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[int], int]] = None, - direction: Optional[ - Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]] - ] = None, - focus_thumb_on_change: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_reversed: Optional[Union[Var[bool], bool]] = None, - min_: Optional[Union[Var[int], int]] = None, - max_: Optional[Union[Var[int], int]] = None, - step: Optional[Union[Var[int], int]] = None, - min_steps_between_thumbs: Optional[Union[Var[int], int]] = None, - orientation: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - min_h: Optional[Union[Var[str], str]] = None, - min_w: Optional[Union[Var[str], str]] = None, - max_h: Optional[Union[Var[str], str]] = None, - max_w: Optional[Union[Var[str], str]] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_change_end: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_change_start: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Slider": - """Create a slider component. - - If no children are provided, a default slider will be created. - - Args: - *children: The children of the component. - value: State var to bind the input. - color_scheme: The color scheme. - default_value: The placeholder text. - direction: The writing mode ("ltr" | "rtl") - focus_thumb_on_change: If false, the slider handle will not capture focus when value changes. - is_disabled: If true, the slider will be disabled - is_read_only: If true, the slider will be in `read-only` state. - is_reversed: If true, the value will be incremented or decremented in reverse. - min_: The minimum value of the slider. - max_: The maximum value of the slider. - step: The step in which increments/decrements have to be made - min_steps_between_thumbs: The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together. - orientation: Oreintation of the slider vertical | horizontal. - min_h: Minimum height of the slider. - min_w: Minimum width of the slider. - max_h: Maximum height of the slider. - max_w: Maximum width of the slider. - name: The name of the form field - 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 properties of the component. - - Returns: - The slider component. - """ - ... - -class SliderTrack(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SliderTrack": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class SliderFilledTrack(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SliderFilledTrack": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class SliderThumb(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - box_size: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SliderThumb": - """Create the component. - - Args: - *children: The children of the component. - box_size: The size of the thumb. - 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 of the component. - - Returns: - The component. - """ - ... - -class SliderMark(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "SliderMark": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/switch.py b/reflex/components/chakra/forms/switch.py deleted file mode 100644 index 6079de2bb..000000000 --- a/reflex/components/chakra/forms/switch.py +++ /dev/null @@ -1,58 +0,0 @@ -"""A switch component.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent, LiteralColorScheme -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class Switch(ChakraComponent): - """Toggleable switch component.""" - - tag = "Switch" - - # If true, the switch will be checked. You'll need to set an on_change event handler to update its value (since it is now controlled) - is_checked: Var[bool] - - # If true, the switch will be disabled - is_disabled: Var[bool] - - # If true and is_disabled prop is set, the switch will remain tabbable but not interactive. - is_focusable: Var[bool] - - # If true, the switch is marked as invalid. Changes style of unchecked state. - is_invalid: Var[bool] - - # If true, the switch will be readonly - is_read_only: Var[bool] - - # If true, the switch will be required - is_required: Var[bool] - - # The name of the input field in a switch (Useful for form submission). - name: Var[str] - - # The value of the input field when checked (use is_checked prop for a bool) - value: Var[str] = Var.create(True) # type: ignore - - # The spacing between the switch and its label text (0.5rem) - spacing: Var[str] - - # The placeholder text. - placeholder: Var[str] - - # The color scheme of the switch (e.g. "blue", "green", "red", etc.) - color_scheme: Var[LiteralColorScheme] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.checked], - } diff --git a/reflex/components/chakra/forms/switch.pyi b/reflex/components/chakra/forms/switch.pyi deleted file mode 100644 index 46258139f..000000000 --- a/reflex/components/chakra/forms/switch.pyi +++ /dev/null @@ -1,162 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/switch.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralColorScheme -from reflex.constants import EventTriggers -from reflex.vars import Var - -class Switch(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_checked: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - name: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - spacing: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Switch": - """Create the component. - - Args: - *children: The children of the component. - is_checked: If true, the switch will be checked. You'll need to set an on_change event handler to update its value (since it is now controlled) - is_disabled: If true, the switch will be disabled - is_focusable: If true and is_disabled prop is set, the switch will remain tabbable but not interactive. - is_invalid: If true, the switch is marked as invalid. Changes style of unchecked state. - is_read_only: If true, the switch will be readonly - is_required: If true, the switch will be required - name: The name of the input field in a switch (Useful for form submission). - value: The value of the input field when checked (use is_checked prop for a bool) - spacing: The spacing between the switch and its label text (0.5rem) - placeholder: The placeholder text. - color_scheme: The color scheme of the switch (e.g. "blue", "green", "red", etc.) - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/textarea.py b/reflex/components/chakra/forms/textarea.py deleted file mode 100644 index ecbe15e1e..000000000 --- a/reflex/components/chakra/forms/textarea.py +++ /dev/null @@ -1,80 +0,0 @@ -"""A textarea component.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.constants import EventTriggers -from reflex.vars import Var - - -class TextArea(ChakraComponent): - """A text area component.""" - - tag = "Textarea" - - # State var to bind the input. - value: Var[str] - - # The default value of the textarea. - default_value: Var[str] - - # The placeholder text. - placeholder: Var[str] - - # The border color when the input is invalid. - error_border_color: Var[str] - - # The border color when the input is focused. - focus_border_color: Var[str] - - # If true, the form control will be disabled. - is_disabled: Var[bool] - - # If true, the form control will be invalid. - is_invalid: Var[bool] - - # If true, the form control will be read-only. - is_read_only: Var[bool] - - # If true, the form control will be required. - is_required: Var[bool] - - # "outline" | "filled" | "flushed" | "unstyled" - variant: Var[LiteralInputVariant] - - # The name of the form field - name: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create an Input component. - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The component. - """ - if props.get("value") is not None and props.get("on_change"): - # create a debounced input if the user requests full control to avoid typing jank - return DebounceInput.create(super().create(*children, **props)) - return super().create(*children, **props) diff --git a/reflex/components/chakra/forms/textarea.pyi b/reflex/components/chakra/forms/textarea.pyi deleted file mode 100644 index 572b92ed2..000000000 --- a/reflex/components/chakra/forms/textarea.pyi +++ /dev/null @@ -1,128 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/textarea.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.constants import EventTriggers -from reflex.vars import Var - -class TextArea(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TextArea": - """Create an Input component. - - Args: - *children: The children of the component. - value: State var to bind the input. - default_value: The default value of the textarea. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. - is_invalid: If true, the form control will be invalid. - is_read_only: If true, the form control will be read-only. - is_required: If true, the form control will be required. - variant: "outline" | "filled" | "flushed" | "unstyled" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/forms/time_picker.py b/reflex/components/chakra/forms/time_picker.py deleted file mode 100644 index d778293fd..000000000 --- a/reflex/components/chakra/forms/time_picker.py +++ /dev/null @@ -1,11 +0,0 @@ -"""A time input component.""" - -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - - -class TimePicker(Input): - """A time input component.""" - - # The type of input. - type_: Var[str] = "time" # type: ignore diff --git a/reflex/components/chakra/forms/time_picker.pyi b/reflex/components/chakra/forms/time_picker.pyi deleted file mode 100644 index 7a8e3c1c1..000000000 --- a/reflex/components/chakra/forms/time_picker.pyi +++ /dev/null @@ -1,129 +0,0 @@ -"""Stub file for reflex/components/chakra/forms/time_picker.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra.forms.input import Input -from reflex.vars import Var - -class TimePicker(Input): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[str], str]] = None, - default_value: Optional[Union[Var[str], str]] = None, - placeholder: Optional[Union[Var[str], str]] = None, - error_border_color: Optional[Union[Var[str], str]] = None, - focus_border_color: Optional[Union[Var[str], str]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_invalid: Optional[Union[Var[bool], bool]] = None, - is_read_only: Optional[Union[Var[bool], bool]] = None, - is_required: Optional[Union[Var[bool], bool]] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "flushed", "unstyled"]], - Literal["outline", "filled", "flushed", "unstyled"], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]] - ] = None, - name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "TimePicker": - """Create an Input component. - - Args: - *children: The children of the component. - type_: The type of input. - value: State var to bind the input. - default_value: The default value of the input. - placeholder: The placeholder text. - error_border_color: The border color when the input is invalid. - focus_border_color: The border color when the input is focused. - is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled - is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true - is_read_only: If true, the form control will be readonly. - is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true - variant: "outline" | "filled" | "flushed" | "unstyled" - size: "lg" | "md" | "sm" | "xs" - name: The name of the form field - 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 properties of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/__init__.py b/reflex/components/chakra/layout/__init__.py deleted file mode 100644 index 13c28fdd4..000000000 --- a/reflex/components/chakra/layout/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -"""Convenience functions to define layout components.""" - -from .aspect_ratio import AspectRatio -from .box import Box -from .card import Card, CardBody, CardFooter, CardHeader -from .center import Center, Circle, Square -from .container import Container -from .flex import Flex -from .grid import Grid, GridItem, ResponsiveGrid -from .spacer import Spacer -from .stack import Hstack, Stack, Vstack -from .wrap import Wrap, WrapItem - -__all__ = [f for f in dir() if f[0].isupper()] # type: ignore diff --git a/reflex/components/chakra/layout/aspect_ratio.py b/reflex/components/chakra/layout/aspect_ratio.py deleted file mode 100644 index 5d0328d7e..000000000 --- a/reflex/components/chakra/layout/aspect_ratio.py +++ /dev/null @@ -1,13 +0,0 @@ -"""A AspectRatio component.""" - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class AspectRatio(ChakraComponent): - """AspectRatio component is used to embed responsive videos and maps, etc.""" - - tag = "AspectRatio" - - # The aspect ratio of the Box - ratio: Var[float] diff --git a/reflex/components/chakra/layout/aspect_ratio.pyi b/reflex/components/chakra/layout/aspect_ratio.pyi deleted file mode 100644 index 79867d697..000000000 --- a/reflex/components/chakra/layout/aspect_ratio.pyi +++ /dev/null @@ -1,89 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/aspect_ratio.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class AspectRatio(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - ratio: Optional[Union[Var[float], float]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AspectRatio": - """Create the component. - - Args: - *children: The children of the component. - ratio: The aspect ratio of the Box - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/box.py b/reflex/components/chakra/layout/box.py deleted file mode 100644 index 497e514b8..000000000 --- a/reflex/components/chakra/layout/box.py +++ /dev/null @@ -1,31 +0,0 @@ -"""A box component that can contain other components.""" - -from reflex.components.chakra import ChakraComponent -from reflex.components.tags import Tag -from reflex.vars import Var - - -class Box(ChakraComponent): - """A generic container component that can contain other components.""" - - tag = "Box" - - # The type element to render. You can specify an image, video, or any other HTML element such as iframe. - element: Var[str] - - # The source of the content. - src: Var[str] - - # The alt text of the content. - alt: Var[str] - - def _render(self) -> Tag: - return ( - super() - ._render() - .add_props( - **{ - "as": self.element, - } - ) - ) diff --git a/reflex/components/chakra/layout/box.pyi b/reflex/components/chakra/layout/box.pyi deleted file mode 100644 index 573a9c0b4..000000000 --- a/reflex/components/chakra/layout/box.pyi +++ /dev/null @@ -1,94 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/box.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.tags import Tag -from reflex.vars import Var - -class Box(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - element: Optional[Union[Var[str], str]] = None, - src: Optional[Union[Var[str], str]] = None, - alt: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Box": - """Create the component. - - Args: - *children: The children of the component. - element: The type element to render. You can specify an image, video, or any other HTML element such as iframe. - src: The source of the content. - alt: The alt text of the content. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/card.py b/reflex/components/chakra/layout/card.py deleted file mode 100644 index 595c5327f..000000000 --- a/reflex/components/chakra/layout/card.py +++ /dev/null @@ -1,100 +0,0 @@ -"""Chakra Card component.""" - -from typing import Optional - -from reflex.components.chakra import ( - ChakraComponent, - LiteralCardVariant, - LiteralColorScheme, - LiteralTagSize, -) -from reflex.components.component import Component -from reflex.vars import Var - - -class CardHeader(ChakraComponent): - """The wrapper that contains a card's header.""" - - tag = "CardHeader" - - -class CardBody(ChakraComponent): - """The wrapper that houses the card's main content.""" - - tag = "CardBody" - - -class CardFooter(ChakraComponent): - """The footer that houses the card actions.""" - - tag = "CardFooter" - - -class Card(ChakraComponent): - """The parent wrapper that provides context for its children.""" - - tag = "Card" - - # [required] The flex alignment of the card - align: Var[str] - - # [required] The flex direction of the card - direction: Var[str] - - # [required] The flex distribution of the card - justify: Var[str] - - # The visual color appearance of the component. - # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | - # "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | - # "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - # default: "gray" - color_scheme: Var[LiteralColorScheme] - - # The size of the Card - # options: "sm" | "md" | "lg" - # default: "md" - size: Var[LiteralTagSize] - - # The variant of the Card - # options: "elevated" | "outline" | "filled" | "unstyled" - # default: "elevated" - variant: Var[LiteralCardVariant] - - @classmethod - def create( - cls, - body: Component, - *, - header: Optional[Component] = None, - footer: Optional[Component] = None, - **props, - ) -> Component: - """Creates a Chakra Card with a body and optionally header and/or footer, and returns it. - If header, body or footer are not already instances of Chead, Cbody or Cfoot respectively, - they will be wrapped as such for layout purposes. If you want to modify their props, - e.g. padding_left, you should wrap them yourself. - - Args: - body (Component): The main content of the Card that will be created. - header (Optional[Component]): The header of the Card. - footer (Optional[Component]): The footer of the Card. - props: The properties to be passed to the component. - - Returns: - The `create()` method returns a Card object. - """ - children = [] - param_to_component_class = ( - (header, CardHeader), - (body, CardBody), - (footer, CardFooter), - ) - - for param, component_class in param_to_component_class: - if isinstance(param, component_class): - children.append(param) - elif param is not None: - children.append(component_class.create(param)) - - return super().create(*children, **props) diff --git a/reflex/components/chakra/layout/card.pyi b/reflex/components/chakra/layout/card.pyi deleted file mode 100644 index 0a0d9b8bc..000000000 --- a/reflex/components/chakra/layout/card.pyi +++ /dev/null @@ -1,383 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/card.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.chakra import ( - ChakraComponent, - LiteralCardVariant, - LiteralColorScheme, - LiteralTagSize, -) -from reflex.components.component import Component -from reflex.vars import Var - -class CardHeader(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CardHeader": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class CardBody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CardBody": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class CardFooter(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "CardFooter": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Card(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - header: Optional[Component] = None, - footer: Optional[Component] = None, - align: Optional[Union[Var[str], str]] = None, - direction: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[str], str]] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - size: Optional[ - Union[Var[Literal["sm", "md", "lg"]], Literal["sm", "md", "lg"]] - ] = None, - variant: Optional[ - Union[ - Var[Literal["outline", "filled", "elevated", "unstyled"]], - Literal["outline", "filled", "elevated", "unstyled"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Card": - """Creates a Chakra Card with a body and optionally header and/or footer, and returns it. - If header, body or footer are not already instances of Chead, Cbody or Cfoot respectively, - they will be wrapped as such for layout purposes. If you want to modify their props, - e.g. padding_left, you should wrap them yourself. - - Args: - body (Component): The main content of the Card that will be created. - header (Optional[Component]): The header of the Card. - footer (Optional[Component]): The footer of the Card. - props: The properties to be passed to the component. - - Returns: - The `create()` method returns a Card object. - """ - ... diff --git a/reflex/components/chakra/layout/center.py b/reflex/components/chakra/layout/center.py deleted file mode 100644 index bc3ced1aa..000000000 --- a/reflex/components/chakra/layout/center.py +++ /dev/null @@ -1,21 +0,0 @@ -"""A box that centers its contents.""" - -from reflex.components.chakra import ChakraComponent - - -class Center(ChakraComponent): - """A box that centers its contents.""" - - tag = "Center" - - -class Square(ChakraComponent): - """A centered square container.""" - - tag = "Square" - - -class Circle(ChakraComponent): - """A square container with round border-radius.""" - - tag = "Circle" diff --git a/reflex/components/chakra/layout/center.pyi b/reflex/components/chakra/layout/center.pyi deleted file mode 100644 index 977f62c06..000000000 --- a/reflex/components/chakra/layout/center.pyi +++ /dev/null @@ -1,238 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/center.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent - -class Center(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Center": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Square(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Square": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Circle(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Circle": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/container.py b/reflex/components/chakra/layout/container.py deleted file mode 100644 index 26863d018..000000000 --- a/reflex/components/chakra/layout/container.py +++ /dev/null @@ -1,13 +0,0 @@ -"""A flexbox container.""" - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Container(ChakraComponent): - """A flexbox container that centers its children and sets a max width.""" - - tag = "Container" - - # If true, container will center its children regardless of their width. - center_content: Var[bool] diff --git a/reflex/components/chakra/layout/container.pyi b/reflex/components/chakra/layout/container.pyi deleted file mode 100644 index 7b4ea5161..000000000 --- a/reflex/components/chakra/layout/container.pyi +++ /dev/null @@ -1,89 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/container.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Container(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - center_content: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Container": - """Create the component. - - Args: - *children: The children of the component. - center_content: If true, container will center its children regardless of their width. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/flex.py b/reflex/components/chakra/layout/flex.py deleted file mode 100644 index ff6e5abce..000000000 --- a/reflex/components/chakra/layout/flex.py +++ /dev/null @@ -1,33 +0,0 @@ -"""A reflexive container component.""" - -from typing import List, Union - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Flex(ChakraComponent): - """A reflexive container component.""" - - tag = "Flex" - - # How to align items in the flex. - align: Var[str] - - # Shorthand for flexBasis style prop - basis: Var[str] - - # Shorthand for flexDirection style prop - direction: Var[Union[str, List[str]]] - - # Shorthand for flexGrow style prop - grow: Var[str] - - # The way to justify the items. - justify: Var[str] - - # Shorthand for flexWrap style prop - wrap: Var[Union[str, List[str]]] - - # Shorthand for flexShrink style prop - shrink: Var[str] diff --git a/reflex/components/chakra/layout/flex.pyi b/reflex/components/chakra/layout/flex.pyi deleted file mode 100644 index a8833c246..000000000 --- a/reflex/components/chakra/layout/flex.pyi +++ /dev/null @@ -1,104 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/flex.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Union -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Flex(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - align: Optional[Union[Var[str], str]] = None, - basis: Optional[Union[Var[str], str]] = None, - direction: Optional[ - Union[Var[Union[str, List[str]]], Union[str, List[str]]] - ] = None, - grow: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[str], str]] = None, - wrap: Optional[Union[Var[Union[str, List[str]]], Union[str, List[str]]]] = None, - shrink: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Flex": - """Create the component. - - Args: - *children: The children of the component. - align: How to align items in the flex. - basis: Shorthand for flexBasis style prop - direction: Shorthand for flexDirection style prop - grow: Shorthand for flexGrow style prop - justify: The way to justify the items. - wrap: Shorthand for flexWrap style prop - shrink: Shorthand for flexShrink style prop - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/grid.py b/reflex/components/chakra/layout/grid.py deleted file mode 100644 index ee1d8aa33..000000000 --- a/reflex/components/chakra/layout/grid.py +++ /dev/null @@ -1,125 +0,0 @@ -"""Container to stack elements with spacing.""" - -from typing import List - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Grid(ChakraComponent): - """A grid component.""" - - tag = "Grid" - - # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_ - auto_columns: Var[str] - - # Shorthand prop for gridAutoFlow to specify exactly how - # auto-placed items get flowed into the grid. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_ - auto_flow: Var[str] - - # Shorthand prop for gridAutoRows. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_ - auto_rows: Var[str] - - # Shorthand prop for gridColumn. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_ - column: Var[str] - - # Shorthand prop for gridRow. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_ - row: Var[str] - - # Shorthand prop for gridTemplateColumns. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_ - template_columns: Var[str] - - # Shorthand prop for gridTemplateRows. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_ - template_rows: Var[str] - - -class GridItem(ChakraComponent): - """Used as a child of Grid to control the span, and start positions within the grid.""" - - tag = "GridItem" - - # Shorthand prop for gridArea - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area)_ - area: Var[str] - - # Shorthand prop for gridColumnEnd - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end)_ - col_end: Var[str] - - # The column number the grid item should start. - col_start: Var[int] - - # The number of columns the grid item should span. - col_span: Var[int] - - # Shorthand prop for gridRowEnd - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end)_ - row_end: Var[str] - - # The row number the grid item should start. - row_start: Var[int] - - # The number of rows the grid item should span. - row_span: Var[int] - - -class ResponsiveGrid(ChakraComponent): - """A responsive grid component.""" - - tag = "SimpleGrid" - - # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_ - auto_columns: Var[str] - - # Shorthand prop for gridAutoFlow to specify exactly how - # auto-placed items get flowed into the grid. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_ - auto_flow: Var[str] - - # Shorthand prop for gridAutoRows. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_ - auto_rows: Var[str] - - # Shorthand prop for gridColumn. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_ - column: Var[str] - - # Shorthand prop for gridRow. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_ - row: Var[str] - - # A list that defines the number of columns for each breakpoint. - columns: Var[List[int]] - - # The width at which child elements will break into columns. Pass a number for pixel values or a string for any other valid CSS length. - min_child_width: Var[str] - - # The gap between the grid items - spacing: Var[str] - - # The column gap between the grid items - spacing_x: Var[str] - - # The row gap between the grid items - spacing_y: Var[str] - - # Shorthand prop for gridTemplateAreas - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas)_ - template_areas: Var[str] - - # Shorthand prop for gridTemplateColumns. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_ - template_columns: Var[str] - - # Shorthand prop for gridTemplateRows. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_ - template_rows: Var[str] diff --git a/reflex/components/chakra/layout/grid.pyi b/reflex/components/chakra/layout/grid.pyi deleted file mode 100644 index 07506e262..000000000 --- a/reflex/components/chakra/layout/grid.pyi +++ /dev/null @@ -1,294 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/grid.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Grid(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - auto_columns: Optional[Union[Var[str], str]] = None, - auto_flow: Optional[Union[Var[str], str]] = None, - auto_rows: Optional[Union[Var[str], str]] = None, - column: Optional[Union[Var[str], str]] = None, - row: Optional[Union[Var[str], str]] = None, - template_columns: Optional[Union[Var[str], str]] = None, - template_rows: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Grid": - """Create the component. - - Args: - *children: The children of the component. - auto_columns: Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_ - auto_flow: Shorthand prop for gridAutoFlow to specify exactly how auto-placed items get flowed into the grid. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_ - auto_rows: Shorthand prop for gridAutoRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_ - column: Shorthand prop for gridColumn. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_ - row: Shorthand prop for gridRow. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_ - template_columns: Shorthand prop for gridTemplateColumns. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_ - template_rows: Shorthand prop for gridTemplateRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_ - 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 of the component. - - Returns: - The component. - """ - ... - -class GridItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - area: Optional[Union[Var[str], str]] = None, - col_end: Optional[Union[Var[str], str]] = None, - col_start: Optional[Union[Var[int], int]] = None, - col_span: Optional[Union[Var[int], int]] = None, - row_end: Optional[Union[Var[str], str]] = None, - row_start: Optional[Union[Var[int], int]] = None, - row_span: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "GridItem": - """Create the component. - - Args: - *children: The children of the component. - area: Shorthand prop for gridArea Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area)_ - col_end: Shorthand prop for gridColumnEnd Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end)_ - col_start: The column number the grid item should start. - col_span: The number of columns the grid item should span. - row_end: Shorthand prop for gridRowEnd Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end)_ - row_start: The row number the grid item should start. - row_span: The number of rows the grid item should span. - 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 of the component. - - Returns: - The component. - """ - ... - -class ResponsiveGrid(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - auto_columns: Optional[Union[Var[str], str]] = None, - auto_flow: Optional[Union[Var[str], str]] = None, - auto_rows: Optional[Union[Var[str], str]] = None, - column: Optional[Union[Var[str], str]] = None, - row: Optional[Union[Var[str], str]] = None, - columns: Optional[Union[Var[List[int]], List[int]]] = None, - min_child_width: Optional[Union[Var[str], str]] = None, - spacing: Optional[Union[Var[str], str]] = None, - spacing_x: Optional[Union[Var[str], str]] = None, - spacing_y: Optional[Union[Var[str], str]] = None, - template_areas: Optional[Union[Var[str], str]] = None, - template_columns: Optional[Union[Var[str], str]] = None, - template_rows: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ResponsiveGrid": - """Create the component. - - Args: - *children: The children of the component. - auto_columns: Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_ - auto_flow: Shorthand prop for gridAutoFlow to specify exactly how auto-placed items get flowed into the grid. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_ - auto_rows: Shorthand prop for gridAutoRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_ - column: Shorthand prop for gridColumn. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_ - row: Shorthand prop for gridRow. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_ - columns: A list that defines the number of columns for each breakpoint. - min_child_width: The width at which child elements will break into columns. Pass a number for pixel values or a string for any other valid CSS length. - spacing: The gap between the grid items - spacing_x: The column gap between the grid items - spacing_y: The row gap between the grid items - template_areas: Shorthand prop for gridTemplateAreas Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas)_ - template_columns: Shorthand prop for gridTemplateColumns. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_ - template_rows: Shorthand prop for gridTemplateRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_ - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/spacer.py b/reflex/components/chakra/layout/spacer.py deleted file mode 100644 index 3888f3726..000000000 --- a/reflex/components/chakra/layout/spacer.py +++ /dev/null @@ -1,9 +0,0 @@ -"""A flexible space component.""" - -from reflex.components.chakra import ChakraComponent - - -class Spacer(ChakraComponent): - """A flexible space component.""" - - tag = "Spacer" diff --git a/reflex/components/chakra/layout/spacer.pyi b/reflex/components/chakra/layout/spacer.pyi deleted file mode 100644 index 1475dac45..000000000 --- a/reflex/components/chakra/layout/spacer.pyi +++ /dev/null @@ -1,86 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/spacer.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent - -class Spacer(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Spacer": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/stack.py b/reflex/components/chakra/layout/stack.py deleted file mode 100644 index 8e2ab34e6..000000000 --- a/reflex/components/chakra/layout/stack.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Container to stack elements with spacing.""" - -from typing import List, Union - -from reflex.components.chakra import ChakraComponent, LiteralStackDirection -from reflex.vars import Var - - -class Stack(ChakraComponent): - """Container to stack elements with spacing.""" - - tag = "Stack" - - # Shorthand for alignItems style prop - align_items: Var[str] - - # The direction to stack the items. - direction: Var[Union[LiteralStackDirection, List[str]]] - - # If true the items will be stacked horizontally. - is_inline: Var[bool] - - # Shorthand for justifyContent style prop - justify_content: Var[str] - - # If true, the children will be wrapped in a Box, and the Box will take the spacing props - should_wrap_children: Var[bool] - - # The space between each stack item - spacing: Var[str] - - # Shorthand for flexWrap style prop - wrap: Var[str] - - # Alignment of contents. - justify: Var[str] - - -class Hstack(Stack): - """Stack items horizontally.""" - - tag = "HStack" - - -class Vstack(Stack): - """Stack items vertically.""" - - tag = "VStack" diff --git a/reflex/components/chakra/layout/stack.pyi b/reflex/components/chakra/layout/stack.pyi deleted file mode 100644 index 8de464523..000000000 --- a/reflex/components/chakra/layout/stack.pyi +++ /dev/null @@ -1,303 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/stack.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Union -from reflex.components.chakra import ChakraComponent, LiteralStackDirection -from reflex.vars import Var - -class Stack(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - align_items: Optional[Union[Var[str], str]] = None, - direction: Optional[ - Union[ - Var[Union[Literal["row", "column"], List[str]]], - Union[Literal["row", "column"], List[str]], - ] - ] = None, - is_inline: Optional[Union[Var[bool], bool]] = None, - justify_content: Optional[Union[Var[str], str]] = None, - should_wrap_children: Optional[Union[Var[bool], bool]] = None, - spacing: Optional[Union[Var[str], str]] = None, - wrap: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Stack": - """Create the component. - - Args: - *children: The children of the component. - align_items: Shorthand for alignItems style prop - direction: The direction to stack the items. - is_inline: If true the items will be stacked horizontally. - justify_content: Shorthand for justifyContent style prop - should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props - spacing: The space between each stack item - wrap: Shorthand for flexWrap style prop - justify: Alignment of contents. - 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 of the component. - - Returns: - The component. - """ - ... - -class Hstack(Stack): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - align_items: Optional[Union[Var[str], str]] = None, - direction: Optional[ - Union[ - Var[Union[Literal["row", "column"], List[str]]], - Union[Literal["row", "column"], List[str]], - ] - ] = None, - is_inline: Optional[Union[Var[bool], bool]] = None, - justify_content: Optional[Union[Var[str], str]] = None, - should_wrap_children: Optional[Union[Var[bool], bool]] = None, - spacing: Optional[Union[Var[str], str]] = None, - wrap: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Hstack": - """Create the component. - - Args: - *children: The children of the component. - align_items: Shorthand for alignItems style prop - direction: The direction to stack the items. - is_inline: If true the items will be stacked horizontally. - justify_content: Shorthand for justifyContent style prop - should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props - spacing: The space between each stack item - wrap: Shorthand for flexWrap style prop - justify: Alignment of contents. - 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 of the component. - - Returns: - The component. - """ - ... - -class Vstack(Stack): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - align_items: Optional[Union[Var[str], str]] = None, - direction: Optional[ - Union[ - Var[Union[Literal["row", "column"], List[str]]], - Union[Literal["row", "column"], List[str]], - ] - ] = None, - is_inline: Optional[Union[Var[bool], bool]] = None, - justify_content: Optional[Union[Var[str], str]] = None, - should_wrap_children: Optional[Union[Var[bool], bool]] = None, - spacing: Optional[Union[Var[str], str]] = None, - wrap: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Vstack": - """Create the component. - - Args: - *children: The children of the component. - align_items: Shorthand for alignItems style prop - direction: The direction to stack the items. - is_inline: If true the items will be stacked horizontally. - justify_content: Shorthand for justifyContent style prop - should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props - spacing: The space between each stack item - wrap: Shorthand for flexWrap style prop - justify: Alignment of contents. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/layout/wrap.py b/reflex/components/chakra/layout/wrap.py deleted file mode 100644 index 5d436c5b2..000000000 --- a/reflex/components/chakra/layout/wrap.py +++ /dev/null @@ -1,57 +0,0 @@ -"""Container to stack elements with spacing.""" - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - - -class Wrap(ChakraComponent): - """Layout component used to add space between elements and wrap automatically if there isn't enough space.""" - - tag = "Wrap" - - # How to align the items. - align: Var[str] - - # The flex direction of the wrap. - direction: Var[str] - - # How to justify the items. - justify: Var[str] - - # Whether to wrap children in `rx.wrap_item`. - should_wrap_children: Var[bool] - - # The spacing between the items. - spacing: Var[str] - - # The horizontal spacing between the items. - spacing_x: Var[str] - - # The vertical spacing between the items. - spacing_y: Var[str] - - @classmethod - def create(cls, *children, items=None, **props) -> Component: - """Return a wrap component. - - Args: - *children: The children of the component. - items (list): The items of the wrap component. - **props: The properties of the component. - - Returns: - The wrap component. - """ - if len(children) == 0: - children = [] - for item in items or []: - children.append(WrapItem.create(*item)) - - return super().create(*children, **props) - - -class WrapItem(ChakraComponent): - """Item of the Wrap component.""" - - tag = "WrapItem" diff --git a/reflex/components/chakra/layout/wrap.pyi b/reflex/components/chakra/layout/wrap.pyi deleted file mode 100644 index 4d99fe552..000000000 --- a/reflex/components/chakra/layout/wrap.pyi +++ /dev/null @@ -1,180 +0,0 @@ -"""Stub file for reflex/components/chakra/layout/wrap.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.vars import Var - -class Wrap(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items=None, - align: Optional[Union[Var[str], str]] = None, - direction: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[str], str]] = None, - should_wrap_children: Optional[Union[Var[bool], bool]] = None, - spacing: Optional[Union[Var[str], str]] = None, - spacing_x: Optional[Union[Var[str], str]] = None, - spacing_y: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Wrap": - """Return a wrap component. - - Args: - *children: The children of the component. - items (list): The items of the wrap component. - align: How to align the items. - direction: The flex direction of the wrap. - justify: How to justify the items. - should_wrap_children: Whether to wrap children in `rx.wrap_item`. - spacing: The spacing between the items. - spacing_x: The horizontal spacing between the items. - spacing_y: The vertical spacing between the items. - 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 properties of the component. - - Returns: - The wrap component. - """ - ... - -class WrapItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "WrapItem": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/media/__init__.py b/reflex/components/chakra/media/__init__.py deleted file mode 100644 index 8346a37a6..000000000 --- a/reflex/components/chakra/media/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Media components.""" - -from .avatar import Avatar, AvatarBadge, AvatarGroup -from .icon import Icon -from .image import Image - -__all__ = [f for f in dir() if f[0].isupper()] # type: ignore diff --git a/reflex/components/chakra/media/avatar.py b/reflex/components/chakra/media/avatar.py deleted file mode 100644 index 80a0b7174..000000000 --- a/reflex/components/chakra/media/avatar.py +++ /dev/null @@ -1,66 +0,0 @@ -"""Avatar components.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent, LiteralAvatarSize -from reflex.vars import Var - - -class Avatar(ChakraComponent): - """The image that represents the user.""" - - tag = "Avatar" - - # The default avatar used as fallback when name, and src is not specified. - icon: Var[str] - - # The label of the icon. - icon_label: Var[str] - - # If true, opt out of the avatar's fallback logic and renders the img at all times. - ignore_fallback: Var[bool] - - # The name of the person in the avatar. - name: Var[str] - - # If true, the Avatar will show a border around it. Best for a group of avatars. - show_border: Var[bool] - - # The image url of the Avatar. - src: Var[str] - - # List of sources to use for different screen resolutions. - src_set: Var[str] - - # "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full" - size: Var[LiteralAvatarSize] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_error": lambda: [], - } - - -class AvatarBadge(ChakraComponent): - """A wrapper that displays its content on the right corner of the avatar.""" - - tag = "AvatarBadge" - - -class AvatarGroup(ChakraComponent): - """A wrapper to stack multiple Avatars together.""" - - tag = "AvatarGroup" - - # The maximum number of visible avatars. - max_: Var[int] - - # The space between the avatars in the group. - spacing: Var[int] diff --git a/reflex/components/chakra/media/avatar.pyi b/reflex/components/chakra/media/avatar.pyi deleted file mode 100644 index 98d2f320b..000000000 --- a/reflex/components/chakra/media/avatar.pyi +++ /dev/null @@ -1,269 +0,0 @@ -"""Stub file for reflex/components/chakra/media/avatar.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralAvatarSize -from reflex.vars import Var - -class Avatar(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - icon: Optional[Union[Var[str], str]] = None, - icon_label: Optional[Union[Var[str], str]] = None, - ignore_fallback: Optional[Union[Var[bool], bool]] = None, - name: Optional[Union[Var[str], str]] = None, - show_border: Optional[Union[Var[bool], bool]] = None, - src: Optional[Union[Var[str], str]] = None, - src_set: Optional[Union[Var[str], str]] = None, - size: Optional[ - Union[ - Var[Literal["sm", "md", "lg", "xl", "xs", "2xl", "full", "2xs"]], - Literal["sm", "md", "lg", "xl", "xs", "2xl", "full", "2xs"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Avatar": - """Create the component. - - Args: - *children: The children of the component. - icon: The default avatar used as fallback when name, and src is not specified. - icon_label: The label of the icon. - ignore_fallback: If true, opt out of the avatar's fallback logic and renders the img at all times. - name: The name of the person in the avatar. - show_border: If true, the Avatar will show a border around it. Best for a group of avatars. - src: The image url of the Avatar. - src_set: List of sources to use for different screen resolutions. - size: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full" - 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 of the component. - - Returns: - The component. - """ - ... - -class AvatarBadge(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AvatarBadge": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AvatarGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - max_: Optional[Union[Var[int], int]] = None, - spacing: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AvatarGroup": - """Create the component. - - Args: - *children: The children of the component. - max_: The maximum number of visible avatars. - spacing: The space between the avatars in the group. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/media/icon.py b/reflex/components/chakra/media/icon.py deleted file mode 100644 index 00ea40579..000000000 --- a/reflex/components/chakra/media/icon.py +++ /dev/null @@ -1,110 +0,0 @@ -"""An icon component.""" -from typing import List - -from reflex.components.chakra import ChakraComponent -from reflex.utils import format - - -class ChakraIconComponent(ChakraComponent): - """A component that wraps a Chakra icon component.""" - - library = "@chakra-ui/icons@2.0.19" - - -class Icon(ChakraIconComponent): - """An image icon.""" - - tag = "None" - - @classmethod - def create(cls, *children, **props): - """Initialize the Icon component. - - Run some additional checks on Icon component. - - Args: - *children: The positional arguments - **props: The keyword arguments - - Raises: - AttributeError: The errors tied to bad usage of the Icon component. - ValueError: If the icon tag is invalid. - - Returns: - The created component. - """ - if children: - raise AttributeError( - f"Passing children to Icon component is not allowed: remove positional arguments {children} to fix" - ) - if "tag" not in props: - raise AttributeError("Missing 'tag' keyword-argument for Icon") - if not isinstance(props["tag"], str) or props["tag"].lower() not in ICON_LIST: - raise ValueError( - f"Invalid icon tag: {props['tag']}. Please use one of the following: {sorted(ICON_LIST)}" - ) - props["tag"] = format.to_title_case(props["tag"]) + "Icon" - return super().create(*children, **props) - - -# List of all icons. -ICON_LIST: List[str] = [ - "add", - "arrow_back", - "arrow_down", - "arrow_forward", - "arrow_left", - "arrow_right", - "arrow_up", - "arrow_up_down", - "at_sign", - "attachment", - "bell", - "calendar", - "chat", - "check_circle", - "check", - "chevron_down", - "chevron_left", - "chevron_right", - "chevron_up", - "close", - "copy", - "delete", - "download", - "drag_handle", - "edit", - "email", - "external_link", - "hamburger", - "info", - "info_outline", - "link", - "lock", - "minus", - "moon", - "not_allowed", - "phone", - "plus_square", - "question", - "question_outline", - "repeat", - "repeat_clock", - "search", - "search2", - "settings", - "small_add", - "small_close", - "spinner", - "star", - "sun", - "time", - "triangle_down", - "triangle_up", - "unlock", - "up_down", - "view", - "view_off", - "warning", - "warning_two", -] diff --git a/reflex/components/chakra/media/icon.pyi b/reflex/components/chakra/media/icon.pyi deleted file mode 100644 index ac5b74d12..000000000 --- a/reflex/components/chakra/media/icon.pyi +++ /dev/null @@ -1,172 +0,0 @@ -"""Stub file for reflex/components/chakra/media/icon.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List -from reflex.components.chakra import ChakraComponent -from reflex.utils import format - -class ChakraIconComponent(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ChakraIconComponent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Icon(ChakraIconComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Icon": - """Initialize the Icon component. - - Run some additional checks on Icon component. - - Args: - *children: The positional arguments - 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 keyword arguments - - Raises: - AttributeError: The errors tied to bad usage of the Icon component. - ValueError: If the icon tag is invalid. - - Returns: - The created component. - """ - ... - -ICON_LIST: List[str] diff --git a/reflex/components/chakra/media/image.py b/reflex/components/chakra/media/image.py deleted file mode 100644 index 2b1a4e26f..000000000 --- a/reflex/components/chakra/media/image.py +++ /dev/null @@ -1,78 +0,0 @@ -"""An image component.""" -from __future__ import annotations - -from typing import Any, Optional, Union - -from reflex.components.chakra import ChakraComponent, LiteralImageLoading -from reflex.components.component import Component -from reflex.vars import Var - - -class Image(ChakraComponent): - """Display an image.""" - - tag = "Image" - alias = "ChakraImage" - # How to align the image within its bounds. It maps to css `object-position` property. - align: Var[str] - - # Fallback Reflex component to show if image is loading or image fails. - fallback: Optional[Component] = None - - # Fallback image src to show if image is loading or image fails. - fallback_src: Var[str] - - # How the image to fit within its bounds. It maps to css `object-fit` property. - fit: Var[str] - - # The native HTML height attribute to the passed to the img. - html_height: Var[str] - - # The native HTML width attribute to the passed to the img. - html_width: Var[str] - - # If true, opt out of the fallbackSrc logic and use as img. - ignore_fallback: Var[bool] - - # "eager" | "lazy" - loading: Var[LiteralImageLoading] - - # The path/url to the image or PIL image object. - src: Var[Any] - - # The alt text of the image. - alt: Var[str] - - # Provide multiple sources for an image, allowing the browser - # to select the most appropriate source based on factors like - # screen resolution and device capabilities. - # Learn more _[here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)_ - src_set: Var[str] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_error": lambda: [], - "on_load": lambda: [], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create an Image component. - - Args: - *children: The children of the image. - **props: The props of the image. - - Returns: - The Image component. - """ - src = props.get("src", None) - if src is not None and not isinstance(src, (Var)): - props["src"] = Var.create(value=src, _var_is_string=True) - return super().create(*children, **props) diff --git a/reflex/components/chakra/media/image.pyi b/reflex/components/chakra/media/image.pyi deleted file mode 100644 index a21ffad39..000000000 --- a/reflex/components/chakra/media/image.pyi +++ /dev/null @@ -1,120 +0,0 @@ -"""Stub file for reflex/components/chakra/media/image.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Optional, Union -from reflex.components.chakra import ChakraComponent, LiteralImageLoading -from reflex.components.component import Component -from reflex.vars import Var - -class Image(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - align: Optional[Union[Var[str], str]] = None, - fallback: Optional[Component] = None, - fallback_src: Optional[Union[Var[str], str]] = None, - fit: Optional[Union[Var[str], str]] = None, - html_height: Optional[Union[Var[str], str]] = None, - html_width: Optional[Union[Var[str], str]] = None, - ignore_fallback: Optional[Union[Var[bool], bool]] = None, - loading: Optional[ - Union[Var[Literal["eager", "lazy"]], Literal["eager", "lazy"]] - ] = None, - src: Optional[Union[Var[Any], Any]] = None, - alt: Optional[Union[Var[str], str]] = None, - src_set: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Image": - """Create an Image component. - - Args: - *children: The children of the image. - align: How to align the image within its bounds. It maps to css `object-position` property. - fallback: Fallback Reflex component to show if image is loading or image fails. - fallback_src: Fallback image src to show if image is loading or image fails. - fit: How the image to fit within its bounds. It maps to css `object-fit` property. - html_height: The native HTML height attribute to the passed to the img. - html_width: The native HTML width attribute to the passed to the img. - ignore_fallback: If true, opt out of the fallbackSrc logic and use as img. - loading: "eager" | "lazy" - src: The path/url to the image or PIL image object. - alt: The alt text of the image. - src_set: Provide multiple sources for an image, allowing the browser to select the most appropriate source based on factors like screen resolution and device capabilities. Learn more _[here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)_ - 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 of the image. - - Returns: - The Image component. - """ - ... diff --git a/reflex/components/chakra/navigation/__init__.py b/reflex/components/chakra/navigation/__init__.py deleted file mode 100644 index 4b61ad8db..000000000 --- a/reflex/components/chakra/navigation/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -"""Navigation components.""" - -from .breadcrumb import Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbSeparator -from .link import Link -from .linkoverlay import LinkBox, LinkOverlay -from .stepper import ( - Step, - StepDescription, - StepIcon, - StepIndicator, - StepNumber, - Stepper, - StepSeparator, - StepStatus, - StepTitle, -) - -__all__ = [f for f in dir() if f[0].isupper()] # type: ignore diff --git a/reflex/components/chakra/navigation/breadcrumb.py b/reflex/components/chakra/navigation/breadcrumb.py deleted file mode 100644 index 7c902bf1a..000000000 --- a/reflex/components/chakra/navigation/breadcrumb.py +++ /dev/null @@ -1,98 +0,0 @@ -"""Breadcrumb components.""" - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.navigation.link import Link -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.vars import Var - - -class Breadcrumb(ChakraComponent): - """The parent container for breadcrumbs.""" - - tag = "Breadcrumb" - - # The visual separator between each breadcrumb item - separator: Var[str] - - # The left and right margin applied to the separator - separator_margin: Var[str] - - @classmethod - def create(cls, *children, items=None, **props) -> Component: - """Create a breadcrumb component. - - If the kw-args `items` is provided and is a list, they will be added as children. - - Args: - *children: The children of the component. - items (list): The items of the breadcrumb: (label, link) - **props: The properties of the component. - - Returns: - The breadcrumb component. - """ - if len(children) == 0: - if isinstance(items, Var): - children = [ - Foreach.create( - items, - lambda item: BreadcrumbItem.create(label=item[0], href=item[1]), - ), - ] - - else: - children = [] - for label, link in items or []: - children.append(BreadcrumbItem.create(label=label, href=link)) - return super().create(*children, **props) - - -class BreadcrumbItem(ChakraComponent): - """Individual breadcrumb element containing a link and a divider.""" - - tag = "BreadcrumbItem" - - # Is the current page of the breadcrumb. - is_current_page: Var[bool] - - # Is the last child of the breadcrumb. - is_last_child: Var[bool] - - # The visual separator between each breadcrumb item - separator: Var[str] - - # The left and right margin applied to the separator - spacing: Var[str] - - @classmethod - def create(cls, *children, label=None, href=None, **props): - """Create a Breadcrumb Item component. - - Args: - *children: The children of the component. - label: The label used in the link. Defaults to None. - href: The URL of the link. Defaults to None. - **props: The properties of the component. - - Returns: - The BreadcrumbItem component - """ - if len(children) == 0: - children = [BreadcrumbLink.create(label or "", href=href or "")] # type: ignore - return super().create(*children, **props) - - -class BreadcrumbSeparator(ChakraComponent): - """The visual separator between each breadcrumb.""" - - tag = "BreadcrumbSeparator" - - -class BreadcrumbLink(Link): - """The breadcrumb link.""" - - tag = "BreadcrumbLink" - - # Is the current page of the breadcrumb. - is_current_page: Var[bool] diff --git a/reflex/components/chakra/navigation/breadcrumb.pyi b/reflex/components/chakra/navigation/breadcrumb.pyi deleted file mode 100644 index 2f66f1231..000000000 --- a/reflex/components/chakra/navigation/breadcrumb.pyi +++ /dev/null @@ -1,353 +0,0 @@ -"""Stub file for reflex/components/chakra/navigation/breadcrumb.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.navigation.link import Link -from reflex.components.component import Component -from reflex.components.core.foreach import Foreach -from reflex.vars import Var - -class Breadcrumb(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items=None, - separator: Optional[Union[Var[str], str]] = None, - separator_margin: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Breadcrumb": - """Create a breadcrumb component. - - If the kw-args `items` is provided and is a list, they will be added as children. - - Args: - *children: The children of the component. - items (list): The items of the breadcrumb: (label, link) - separator: The visual separator between each breadcrumb item - separator_margin: The left and right margin applied to the separator - 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 properties of the component. - - Returns: - The breadcrumb component. - """ - ... - -class BreadcrumbItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - label=None, - href=None, - is_current_page: Optional[Union[Var[bool], bool]] = None, - is_last_child: Optional[Union[Var[bool], bool]] = None, - separator: Optional[Union[Var[str], str]] = None, - spacing: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "BreadcrumbItem": - """Create a Breadcrumb Item component. - - Args: - *children: The children of the component. - label: The label used in the link. Defaults to None. - href: The URL of the link. Defaults to None. - is_current_page: Is the current page of the breadcrumb. - is_last_child: Is the last child of the breadcrumb. - separator: The visual separator between each breadcrumb item - spacing: The left and right margin applied to the separator - 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 properties of the component. - - Returns: - The BreadcrumbItem component - """ - ... - -class BreadcrumbSeparator(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "BreadcrumbSeparator": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class BreadcrumbLink(Link): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_current_page: Optional[Union[Var[bool], bool]] = None, - rel: Optional[Union[Var[str], str]] = None, - href: Optional[Union[Var[str], str]] = None, - text: Optional[Union[Var[str], str]] = None, - as_: Optional[Union[Var[str], str]] = None, - is_external: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "BreadcrumbLink": - """Create a Link component. - - Args: - *children: The children of the component. - is_current_page: Is the current page of the breadcrumb. - rel: The rel. - href: The page to link to. - text: The text to display. - as_: What the link renders to. - is_external: If true, the link will open in new tab. - 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 of the component. - - Raises: - ValueError: in case of missing children - - Returns: - Component: The link component - """ - ... diff --git a/reflex/components/chakra/navigation/link.py b/reflex/components/chakra/navigation/link.py deleted file mode 100644 index a524202df..000000000 --- a/reflex/components/chakra/navigation/link.py +++ /dev/null @@ -1,56 +0,0 @@ -"""A link component.""" - - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.next.link import NextLink -from reflex.utils import imports -from reflex.vars import BaseVar, Var - -next_link = NextLink.create() - - -class Link(ChakraComponent): - """Link to another page.""" - - tag = "Link" - - # The rel. - rel: Var[str] - - # The page to link to. - href: Var[str] - - # The text to display. - text: Var[str] - - # What the link renders to. - as_: Var[str] = BaseVar.create(value="{NextLink}", _var_is_local=False) # type: ignore - - # If true, the link will open in new tab. - is_external: Var[bool] - - def _get_imports(self) -> imports.ImportDict: - return {**super()._get_imports(), **next_link._get_imports()} - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a Link component. - - Args: - *children: The children of the component. - **props: The props of the component. - - Raises: - ValueError: in case of missing children - - Returns: - Component: The link component - """ - if props.get("href") is not None: - if not len(children): - raise ValueError("Link without a child will not display") - else: - # Don't use a NextLink if there is no href. - props["as_"] = "" - return super().create(*children, **props) diff --git a/reflex/components/chakra/navigation/link.pyi b/reflex/components/chakra/navigation/link.pyi deleted file mode 100644 index 583ced1e1..000000000 --- a/reflex/components/chakra/navigation/link.pyi +++ /dev/null @@ -1,105 +0,0 @@ -"""Stub file for reflex/components/chakra/navigation/link.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.components.next.link import NextLink -from reflex.utils import imports -from reflex.vars import BaseVar, Var - -next_link = NextLink.create() - -class Link(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - rel: Optional[Union[Var[str], str]] = None, - href: Optional[Union[Var[str], str]] = None, - text: Optional[Union[Var[str], str]] = None, - as_: Optional[Union[Var[str], str]] = None, - is_external: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Link": - """Create a Link component. - - Args: - *children: The children of the component. - rel: The rel. - href: The page to link to. - text: The text to display. - as_: What the link renders to. - is_external: If true, the link will open in new tab. - 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 of the component. - - Raises: - ValueError: in case of missing children - - Returns: - Component: The link component - """ - ... diff --git a/reflex/components/chakra/navigation/linkoverlay.py b/reflex/components/chakra/navigation/linkoverlay.py deleted file mode 100644 index 370e3df48..000000000 --- a/reflex/components/chakra/navigation/linkoverlay.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Link overlay components.""" - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class LinkOverlay(ChakraComponent): - """Wraps child component in a link.""" - - tag = "LinkOverlay" - - # If true, the link will open in new tab - is_external: Var[bool] - - # Href of the link overlay. - href: Var[str] - - -class LinkBox(ChakraComponent): - """The LinkBox lifts any nested links to the top using z-index to ensure proper keyboard navigation between links.""" - - tag = "LinkBox" diff --git a/reflex/components/chakra/navigation/linkoverlay.pyi b/reflex/components/chakra/navigation/linkoverlay.pyi deleted file mode 100644 index 9d575e5d4..000000000 --- a/reflex/components/chakra/navigation/linkoverlay.pyi +++ /dev/null @@ -1,167 +0,0 @@ -"""Stub file for reflex/components/chakra/navigation/linkoverlay.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class LinkOverlay(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - is_external: Optional[Union[Var[bool], bool]] = None, - href: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "LinkOverlay": - """Create the component. - - Args: - *children: The children of the component. - is_external: If true, the link will open in new tab - href: Href of the link overlay. - 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 of the component. - - Returns: - The component. - """ - ... - -class LinkBox(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "LinkBox": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/navigation/stepper.py b/reflex/components/chakra/navigation/stepper.py deleted file mode 100644 index 7c47760e5..000000000 --- a/reflex/components/chakra/navigation/stepper.py +++ /dev/null @@ -1,113 +0,0 @@ -"""A component to indicate progress through a multi-step process.""" - -from typing import List, Literal, Optional, Tuple - -from reflex.components.chakra import ChakraComponent, LiteralColorScheme -from reflex.components.component import Component -from reflex.vars import Var - - -class Stepper(ChakraComponent): - """The parent container for a stepper.""" - - tag = "Stepper" - - orientation: Var[Literal["vertical", "horizontal"]] - - # The color scheme to use for the stepper; default is blue. - colorScheme: Var[LiteralColorScheme] - - # Chakra provides a useSteps hook to control the stepper. - # Instead, use an integer state value to set progress in the stepper. - - # The index of the current step. - index: Var[int] - - # The size of the steps in the stepper. - size: Var[str] - - @classmethod - def create( - cls, *children, items: Optional[List[Tuple]] = None, **props - ) -> Component: - """Create a Stepper component. - - If the kw-args `items` is provided and is a list, they will be added as children. - - Args: - *children: The children of the component. - items (list): The child components for each step. - **props: The properties of the component. - - Returns: - The stepper component. - """ - if len(children) == 0: - children = [] - for indicator, layout, separator in items or []: - children.append( - Step.create( - StepIndicator.create(indicator), - layout, - StepSeparator.create(separator), - ) - ) - return super().create(*children, **props) - - -class Step(ChakraComponent): - """A component for an individual step in the stepper.""" - - tag = "Step" - - -class StepDescription(ChakraComponent): - """The description text for a step component.""" - - tag = "StepDescription" - - -class StepIcon(ChakraComponent): - """The icon displayed in a step indicator component.""" - - tag = "StepIcon" - - -class StepIndicator(ChakraComponent): - """The component displaying the status of a step.""" - - tag = "StepIndicator" - - -class StepNumber(ChakraComponent): - """The number of a step displayed in a step indicator component.""" - - tag = "StepNumber" - - -class StepSeparator(ChakraComponent): - """The component separting steps.""" - - tag = "StepSeparator" - - -class StepStatus(ChakraComponent): - """A component that displays a number or icon based on the status of a step.""" - - # [not working yet] - # active, complete, and incomplete should also be able to accept StepIcon or StepNumber components - # currently, these props only support strings - - active: Var[str] - - complete: Var[str] - - incomplete: Var[str] - - tag = "StepStatus" - - -class StepTitle(ChakraComponent): - """The title text for a step component.""" - - tag = "StepTitle" diff --git a/reflex/components/chakra/navigation/stepper.pyi b/reflex/components/chakra/navigation/stepper.pyi deleted file mode 100644 index 323e73c2c..000000000 --- a/reflex/components/chakra/navigation/stepper.pyi +++ /dev/null @@ -1,764 +0,0 @@ -"""Stub file for reflex/components/chakra/navigation/stepper.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Literal, Optional, Tuple -from reflex.components.chakra import ChakraComponent, LiteralColorScheme -from reflex.components.component import Component -from reflex.vars import Var - -class Stepper(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[List[Tuple]] = None, - orientation: Optional[ - Union[ - Var[Literal["vertical", "horizontal"]], - Literal["vertical", "horizontal"], - ] - ] = None, - colorScheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = None, - index: Optional[Union[Var[int], int]] = None, - size: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Stepper": - """Create a Stepper component. - - If the kw-args `items` is provided and is a list, they will be added as children. - - Args: - *children: The children of the component. - items (list): The child components for each step. - colorScheme: The color scheme to use for the stepper; default is blue. - index: Chakra provides a useSteps hook to control the stepper. Instead, use an integer state value to set progress in the stepper. The index of the current step. - size: The size of the steps in the stepper. - 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 properties of the component. - - Returns: - The stepper component. - """ - ... - -class Step(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Step": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepDescription(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepDescription": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepIcon(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepIcon": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepIndicator(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepIndicator": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepNumber(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepNumber": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepSeparator(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepSeparator": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class StepStatus(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - active: Optional[Union[Var[str], str]] = None, - complete: Optional[Union[Var[str], str]] = None, - incomplete: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepStatus": - """Create the component. - - Args: - *children: The children of the component. - active: [not working yet] active, complete, and incomplete should also be able to accept StepIcon or StepNumber components currently, these props only support strings - 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 of the component. - - Returns: - The component. - """ - ... - -class StepTitle(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "StepTitle": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/__init__.py b/reflex/components/chakra/overlay/__init__.py deleted file mode 100644 index 322d09318..000000000 --- a/reflex/components/chakra/overlay/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Overlay components.""" - -from .alertdialog import ( - AlertDialog, - AlertDialogBody, - AlertDialogContent, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogOverlay, -) -from .drawer import ( - Drawer, - DrawerBody, - DrawerCloseButton, - DrawerContent, - DrawerFooter, - DrawerHeader, - DrawerOverlay, -) -from .menu import ( - Menu, - MenuButton, - MenuDivider, - MenuGroup, - MenuItem, - MenuItemOption, - MenuList, - MenuOptionGroup, -) -from .modal import ( - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, -) -from .popover import ( - Popover, - PopoverAnchor, - PopoverArrow, - PopoverBody, - PopoverCloseButton, - PopoverContent, - PopoverFooter, - PopoverHeader, - PopoverTrigger, -) -from .tooltip import Tooltip diff --git a/reflex/components/chakra/overlay/alertdialog.py b/reflex/components/chakra/overlay/alertdialog.py deleted file mode 100644 index 48829c5ff..000000000 --- a/reflex/components/chakra/overlay/alertdialog.py +++ /dev/null @@ -1,155 +0,0 @@ -"""Alert dialog components.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent, LiteralAlertDialogSize -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.vars import Var - - -class AlertDialog(ChakraComponent): - """Provides context and state for the dialog.""" - - tag = "AlertDialog" - - # If true, the modal will be open. - is_open: Var[bool] - - # The least destructive element to focus when the dialog opens. - least_destructive_ref: Var[str] - - # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - allow_pinch_zoom: Var[bool] - - # If true, the modal will autofocus the first enabled and interactive element within the ModalContent - auto_focus: Var[bool] - - # If true, scrolling will be disabled on the body when the modal opens. - block_scroll_on_mount: Var[bool] - - # If true, the modal will close when the Esc key is pressed - close_on_esc: Var[bool] - - # If true, the modal will close when the overlay is clicked - close_on_overlay_click: Var[bool] - - # If true, the modal will be centered on screen. - is_centered: Var[bool] - - # Enables aggressive focus capturing within iframes. If true, keep focus in the lock, no matter where lock is active. If false, allows focus to move outside of iframe. - lock_focus_across_frames: Var[bool] - - # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - preserve_scroll_bar_gap: Var[bool] - - # If true, the modal will return focus to the element that triggered it when it closes. - return_focus_on_close: Var[bool] - - # "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full" - size: Var[LiteralAlertDialogSize] - - # If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - use_inert: Var[bool] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_close_complete": lambda: [], - "on_esc": lambda: [], - "on_overlay_click": lambda: [], - } - - @classmethod - def create( - cls, *children, header=None, body=None, footer=None, close_button=None, **props - ) -> Component: - """Create an alert dialog component. - - Args: - *children: The children of the alert dialog component. - header: The header of the alert dialog. - body: The body of the alert dialog. - footer: The footer of the alert dialog. - close_button: The close button of the alert dialog. - **props: The properties of the alert dialog component. - - Raises: - AttributeError: if there is a conflict between the props used. - - Returns: - The alert dialog component. - """ - if len(children) == 0: - contents = [] - - if header: - contents.append(AlertDialogHeader.create(header)) - - if body: - contents.append(AlertDialogBody.create(body)) - - if footer: - contents.append(AlertDialogFooter.create(footer)) - - # add AlertDialogCloseButton if either a prop for one was passed, or if on_close callback is present - if props.get("on_close"): - # get user defined close button or use default one - if not close_button: - close_button = Icon.create(tag="close") - contents.append(AlertDialogCloseButton.create(close_button)) - elif close_button: - raise AttributeError( - "Close button can not be used if on_close event handler is not defined" - ) - - children = [ - AlertDialogOverlay.create( - AlertDialogContent.create(*contents), - ) - ] - - return super().create(*children, **props) - - -class AlertDialogBody(ChakraComponent): - """Should contain the description announced by screen readers.""" - - tag = "AlertDialogBody" - - -class AlertDialogHeader(ChakraComponent): - """Should contain the title announced by screen readers.""" - - tag = "AlertDialogHeader" - - -class AlertDialogFooter(ChakraComponent): - """Should contain the events of the dialog.""" - - tag = "AlertDialogFooter" - - -class AlertDialogContent(ChakraComponent): - """The wrapper for the alert dialog's content.""" - - tag = "AlertDialogContent" - - -class AlertDialogOverlay(ChakraComponent): - """The dimmed overlay behind the dialog.""" - - tag = "AlertDialogOverlay" - - -class AlertDialogCloseButton(ChakraComponent): - """The button that closes the dialog.""" - - tag = "AlertDialogCloseButton" diff --git a/reflex/components/chakra/overlay/alertdialog.pyi b/reflex/components/chakra/overlay/alertdialog.pyi deleted file mode 100644 index 9ca91b783..000000000 --- a/reflex/components/chakra/overlay/alertdialog.pyi +++ /dev/null @@ -1,616 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/alertdialog.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralAlertDialogSize -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.vars import Var - -class AlertDialog(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - header=None, - body=None, - footer=None, - close_button=None, - is_open: Optional[Union[Var[bool], bool]] = None, - least_destructive_ref: Optional[Union[Var[str], str]] = None, - allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None, - auto_focus: Optional[Union[Var[bool], bool]] = None, - block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None, - close_on_esc: Optional[Union[Var[bool], bool]] = None, - close_on_overlay_click: Optional[Union[Var[bool], bool]] = None, - is_centered: Optional[Union[Var[bool], bool]] = None, - lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None, - preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None, - return_focus_on_close: Optional[Union[Var[bool], bool]] = None, - size: Optional[ - Union[ - Var[ - Literal[ - "sm", - "md", - "lg", - "xs", - "2xl", - "full", - "3xl", - "4xl", - "5xl", - "6xl", - ] - ], - Literal[ - "sm", "md", "lg", "xs", "2xl", "full", "3xl", "4xl", "5xl", "6xl" - ], - ] - ] = None, - use_inert: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialog": - """Create an alert dialog component. - - Args: - *children: The children of the alert dialog component. - header: The header of the alert dialog. - body: The body of the alert dialog. - footer: The footer of the alert dialog. - close_button: The close button of the alert dialog. - is_open: If true, the modal will be open. - least_destructive_ref: The least destructive element to focus when the dialog opens. - allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent - block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens. - close_on_esc: If true, the modal will close when the Esc key is pressed - close_on_overlay_click: If true, the modal will close when the overlay is clicked - is_centered: If true, the modal will be centered on screen. - lock_focus_across_frames: Enables aggressive focus capturing within iframes. If true, keep focus in the lock, no matter where lock is active. If false, allows focus to move outside of iframe. - preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes. - size: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full" - use_inert: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - 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 properties of the alert dialog component. - - Raises: - AttributeError: if there is a conflict between the props used. - - Returns: - The alert dialog component. - """ - ... - -class AlertDialogBody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogBody": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDialogHeader(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogHeader": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDialogFooter(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogFooter": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDialogContent(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogContent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDialogOverlay(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogOverlay": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class AlertDialogCloseButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "AlertDialogCloseButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/drawer.py b/reflex/components/chakra/overlay/drawer.py deleted file mode 100644 index 7d317fe9c..000000000 --- a/reflex/components/chakra/overlay/drawer.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Container to stack elements with spacing.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralDrawerSize, -) -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.vars import Var - - -class Drawer(ChakraComponent): - """A drawer component.""" - - tag = "Drawer" - - # If true, the modal will be open. - is_open: Var[bool] - - # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - allow_pinch_zoom: Var[bool] - - # If true, the modal will autofocus the first enabled and interactive element within the ModalContent - auto_focus: Var[bool] - - # If true, scrolling will be disabled on the body when the modal opens. - block_scroll_on_mount: Var[bool] - - # If true, the modal will close when the Esc key is pressed - close_on_esc: Var[bool] - - # If true, the modal will close when the overlay is clicked - close_on_overlay_click: Var[bool] - - # If true, the modal will be centered on screen. - is_centered: Var[bool] - - # If true and drawer's placement is top or bottom, the drawer will occupy the viewport height (100vh) - is_full_height: Var[bool] - - # Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe - lock_focus_across_frames: Var[bool] - - # The placement of the drawer - placement: Var[str] - - # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - preserve_scroll_bar_gap: Var[bool] - - # If true, the modal will return focus to the element that triggered it when it closes. - return_focus_on_close: Var[bool] - - # "xs" | "sm" | "md" | "lg" | "xl" | "full" - size: Var[LiteralDrawerSize] - - # A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - use_inert: Var[bool] - - # Variant of drawer - variant: Var[str] - - # Color scheme of the Drawer - # Options: - # "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" - # | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - color_scheme: Var[LiteralColorScheme] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_close_complete": lambda: [], - "on_esc": lambda: [], - "on_overlay_click": lambda: [], - } - - @classmethod - def create( - cls, *children, header=None, body=None, footer=None, close_button=None, **props - ) -> Component: - """Create a drawer component. - - Args: - *children: The children of the drawer component. - header: The header of the drawer. - body: The body of the drawer. - footer: The footer of the drawer. - close_button: The close button of the drawer. - **props: The properties of the drawer component. - - Raises: - AttributeError: error that occurs if conflicting props are passed - - Returns: - The drawer component. - """ - if len(children) == 0: - contents = [] - - if header: - contents.append(DrawerHeader.create(header)) - - if body: - contents.append(DrawerBody.create(body)) - - if footer: - contents.append(DrawerFooter.create(footer)) - - if props.get("on_close"): - # use default close button if undefined - if not close_button: - close_button = Icon.create(tag="close") - contents.append(DrawerCloseButton.create(close_button)) - elif close_button: - raise AttributeError( - "Close button can not be used if on_close event handler is not defined" - ) - - children = [ - DrawerOverlay.create( - DrawerContent.create(*contents), - ) - ] - - return super().create(*children, **props) - - -class DrawerBody(ChakraComponent): - """Drawer body.""" - - tag = "DrawerBody" - - -class DrawerHeader(ChakraComponent): - """Drawer header.""" - - tag = "DrawerHeader" - - -class DrawerFooter(ChakraComponent): - """Drawer footer.""" - - tag = "DrawerFooter" - - -class DrawerOverlay(ChakraComponent): - """Drawer overlay.""" - - tag = "DrawerOverlay" - - -class DrawerContent(ChakraComponent): - """Drawer content.""" - - tag = "DrawerContent" - - -class DrawerCloseButton(ChakraComponent): - """Drawer close button.""" - - tag = "DrawerCloseButton" diff --git a/reflex/components/chakra/overlay/drawer.pyi b/reflex/components/chakra/overlay/drawer.pyi deleted file mode 100644 index f0ca10ca4..000000000 --- a/reflex/components/chakra/overlay/drawer.pyi +++ /dev/null @@ -1,658 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/drawer.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralDrawerSize, -) -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.vars import Var - -class Drawer(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - header=None, - body=None, - footer=None, - close_button=None, - is_open: Optional[Union[Var[bool], bool]] = None, - allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None, - auto_focus: Optional[Union[Var[bool], bool]] = None, - block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None, - close_on_esc: Optional[Union[Var[bool], bool]] = None, - close_on_overlay_click: Optional[Union[Var[bool], bool]] = None, - is_centered: Optional[Union[Var[bool], bool]] = None, - is_full_height: Optional[Union[Var[bool], bool]] = None, - lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None, - placement: Optional[Union[Var[str], str]] = None, - preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None, - return_focus_on_close: Optional[Union[Var[bool], bool]] = None, - size: Optional[ - Union[ - Var[Literal["sm", "md", "lg", "xs", "xl", "full"]], - Literal["sm", "md", "lg", "xs", "xl", "full"], - ] - ] = None, - use_inert: Optional[Union[Var[bool], bool]] = None, - variant: Optional[Union[Var[str], str]] = None, - color_scheme: Optional[ - Union[ - Var[ - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ] - ], - Literal[ - "none", - "gray", - "red", - "orange", - "yellow", - "green", - "teal", - "blue", - "cyan", - "purple", - "pink", - "whiteAlpha", - "blackAlpha", - "linkedin", - "facebook", - "messenger", - "whatsapp", - "twitter", - "telegram", - ], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Drawer": - """Create a drawer component. - - Args: - *children: The children of the drawer component. - header: The header of the drawer. - body: The body of the drawer. - footer: The footer of the drawer. - close_button: The close button of the drawer. - is_open: If true, the modal will be open. - allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent - block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens. - close_on_esc: If true, the modal will close when the Esc key is pressed - close_on_overlay_click: If true, the modal will close when the overlay is clicked - is_centered: If true, the modal will be centered on screen. - is_full_height: If true and drawer's placement is top or bottom, the drawer will occupy the viewport height (100vh) - lock_focus_across_frames: Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe - placement: The placement of the drawer - preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes. - size: "xs" | "sm" | "md" | "lg" | "xl" | "full" - use_inert: A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - variant: Variant of drawer - color_scheme: Color scheme of the Drawer Options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" - 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 properties of the drawer component. - - Raises: - AttributeError: error that occurs if conflicting props are passed - - Returns: - The drawer component. - """ - ... - -class DrawerBody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerBody": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class DrawerHeader(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerHeader": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class DrawerFooter(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerFooter": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class DrawerOverlay(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerOverlay": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class DrawerContent(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerContent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class DrawerCloseButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "DrawerCloseButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/menu.py b/reflex/components/chakra/overlay/menu.py deleted file mode 100644 index 1401fce7c..000000000 --- a/reflex/components/chakra/overlay/menu.py +++ /dev/null @@ -1,229 +0,0 @@ -"""Menu components.""" -from __future__ import annotations - -from typing import Any, List, Optional, Union - -from reflex.components.chakra import ( - ChakraComponent, - LiteralChakraDirection, - LiteralMenuOption, - LiteralMenuStrategy, -) -from reflex.components.chakra.forms.button import Button -from reflex.components.component import Component -from reflex.vars import Var - - -class Menu(ChakraComponent): - """The wrapper component provides context, state, and focus management.""" - - tag = "Menu" - - # The padding required to prevent the arrow from reaching the very edge of the popper. - arrow_padding: Var[int] - - # If true, the first enabled menu item will receive focus and be selected when the menu opens. - auto_select: Var[bool] - - # The boundary area for the popper. Used within the preventOverflow modifier - boundary: Var[str] - - # If true, the menu will close when you click outside the menu list - close_on_blur: Var[bool] - - # If true, the menu will close when a menu item is clicked - close_on_select: Var[bool] - - # If by default the menu is open. - default_is_open: Var[bool] - - # If rtl, popper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse ("ltr" | "rtl") - direction: Var[LiteralChakraDirection] - - # If true, the popper will change its placement and flip when it's about to overflow its boundary area. - flip: Var[bool] - - # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - gutter: Var[int] - - # Performance 🚀: If true, the MenuItem rendering will be deferred until the menu is open. - is_lazy: Var[bool] - - # Performance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open. - lazy_behavior: Var[str] - - # Determines if the menu is open or not. - is_open: Var[bool] - - # If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns. - match_width: Var[bool] - - # The placement of the popper relative to its reference. - placement: Var[str] - - # If true, will prevent the popper from being cut off and ensure it's visible within the boundary area. - prevent_overflow: Var[bool] - - # The CSS positioning strategy to use. ("fixed" | "absolute") - strategy: Var[LiteralMenuStrategy] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_open": lambda: [], - } - - @classmethod - def create( - cls, - *children, - button: Optional[Component] = None, - items: Optional[List] = None, - **props, - ) -> Component: - """Create a menu component. - - Args: - *children: The children of the component. - button: the button that open the menu. - items (list): The items of the menu. - **props: The properties of the component. - - Returns: - The menu component. - """ - if len(children) == 0: - children = [] - - if button: - if not isinstance(button, (MenuButton, Button)): - children.append(MenuButton.create(button)) - else: - children.append(button) - if not items: - items = [] - children.append(MenuList.create(items=items)) - return super().create(*children, **props) - - -class MenuButton(ChakraComponent): - """The trigger for the menu list. Must be a direct child of Menu.""" - - tag = "MenuButton" - - # The variant of the menu button. - variant: Var[str] - - # Components that are not allowed as children. - _invalid_children: List[str] = ["Button", "MenuButton"] - - # The tag to use for the menu button. - as_: Var[str] - - -class MenuList(ChakraComponent): - """The wrapper for the menu items. Must be a direct child of Menu.""" - - tag = "MenuList" - - @classmethod - def create(cls, *children, items: Optional[list] = None, **props) -> Component: - """Create a MenuList component, and automatically wrap in MenuItem if not already one. - - Args: - *children: The children of the component. - items: A list of item to add as child of the component. - **props: The properties of the component. - - Returns: - The MenuList component. - """ - if len(children) == 0: - if items is None: - items = [] - children = [ - child if isinstance(child, MenuItem) else MenuItem.create(child) - for child in items - ] - return super().create(*children, **props) - - -class MenuItem(ChakraComponent): - """The trigger that handles menu selection. Must be a direct child of a MenuList.""" - - tag = "MenuItem" - - # Overrides the parent menu's closeOnSelect prop. - close_on_select: Var[bool] - - # Right-aligned label text content, useful for displaying hotkeys. - command: Var[str] - - # The spacing between the command and menu item's label. - command_spacing: Var[int] - - # If true, the menuitem will be disabled. - is_disabled: Var[bool] - - # If true and the menuitem is disabled, it'll remain keyboard-focusable - is_focusable: Var[bool] - - -class MenuItemOption(ChakraComponent): - """The checkable menu item, to be used with MenuOptionGroup.""" - - tag = "MenuItemOption" - - # Overrides the parent menu's closeOnSelect prop. - close_on_select: Var[bool] - - # Right-aligned label text content, useful for displaying hotkeys. - command: Var[str] - - # The spacing between the command and menu item's label. - command_spacing: Var[int] - - # Determines if menu item is checked. - is_checked: Var[bool] - - # If true, the menuitem will be disabled. - is_disabled: Var[bool] - - # If true and the menuitem is disabled, it'll remain keyboard-focusable - is_focusable: Var[bool] - - # "checkbox" | "radio" - type_: Var[LiteralMenuOption] - - # Value of the menu item. - value: Var[str] - - -class MenuGroup(ChakraComponent): - """A wrapper to group related menu items.""" - - tag = "MenuGroup" - - -class MenuOptionGroup(ChakraComponent): - """A wrapper for checkable menu items (radio and checkbox).""" - - tag = "MenuOptionGroup" - - # "checkbox" | "radio" - type_: Var[LiteralMenuOption] - - # Value of the option group. - value: Var[str] - - -class MenuDivider(ChakraComponent): - """A visual separator for menu items and groups.""" - - tag = "MenuDivider" diff --git a/reflex/components/chakra/overlay/menu.pyi b/reflex/components/chakra/overlay/menu.pyi deleted file mode 100644 index c69b31abd..000000000 --- a/reflex/components/chakra/overlay/menu.pyi +++ /dev/null @@ -1,714 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/menu.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, List, Optional, Union -from reflex.components.chakra import ( - ChakraComponent, - LiteralChakraDirection, - LiteralMenuOption, - LiteralMenuStrategy, -) -from reflex.components.chakra.forms.button import Button -from reflex.components.component import Component -from reflex.vars import Var - -class Menu(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - button: Optional[Component] = None, - items: Optional[List] = None, - arrow_padding: Optional[Union[Var[int], int]] = None, - auto_select: Optional[Union[Var[bool], bool]] = None, - boundary: Optional[Union[Var[str], str]] = None, - close_on_blur: Optional[Union[Var[bool], bool]] = None, - close_on_select: Optional[Union[Var[bool], bool]] = None, - default_is_open: Optional[Union[Var[bool], bool]] = None, - direction: Optional[ - Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]] - ] = None, - flip: Optional[Union[Var[bool], bool]] = None, - gutter: Optional[Union[Var[int], int]] = None, - is_lazy: Optional[Union[Var[bool], bool]] = None, - lazy_behavior: Optional[Union[Var[str], str]] = None, - is_open: Optional[Union[Var[bool], bool]] = None, - match_width: Optional[Union[Var[bool], bool]] = None, - placement: Optional[Union[Var[str], str]] = None, - prevent_overflow: Optional[Union[Var[bool], bool]] = None, - strategy: Optional[ - Union[Var[Literal["fixed", "absolute"]], Literal["fixed", "absolute"]] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Menu": - """Create a menu component. - - Args: - *children: The children of the component. - button: the button that open the menu. - items (list): The items of the menu. - arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper. - auto_select: If true, the first enabled menu item will receive focus and be selected when the menu opens. - boundary: The boundary area for the popper. Used within the preventOverflow modifier - close_on_blur: If true, the menu will close when you click outside the menu list - close_on_select: If true, the menu will close when a menu item is clicked - default_is_open: If by default the menu is open. - direction: If rtl, popper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse ("ltr" | "rtl") - flip: If true, the popper will change its placement and flip when it's about to overflow its boundary area. - gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - is_lazy: Performance 🚀: If true, the MenuItem rendering will be deferred until the menu is open. - lazy_behavior: Performance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open. - is_open: Determines if the menu is open or not. - match_width: If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns. - placement: The placement of the popper relative to its reference. - prevent_overflow: If true, will prevent the popper from being cut off and ensure it's visible within the boundary area. - strategy: The CSS positioning strategy to use. ("fixed" | "absolute") - 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 properties of the component. - - Returns: - The menu component. - """ - ... - -class MenuButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - variant: Optional[Union[Var[str], str]] = None, - as_: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuButton": - """Create the component. - - Args: - *children: The children of the component. - variant: The variant of the menu button. - as_: The tag to use for the menu button. - 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 of the component. - - Returns: - The component. - """ - ... - -class MenuList(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - items: Optional[list] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuList": - """Create a MenuList component, and automatically wrap in MenuItem if not already one. - - Args: - *children: The children of the component. - items: A list of item to add as child of the component. - 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 properties of the component. - - Returns: - The MenuList component. - """ - ... - -class MenuItem(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - close_on_select: Optional[Union[Var[bool], bool]] = None, - command: Optional[Union[Var[str], str]] = None, - command_spacing: Optional[Union[Var[int], int]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuItem": - """Create the component. - - Args: - *children: The children of the component. - close_on_select: Overrides the parent menu's closeOnSelect prop. - command: Right-aligned label text content, useful for displaying hotkeys. - command_spacing: The spacing between the command and menu item's label. - is_disabled: If true, the menuitem will be disabled. - is_focusable: If true and the menuitem is disabled, it'll remain keyboard-focusable - 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 of the component. - - Returns: - The component. - """ - ... - -class MenuItemOption(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - close_on_select: Optional[Union[Var[bool], bool]] = None, - command: Optional[Union[Var[str], str]] = None, - command_spacing: Optional[Union[Var[int], int]] = None, - is_checked: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_focusable: Optional[Union[Var[bool], bool]] = None, - type_: Optional[ - Union[Var[Literal["checkbox", "radio"]], Literal["checkbox", "radio"]] - ] = None, - value: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuItemOption": - """Create the component. - - Args: - *children: The children of the component. - close_on_select: Overrides the parent menu's closeOnSelect prop. - command: Right-aligned label text content, useful for displaying hotkeys. - command_spacing: The spacing between the command and menu item's label. - is_checked: Determines if menu item is checked. - is_disabled: If true, the menuitem will be disabled. - is_focusable: If true and the menuitem is disabled, it'll remain keyboard-focusable - type_: "checkbox" | "radio" - value: Value of the menu item. - 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 of the component. - - Returns: - The component. - """ - ... - -class MenuGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuGroup": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class MenuOptionGroup(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - type_: Optional[ - Union[Var[Literal["checkbox", "radio"]], Literal["checkbox", "radio"]] - ] = None, - value: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuOptionGroup": - """Create the component. - - Args: - *children: The children of the component. - type_: "checkbox" | "radio" - value: Value of the option group. - 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 of the component. - - Returns: - The component. - """ - ... - -class MenuDivider(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "MenuDivider": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/modal.py b/reflex/components/chakra/overlay/modal.py deleted file mode 100644 index 78b8a8164..000000000 --- a/reflex/components/chakra/overlay/modal.py +++ /dev/null @@ -1,166 +0,0 @@ -"""Modal components.""" -from __future__ import annotations - -from typing import Any, Literal, Optional, Union - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.media import Icon -from reflex.components.component import Component -from reflex.vars import Var - -ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"] - - -class Modal(ChakraComponent): - """The wrapper that provides context for its children.""" - - tag = "Modal" - - # If true, the modal will be open. - is_open: Var[bool] - - # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - allow_pinch_zoom: Var[bool] - - # If true, the modal will autofocus the first enabled and interactive element within the ModalContent - auto_focus: Var[bool] - - # If true, scrolling will be disabled on the body when the modal opens. - block_scroll_on_mount: Var[bool] - - # If true, the modal will close when the Esc key is pressed - close_on_esc: Var[bool] - - # If true, the modal will close when the overlay is clicked - close_on_overlay_click: Var[bool] - - # If true, the modal will be centered on screen. - is_centered: Var[bool] - - # Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe - lock_focus_across_frames: Var[bool] - - # The transition that should be used for the modal - motion_preset: Var[str] - - # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - preserve_scroll_bar_gap: Var[bool] - - # If true, the modal will return focus to the element that triggered it when it closes. - return_focus_on_close: Var[bool] - - # "xs" | "sm" | "md" | "lg" | "xl" | "full" - size: Var[ModalSizes] - - # A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - use_inert: Var[bool] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_close_complete": lambda: [], - "on_esc": lambda: [], - "on_overlay_click": lambda: [], - } - - @classmethod - def create( - cls, - *children, - header: Optional[Union[Component, str]] = None, - body: Optional[Union[Component, str]] = None, - footer: Optional[Union[Component, str]] = None, - close_button: Optional[Component] = None, - **props, - ) -> Component: - """Create a modal component. - - Args: - *children: The children of the component. - header: The header of the modal. - body: The body of the modal. - footer: The footer of the modal. - close_button: The close button of the modal. - **props: The properties of the component. - - Raises: - AttributeError: error that occurs if conflicting props are passed - - Returns: - The modal component. - """ - if len(children) == 0: - contents = [] - - # add header if present in props - if header: - contents.append(ModalHeader.create(header)) - - # add ModalBody if present in props - if body: - contents.append(ModalBody.create(body)) - - # add ModalFooter if present in props - if footer: - contents.append(ModalFooter.create(footer)) - - # add ModalCloseButton if either a prop for one was passed, or if - if props.get("on_close"): - # get user defined close button or use default one - if not close_button: - close_button = Icon.create(tag="close") - contents.append(ModalCloseButton.create(close_button)) - elif close_button: - raise AttributeError( - "Close button can not be used if on_close event handler is not defined" - ) - - children = [ - ModalOverlay.create( - ModalContent.create(*contents), - ) - ] - - return super().create(*children, **props) - - -class ModalOverlay(ChakraComponent): - """The dimmed overlay behind the modal dialog.""" - - tag = "ModalOverlay" - - -class ModalHeader(ChakraComponent): - """The header that labels the modal dialog.""" - - tag = "ModalHeader" - - -class ModalFooter(ChakraComponent): - """The footer that houses the modal events.""" - - tag = "ModalFooter" - - -class ModalContent(ChakraComponent): - """The container for the modal dialog's content.""" - - tag = "ModalContent" - - -class ModalBody(ChakraComponent): - """The wrapper that houses the modal's main content.""" - - tag = "ModalBody" - - -class ModalCloseButton(ChakraComponent): - """The button that closes the modal.""" - - tag = "ModalCloseButton" diff --git a/reflex/components/chakra/overlay/modal.pyi b/reflex/components/chakra/overlay/modal.pyi deleted file mode 100644 index 415095873..000000000 --- a/reflex/components/chakra/overlay/modal.pyi +++ /dev/null @@ -1,603 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/modal.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Literal, Optional, Union -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.media import Icon -from reflex.components.component import Component -from reflex.vars import Var - -ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"] - -class Modal(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - header: Optional[Union[Component, str]] = None, - body: Optional[Union[Component, str]] = None, - footer: Optional[Union[Component, str]] = None, - close_button: Optional[Component] = None, - is_open: Optional[Union[Var[bool], bool]] = None, - allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None, - auto_focus: Optional[Union[Var[bool], bool]] = None, - block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None, - close_on_esc: Optional[Union[Var[bool], bool]] = None, - close_on_overlay_click: Optional[Union[Var[bool], bool]] = None, - is_centered: Optional[Union[Var[bool], bool]] = None, - lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None, - motion_preset: Optional[Union[Var[str], str]] = None, - preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None, - return_focus_on_close: Optional[Union[Var[bool], bool]] = None, - size: Optional[ - Union[ - Var[Literal["xs", "sm", "md", "lg", "xl", "full"]], - Literal["xs", "sm", "md", "lg", "xl", "full"], - ] - ] = None, - use_inert: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Modal": - """Create a modal component. - - Args: - *children: The children of the component. - header: The header of the modal. - body: The body of the modal. - footer: The footer of the modal. - close_button: The close button of the modal. - is_open: If true, the modal will be open. - allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false. - auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent - block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens. - close_on_esc: If true, the modal will close when the Esc key is pressed - close_on_overlay_click: If true, the modal will close when the overlay is clicked - is_centered: If true, the modal will be centered on screen. - lock_focus_across_frames: Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe - motion_preset: The transition that should be used for the modal - preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens - return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes. - size: "xs" | "sm" | "md" | "lg" | "xl" | "full" - use_inert: A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert** - 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 properties of the component. - - Raises: - AttributeError: error that occurs if conflicting props are passed - - Returns: - The modal component. - """ - ... - -class ModalOverlay(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalOverlay": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ModalHeader(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalHeader": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ModalFooter(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalFooter": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ModalContent(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalContent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ModalBody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalBody": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class ModalCloseButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "ModalCloseButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/popover.py b/reflex/components/chakra/overlay/popover.py deleted file mode 100644 index 7e1fa3e99..000000000 --- a/reflex/components/chakra/overlay/popover.py +++ /dev/null @@ -1,189 +0,0 @@ -"""Popover components.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ( - ChakraComponent, - LiteralChakraDirection, - LiteralMenuStrategy, - LiteralPopOverTrigger, -) -from reflex.components.component import Component -from reflex.vars import Var - - -class Popover(ChakraComponent): - """The wrapper that provides props, state, and context to its children.""" - - tag = "Popover" - - # The padding required to prevent the arrow from reaching the very edge of the popper. - arrow_padding: Var[int] - - # The `box-shadow` of the popover arrow - arrow_shadow_color: Var[str] - - # The size of the popover arrow - arrow_size: Var[int] - - # If true, focus will be transferred to the first interactive element when the popover opens - auto_focus: Var[bool] - - # The boundary area for the popper. Used within the preventOverflow modifier - boundary: Var[str] - - # If true, the popover will close when you blur out it by clicking outside or tabbing out - close_on_blur: Var[bool] - - # If true, the popover will close when you hit the Esc key - close_on_esc: Var[bool] - - # If true, the popover will be initially opened. - default_is_open: Var[bool] - - # Theme direction ltr or rtl. Popper's placement will be set accordingly - direction: Var[LiteralChakraDirection] - - # If true, the popper will change its placement and flip when it's about to overflow its boundary area. - flip: Var[bool] - - # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - gutter: Var[int] - - # The html id attribute of the popover. If not provided, we generate a unique id. This id is also used to auto-generate the `aria-labelledby` and `aria-describedby` attributes that points to the PopoverHeader and PopoverBody - id_: Var[str] - - # Performance 🚀: If true, the PopoverContent rendering will be deferred until the popover is open. - is_lazy: Var[bool] - - # Performance 🚀: The lazy behavior of popover's content when not visible. Only works when `isLazy={true}` - "unmount": The popover's content is always unmounted when not open. - "keepMounted": The popover's content initially unmounted, but stays mounted when popover is open. - lazy_behavior: Var[str] - - # If true, the popover will be opened in controlled mode. - is_open: Var[bool] - - # If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns. - match_width: Var[bool] - - # The placement of the popover. It's used internally by Popper.js. - placement: Var[str] - - # If true, will prevent the popper from being cut off and ensure it's visible within the boundary area. - prevent_overflow: Var[bool] - - # If true, focus will be returned to the element that triggers the popover when it closes - return_focus_on_close: Var[bool] - - # The CSS positioning strategy to use. ("fixed" | "absolute") - strategy: Var[LiteralMenuStrategy] - - # The interaction that triggers the popover. hover - means the popover will open when you hover with mouse or focus with keyboard on the popover trigger click - means the popover will open on click or press Enter to Space on keyboard ("click" | "hover") - trigger: Var[LiteralPopOverTrigger] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_open": lambda: [], - } - - @classmethod - def create( - cls, - *children, - trigger=None, - header=None, - body=None, - footer=None, - use_close_button=False, - **props, - ) -> Component: - """Create a popover component. - - Args: - *children: The children of the component. - trigger: The trigger that opens the popover. - header: The header of the popover. - body: The body of the popover. - footer: The footer of the popover. - use_close_button: Whether to add a close button on the popover. - **props: The properties of the component. - - Returns: - The popover component. - """ - if len(children) == 0: - contents = [] - - trigger = PopoverTrigger.create(trigger) - - # add header if present in props - if header: - contents.append(PopoverHeader.create(header)) - - if body: - contents.append(PopoverBody.create(body)) - - if footer: - contents.append(PopoverFooter.create(footer)) - - if use_close_button: - contents.append(PopoverCloseButton.create()) - - children = [trigger, PopoverContent.create(*contents)] - - return super().create(*children, **props) - - -class PopoverContent(ChakraComponent): - """The popover itself.""" - - tag = "PopoverContent" - - -class PopoverHeader(ChakraComponent): - """The header of the popover.""" - - tag = "PopoverHeader" - - -class PopoverFooter(ChakraComponent): - """Display a popover footer.""" - - tag = "PopoverFooter" - - -class PopoverBody(ChakraComponent): - """The body of the popover.""" - - tag = "PopoverBody" - - -class PopoverArrow(ChakraComponent): - """A visual arrow that points to the reference (or trigger).""" - - tag = "PopoverArrow" - - -class PopoverCloseButton(ChakraComponent): - """A button to close the popover.""" - - tag = "PopoverCloseButton" - - -class PopoverAnchor(ChakraComponent): - """Used to wrap the position-reference element.""" - - tag = "PopoverAnchor" - - -class PopoverTrigger(ChakraComponent): - """Used to wrap the reference (or trigger) element.""" - - tag = "PopoverTrigger" diff --git a/reflex/components/chakra/overlay/popover.pyi b/reflex/components/chakra/overlay/popover.pyi deleted file mode 100644 index e6237fb32..000000000 --- a/reflex/components/chakra/overlay/popover.pyi +++ /dev/null @@ -1,763 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/popover.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ( - ChakraComponent, - LiteralChakraDirection, - LiteralMenuStrategy, - LiteralPopOverTrigger, -) -from reflex.components.component import Component -from reflex.vars import Var - -class Popover(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - trigger=None, - header=None, - body=None, - footer=None, - use_close_button=False, - arrow_padding: Optional[Union[Var[int], int]] = None, - arrow_shadow_color: Optional[Union[Var[str], str]] = None, - arrow_size: Optional[Union[Var[int], int]] = None, - auto_focus: Optional[Union[Var[bool], bool]] = None, - boundary: Optional[Union[Var[str], str]] = None, - close_on_blur: Optional[Union[Var[bool], bool]] = None, - close_on_esc: Optional[Union[Var[bool], bool]] = None, - default_is_open: Optional[Union[Var[bool], bool]] = None, - direction: Optional[ - Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]] - ] = None, - flip: Optional[Union[Var[bool], bool]] = None, - gutter: Optional[Union[Var[int], int]] = None, - id_: Optional[Union[Var[str], str]] = None, - is_lazy: Optional[Union[Var[bool], bool]] = None, - lazy_behavior: Optional[Union[Var[str], str]] = None, - is_open: Optional[Union[Var[bool], bool]] = None, - match_width: Optional[Union[Var[bool], bool]] = None, - placement: Optional[Union[Var[str], str]] = None, - prevent_overflow: Optional[Union[Var[bool], bool]] = None, - return_focus_on_close: Optional[Union[Var[bool], bool]] = None, - strategy: Optional[ - Union[Var[Literal["fixed", "absolute"]], Literal["fixed", "absolute"]] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Popover": - """Create a popover component. - - Args: - *children: The children of the component. - trigger: The trigger that opens the popover. - header: The header of the popover. - body: The body of the popover. - footer: The footer of the popover. - use_close_button: Whether to add a close button on the popover. - arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper. - arrow_shadow_color: The `box-shadow` of the popover arrow - arrow_size: The size of the popover arrow - auto_focus: If true, focus will be transferred to the first interactive element when the popover opens - boundary: The boundary area for the popper. Used within the preventOverflow modifier - close_on_blur: If true, the popover will close when you blur out it by clicking outside or tabbing out - close_on_esc: If true, the popover will close when you hit the Esc key - default_is_open: If true, the popover will be initially opened. - direction: Theme direction ltr or rtl. Popper's placement will be set accordingly - flip: If true, the popper will change its placement and flip when it's about to overflow its boundary area. - gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - id_: The html id attribute of the popover. If not provided, we generate a unique id. This id is also used to auto-generate the `aria-labelledby` and `aria-describedby` attributes that points to the PopoverHeader and PopoverBody - is_lazy: Performance 🚀: If true, the PopoverContent rendering will be deferred until the popover is open. - lazy_behavior: Performance 🚀: The lazy behavior of popover's content when not visible. Only works when `isLazy={true}` - "unmount": The popover's content is always unmounted when not open. - "keepMounted": The popover's content initially unmounted, but stays mounted when popover is open. - is_open: If true, the popover will be opened in controlled mode. - match_width: If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns. - placement: The placement of the popover. It's used internally by Popper.js. - prevent_overflow: If true, will prevent the popper from being cut off and ensure it's visible within the boundary area. - return_focus_on_close: If true, focus will be returned to the element that triggers the popover when it closes - strategy: The CSS positioning strategy to use. ("fixed" | "absolute") - 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 properties of the component. - - Returns: - The popover component. - """ - ... - -class PopoverContent(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverContent": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverHeader(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverHeader": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverFooter(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverFooter": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverBody(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverBody": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverArrow(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverArrow": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverCloseButton(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverCloseButton": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverAnchor(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverAnchor": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class PopoverTrigger(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PopoverTrigger": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/overlay/tooltip.py b/reflex/components/chakra/overlay/tooltip.py deleted file mode 100644 index bd3a062c6..000000000 --- a/reflex/components/chakra/overlay/tooltip.py +++ /dev/null @@ -1,76 +0,0 @@ -"""Tooltip components.""" -from __future__ import annotations - -from typing import Any, Union - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.vars import Var - - -class Tooltip(ChakraComponent): - """A tooltip message to appear.""" - - tag = "Tooltip" - - # The padding required to prevent the arrow from reaching the very edge of the popper. - arrow_padding: Var[int] - - # The color of the arrow shadow. - arrow_shadow_color: Var[str] - - # Size of the arrow. - arrow_size: Var[int] - - # Delay (in ms) before hiding the tooltip - delay: Var[int] - - # If true, the tooltip will hide on click - close_on_click: Var[bool] - - # If true, the tooltip will hide on pressing Esc key - close_on_esc: Var[bool] - - # If true, the tooltip will hide while the mouse is down - close_on_mouse_down: Var[bool] - - # If true, the tooltip will be initially shown - default_is_open: Var[bool] - - # Theme direction ltr or rtl. Popper's placement will be set accordingly - direction: Var[LiteralChakraDirection] - - # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - gutter: Var[int] - - # If true, the tooltip will show an arrow tip - has_arrow: Var[bool] - - # If true, the tooltip with be disabled. - is_disabled: Var[bool] - - # If true, the tooltip will be open. - is_open: Var[bool] - - # The label of the tooltip - label: Var[str] - - # Delay (in ms) before showing the tooltip - open_delay: Var[int] - - # The placement of the popper relative to its reference. - placement: Var[str] - - # If true, the tooltip will wrap its children in a `` with `tabIndex=0` - should_wrap_children: Var[bool] - - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers for the component. - - Returns: - The event triggers. - """ - return { - **super().get_event_triggers(), - "on_close": lambda: [], - "on_open": lambda: [], - } diff --git a/reflex/components/chakra/overlay/tooltip.pyi b/reflex/components/chakra/overlay/tooltip.pyi deleted file mode 100644 index 9d6a77831..000000000 --- a/reflex/components/chakra/overlay/tooltip.pyi +++ /dev/null @@ -1,131 +0,0 @@ -"""Stub file for reflex/components/chakra/overlay/tooltip.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Union -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.vars import Var - -class Tooltip(ChakraComponent): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... - @overload - @classmethod - def create( # type: ignore - cls, - *children, - arrow_padding: Optional[Union[Var[int], int]] = None, - arrow_shadow_color: Optional[Union[Var[str], str]] = None, - arrow_size: Optional[Union[Var[int], int]] = None, - delay: Optional[Union[Var[int], int]] = None, - close_on_click: Optional[Union[Var[bool], bool]] = None, - close_on_esc: Optional[Union[Var[bool], bool]] = None, - close_on_mouse_down: Optional[Union[Var[bool], bool]] = None, - default_is_open: Optional[Union[Var[bool], bool]] = None, - direction: Optional[ - Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]] - ] = None, - gutter: Optional[Union[Var[int], int]] = None, - has_arrow: Optional[Union[Var[bool], bool]] = None, - is_disabled: Optional[Union[Var[bool], bool]] = None, - is_open: Optional[Union[Var[bool], bool]] = None, - label: Optional[Union[Var[str], str]] = None, - open_delay: Optional[Union[Var[int], int]] = None, - placement: Optional[Union[Var[str], str]] = None, - should_wrap_children: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Tooltip": - """Create the component. - - Args: - *children: The children of the component. - arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper. - arrow_shadow_color: The color of the arrow shadow. - arrow_size: Size of the arrow. - delay: Delay (in ms) before hiding the tooltip - close_on_click: If true, the tooltip will hide on click - close_on_esc: If true, the tooltip will hide on pressing Esc key - close_on_mouse_down: If true, the tooltip will hide while the mouse is down - default_is_open: If true, the tooltip will be initially shown - direction: Theme direction ltr or rtl. Popper's placement will be set accordingly - gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter. - has_arrow: If true, the tooltip will show an arrow tip - is_disabled: If true, the tooltip with be disabled. - is_open: If true, the tooltip will be open. - label: The label of the tooltip - open_delay: Delay (in ms) before showing the tooltip - placement: The placement of the popper relative to its reference. - should_wrap_children: If true, the tooltip will wrap its children in a `` with `tabIndex=0` - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/typography/__init__.py b/reflex/components/chakra/typography/__init__.py deleted file mode 100644 index be06b137b..000000000 --- a/reflex/components/chakra/typography/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Typography components.""" - -from reflex.components.component import Component - -from .heading import Heading -from .highlight import Highlight -from .span import Span -from .text import Text - -__all__ = [f for f in dir() if f[0].isupper() or f in ("span",)] # type: ignore diff --git a/reflex/components/chakra/typography/heading.py b/reflex/components/chakra/typography/heading.py deleted file mode 100644 index d681802fa..000000000 --- a/reflex/components/chakra/typography/heading.py +++ /dev/null @@ -1,17 +0,0 @@ -"""A heading component.""" - - -from reflex.components.chakra import ChakraComponent, LiteralHeadingSize -from reflex.vars import Var - - -class Heading(ChakraComponent): - """A page heading.""" - - tag = "Heading" - - # Override the tag. The default tag is `

`. - as_: Var[str] - - # "4xl" | "3xl" | "2xl" | "xl" | "lg" | "md" | "sm" | "xs" - size: Var[LiteralHeadingSize] diff --git a/reflex/components/chakra/typography/heading.pyi b/reflex/components/chakra/typography/heading.pyi deleted file mode 100644 index b9f849ecc..000000000 --- a/reflex/components/chakra/typography/heading.pyi +++ /dev/null @@ -1,96 +0,0 @@ -"""Stub file for reflex/components/chakra/typography/heading.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent, LiteralHeadingSize -from reflex.vars import Var - -class Heading(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - as_: Optional[Union[Var[str], str]] = None, - size: Optional[ - Union[ - Var[Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"]], - Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"], - ] - ] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Heading": - """Create the component. - - Args: - *children: The children of the component. - as_: Override the tag. The default tag is `

`. - size: "4xl" | "3xl" | "2xl" | "xl" | "lg" | "md" | "sm" | "xs" - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/typography/highlight.py b/reflex/components/chakra/typography/highlight.py deleted file mode 100644 index 0308c091e..000000000 --- a/reflex/components/chakra/typography/highlight.py +++ /dev/null @@ -1,23 +0,0 @@ -"""A highlight component.""" - -from typing import Dict, List - -from reflex.components.chakra import ChakraComponent -from reflex.components.tags import Tag -from reflex.vars import Var - - -class Highlight(ChakraComponent): - """Highlights a specific part of a string.""" - - tag = "Highlight" - - # A query for the text to highlight. Can be a string or a list of strings. - query: Var[List[str]] - - # The style of the content. - # Note: styles and style are different prop. - styles: Var[Dict] = {"px": "2", "py": "1", "rounded": "full", "bg": "teal.100"} # type: ignore - - def _render(self) -> Tag: - return super()._render().add_props(styles=self.style) diff --git a/reflex/components/chakra/typography/highlight.pyi b/reflex/components/chakra/typography/highlight.pyi deleted file mode 100644 index 9ad97c1f4..000000000 --- a/reflex/components/chakra/typography/highlight.pyi +++ /dev/null @@ -1,93 +0,0 @@ -"""Stub file for reflex/components/chakra/typography/highlight.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Dict, List -from reflex.components.chakra import ChakraComponent -from reflex.components.tags import Tag -from reflex.vars import Var - -class Highlight(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - query: Optional[Union[Var[List[str]], List[str]]] = None, - styles: Optional[Union[Var[Dict], Dict]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Highlight": - """Create the component. - - Args: - *children: The children of the component. - query: A query for the text to highlight. Can be a string or a list of strings. - styles: The style of the content. Note: styles and style are different prop. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/typography/span.py b/reflex/components/chakra/typography/span.py deleted file mode 100644 index e4bc698e6..000000000 --- a/reflex/components/chakra/typography/span.py +++ /dev/null @@ -1,14 +0,0 @@ -"""A span component.""" -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Span(ChakraComponent): - """Render an inline span of text.""" - - tag = "Text" - - # Override the tag. The default tag is ``. - as_: Var[str] = "span" # type: ignore diff --git a/reflex/components/chakra/typography/span.pyi b/reflex/components/chakra/typography/span.pyi deleted file mode 100644 index 966eb8aca..000000000 --- a/reflex/components/chakra/typography/span.pyi +++ /dev/null @@ -1,89 +0,0 @@ -"""Stub file for reflex/components/chakra/typography/span.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Span(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - as_: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Span": - """Create the component. - - Args: - *children: The children of the component. - as_: Override the tag. The default tag is ``. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/chakra/typography/text.py b/reflex/components/chakra/typography/text.py deleted file mode 100644 index e211c4d64..000000000 --- a/reflex/components/chakra/typography/text.py +++ /dev/null @@ -1,17 +0,0 @@ -"""A text component.""" -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - - -class Text(ChakraComponent): - """Render a paragraph of text.""" - - tag = "Text" - - # Override the tag. The default tag is `

`. - as_: Var[str] - - # Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. - no_of_lines: Var[int] diff --git a/reflex/components/chakra/typography/text.pyi b/reflex/components/chakra/typography/text.pyi deleted file mode 100644 index 889039784..000000000 --- a/reflex/components/chakra/typography/text.pyi +++ /dev/null @@ -1,91 +0,0 @@ -"""Stub file for reflex/components/chakra/typography/text.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex.components.chakra import ChakraComponent -from reflex.vars import Var - -class Text(ChakraComponent): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - as_: Optional[Union[Var[str], str]] = None, - no_of_lines: Optional[Union[Var[int], int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "Text": - """Create the component. - - Args: - *children: The children of the component. - as_: Override the tag. The default tag is `

`. - no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop. - 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 of the component. - - Returns: - The component. - """ - ... diff --git a/reflex/components/component.py b/reflex/components/component.py index 39a97792e..85db3906d 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -3,6 +3,7 @@ from __future__ import annotations import copy +import dataclasses import typing from abc import ABC, abstractmethod from functools import lru_cache, wraps @@ -24,6 +25,8 @@ from typing import ( 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, @@ -34,19 +37,39 @@ from reflex.constants import ( MemoizationMode, PageNames, ) +from reflex.constants.compiler import SpecialAttributes from reflex.event import ( + EventCallback, EventChain, + EventChainVar, EventHandler, EventSpec, + EventVar, call_event_fn, call_event_handler, + empty_event, get_handler_args, ) from reflex.style import Style, format_as_emotion -from reflex.utils import console, format, imports, types -from reflex.utils.imports import ImportVar -from reflex.utils.serializers import serializer -from reflex.vars import BaseVar, 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 ( + CachedVarOperation, + LiteralVar, + Var, + cached_property_no_lock, +) +from reflex.vars.function import ArgsFunctionOperation, FunctionStringVar +from reflex.vars.number import ternary_operation +from reflex.vars.object import ObjectVar +from reflex.vars.sequence import LiteralArrayVar class BaseComponent(Base, ABC): @@ -95,7 +118,7 @@ class BaseComponent(Base, ABC): """ @abstractmethod - def _get_all_imports(self) -> imports.ImportDict: + def _get_all_imports(self) -> ParsedImportDict: """Get all the libraries and fields that are used by the component. Returns: @@ -187,7 +210,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 @@ -213,7 +236,7 @@ class Component(BaseComponent, ABC): # State class associated with this component instance State: Optional[Type[reflex.state.State]] = None - def add_imports(self) -> dict[str, str | ImportVar | list[str | ImportVar]]: + def add_imports(self) -> ImportDict | list[ImportDict]: """Add imports for the component. This method should be implemented by subclasses to add new imports for the component. @@ -241,7 +264,7 @@ class Component(BaseComponent, ABC): """ return {} - def add_hooks(self) -> list[str]: + def add_hooks(self) -> list[str | Var]: """Add hooks inside the component function. Hooks are pieces of literal Javascript code that is inserted inside the @@ -319,7 +342,8 @@ class Component(BaseComponent, ABC): # Set default values for any props. if types._issubclass(field.type_, Var): field.required = False - field.default = Var.create(field.default) + if field.default is not None: + field.default = LiteralVar.create(field.default) elif types._issubclass(field.type_, EventHandler): field.required = False @@ -348,7 +372,7 @@ class Component(BaseComponent, ABC): "id": kwargs.get("id"), "children": children, **{ - prop: Var.create(kwargs[prop]) + prop: LiteralVar.create(kwargs[prop]) for prop in self.get_initial_props() if prop in kwargs }, @@ -360,7 +384,6 @@ class Component(BaseComponent, ABC): # Get the component fields, triggers, and props. fields = self.get_fields() component_specific_triggers = self.get_event_triggers() - triggers = component_specific_triggers.keys() props = self.get_props() # Add any events triggers. @@ -370,13 +393,17 @@ class Component(BaseComponent, ABC): # Iterate through the kwargs and set the props. for key, value in kwargs.items(): - if key.startswith("on_") and key not in triggers and key not in props: + if ( + key.startswith("on_") + and key not in component_specific_triggers + and key not in props + ): raise ValueError( f"The {(comp_name := type(self).__name__)} does not take in an `{key}` event trigger. If {comp_name}" f" is a third party component make sure to add `{key}` to the component's event triggers. " - f"visit https://reflex.dev/docs/wrapping-react/logic/#event-triggers for more info." + f"visit https://reflex.dev/docs/wrapping-react/guide/#event-triggers for more info." ) - if key in triggers: + if key in component_specific_triggers: # Event triggers are bound to event chains. field_type = EventChain elif key in props: @@ -392,7 +419,10 @@ class Component(BaseComponent, ABC): passed_types = None try: # Try to create a var from the value. - kwargs[key] = Var.create(value) + if isinstance(value, Var): + kwargs[key] = value + else: + kwargs[key] = LiteralVar.create(value) # Check that the var type is not None. if kwargs[key] is None: @@ -417,7 +447,9 @@ class Component(BaseComponent, ABC): if types.is_union(passed_type): # We need to check all possible types in the union. passed_types = ( - arg for arg in passed_type.__args__ if arg is not type(None) + arg + for arg in passed_type.__args__ # type: ignore + if arg is not type(None) ) if ( # If the passed var is a union, check if all possible types are valid. @@ -428,30 +460,56 @@ class Component(BaseComponent, ABC): ) or ( # Else just check if the passed var type is valid. not passed_types - and not types._issubclass(passed_type, expected_type) + and not types._issubclass(passed_type, expected_type, value) ): - value_name = value._var_name 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}." + value_name = value._js_expr if isinstance(value, Var) else value + + additional_info = ( + " You can call `.bool()` on the value to convert it to a boolean." + if expected_type is bool and isinstance(value, Var) + else "" ) + raise TypeError( + f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_type}." + + additional_info + ) # Check if the key is an event trigger. - if key in triggers: + if key in component_specific_triggers: # Temporarily disable full control for event triggers. kwargs["event_triggers"][key] = self._create_event_chain( - value=value, args_spec=component_specific_triggers[key] + value=value, # type: ignore + args_spec=component_specific_triggers[key], + key=key, ) # Remove any keys that were added as events. for key in kwargs["event_triggers"]: del kwargs[key] + # Place data_ and aria_ attributes into custom_attrs + special_attributes = tuple( + key + for key in kwargs + if key not in fields and SpecialAttributes.is_special(key) + ) + if special_attributes: + custom_attrs = kwargs.setdefault("custom_attrs", {}) + for key in special_attributes: + custom_attrs[format.to_kebab_case(key)] = kwargs.pop(key) + # Add style props to the component. style = kwargs.get("style", {}) if isinstance(style, List): # Merge styles, the later ones overriding keys in the earlier ones. style = {k: v for style_dict in style for k, v in style_dict.items()} + if isinstance(style, (Breakpoints, Var)): + style = { + # Assign the Breakpoints to the self-referential selector to avoid squashing down to a regular dict. + "&": style, + } + kwargs["style"] = Style( { **self.get_fields()["style"].default, @@ -459,13 +517,16 @@ class Component(BaseComponent, ABC): **{attr: value for attr, value in kwargs.items() if attr not in fields}, } ) - if "custom_attrs" not in kwargs: - kwargs["custom_attrs"] = {} # Convert class_name to str if it's list class_name = kwargs.get("class_name", "") if isinstance(class_name, (List, tuple)): - kwargs["class_name"] = " ".join(class_name) + if any(isinstance(c, Var) for c in class_name): + kwargs["class_name"] = LiteralArrayVar.create( + class_name, _var_type=List[str] + ).join(" ") + else: + kwargs["class_name"] = " ".join(class_name) # Construct the component. super().__init__(*args, **kwargs) @@ -474,14 +535,20 @@ 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, EventVar]], + Callable, ], + key: Optional[str] = None, ) -> Union[EventChain, Var]: """Create an event chain from a variety of input types. Args: args_spec: The args_spec of the event trigger being bound. value: The value to create the event chain from. + key: The key of the event trigger being bound. Returns: The event chain. @@ -491,9 +558,16 @@ class Component(BaseComponent, ABC): """ # If it's an event chain var, return it. if isinstance(value, Var): - if value._var_type is not EventChain: - raise ValueError(f"Invalid event chain: {value}") - return value + if isinstance(value, EventChainVar): + return value + elif isinstance(value, EventVar): + value = [value] + elif issubclass(value._var_type, (EventChain, EventSpec)): + return self._create_event_chain(args_spec, value.guess_type(), key=key) + else: + raise ValueError( + f"Invalid event chain: {str(value)} of type {value._var_type}" + ) elif isinstance(value, EventChain): # Trust that the caller knows what they're doing passing an EventChain directly return value @@ -504,53 +578,55 @@ class Component(BaseComponent, ABC): # If the input is a list of event handlers, create an event chain. if isinstance(value, List): - events: list[EventSpec] = [] + events: List[Union[EventSpec, EventVar]] = [] 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, key=key)) elif isinstance(v, Callable): # Call the lambda to get the event chain. - events.extend(call_event_fn(v, args_spec)) + result = call_event_fn(v, args_spec, key=key) + if isinstance(result, Var): + raise ValueError( + f"Invalid event chain: {v}. Cannot use a Var-returning " + "lambda inside an EventChain list." + ) + events.extend(result) + elif isinstance(v, EventVar): + events.append(v) else: raise ValueError(f"Invalid event: {v}") # If the input is a callable, create an event chain. elif isinstance(value, Callable): - events = call_event_fn(value, args_spec) + result = call_event_fn(value, args_spec) + if isinstance(result, Var): + # Recursively call this function if the lambda returned an EventChain Var. + return self._create_event_chain(args_spec, result, key=key) + events = [*result] # Otherwise, raise an error. else: raise ValueError(f"Invalid event chain: {value}") # Add args to the event specs if necessary. - events = [e.with_args(get_handler_args(e)) for e in events] - - # Collect event_actions from each spec - event_actions = {} - for e in events: - event_actions.update(e.event_actions) + events = [ + (e.with_args(get_handler_args(e)) if isinstance(e, EventSpec) else e) + for e in events + ] # Return the event chain. if isinstance(args_spec, Var): return EventChain( events=events, args_spec=None, - event_actions=event_actions, + event_actions={}, ) else: return EventChain( events=events, args_spec=args_spec, - event_actions=event_actions, + event_actions={}, ) def get_event_triggers(self) -> Dict[str, Any]: @@ -558,33 +634,35 @@ class Component(BaseComponent, ABC): Returns: The event triggers. + """ default_triggers = { - EventTriggers.ON_FOCUS: lambda: [], - EventTriggers.ON_BLUR: lambda: [], - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_CONTEXT_MENU: lambda: [], - EventTriggers.ON_DOUBLE_CLICK: lambda: [], - EventTriggers.ON_MOUSE_DOWN: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_UP: lambda: [], - EventTriggers.ON_SCROLL: lambda: [], - EventTriggers.ON_MOUNT: lambda: [], - EventTriggers.ON_UNMOUNT: lambda: [], + EventTriggers.ON_FOCUS: empty_event, + EventTriggers.ON_BLUR: empty_event, + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_CONTEXT_MENU: empty_event, + EventTriggers.ON_DOUBLE_CLICK: empty_event, + EventTriggers.ON_MOUSE_DOWN: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, + EventTriggers.ON_MOUSE_MOVE: empty_event, + EventTriggers.ON_MOUSE_OUT: empty_event, + EventTriggers.ON_MOUSE_OVER: empty_event, + EventTriggers.ON_MOUSE_UP: empty_event, + EventTriggers.ON_SCROLL: empty_event, + EventTriggers.ON_MOUNT: empty_event, + EventTriggers.ON_UNMOUNT: empty_event, } + # Look for component specific triggers, # e.g. variable declared as EventHandler types. for field in self.get_fields().values(): - if types._issubclass(field.type_, EventHandler): + if types._issubclass(field.outer_type_, EventHandler): args_spec = None annotation = field.annotation - if hasattr(annotation, "__metadata__"): - args_spec = annotation.__metadata__[0] - default_triggers[field.name] = args_spec or (lambda: []) + if (metadata := getattr(annotation, "__metadata__", None)) is not None: + args_spec = metadata[0] + default_triggers[field.name] = args_spec or (empty_event) # type: ignore return default_triggers def __repr__(self) -> str: @@ -605,27 +683,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. @@ -645,7 +702,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, ) @@ -659,7 +716,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"] = Var.create(ref, _var_is_local=False) + props["ref"] = Var(_js_expr=ref) else: props = props.copy() @@ -733,22 +790,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} @@ -774,7 +815,7 @@ class Component(BaseComponent, ABC): else ( Fragment.create(*child) if isinstance(child, tuple) - else Bare.create(contents=Var.create(child, _var_is_string=True)) + else Bare.create(contents=LiteralVar.create(child)) ) ) for child in children @@ -865,17 +906,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) @@ -901,7 +931,12 @@ class Component(BaseComponent, ABC): """ if isinstance(self.style, Var): return {"css": self.style} - return {"css": Var.create(format_as_emotion(self.style))} + emotion_style = format_as_emotion(self.style) + return ( + {"css": LiteralVar.create(emotion_style)} + if emotion_style is not None + else {} + ) def render(self) -> Dict: """Render the component. @@ -994,10 +1029,10 @@ class Component(BaseComponent, ABC): f"The component `{comp_name}` only allows the components: {valid_child_list} as children. Got `{child_name}` instead." ) - if child._valid_parents and comp_name not in [ - *child._valid_parents, - *allowed_components, - ]: + if child._valid_parents and all( + clz_name not in [*child._valid_parents, *allowed_components] + for clz_name in self._iter_parent_classes_names() + ): valid_parent_list = ", ".join( [f"`{v_parent}`" for v_parent in child._valid_parents] ) @@ -1026,8 +1061,11 @@ class Component(BaseComponent, ABC): elif isinstance(event, EventChain): event_args = [] for spec in event.events: - for args in spec.args: - event_args.extend(args) + if isinstance(spec, EventSpec): + for args in spec.args: + event_args.extend(args) + else: + event_args.append(spec) yield event_trigger, event_args def _get_vars(self, include_children: bool = False) -> list[Var]: @@ -1056,10 +1094,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( - BaseVar( - _var_name="style", + Var( + _js_expr="style", _var_type=str, - _var_data=self.style._var_data, + _var_data=VarData.merge(self.style._var_data), ) ) @@ -1078,8 +1116,8 @@ class Component(BaseComponent, ABC): vars.append(comp_prop) elif isinstance(comp_prop, str): # Collapse VarData encoded in f-strings. - var = Var.create_safe(comp_prop) - if var._var_data is not None: + var = LiteralVar.create(comp_prop) + if var._get_all_var_data() is not None: vars.append(var) # Get Vars associated with children. @@ -1087,24 +1125,56 @@ class Component(BaseComponent, ABC): for child in self.children: if not isinstance(child, Component): continue - vars.extend(child._get_vars(include_children=include_children)) + child_vars = child._get_vars(include_children=include_children) + vars.extend(child_vars) return vars - def _has_event_triggers(self) -> bool: - """Check if the component or children have any event triggers. + def _event_trigger_values_use_state(self) -> bool: + """Check if the values of a component's event trigger use state. Returns: - True if the component or children have any event triggers. + True if any of the component's event trigger values uses State. """ - if self.event_triggers: + for trigger in self.event_triggers.values(): + if isinstance(trigger, EventChain): + for event in trigger.events: + if isinstance(event, EventCallback): + continue + if isinstance(event, EventSpec): + if event.handler.state_full_name: + return True + else: + if event._var_state: + return True + elif isinstance(trigger, Var) and trigger._var_state: + return True + return False + + def _has_stateful_event_triggers(self): + """Check if component or children have any event triggers that use state. + + Returns: + True if the component or children have any event triggers that uses state. + """ + if self.event_triggers and self._event_trigger_values_use_state(): return True else: for child in self.children: - if isinstance(child, Component) and child._has_event_triggers(): + if ( + isinstance(child, Component) + and child._has_stateful_event_triggers() + ): return True return False + @classmethod + def _iter_parent_classes_names(cls) -> Iterator[str]: + for clz in cls.mro(): + if clz is Component: + break + yield clz.__name__ + @classmethod def _iter_parent_classes_with_method(cls, method: str) -> Iterator[Type[Component]]: """Iterate through parent classes that define a given method. @@ -1196,7 +1266,7 @@ class Component(BaseComponent, ABC): # Return the dynamic imports return dynamic_imports - def _get_props_imports(self) -> List[str]: + def _get_props_imports(self) -> List[ParsedImportDict]: """Get the imports needed for components props. Returns: @@ -1222,7 +1292,7 @@ class Component(BaseComponent, ABC): or format.format_library_name(dep or "") in self.transpile_packages ) - def _get_dependencies_imports(self) -> imports.ImportDict: + def _get_dependencies_imports(self) -> ParsedImportDict: """Get the imports from lib_dependencies for installing. Returns: @@ -1239,7 +1309,7 @@ class Component(BaseComponent, ABC): for dep in self.lib_dependencies } - def _get_hooks_imports(self) -> imports.ImportDict: + def _get_hooks_imports(self) -> ParsedImportDict: """Get the imports required by certain hooks. Returns: @@ -1250,7 +1320,9 @@ class Component(BaseComponent, ABC): if self._get_ref_hook(): # Handle hooks needed for attaching react refs to DOM nodes. _imports.setdefault("react", set()).add(ImportVar(tag="useRef")) - _imports.setdefault(f"/{Dirs.STATE_PATH}", set()).add(ImportVar(tag="refs")) + _imports.setdefault(f"$/{Dirs.STATE_PATH}", set()).add( + ImportVar(tag="refs") + ) if self._get_mount_lifecycle_hook(): # Handle hooks for `on_mount` / `on_unmount`. @@ -1265,13 +1337,22 @@ class Component(BaseComponent, ABC): }, ) + other_imports = [] user_hooks = self._get_hooks() - if user_hooks is not None and isinstance(user_hooks, Var): - _imports = imports.merge_imports(_imports, user_hooks._var_data.imports) # type: ignore + user_hooks_data = ( + VarData.merge(user_hooks._get_all_var_data()) + if user_hooks is not None and isinstance(user_hooks, Var) + else None + ) + if user_hooks_data is not None: + other_imports.append(user_hooks_data.imports) + other_imports.extend( + hook_imports for hook_imports in self._get_added_hooks().values() + ) - return _imports + return imports.merge_imports(_imports, *other_imports) - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ParsedImportDict: """Get all the libraries and fields that are used by the component. Returns: @@ -1287,29 +1368,26 @@ class Component(BaseComponent, ABC): event_imports = Imports.EVENTS if self.event_triggers else {} # Collect imports from Vars used directly by this component. - var_imports = [ - var._var_data.imports for var in self._get_vars() if var._var_data - ] - - # If any subclass implements add_imports, merge the imports. - def _make_list( - value: str | ImportVar | list[str | ImportVar], - ) -> list[str | ImportVar]: - if isinstance(value, (str, ImportVar)): - return [value] - return value - - _added_import_dicts = [] - for clz in self._iter_parent_classes_with_method("add_imports"): - _added_import_dicts.append( - { - package: [ - ImportVar(tag=tag) if not isinstance(tag, ImportVar) else tag - for tag in _make_list(maybe_tags) - ] - for package, maybe_tags in clz.add_imports(self).items() - } + var_datas = [var._get_all_var_data() for var in self._get_vars()] + 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"): + list_of_import_dict = clz.add_imports(self) + + if not isinstance(list_of_import_dict, list): + list_of_import_dict = [list_of_import_dict] + + for import_dict in list_of_import_dict: + added_import_dicts.append(parse_imports(import_dict)) return imports.merge_imports( *self._get_props_imports(), @@ -1318,10 +1396,10 @@ class Component(BaseComponent, ABC): _imports, event_imports, *var_imports, - *_added_import_dicts, + *added_import_dicts, ) - def _get_all_imports(self, collapse: bool = False) -> imports.ImportDict: + def _get_all_imports(self, collapse: bool = False) -> ParsedImportDict: """Get all the libraries and fields that are used by the component and its children. Args: @@ -1346,9 +1424,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(() => {{ @@ -1366,7 +1444,7 @@ class Component(BaseComponent, ABC): """ ref = self.get_ref() if ref is not None: - return f"const {ref} = useRef(null); {str(Var.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. @@ -1376,8 +1454,13 @@ class Component(BaseComponent, ABC): """ vars_hooks = {} for var in self._get_vars(): - if var._var_data: - vars_hooks.update(var._var_data.hooks) + var_data = var._get_all_var_data() + if var_data is not None: + vars_hooks.update( + var_data.hooks + if isinstance(var_data.hooks, dict) + else {k: None for k in var_data.hooks} + ) return vars_hooks def _get_events_hooks(self) -> dict[str, None]: @@ -1416,6 +1499,38 @@ class Component(BaseComponent, ABC): **self._get_special_hooks(), } + def _get_added_hooks(self) -> dict[str, ImportDict]: + """Get the hooks added via `add_hooks` method. + + Returns: + The deduplicated hooks and imports added by the component and parent components. + """ + code = {} + + def extract_var_hooks(hook: Var): + _imports = {} + var_data = VarData.merge(hook._get_all_var_data()) + if var_data is not None: + for sub_hook in var_data.hooks: + code[sub_hook] = {} + if var_data.imports: + _imports = var_data.imports + if str(hook) in code: + code[str(hook)] = imports.merge_imports(code[str(hook)], _imports) + else: + code[str(hook)] = _imports + + # Add the hook code from add_hooks for each parent class (this is reversed to preserve + # the order of the hooks in the final output) + for clz in reversed(tuple(self._iter_parent_classes_with_method("add_hooks"))): + for hook in clz.add_hooks(self): + if isinstance(hook, Var): + extract_var_hooks(hook) + else: + code[hook] = {} + + return code + def _get_hooks(self) -> str | None: """Get the React hooks for this component. @@ -1454,11 +1569,8 @@ class Component(BaseComponent, ABC): if hooks is not None: code[hooks] = None - # Add the hook code from add_hooks for each parent class (this is reversed to preserve - # the order of the hooks in the final output) - for clz in reversed(tuple(self._iter_parent_classes_with_method("add_hooks"))): - for hook in clz.add_hooks(self): - code[hook] = None + for hook in self._get_added_hooks(): + code[hook] = None # Add the hook code for the children. for child in self.children: @@ -1473,7 +1585,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): + if self.id is None or isinstance(self.id, Var): return None return format.format_ref(self.id) @@ -1567,7 +1679,7 @@ class CustomComponent(Component): """A custom user-defined component.""" # Use the components library. - library = f"/{Dirs.COMPONENTS_PATH}" + library = f"$/{Dirs.COMPONENTS_PATH}" # The function that creates the component. component_fn: Callable[..., Component] = Component.create @@ -1611,15 +1723,16 @@ class CustomComponent(Component): value = self._create_event_chain( value=value, args_spec=event_triggers_in_component_declaration.get( - key, lambda: [] + key, empty_event ), + key=key, ) self.props[format.to_camel_case(key)] = value continue # Handle subclasses of Base. if isinstance(value, Base): - base_value = Var.create(value) + base_value = LiteralVar.create(value) # Track hooks and imports associated with Component instances. if base_value is not None and isinstance(value, Component): @@ -1633,7 +1746,7 @@ class CustomComponent(Component): else: value = base_value else: - value = Var.create(value, _var_is_string=isinstance(value, str)) + value = LiteralVar.create(value) # Set the prop. self.props[format.to_camel_case(key)] = value @@ -1674,10 +1787,14 @@ class CustomComponent(Component): Args: seen: The tags of the components that have already been seen. + Raises: + ValueError: If the tag is not set. + Returns: The set of custom components. """ - assert self.tag is not None, "The tag must be set." + if self.tag is None: + raise ValueError("The tag must be set.") # Store the seen components in a set to avoid infinite recursion. if seen is None: @@ -1712,19 +1829,19 @@ class CustomComponent(Component): """ return super()._render(props=self.props) - def get_prop_vars(self) -> List[BaseVar]: + def get_prop_vars(self) -> List[Var]: """Get the prop vars. Returns: The prop vars. """ return [ - BaseVar( - _var_name=name, + Var( + _js_expr=name, _var_type=( prop._var_type if types._isinstance(prop, Var) else type(prop) ), - ) + ).guess_type() for name, prop in self.props.items() ] @@ -1737,9 +1854,11 @@ class CustomComponent(Component): Returns: Each var referenced by the component (props, styles, event handlers). """ - return super()._get_vars(include_children=include_children) + [ - prop for prop in self.props.values() if isinstance(prop, Var) - ] + return ( + super()._get_vars(include_children=include_children) + + [prop for prop in self.props.values() if isinstance(prop, Var)] + + self.get_component(self)._get_vars(include_children=include_children) + ) @lru_cache(maxsize=None) # noqa def get_component(self) -> Component: @@ -1779,7 +1898,7 @@ memo = custom_component class NoSSRComponent(Component): """A dynamic component that is not rendered on the server.""" - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ParsedImportDict: """Get the imports for the component. Returns: @@ -1824,19 +1943,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. @@ -1893,7 +1999,7 @@ class StatefulComponent(BaseComponent): if not should_memoize: # Determine if any Vars have associated data. for prop_var in component._get_vars(): - if prop_var._var_data: + if prop_var._get_all_var_data(): should_memoize = True break @@ -1908,7 +2014,7 @@ class StatefulComponent(BaseComponent): should_memoize = True break child = cls._child_var(child) - if isinstance(child, Var) and child._var_data: + if isinstance(child, Var) and child._get_all_var_data(): should_memoize = True break @@ -1958,6 +2064,7 @@ class StatefulComponent(BaseComponent): from reflex.components.base.bare import Bare from reflex.components.core.cond import Cond from reflex.components.core.foreach import Foreach + from reflex.components.core.match import Match if isinstance(child, Bare): return child.contents @@ -1965,6 +2072,8 @@ class StatefulComponent(BaseComponent): return child.cond if isinstance(child, Foreach): return child.iterable + if isinstance(child, Match): + return child.cond return child @classmethod @@ -2041,10 +2150,20 @@ class StatefulComponent(BaseComponent): Returns: A list of var names created by the hook declaration. """ - var_name = hook.partition("=")[0].strip().split(None, 1)[1].strip() - if var_name.startswith("["): - # Break up array destructuring. - return [v.strip() for v in var_name.strip("[]").split(",")] + # Ensure that the hook is a var declaration. + var_decl = hook.partition("=")[0].strip() + if not any(var_decl.startswith(kw) for kw in ["const ", "let ", "var "]): + return [] + + # Extract the var name from the declaration. + _, _, var_name = var_decl.partition(" ") + var_name = var_name.strip() + + # Break up array and object destructuring if used. + if var_name.startswith("[") or var_name.startswith("{"): + return [ + v.strip().replace("...", "") for v in var_name.strip("[]{}").split(",") + ] return [var_name] @classmethod @@ -2075,9 +2194,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() @@ -2086,20 +2203,21 @@ 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._var_data is None: + var_data = arg._get_all_var_data() + if var_data is None: continue - for hook in arg._var_data.hooks: + for hook in var_data.hooks: var_deps.extend(cls._get_hook_deps(hook)) memo_var_data = VarData.merge( - *[var._var_data for var in event_args], - VarData( # type: ignore - imports={"react": {ImportVar(tag="useCallback")}}, + *[var._get_all_var_data() for var in event_args], + VarData( + imports={"react": [ImportVar(tag="useCallback")]}, ), ) # Store the memoized function name and hook code for this event trigger. trigger_memo[event_trigger] = ( - Var.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)}])", @@ -2122,7 +2240,7 @@ class StatefulComponent(BaseComponent): """ return {} - def _get_all_imports(self) -> imports.ImportDict: + def _get_all_imports(self) -> ParsedImportDict: """Get all the libraries and fields that are used by the component. Returns: @@ -2130,7 +2248,7 @@ class StatefulComponent(BaseComponent): """ if self.rendered_as_shared: return { - f"/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [ + f"$/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [ ImportVar(tag=self.tag) ] } @@ -2172,7 +2290,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. @@ -2237,3 +2355,206 @@ class MemoizationLeaf(Component): update={"disposition": MemoizationDisposition.ALWAYS} ) return comp + + +load_dynamic_serializer() + + +class ComponentVar(Var[Component], python_types=BaseComponent): + """A Var that represents a Component.""" + + +def empty_component() -> Component: + """Create an empty component. + + Returns: + An empty component. + """ + from reflex.components.base.bare import Bare + + return Bare.create("") + + +def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) -> Var: + """Convert a render dict to a Var. + + Args: + tag: The render dict. + imported_names: The names of the imported components. + + Returns: + The Var. + """ + if not isinstance(tag, dict): + if isinstance(tag, Component): + return render_dict_to_var(tag.render(), imported_names) + return Var.create(tag) + + if "iterable" in tag: + function_return = Var.create( + [ + render_dict_to_var(child.render(), imported_names) + for child in tag["children"] + ] + ) + + func = ArgsFunctionOperation.create( + (tag["arg_var_name"], tag["index_var_name"]), + function_return, + ) + + return FunctionStringVar.create("Array.prototype.map.call").call( + tag["iterable"] + if not isinstance(tag["iterable"], ObjectVar) + else tag["iterable"].items(), + func, + ) + + if tag["name"] == "match": + element = tag["cond"] + + conditionals = tag["default"] + + for case in tag["match_cases"][::-1]: + condition = case[0].to_string() == element.to_string() + for pattern in case[1:-1]: + condition = condition | (pattern.to_string() == element.to_string()) + + conditionals = ternary_operation( + condition, + case[-1], + conditionals, + ) + + return conditionals + + if "cond" in tag: + return ternary_operation( + tag["cond"], + render_dict_to_var(tag["true_value"], imported_names), + render_dict_to_var(tag["false_value"], imported_names) + if tag["false_value"] is not None + else Var.create(None), + ) + + props = {} + + special_props = [] + + for prop_str in tag["props"]: + if "=" not in prop_str: + special_props.append(Var(prop_str).to(ObjectVar)) + continue + prop = prop_str.index("=") + key = prop_str[:prop] + value = prop_str[prop + 2 : -1] + props[key] = value + + props = Var.create({Var.create(k): Var(v) for k, v in props.items()}) + + for prop in special_props: + props = props.merge(prop) + + contents = tag["contents"][1:-1] if tag["contents"] else None + + raw_tag_name = tag.get("name") + tag_name = Var(raw_tag_name or "Fragment") + + tag_name = ( + Var.create(raw_tag_name) + if raw_tag_name + and raw_tag_name.split(".")[0] not in imported_names + and raw_tag_name.lower() == raw_tag_name + else tag_name + ) + + return FunctionStringVar.create( + "jsx", + ).call( + tag_name, + props, + *([Var(contents)] if contents is not None else []), + *[render_dict_to_var(child, imported_names) for child in tag["children"]], + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, +) +class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar): + """A Var that represents a Component.""" + + _var_value: BaseComponent = dataclasses.field(default_factory=empty_component) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """Get the name of the var. + + Returns: + The name of the var. + """ + var_data = self._get_all_var_data() + if var_data is not None: + # flatten imports + imported_names = {j.alias or j.name for i in var_data.imports for j in i[1]} + else: + imported_names = set() + return str(render_dict_to_var(self._var_value.render(), imported_names)) + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get the VarData for the var. + + Returns: + The VarData for the var. + """ + return VarData.merge( + VarData( + imports={ + "@emotion/react": [ + ImportVar(tag="jsx"), + ], + } + ), + VarData( + imports=self._var_value._get_all_imports(), + ), + VarData( + imports={ + "react": [ + ImportVar(tag="Fragment"), + ], + } + ), + ) + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._js_expr)) + + @classmethod + def create( + cls, + value: Component, + _var_data: VarData | None = None, + ): + """Create a var from a value. + + Args: + value: The value of the var. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The var. + """ + return LiteralComponentVar( + _js_expr="", + _var_type=type(value), + _var_data=_var_data, + _var_value=value, + ) diff --git a/reflex/components/core/__init__.py b/reflex/components/core/__init__.py index 80c73add8..fbe0bdc84 100644 --- a/reflex/components/core/__init__.py +++ b/reflex/components/core/__init__.py @@ -1,34 +1,57 @@ """Core Reflex components.""" -from . import layout as layout -from .banner import ConnectionBanner, ConnectionModal, ConnectionPulser -from .colors import color -from .cond import Cond, color_mode_cond, cond -from .debounce import DebounceInput -from .foreach import Foreach -from .html import Html -from .match import Match -from .responsive import ( - desktop_only, - mobile_and_tablet, - mobile_only, - tablet_and_desktop, - tablet_only, -) -from .upload import ( - UploadNamespace, - cancel_upload, - clear_selected_files, - get_upload_dir, - get_upload_url, - selected_files, -) +from __future__ import annotations -connection_banner = ConnectionBanner.create -connection_modal = ConnectionModal.create -connection_pulser = ConnectionPulser.create -debounce_input = DebounceInput.create -foreach = Foreach.create -html = Html.create -match = Match.create -upload = UploadNamespace() +from reflex.utils import lazy_loader + +_SUBMODULES: set[str] = {"layout"} + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "banner": [ + "ConnectionBanner", + "ConnectionModal", + "ConnectionPulser", + "ConnectionToaster", + "connection_banner", + "connection_modal", + "connection_toaster", + "connection_pulser", + ], + "clipboard": ["Clipboard", "clipboard"], + "colors": [ + "color", + ], + "cond": ["Cond", "color_mode_cond", "cond"], + "debounce": ["DebounceInput", "debounce_input"], + "foreach": [ + "foreach", + "Foreach", + ], + "html": ["html", "Html"], + "match": [ + "match", + "Match", + ], + "breakpoints": ["breakpoints", "set_breakpoints"], + "responsive": [ + "desktop_only", + "mobile_and_tablet", + "mobile_only", + "tablet_and_desktop", + "tablet_only", + ], + "upload": [ + "upload", + "cancel_upload", + "clear_selected_files", + "get_upload_dir", + "get_upload_url", + "selected_files", + ], +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/core/__init__.pyi b/reflex/components/core/__init__.pyi new file mode 100644 index 000000000..ea9275334 --- /dev/null +++ b/reflex/components/core/__init__.pyi @@ -0,0 +1,41 @@ +"""Stub file for reflex/components/core/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import layout as layout +from .banner import ConnectionBanner as ConnectionBanner +from .banner import ConnectionModal as ConnectionModal +from .banner import ConnectionPulser as ConnectionPulser +from .banner import ConnectionToaster as ConnectionToaster +from .banner import connection_banner as connection_banner +from .banner import connection_modal as connection_modal +from .banner import connection_pulser as connection_pulser +from .banner import connection_toaster as connection_toaster +from .breakpoints import breakpoints as breakpoints +from .breakpoints import set_breakpoints as set_breakpoints +from .clipboard import Clipboard as Clipboard +from .clipboard import clipboard as clipboard +from .colors import color as color +from .cond import Cond as Cond +from .cond import color_mode_cond as color_mode_cond +from .cond import cond as cond +from .debounce import DebounceInput as DebounceInput +from .debounce import debounce_input as debounce_input +from .foreach import Foreach as Foreach +from .foreach import foreach as foreach +from .html import Html as Html +from .html import html as html +from .match import Match as Match +from .match import match as match +from .responsive import desktop_only as desktop_only +from .responsive import mobile_and_tablet as mobile_and_tablet +from .responsive import mobile_only as mobile_only +from .responsive import tablet_and_desktop as tablet_and_desktop +from .responsive import tablet_only as tablet_only +from .upload import cancel_upload as cancel_upload +from .upload import clear_selected_files as clear_selected_files +from .upload import get_upload_dir as get_upload_dir +from .upload import get_upload_url as get_upload_url +from .upload import selected_files as selected_files +from .upload import upload as upload diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py index 0c781fba8..8a37b0bf7 100644 --- a/reflex/components/core/banner.py +++ b/reflex/components/core/banner.py @@ -4,7 +4,6 @@ from __future__ import annotations from typing import Optional -from reflex.components.base.bare import Bare from reflex.components.component import Component from reflex.components.core.cond import cond from reflex.components.el.elements.typography import Div @@ -14,57 +13,65 @@ from reflex.components.radix.themes.components.dialog import ( DialogRoot, DialogTitle, ) -from reflex.components.radix.themes.layout import Flex +from reflex.components.radix.themes.layout.flex import Flex 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.utils import imports -from reflex.vars import Var, VarData +from reflex.constants.compiler import CompileVars +from reflex.utils.imports import ImportVar +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}, ) -connection_error: Var = Var.create_safe( - value="(connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : ''", - _var_is_local=False, - _var_is_string=False, -)._replace(merge_var_data=connect_error_var_data) +connect_errors = Var( + _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data +) -connection_errors_count: Var = Var.create_safe( - value="connectErrors.length", - _var_is_string=False, - _var_is_local=False, -)._replace(merge_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, +) -has_connection_errors: Var = Var.create_safe( - value="connectErrors.length > 0", - _var_is_string=False, -)._replace(_var_type=bool, merge_var_data=connect_error_var_data) +connection_errors_count = Var( + _js_expr="connectErrors.length", _var_data=connect_error_var_data +) -has_too_many_connection_errors: Var = Var.create_safe( - value="connectErrors.length >= 2", - _var_is_string=False, -)._replace(_var_type=bool, merge_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(Bare): +class WebsocketTargetURL(Var): """A component that renders the websocket target URL.""" - def _get_imports(self) -> imports.ImportDict: - return { - f"/{Dirs.STATE_PATH}": [imports.ImportVar(tag="getBackendURL")], - "/env.json": [imports.ImportVar(tag="env", is_default=True)], - } - @classmethod - def create(cls) -> Component: + def create(cls) -> Var: """Create a websocket target URL component. Returns: The websocket target URL component. """ - return super().create(contents="{getBackendURL(env.EVENT).href}") + 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")], + }, + ), + _var_type=WebsocketTargetURL, + ) def default_connection_error() -> list[str | Var | Component]: @@ -81,6 +88,80 @@ def default_connection_error() -> list[str | Var | Component]: ] +class ConnectionToaster(Toaster): + """A connection toaster component.""" + + def add_hooks(self) -> list[str | Var]: + """Add the hooks for the connection toaster. + + Returns: + The hooks for the connection toaster. + """ + toast_id = "websocket-error" + target_url = WebsocketTargetURL.create() + props = ToastProps( # type: ignore + description=LiteralVar.create( + f"Check if server is reachable at {target_url}", + ), + close_button=True, + duration=120000, + id=toast_id, + ) + + individual_hooks = [ + f"const toast_props = {str(LiteralVar.create(props))};", + f"const [userDismissed, setUserDismissed] = useState(false);", + FunctionStringVar( + "useEffect", + _var_data=VarData( + imports={ + "react": ["useEffect", "useState"], + **dict(target_url._get_all_var_data().imports), # type: ignore + } + ), + ).call( + # TODO: This breaks the assumption that Vars are JS expressions + Var( + _js_expr=f""" +() => {{ + if ({str(has_too_many_connection_errors)}) {{ + if (!userDismissed) {{ + toast.error( + `Cannot connect to server: ${{{connection_error}}}.`, + {{...toast_props, onDismiss: () => setUserDismissed(true)}}, + ) + }} + }} else {{ + toast.dismiss("{toast_id}"); + setUserDismissed(false); // after reconnection reset dismissed state + }} +}} +""" + ), + LiteralArrayVar.create([connect_errors]), + ), + ] + + return [ + Hooks.EVENTS, + *individual_hooks, + ] + + @classmethod + def create(cls, *children, **props) -> Component: + """Create a connection toaster component. + + Args: + *children: The children of the component. + **props: The properties of the component. + + Returns: + The connection toaster component. + """ + Toaster.is_used = True + return super().create(*children, **props) + + class ConnectionBanner(Component): """A connection banner component.""" @@ -143,32 +224,36 @@ class WifiOffPulse(Icon): """A wifi_off icon with an animated opacity pulse.""" @classmethod - def create(cls, **props) -> Component: + def create(cls, *children, **props) -> Icon: """Create a wifi_off icon with an animated opacity pulse. Args: + *children: The children of the component. **props: The properties of the component. Returns: The icon component with default props applied. """ + pulse_var = Var(_js_expr="pulse") return super().create( "wifi_off", color=props.pop("color", "crimson"), size=props.pop("size", 32), z_index=props.pop("z_index", 9999), position=props.pop("position", "fixed"), - bottom=props.pop("botton", "30px"), - right=props.pop("right", "30px"), - animation=Var.create(f"${{pulse}} 1s infinite", _var_is_string=True), + bottom=props.pop("botton", "33px"), + right=props.pop("right", "33px"), + animation=LiteralVar.create(f"{pulse_var} 1s infinite"), **props, ) - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - {"@emotion/react": [imports.ImportVar(tag="keyframes")]}, - ) + def add_imports(self) -> dict[str, str | ImportVar | list[str | ImportVar]]: + """Add imports for the WifiOffPulse component. + + Returns: + The import dict. + """ + return {"@emotion/react": [ImportVar(tag="keyframes")]} def _get_custom_code(self) -> str | None: return """ @@ -201,7 +286,14 @@ class ConnectionPulser(Div): has_connection_errors, WifiOffPulse.create(**props), ), + title=f"Connection Error: {connection_error}", position="fixed", width="100vw", height="0", ) + + +connection_banner = ConnectionBanner.create +connection_modal = ConnectionModal.create +connection_toaster = ConnectionToaster.create +connection_pulser = ConnectionPulser.create diff --git a/reflex/components/core/banner.pyi b/reflex/components/core/banner.pyi index 43fc53e29..7c2be272c 100644 --- a/reflex/components/core/banner.pyi +++ b/reflex/components/core/banner.pyi @@ -1,104 +1,142 @@ """Stub file for reflex/components/core/banner.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.base.bare import Bare + from reflex.components.component import Component -from reflex.components.core.cond import cond from reflex.components.el.elements.typography import Div from reflex.components.lucide.icon import Icon -from reflex.components.radix.themes.components.dialog import ( - DialogContent, - DialogRoot, - DialogTitle, -) -from reflex.components.radix.themes.layout import Flex -from reflex.components.radix.themes.typography.text import Text -from reflex.constants import Dirs, Hooks, Imports -from reflex.utils import imports -from reflex.vars import Var, VarData +from reflex.components.sonner.toast import Toaster, ToastProps +from reflex.constants.compiler import CompileVars +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import Var +from reflex.vars.number import BooleanVar connect_error_var_data: VarData -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(Bare): +class WebsocketTargetURL(Var): + @classmethod + def create(cls) -> Var: ... # type: ignore + +def default_connection_error() -> list[str | Var | Component]: ... + +class ConnectionToaster(Toaster): + def add_hooks(self) -> list[str | Var]: ... @overload @classmethod def create( # type: ignore cls, *children, - contents: Optional[Union[Var[str], str]] = None, + theme: Optional[Union[Var[str], str]] = None, + rich_colors: Optional[Union[Var[bool], bool]] = None, + expand: Optional[Union[Var[bool], bool]] = None, + 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[ + "bottom-center", + "bottom-left", + "bottom-right", + "top-center", + "top-left", + "top-right", + ] + ], + ] + ] = None, + close_button: Optional[Union[Var[bool], bool]] = None, + offset: Optional[Union[Var[str], str]] = None, + 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[ToastProps, Var[ToastProps]]] = None, + gap: Optional[Union[Var[int], int]] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "WebsocketTargetURL": - """Create a websocket target URL component. + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "ConnectionToaster": + """Create a connection toaster component. + + Args: + *children: The children of the component. + theme: the theme of the toast + rich_colors: whether to show rich colors + expand: whether to expand the toast + visible_toasts: the number of toasts that are currently visible + position: the position of the toast + close_button: whether to show the close button + offset: offset of the toast + dir: directionality of the toast (default: ltr) + hotkey: Keyboard shortcut that will move focus to the toaster area. + invert: Dark toasts in light mode and vice versa. + toast_options: These will act as default options for all toasts. See toast() for all available options. + gap: Gap between toasts when expanded + loading_icon: Changes the default loading icon + pause_when_page_is_hidden: Pauses toast timers when the page is hidden, e.g., when the tab is backgrounded, the browser is minimized, or the OS is locked. + 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 properties of the component. Returns: - The websocket target URL component. + The connection toaster component. """ ... -def default_connection_error() -> list[str | Var | Component]: ... - class ConnectionBanner(Component): @overload @classmethod @@ -111,52 +149,22 @@ class ConnectionBanner(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ConnectionBanner": """Create a connection banner component. @@ -180,52 +188,22 @@ class ConnectionModal(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ConnectionModal": """Create a connection banner component. @@ -250,56 +228,27 @@ class WifiOffPulse(Icon): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "WifiOffPulse": """Create a wifi_off icon with an animated opacity pulse. Args: + *children: The children of the component. size: The size of the icon in pixels. style: The style of the component. key: A unique key for the component. @@ -314,104 +263,60 @@ class WifiOffPulse(Icon): """ ... + def add_imports(self) -> dict[str, str | ImportVar | list[str | ImportVar]]: ... + class ConnectionPulser(Div): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ConnectionPulser": """Create a connection pulser component. @@ -444,3 +349,8 @@ class ConnectionPulser(Div): The connection pulser component. """ ... + +connection_banner = ConnectionBanner.create +connection_modal = ConnectionModal.create +connection_toaster = ConnectionToaster.create +connection_pulser = ConnectionPulser.create diff --git a/reflex/components/core/breakpoints.py b/reflex/components/core/breakpoints.py new file mode 100644 index 000000000..4b2372a70 --- /dev/null +++ b/reflex/components/core/breakpoints.py @@ -0,0 +1,95 @@ +"""Breakpoints utility.""" + +from __future__ import annotations + +from typing import Dict, Tuple, TypeVar, Union + +breakpoints_values = ["30em", "48em", "62em", "80em", "96em"] +breakpoint_names = ["xs", "sm", "md", "lg", "xl"] + + +def set_breakpoints(values: Tuple[str, str, str, str, str]): + """Overwrite default breakpoint values. + + Args: + values: CSS values in order defining the breakpoints of responsive layouts + """ + breakpoints_values.clear() + breakpoints_values.extend(values) + + +K = TypeVar("K") +V = TypeVar("V") + + +class Breakpoints(Dict[K, V]): + """A responsive styling helper.""" + + def factorize(self): + """Removes references to breakpoints names and instead replaces them with their corresponding values. + + Returns: + The factorized breakpoints. + """ + return Breakpoints( + { + ( + breakpoints_values[breakpoint_names.index(k)] + if k in breakpoint_names + else ("0px" if k == "initial" else k) + ): v + for k, v in self.items() + if v is not None + } + ) + + @classmethod + def create( + cls, + custom: Dict[K, V] | None = None, + initial: V | None = None, + xs: V | None = None, + sm: V | None = None, + md: V | None = None, + lg: V | None = None, + xl: V | None = None, + ): + """Create a new instance of the helper. Only provide a custom component OR use named props. + + Args: + custom: Custom mapping using CSS values or variables. + initial: Styling when in the inital width + xs: Styling when in the extra-small width + sm: Styling when in the small width + md: Styling when in the medium width + lg: Styling when in the large width + xl: Styling when in the extra-large width + + Raises: + ValueError: If both custom and any other named parameters are provided. + + Returns: + The responsive mapping. + """ + thresholds = [initial, xs, sm, md, lg, xl] + + if custom is not None: + if any((threshold is not None for threshold in thresholds)): + raise ValueError("Named props cannot be used with custom thresholds") + + return Breakpoints(custom) + else: + return Breakpoints( + { + k: v + for k, v in zip(["initial", *breakpoint_names], thresholds) + if v is not None + } + ) + + +breakpoints = Breakpoints.create + +T = TypeVar("T") + +Responsive = Union[T, Breakpoints[str, T]] diff --git a/reflex/components/core/client_side_routing.py b/reflex/components/core/client_side_routing.py index 3d2090cd3..342c69632 100644 --- a/reflex/components/core/client_side_routing.py +++ b/reflex/components/core/client_side_routing.py @@ -7,29 +7,30 @@ setting a reactive state var "routeNotFound" to true if the redirect fails. The `wait_for_client_redirect` function will render the component only after routeNotFound becomes true. """ + 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) +route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND) class ClientSideRouting(Component): """The client-side routing component.""" - library = "/utils/client_side_routing" + library = "$/utils/client_side_routing" tag = "useClientSideRouting" - def _get_hooks(self) -> str: + def add_hooks(self) -> list[str]: """Get the hooks to render. Returns: The useClientSideRouting hook. """ - return f"const {constants.ROUTE_NOT_FOUND} = {self.tag}()" + return [f"const {constants.ROUTE_NOT_FOUND} = {self.tag}()"] def render(self) -> str: """Render the component. diff --git a/reflex/components/core/client_side_routing.pyi b/reflex/components/core/client_side_routing.pyi index 08fbf7e54..1d528daaf 100644 --- a/reflex/components/core/client_side_routing.pyi +++ b/reflex/components/core/client_side_routing.pyi @@ -1,20 +1,19 @@ """Stub file for reflex/components/core/client_side_routing.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex import constants from reflex.components.component import Component -from reflex.components.core.cond import cond -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var route_not_found: Var class ClientSideRouting(Component): + def add_hooks(self) -> list[str]: ... def render(self) -> str: ... @overload @classmethod @@ -27,52 +26,22 @@ class ClientSideRouting(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ClientSideRouting": """Create the component. @@ -106,52 +75,22 @@ class Default404Page(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Default404Page": """Create the component. diff --git a/reflex/components/core/clipboard.py b/reflex/components/core/clipboard.py new file mode 100644 index 000000000..cce0af4a7 --- /dev/null +++ b/reflex/components/core/clipboard.py @@ -0,0 +1,96 @@ +"""Global on_paste handling for Reflex app.""" + +from __future__ import annotations + +from typing import Dict, List, Tuple, Union + +from reflex.components.base.fragment import Fragment +from reflex.components.tags.tag import Tag +from reflex.event import EventChain, EventHandler, identity_event +from reflex.utils.format import format_prop, wrap +from reflex.utils.imports import ImportVar +from reflex.vars import get_unique_variable_name +from reflex.vars.base import Var + + +class Clipboard(Fragment): + """Clipboard component.""" + + # The element ids to attach the event listener to. Defaults to all child components or the document. + targets: Var[List[str]] + + # Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri. + on_paste: EventHandler[identity_event(List[Tuple[str, str]])] + + # Save the original event actions for the on_paste event. + on_paste_event_actions: Var[Dict[str, Union[bool, int]]] + + @classmethod + def create(cls, *children, **props): + """Create a Clipboard component. + + Args: + *children: The children of the component. + **props: The properties of the component. + + Returns: + The Clipboard Component. + """ + if "targets" not in props: + # Add all children as targets if not specified. + targets = props.setdefault("targets", []) + for c in children: + if c.id is None: + c.id = f"clipboard_{get_unique_variable_name()}" + targets.append(c.id) + + if "on_paste" in props: + # Capture the event actions for the on_paste handler if not specified. + props.setdefault("on_paste_event_actions", props["on_paste"].event_actions) + + return super().create(*children, **props) + + def _exclude_props(self) -> list[str]: + return super()._exclude_props() + ["on_paste", "on_paste_event_actions"] + + def _render(self) -> Tag: + tag = super()._render() + tag.remove_props("targets") + # Ensure a different Fragment component is created whenever targets differ + tag.add_props(key=self.targets) + return tag + + def add_imports(self) -> dict[str, ImportVar]: + """Add the imports for the Clipboard component. + + Returns: + The import dict for the component. + """ + return { + "$/utils/helpers/paste.js": ImportVar( + tag="usePasteHandler", is_default=True + ), + } + + def add_hooks(self) -> list[str]: + """Add hook to register paste event listener. + + Returns: + The hooks to add to the component. + """ + on_paste = self.event_triggers["on_paste"] + if on_paste is None: + return [] + if isinstance(on_paste, EventChain): + on_paste = wrap(str(format_prop(on_paste)).strip("{}"), "(") + return [ + "usePasteHandler(%s, %s, %s)" + % ( + str(self.targets), + str(self.on_paste_event_actions), + on_paste, + ) + ] + + +clipboard = Clipboard.create diff --git a/reflex/components/core/clipboard.pyi b/reflex/components/core/clipboard.pyi new file mode 100644 index 000000000..1284b8050 --- /dev/null +++ b/reflex/components/core/clipboard.pyi @@ -0,0 +1,71 @@ +"""Stub file for reflex/components/core/clipboard.py""" + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from typing import Any, Dict, List, Optional, Union, overload + +from reflex.components.base.fragment import Fragment +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportVar +from reflex.vars.base import Var + +class Clipboard(Fragment): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + targets: Optional[Union[List[str], Var[List[str]]]] = None, + on_paste_event_actions: Optional[ + Union[Dict[str, Union[bool, int]], Var[Dict[str, Union[bool, int]]]] + ] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_paste: Optional[EventType[list[tuple[str, str]]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Clipboard": + """Create a Clipboard component. + + Args: + *children: The children of the component. + targets: The element ids to attach the event listener to. Defaults to all child components or the document. + on_paste: Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri. + on_paste_event_actions: Save the original event actions for the on_paste event. + 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 properties of the component. + + Returns: + The Clipboard Component. + """ + ... + + def add_imports(self) -> dict[str, ImportVar]: ... + def add_hooks(self) -> list[str]: ... + +clipboard = Clipboard.create diff --git a/reflex/components/core/cond.py b/reflex/components/core/cond.py index 0e3e43672..e0c47f0fe 100644 --- a/reflex/components/core/cond.py +++ b/reflex/components/core/cond.py @@ -1,4 +1,5 @@ """Create a list of components from an iterable.""" + from __future__ import annotations from typing import Any, Dict, Optional, overload @@ -7,13 +8,14 @@ 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.constants.colors import Color -from reflex.style import LIGHT_COLOR_MODE, color_mode -from reflex.utils import format, imports -from reflex.vars import BaseVar, Var, VarData +from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode +from reflex.utils.imports import ImportDict, ImportVar +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.number import ternary_operation -_IS_TRUE_IMPORT = { - f"/{Dirs.STATE_PATH}": {imports.ImportVar(tag="isTrue")}, +_IS_TRUE_IMPORT: ImportDict = { + f"$/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")], } @@ -92,33 +94,35 @@ 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 _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - getattr(self.cond._var_data, "imports", {}), - _IS_TRUE_IMPORT, - ) + def add_imports(self) -> ImportDict: + """Add imports for the Cond component. + + Returns: + The import dict for the component. + """ + 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 -def cond(condition: Any, c1: Component, c2: Any) -> Component: - ... +def cond(condition: Any, c1: Component, c2: Any) -> Component: ... @overload -def cond(condition: Any, c1: Component) -> Component: - ... +def cond(condition: Any, c1: Component) -> Component: ... @overload -def cond(condition: Any, c1: Any, c2: Any) -> Var: - ... +def cond(condition: Any, c1: Any, c2: Any) -> Var: ... -def cond(condition: Any, c1: Any, c2: Any = None): +def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var: """Create a conditional component or Prop. Args: @@ -132,24 +136,16 @@ def cond(condition: Any, c1: Any, c2: Any = None): Raises: ValueError: If the arguments are invalid. """ - var_datas: list[VarData | None] = [ - VarData( # type: ignore - imports=_IS_TRUE_IMPORT, - ), - ] - # Convert the condition to a Var. - cond_var = Var.create(condition) - assert cond_var is not None, "The condition must be set." + cond_var = LiteralVar.create(condition) + if cond_var is None: + raise ValueError("The condition must be set.") # If the first component is a component, create a Cond component. if isinstance(c1, BaseComponent): - assert c2 is None or isinstance( - c2, BaseComponent - ), "Both arguments must be components." + if c2 is not None and not isinstance(c2, BaseComponent): + raise ValueError("Both arguments must be components.") return Cond.create(cond_var, c1, c2) - if isinstance(c1, Var): - var_datas.append(c1._var_data) # Otherwise, create a conditional Var. # Check that the second argument is valid. @@ -157,32 +153,21 @@ def cond(condition: Any, c1: Any, c2: Any = None): raise ValueError("Both arguments must be props.") if c2 is None: raise ValueError("For conditional vars, the second argument must be set.") - if isinstance(c2, Var): - var_datas.append(c2._var_data) def create_var(cond_part): - return Var.create_safe( - cond_part, - _var_is_string=isinstance(cond_part, (str, Color)), - ) + return LiteralVar.create(cond_part) # convert the truth and false cond parts into vars so the _var_data can be obtained. c1 = create_var(c1) c2 = create_var(c2) - var_datas.extend([c1._var_data, c2._var_data]) # Create the conditional var. - return cond_var._replace( - _var_name=format.format_cond( - cond=cond_var._var_full_name, - true_value=c1, - false_value=c2, - is_prop=True, - ), - _var_type=c1._var_type if isinstance(c1, BaseVar) else type(c1), - _var_is_local=False, - _var_full_name_needs_state_prefix=False, - merge_var_data=VarData.merge(*var_datas), + return ternary_operation( + cond_var.bool()._replace( # type: ignore + merge_var_data=VarData(imports=_IS_TRUE_IMPORT), + ), # type: ignore + c1, + c2, ) @@ -197,7 +182,7 @@ def color_mode_cond(light: Any, dark: Any = None) -> Var | Component: The conditional component or prop. """ return cond( - color_mode == Var.create(LIGHT_COLOR_MODE, _var_is_string=True), + resolved_color_mode == LiteralVar.create(LIGHT_COLOR_MODE), light, dark, ) diff --git a/reflex/components/core/debounce.py b/reflex/components/core/debounce.py index 5fabd4486..86efb7dcd 100644 --- a/reflex/components/core/debounce.py +++ b/reflex/components/core/debounce.py @@ -6,7 +6,9 @@ from typing import Any, Type, Union from reflex.components.component import Component from reflex.constants import EventTriggers -from reflex.vars import Var, VarData +from reflex.event import EventHandler, empty_event +from reflex.vars import VarData +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -43,6 +45,9 @@ class DebounceInput(Component): # The element to wrap element: Var[Type[Component]] + # Fired when the input value changes + on_change: EventHandler[empty_event] + @classmethod def create(cls, *children: Component, **props: Any) -> Component: """Create a DebounceInput component. @@ -97,23 +102,23 @@ class DebounceInput(Component): props.setdefault("style", {}).update(child.style) if child.class_name is not None: props["class_name"] = f"{props.get('class_name', '')} {child.class_name}" + for field in ("key", "special_props"): + if getattr(child, field) is not None: + 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) + 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, - )._replace( + Var( + _js_expr=str(child.alias or child.tag), _var_type=Type[Component], - merge_var_data=VarData( # type: ignore + _var_data=VarData( imports=child._get_imports(), - hooks=child._get_hooks_internal(), + hooks=child._get_all_hooks(), ), ), ) @@ -123,18 +128,14 @@ class DebounceInput(Component): component.event_triggers.update(child.event_triggers) component.children = child.children component._rename_props = child._rename_props + outer_get_all_custom_code = component._get_all_custom_code + component._get_all_custom_code = lambda: outer_get_all_custom_code().union( + child._get_all_custom_code() + ) return component - def get_event_triggers(self) -> dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.value], - } - def _render(self): return super()._render().remove_props("ref") + + +debounce_input = DebounceInput.create diff --git a/reflex/components/core/debounce.pyi b/reflex/components/core/debounce.pyi index 7b87a3cfe..6d7b76510 100644 --- a/reflex/components/core/debounce.pyi +++ b/reflex/components/core/debounce.pyi @@ -1,16 +1,14 @@ """Stub file for reflex/components/core/debounce.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Type, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Type, Union from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var, VarData +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -24,66 +22,32 @@ 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[str, int, float]], Union[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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DebounceInput": """Create a DebounceInput component. @@ -105,4 +69,5 @@ class DebounceInput(Component): ValueError: if the child element does not have an on_change handler. """ ... - def get_event_triggers(self) -> dict[str, Any]: ... + +debounce_input = DebounceInput.create diff --git a/reflex/components/core/foreach.py b/reflex/components/core/foreach.py index 88f2886a8..a3f97d594 100644 --- a/reflex/components/core/foreach.py +++ b/reflex/components/core/foreach.py @@ -1,4 +1,5 @@ """Create a list of components from an iterable.""" + from __future__ import annotations import inspect @@ -8,8 +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.utils import console -from reflex.vars import Var +from reflex.state import ComponentState +from reflex.vars.base import LiteralVar, Var class ForeachVarError(TypeError): @@ -36,35 +37,36 @@ 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. Raises: 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 = Var.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/layout/foreach/" + "See https://reflex.dev/docs/library/dynamic-rendering/foreach/" ) + + if ( + hasattr(render_fn, "__qualname__") + and render_fn.__qualname__ == ComponentState.create.__qualname__ + ): + raise TypeError( + "Using a ComponentState as `render_fn` inside `rx.foreach` is not supported yet." + ) + component = cls( iterable=iterable, render_fn=render_fn, @@ -83,7 +85,8 @@ class Foreach(Component): if len(params) == 0 or len(params) > 2: raise ForeachRenderError( "Expected 1 or 2 parameters in foreach render function, got " - f"{[p.name for p in params]}. See https://reflex.dev/docs/library/layout/foreach/" + f"{[p.name for p in params]}. See " + "https://reflex.dev/docs/library/dynamic-rendering/foreach/" ) if len(params) >= 1: @@ -123,8 +126,11 @@ 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__, ) + + +foreach = Foreach.create diff --git a/reflex/components/core/html.py b/reflex/components/core/html.py index e344cb3d7..cfe46e591 100644 --- a/reflex/components/core/html.py +++ b/reflex/components/core/html.py @@ -1,15 +1,16 @@ """A html component.""" + 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): """Render the html. Returns: - The code to render the html component. + The code to render the html component. """ # The HTML to render. @@ -43,3 +44,6 @@ class Html(Div): # Create the component. return super().create(**props) + + +html = Html.create diff --git a/reflex/components/core/html.pyi b/reflex/components/core/html.pyi index e07f455bb..7f3ff603d 100644 --- a/reflex/components/core/html.pyi +++ b/reflex/components/core/html.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/core/html.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Dict from reflex.components.el.elements.typography import Div -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Html(Div): @overload @@ -18,100 +17,54 @@ class Html(Div): cls, *children, dangerouslySetInnerHTML: Optional[ - Union[Var[Dict[str, str]], Dict[str, str]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Dict[str, str], Var[Dict[str, str]]] ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Html": """Create a html component. @@ -149,3 +102,5 @@ class Html(Div): ValueError: If children are not provided or more than one child is provided. """ ... + +html = Html.create diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py index 97741b9fa..8b9382c89 100644 --- a/reflex/components/core/match.py +++ b/reflex/components/core/match.py @@ -5,12 +5,13 @@ 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.core.colors import Color from reflex.components.tags import MatchTag, Tag from reflex.style import Style -from reflex.utils import format, imports, types +from reflex.utils import format, types from reflex.utils.exceptions import MatchTypeError -from reflex.vars import BaseVar, Var, VarData +from reflex.utils.imports import ImportDict +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var class Match(MemoizationLeaf): @@ -26,7 +27,7 @@ class Match(MemoizationLeaf): default: Any @classmethod - def create(cls, cond: Any, *cases) -> Union[Component, BaseVar]: + def create(cls, cond: Any, *cases) -> Union[Component, Var]: """Create a Match Component. Args: @@ -45,7 +46,7 @@ class Match(MemoizationLeaf): cls._validate_return_types(match_cases) - if default is None and types._issubclass(type(match_cases[0][-1]), BaseVar): + if default is None and types._issubclass(type(match_cases[0][-1]), Var): raise ValueError( "For cases with return types as Vars, a default case must be provided" ) @@ -55,7 +56,7 @@ class Match(MemoizationLeaf): ) @classmethod - def _create_condition_var(cls, cond: Any) -> BaseVar: + def _create_condition_var(cls, cond: Any) -> Var: """Convert the condition to a Var. Args: @@ -67,16 +68,16 @@ class Match(MemoizationLeaf): Raises: ValueError: If the condition is not provided. """ - match_cond_var = Var.create(cond, _var_is_string=isinstance(cond, str)) + match_cond_var = LiteralVar.create(cond) if match_cond_var is None: raise ValueError("The condition must be set") - return match_cond_var # type: ignore + return match_cond_var @classmethod def _process_cases( cls, cases: List - ) -> Tuple[List, Optional[Union[BaseVar, BaseComponent]]]: + ) -> Tuple[List, Optional[Union[Var, BaseComponent]]]: """Process the list of match cases and the catchall default case. Args: @@ -93,6 +94,9 @@ class Match(MemoizationLeaf): if len([case for case in cases if not isinstance(case, tuple)]) > 1: raise ValueError("rx.match can only have one default case.") + if not cases: + raise ValueError("rx.match should have at least one case.") + # Get the default case which should be the last non-tuple arg if not isinstance(cases[-1], tuple): default = cases.pop() @@ -102,7 +106,7 @@ class Match(MemoizationLeaf): else default ) - return cases, default # type: ignore + return cases, default @classmethod def _create_case_var_with_var_data(cls, case_element): @@ -116,17 +120,12 @@ class Match(MemoizationLeaf): Returns: The case element Var. """ - _var_data = case_element._var_data if isinstance(case_element, Style) else None # type: ignore - case_element = Var.create( - case_element, - _var_is_string=isinstance(case_element, (str, Color)), - ) - if _var_data is not None: - case_element._var_data = VarData.merge(case_element._var_data, _var_data) # type: ignore + _var_data = case_element._var_data if isinstance(case_element, Style) else None + case_element = LiteralVar.create(case_element, _var_data=_var_data) return case_element @classmethod - def _process_match_cases(cls, cases: List) -> List[List[BaseVar]]: + def _process_match_cases(cls, cases: List) -> List[List[Var]]: """Process the individual match cases. Args: @@ -158,7 +157,7 @@ class Match(MemoizationLeaf): if not isinstance(element, BaseComponent) else element ) - if not isinstance(el, (BaseVar, BaseComponent)): + if not isinstance(el, (Var, BaseComponent)): raise ValueError("Case element must be a var or component") case_list.append(el) @@ -167,7 +166,7 @@ class Match(MemoizationLeaf): return match_cases @classmethod - def _validate_return_types(cls, match_cases: List[List[BaseVar]]) -> None: + def _validate_return_types(cls, match_cases: List[List[Var]]) -> None: """Validate that match cases have the same return types. Args: @@ -181,14 +180,14 @@ class Match(MemoizationLeaf): if types._isinstance(first_case_return, BaseComponent): return_type = BaseComponent - elif types._isinstance(first_case_return, BaseVar): - return_type = BaseVar + elif types._isinstance(first_case_return, Var): + return_type = Var for index, case in enumerate(match_cases): 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], BaseVar) 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}" ) @@ -196,9 +195,9 @@ class Match(MemoizationLeaf): def _create_match_cond_var_or_component( cls, match_cond_var: Var, - match_cases: List[List[BaseVar]], - default: Optional[Union[BaseVar, BaseComponent]], - ) -> Union[Component, BaseVar]: + match_cases: List[List[Var]], + default: Optional[Union[Var, BaseComponent]], + ) -> Union[Component, Var]: """Create and return the match condition var or component. Args: @@ -229,28 +228,22 @@ class Match(MemoizationLeaf): # Validate the match cases (as well as the default case) to have Var return types. if any( - case for case in match_cases if not types._isinstance(case[-1], BaseVar) - ) or not types._isinstance(default, BaseVar): + case for case in match_cases if not types._isinstance(case[-1], Var) + ) or not types._isinstance(default, Var): raise ValueError("Return types of match cases should be Vars.") - # match cases and default should all be Vars at this point. - # Retrieve var data of every var in the match cases and default. - var_data = [ - *[el._var_data for case in match_cases for el in case], - default._var_data, # type: ignore - ] - - return match_cond_var._replace( - _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_is_local=False, - _var_full_name_needs_state_prefix=False, - _var_is_string=False, - merge_var_data=VarData.merge(*var_data), + _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 + ), ) def _render(self) -> Tag: @@ -268,8 +261,14 @@ class Match(MemoizationLeaf): tag.name = "match" return dict(tag) - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - getattr(self.cond._var_data, "imports", {}), - ) + def add_imports(self) -> ImportDict: + """Add imports for the Match component. + + Returns: + The import dict. + """ + 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/responsive.py b/reflex/components/core/responsive.py index 98033fd70..e1c7f0cb3 100644 --- a/reflex/components/core/responsive.py +++ b/reflex/components/core/responsive.py @@ -1,6 +1,6 @@ """Responsive components.""" -from reflex.components.radix.themes.layout import Box +from reflex.components.radix.themes.layout.box import Box # Add responsive styles shortcuts. diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index b3ac37c15..787cca9d0 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -2,34 +2,41 @@ from __future__ import annotations -import os from pathlib import Path -from typing import Any, Callable, ClassVar, Dict, List, Optional, Union +from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple -from reflex import constants -from reflex.components.chakra.forms.input import Input -from reflex.components.chakra.layout.box import Box -from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf +from reflex.components.component import ( + Component, + ComponentNamespace, + MemoizationLeaf, + StatefulComponent, +) +from reflex.components.el.elements.forms import Input +from reflex.components.radix.themes.layout.box import Box +from reflex.config import environment from reflex.constants import Dirs +from reflex.constants.compiler import Imports from reflex.event import ( CallableEventSpec, EventChain, + EventHandler, EventSpec, call_event_fn, call_script, parse_args_spec, ) -from reflex.utils import imports -from reflex.vars import BaseVar, CallableVar, Var, VarData +from reflex.utils import format +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import CallableVar, LiteralVar, Var, get_unique_variable_name +from reflex.vars.sequence import LiteralStringVar DEFAULT_UPLOAD_ID: str = "default" -upload_files_context_var_data: VarData = VarData( # type: ignore +upload_files_context_var_data: VarData = VarData( imports={ - "react": {imports.ImportVar(tag="useContext")}, - f"/{Dirs.CONTEXTS_PATH}": { - imports.ImportVar(tag="UploadFilesContext"), - }, + "react": "useContext", + f"$/{Dirs.CONTEXTS_PATH}": "UploadFilesContext", }, hooks={ "const [filesById, setFilesById] = useContext(UploadFilesContext);": None, @@ -38,7 +45,7 @@ upload_files_context_var_data: VarData = VarData( # type: ignore @CallableVar -def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: +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 @@ -50,15 +57,25 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: Returns: A var referencing the file upload drop trigger. """ - return BaseVar( - _var_name=f"e => setFilesById(filesById => ({{...filesById, {id_}: e}}))", + id_var = LiteralStringVar.create(id_) + var_name = f"""e => setFilesById(filesById => {{ + const updatedFilesById = Object.assign({{}}, filesById); + updatedFilesById[{str(id_var)}] = e; + return updatedFilesById; + }}) + """ + + return Var( + _js_expr=var_name, _var_type=EventChain, - _var_data=upload_files_context_var_data, + _var_data=VarData.merge( + upload_files_context_var_data, id_var._get_all_var_data() + ), ) @CallableVar -def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: +def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: """Get the list of selected files. Args: @@ -67,11 +84,14 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: Returns: A var referencing the list of selected file paths. """ - return BaseVar( - _var_name=f"(filesById.{id_} ? filesById.{id_}.map((f) => (f.path || f.name)) : [])", + id_var = LiteralStringVar.create(id_) + 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=upload_files_context_var_data, - ) + _var_data=VarData.merge( + upload_files_context_var_data, id_var._get_all_var_data() + ), + ).guess_type() @CallableEventSpec @@ -99,7 +119,9 @@ def cancel_upload(upload_id: str) -> EventSpec: Returns: An event spec that cancels the upload when triggered. """ - return call_script(f"upload_controllers[{upload_id!r}]?.abort()") + return call_script( + f"upload_controllers[{str(LiteralVar.create(upload_id))}]?.abort()" + ) def get_upload_dir() -> Path: @@ -110,23 +132,20 @@ def get_upload_dir() -> Path: """ Upload.is_used = True - uploaded_files_dir = Path( - os.environ.get("REFLEX_UPLOADED_FILES_DIR", "./uploaded_files") - ) + uploaded_files_dir = environment.REFLEX_UPLOADED_FILES_DIR uploaded_files_dir.mkdir(parents=True, exist_ok=True) return uploaded_files_dir -uploaded_files_url_prefix: Var = Var.create_safe( - "${getBackendURL(env.UPLOAD)}" -)._replace( - merge_var_data=VarData( # type: ignore +uploaded_files_url_prefix = Var( + _js_expr="getBackendURL(env.UPLOAD)", + _var_data=VarData( imports={ - f"/{Dirs.STATE_PATH}": {imports.ImportVar(tag="getBackendURL")}, - "/env.json": {imports.ImportVar(tag="env", is_default=True)}, + f"$/{Dirs.STATE_PATH}": "getBackendURL", + "$/env.json": ImportVar(tag="env", is_default=True), } - ) -) + ), +).to(str) def get_upload_url(file_path: str) -> Var[str]: @@ -140,12 +159,10 @@ 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): +def _on_drop_spec(files: Var) -> Tuple[Var[Any]]: """Args spec for the on_drop event trigger. Args: @@ -154,24 +171,22 @@ def _on_drop_spec(files: Var): Returns: Signature for on_drop handler including the files to upload. """ - return [files] + return (files,) class UploadFilesProvider(Component): """AppWrap component that provides a dict of selected files by ID via useContext.""" - library = f"/{Dirs.CONTEXTS_PATH}" + library = f"$/{Dirs.CONTEXTS_PATH}" tag = "UploadFilesProvider" class Upload(MemoizationLeaf): """A file upload component.""" - library = "react-dropzone@14.2.3" + library = "react-dropzone@14.2.10" - tag = "ReactDropzone" - - is_default = True + tag = "" # The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as # values. @@ -191,7 +206,7 @@ class Upload(MemoizationLeaf): min_size: Var[int] # Whether to allow multiple files to be uploaded. - multiple: Var[bool] = True # type: ignore + multiple: Var[bool] # Whether to disable click to upload. no_click: Var[bool] @@ -205,6 +220,9 @@ class Upload(MemoizationLeaf): # Marked True when any Upload component is created. is_used: ClassVar[bool] = False + # Fired when files are dropped. + on_drop: EventHandler[_on_drop_spec] + @classmethod def create(cls, *children, **props) -> Component: """Create an upload component. @@ -219,6 +237,8 @@ class Upload(MemoizationLeaf): # Mark the Upload component as used in the app. cls.is_used = True + props.setdefault("multiple", True) + # Apply the default classname given_class_name = props.pop("class_name", []) if isinstance(given_class_name, str): @@ -230,19 +250,6 @@ class Upload(MemoizationLeaf): upload_props = { key: value for key, value in props.items() if key in supported_props } - # The file input to use. - upload = Input.create(type_="file") - upload.special_props = { - BaseVar(_var_name="{...getInputProps()}", _var_type=None) - } - - # The dropzone to use. - zone = Box.create( - upload, - *children, - **{k: v for k, v in props.items() if k not in supported_props}, - ) - zone.special_props = {BaseVar(_var_name="{...getRootProps()}", _var_type=None)} # Create the component. upload_props["id"] = props.get("id", DEFAULT_UPLOAD_ID) @@ -264,21 +271,75 @@ class Upload(MemoizationLeaf): ), ) upload_props["on_drop"] = on_drop - return super().create( - zone, + + input_props_unique_name = get_unique_variable_name() + root_props_unique_name = get_unique_variable_name() + + event_var, callback_str = StatefulComponent._get_memoized_event_triggers( + Box.create(on_click=upload_props["on_drop"]) # type: ignore + )["on_click"] + + upload_props["on_drop"] = event_var + + upload_props = { + format.to_camel_case(key): value for key, value in upload_props.items() + } + + use_dropzone_arguements = { + "onDrop": event_var, **upload_props, + } + + left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} " + right_side = f"useDropzone({str(Var.create(use_dropzone_arguements))})" + + var_data = VarData.merge( + VarData( + imports=Imports.EVENTS, + hooks={ + "const [addEvents, connectError] = useContext(EventLoopContext);": None + }, + ), + event_var._get_all_var_data(), + VarData( + hooks={ + callback_str: None, + f"{left_side} = {right_side};": None, + }, + imports={ + "react-dropzone": "useDropzone", + **Imports.EVENTS, + }, + ), ) - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # The file input to use. + upload = Input.create(type="file") + upload.special_props = [ + Var( + _js_expr=f"{{...{input_props_unique_name}()}}", + _var_type=None, + _var_data=var_data, + ) + ] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - constants.EventTriggers.ON_DROP: _on_drop_spec, - } + # The dropzone to use. + zone = Box.create( + upload, + *children, + **{k: v for k, v in props.items() if k not in supported_props}, + ) + zone.special_props = [ + Var( + _js_expr=f"{{...{root_props_unique_name}()}}", + _var_type=None, + _var_data=var_data, + ) + ] + + return super().create( + zone, + ) @classmethod def _update_arg_tuple_for_on_drop(cls, arg_value: tuple[Var, Var]): @@ -290,16 +351,11 @@ 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 - def _render(self): - out = super()._render() - out.args = ("getRootProps", "getInputProps") - return out - @staticmethod def _get_app_wrap_components() -> dict[tuple[int, str], Component]: return { @@ -340,3 +396,6 @@ class UploadNamespace(ComponentNamespace): root = Upload.create __call__ = StyledUpload.create + + +upload = UploadNamespace() diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi index e415761e0..a63854ef2 100644 --- a/reflex/components/core/upload.pyi +++ b/reflex/components/core/upload.pyi @@ -1,44 +1,48 @@ """Stub file for reflex/components/core/upload.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -import os from pathlib import Path -from typing import Any, Callable, ClassVar, Dict, List, Optional, Union -from reflex import constants -from reflex.components.chakra.forms.input import Input -from reflex.components.chakra.layout.box import Box -from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf +from typing import Any, ClassVar, Dict, List, Optional, Union, overload + +from reflex.components.component import ( + Component, + ComponentNamespace, + MemoizationLeaf, +) from reflex.constants import Dirs from reflex.event import ( CallableEventSpec, - EventChain, EventSpec, - call_event_fn, - call_script, - parse_args_spec, + EventType, ) -from reflex.utils import imports -from reflex.vars import BaseVar, CallableVar, Var, VarData +from reflex.style import Style +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 @CallableVar -def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: ... +def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ... @CallableVar -def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: ... +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]: ... @@ -54,52 +58,22 @@ class UploadFilesProvider(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "UploadFilesProvider": """Create the component. @@ -126,9 +100,7 @@ class Upload(MemoizationLeaf): def create( # type: ignore cls, *children, - accept: Optional[ - Union[Var[Optional[Dict[str, List]]], Optional[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, @@ -143,55 +115,23 @@ class Upload(MemoizationLeaf): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_drop: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_drop: Optional[EventType[Any]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Upload": """Create an upload component. @@ -206,6 +146,7 @@ class Upload(MemoizationLeaf): no_click: Whether to disable click to upload. no_drag: Whether to disable drag and drop. no_keyboard: Whether to disable using the space/enter keys to upload. + on_drop: Fired when files are dropped. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -218,7 +159,6 @@ class Upload(MemoizationLeaf): The upload component. """ ... - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... class StyledUpload(Upload): @overload @@ -226,9 +166,7 @@ class StyledUpload(Upload): def create( # type: ignore cls, *children, - accept: Optional[ - Union[Var[Optional[Dict[str, List]]], Optional[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, @@ -243,55 +181,23 @@ class StyledUpload(Upload): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_drop: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_drop: Optional[EventType[Any]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "StyledUpload": """Create the styled upload component. @@ -306,6 +212,7 @@ class StyledUpload(Upload): no_click: Whether to disable click to upload. no_drag: Whether to disable drag and drop. no_keyboard: Whether to disable using the space/enter keys to upload. + on_drop: Fired when files are dropped. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -325,9 +232,7 @@ class UploadNamespace(ComponentNamespace): @staticmethod def __call__( *children, - accept: Optional[ - Union[Var[Optional[Dict[str, List]]], Optional[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, @@ -342,55 +247,23 @@ class UploadNamespace(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_drop: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_drop: Optional[EventType[Any]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "StyledUpload": """Create the styled upload component. @@ -405,6 +278,7 @@ class UploadNamespace(ComponentNamespace): no_click: Whether to disable click to upload. no_drag: Whether to disable drag and drop. no_keyboard: Whether to disable using the space/enter keys to upload. + on_drop: Fired when files are dropped. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -417,3 +291,5 @@ class UploadNamespace(ComponentNamespace): The styled upload component. """ ... + +upload = UploadNamespace() diff --git a/reflex/components/datadisplay/__init__.py b/reflex/components/datadisplay/__init__.py index 2d90b1843..1aff69676 100644 --- a/reflex/components/datadisplay/__init__.py +++ b/reflex/components/datadisplay/__init__.py @@ -1,11 +1,20 @@ """Data grid components.""" -from .code import CodeBlock -from .code import LiteralCodeBlockTheme as LiteralCodeBlockTheme -from .code import LiteralCodeLanguage as LiteralCodeLanguage -from .dataeditor import DataEditor, DataEditorTheme -from .logo import logo +from __future__ import annotations -code_block = CodeBlock.create -data_editor = DataEditor.create -data_editor_theme = DataEditorTheme +from reflex.utils import lazy_loader + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "code": [ + "CodeBlock", + "code_block", + "LiteralCodeLanguage", + ], + "dataeditor": ["data_editor", "data_editor_theme", "DataEditorTheme"], + "logo": ["logo"], +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/datadisplay/__init__.pyi b/reflex/components/datadisplay/__init__.pyi new file mode 100644 index 000000000..32b29d106 --- /dev/null +++ b/reflex/components/datadisplay/__init__.pyi @@ -0,0 +1,12 @@ +"""Stub file for reflex/components/datadisplay/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .code import CodeBlock as CodeBlock +from .code import LiteralCodeLanguage as LiteralCodeLanguage +from .code import code_block as code_block +from .dataeditor import DataEditorTheme as DataEditorTheme +from .dataeditor import data_editor as data_editor +from .dataeditor import data_editor_theme as data_editor_theme +from .logo import logo as logo diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py index c59256b07..53761284a 100644 --- a/reflex/components/datadisplay/code.py +++ b/reflex/components/datadisplay/code.py @@ -1,69 +1,21 @@ """A code component.""" + from __future__ import annotations -import re -from typing import Dict, Literal, Optional, Union +import dataclasses +from typing import ClassVar, Dict, Literal, Optional, Union -from reflex.components.chakra.forms import Button -from reflex.components.chakra.layout import Box -from reflex.components.chakra.media import Icon -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.style import Style -from reflex.utils import format, imports -from reflex.utils.imports import ImportVar -from reflex.vars import Var - -LiteralCodeBlockTheme = 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", # not present in react-syntax-highlighter styles - "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", -] - +from reflex.utils import console, format +from reflex.utils.imports import ImportDict, ImportVar +from reflex.vars.base import LiteralVar, Var, VarData LiteralCodeLanguage = Literal[ "abap", @@ -348,20 +300,98 @@ LiteralCodeLanguage = Literal[ ] +def construct_theme_var(theme: str) -> Var[Theme]: + """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) + ] + } + ), + ) + + +@dataclasses.dataclass(init=False) +class Theme: + """Themes for the CodeBlock component.""" + + a11y_dark: ClassVar[Var[Theme]] = construct_theme_var("a11yDark") + atom_dark: ClassVar[Var[Theme]] = construct_theme_var("atomDark") + cb: ClassVar[Var[Theme]] = construct_theme_var("cb") + coldark_cold: ClassVar[Var[Theme]] = construct_theme_var("coldarkCold") + coldark_dark: ClassVar[Var[Theme]] = construct_theme_var("coldarkDark") + coy: ClassVar[Var[Theme]] = construct_theme_var("coy") + coy_without_shadows: ClassVar[Var[Theme]] = construct_theme_var("coyWithoutShadows") + darcula: ClassVar[Var[Theme]] = construct_theme_var("darcula") + dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark") + dracula: ClassVar[Var[Theme]] = construct_theme_var("dracula") + duotone_dark: ClassVar[Var[Theme]] = construct_theme_var("duotoneDark") + duotone_earth: ClassVar[Var[Theme]] = construct_theme_var("duotoneEarth") + duotone_forest: ClassVar[Var[Theme]] = construct_theme_var("duotoneForest") + duotone_light: ClassVar[Var[Theme]] = construct_theme_var("duotoneLight") + duotone_sea: ClassVar[Var[Theme]] = construct_theme_var("duotoneSea") + duotone_space: ClassVar[Var[Theme]] = construct_theme_var("duotoneSpace") + funky: ClassVar[Var[Theme]] = construct_theme_var("funky") + ghcolors: ClassVar[Var[Theme]] = construct_theme_var("ghcolors") + gruvbox_dark: ClassVar[Var[Theme]] = construct_theme_var("gruvboxDark") + gruvbox_light: ClassVar[Var[Theme]] = construct_theme_var("gruvboxLight") + holi_theme: ClassVar[Var[Theme]] = construct_theme_var("holiTheme") + hopscotch: ClassVar[Var[Theme]] = construct_theme_var("hopscotch") + light: ClassVar[Var[Theme]] = construct_theme_var("oneLight") + lucario: ClassVar[Var[Theme]] = construct_theme_var("lucario") + material_dark: ClassVar[Var[Theme]] = construct_theme_var("materialDark") + material_light: ClassVar[Var[Theme]] = construct_theme_var("materialLight") + material_oceanic: ClassVar[Var[Theme]] = construct_theme_var("materialOceanic") + night_owl: ClassVar[Var[Theme]] = construct_theme_var("nightOwl") + nord: ClassVar[Var[Theme]] = construct_theme_var("nord") + okaidia: ClassVar[Var[Theme]] = construct_theme_var("okaidia") + one_dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark") + one_light: ClassVar[Var[Theme]] = construct_theme_var("oneLight") + pojoaque: ClassVar[Var[Theme]] = construct_theme_var("pojoaque") + prism: ClassVar[Var[Theme]] = construct_theme_var("prism") + shades_of_purple: ClassVar[Var[Theme]] = construct_theme_var("shadesOfPurple") + solarized_dark_atom: ClassVar[Var[Theme]] = construct_theme_var("solarizedDarkAtom") + solarizedlight: ClassVar[Var[Theme]] = construct_theme_var("solarizedlight") + synthwave84: ClassVar[Var[Theme]] = construct_theme_var("synthwave84") + tomorrow: ClassVar[Var[Theme]] = construct_theme_var("tomorrow") + twilight: ClassVar[Var[Theme]] = construct_theme_var("twilight") + vs: ClassVar[Var[Theme]] = construct_theme_var("vs") + vs_dark: ClassVar[Var[Theme]] = construct_theme_var("vsDark") + vsc_dark_plus: ClassVar[Var[Theme]] = construct_theme_var("vscDarkPlus") + xonokai: ClassVar[Var[Theme]] = construct_theme_var("xonokai") + z_touch: ClassVar[Var[Theme]] = construct_theme_var("zTouch") + + +for theme_name in dir(Theme): + if theme_name.startswith("_"): + continue + setattr(Theme, theme_name, getattr(Theme, theme_name)._replace(_var_type=Theme)) + + class CodeBlock(Component): """A code block.""" - library = "react-syntax-highlighter@15.5.0" + library = "react-syntax-highlighter@15.6.1" tag = "PrismAsyncLight" alias = "SyntaxHighlighter" # The theme to use ("light" or "dark"). - theme: Var[LiteralCodeBlockTheme] = "one-light" # type: ignore + theme: Var[Union[Theme, str]] = Theme.one_light # The language to use. - language: Var[LiteralCodeLanguage] = "python" # type: ignore + language: Var[LiteralCodeLanguage] = Var.create("python") # The code to display. code: Var[str] @@ -381,64 +411,55 @@ class CodeBlock(Component): # Props passed down to the code tag. code_tag_props: Var[Dict[str, str]] - def _get_imports(self) -> imports.ImportDict: - merged_imports = super()._get_imports() - # Get all themes from a cond literal - themes = re.findall(r"`(.*?)`", self.theme._var_name) - if not themes: - themes = [self.theme._var_name] - merged_imports = imports.merge_imports( - merged_imports, - { - f"react-syntax-highlighter/dist/cjs/styles/prism/{self.convert_theme_name(theme)}": { - ImportVar( - tag=format.to_camel_case(self.convert_theme_name(theme)), - is_default=True, - install=False, - ) - } - for theme in themes - }, - ) + # Whether a copy button should appear. + can_copy: Optional[bool] = False + + # A custom copy button to override the default one. + copy_button: Optional[Union[bool, Component]] = None + + def add_imports(self) -> ImportDict: + """Add imports for the CodeBlock component. + + Returns: + The import dict. + """ + imports_: ImportDict = {} + if ( self.language is not None - and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore + and (language_without_quotes := str(self.language).replace('"', "")) + in LiteralCodeLanguage.__args__ # type: ignore ): - merged_imports = imports.merge_imports( - merged_imports, - { - f"react-syntax-highlighter/dist/cjs/languages/prism/{self.language._var_name}": { - ImportVar( - tag=format.to_camel_case(self.language._var_name), - is_default=True, - install=False, - ) - } - }, - ) - return merged_imports + imports_[ + f"react-syntax-highlighter/dist/cjs/languages/prism/{language_without_quotes}" + ] = [ + ImportVar( + tag=format.to_camel_case(language_without_quotes), + is_default=True, + install=False, + ) + ] + + return imports_ def _get_custom_code(self) -> Optional[str]: if ( self.language is not None - and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore + and (language_without_quotes := str(self.language).replace('"', "")) + in LiteralCodeLanguage.__args__ # type: ignore ): - return f"{self.alias}.registerLanguage('{self.language._var_name}', {format.to_camel_case(self.language._var_name)})" + return f"{self.alias}.registerLanguage('{language_without_quotes}', {format.to_camel_case(language_without_quotes)})" @classmethod def create( cls, *children, - can_copy: Optional[bool] = False, - copy_button: Optional[Union[bool, Component]] = None, **props, ): """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. **props: The props to pass to the component. Returns: @@ -446,15 +467,26 @@ class CodeBlock(Component): """ # This component handles style in a special prop. custom_style = props.pop("custom_style", {}) + can_copy = props.pop("can_copy", False) + copy_button = props.pop("copy_button", None) if "theme" not in props: # Default color scheme responds to global color mode. - props["theme"] = color_mode_cond(light="one-light", dark="one-dark") + props["theme"] = color_mode_cond( + 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] @@ -480,7 +512,7 @@ class CodeBlock(Component): if children: props["code"] = children[0] if not isinstance(props["code"], Var): - props["code"] = Var.create(props["code"], _var_is_string=True) + props["code"] = LiteralVar.create(props["code"]) # Create the component. code_block = super().create( @@ -493,33 +525,31 @@ class CodeBlock(Component): else: return code_block - def add_style(self) -> Style | None: + def add_style(self): """Add style to the component.""" self.custom_style.update(self.style) def _render(self): out = super()._render() - predicate, qmark, value = self.theme._var_name.partition("?") - out.add_props( - style=Var.create( - format.to_camel_case(f"{predicate}{qmark}{value.replace('`', '')}"), - _var_is_local=False, - ) - ).remove_props("theme", "code") - if self.code is not None: - out.special_props.add(Var.create_safe(f"children={str(self.code)}")) + + theme = self.theme + + out.add_props(style=theme).remove_props("theme", "code").add_props( + children=self.code + ) + return out - @staticmethod - def convert_theme_name(theme) -> str: - """Convert theme names to appropriate names. + def _exclude_props(self) -> list[str]: + return ["can_copy", "copy_button"] - Args: - theme: The theme name. - Returns: - The right theme name. - """ - if theme in ["light", "dark"]: - return f"one-{theme}" - return theme +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 f3aeb8e18..1e4f7110c 100644 --- a/reflex/components/datadisplay/code.pyi +++ b/reflex/components/datadisplay/code.pyi @@ -1,73 +1,18 @@ """Stub file for reflex/components/datadisplay/code.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +import dataclasses +from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -import re -from typing import Dict, Literal, Optional, Union -from reflex.components.chakra.forms import Button -from reflex.components.chakra.layout import Box -from reflex.components.chakra.media import Icon -from reflex.components.component import Component -from reflex.components.core.cond import color_mode_cond +from reflex.components.component import Component, ComponentNamespace from reflex.constants.colors import Color -from reflex.event import set_clipboard +from reflex.event import EventType from reflex.style import Style -from reflex.utils import format, imports -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var -LiteralCodeBlockTheme = 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", -] LiteralCodeLanguage = Literal[ "abap", "abnf", @@ -350,116 +295,351 @@ LiteralCodeLanguage = Literal[ "zig", ] +def construct_theme_var(theme: str) -> Var[Theme]: ... +@dataclasses.dataclass(init=False) +class Theme: + a11y_dark: ClassVar[Var[Theme]] = construct_theme_var("a11yDark") + atom_dark: ClassVar[Var[Theme]] = construct_theme_var("atomDark") + cb: ClassVar[Var[Theme]] = construct_theme_var("cb") + coldark_cold: ClassVar[Var[Theme]] = construct_theme_var("coldarkCold") + coldark_dark: ClassVar[Var[Theme]] = construct_theme_var("coldarkDark") + coy: ClassVar[Var[Theme]] = construct_theme_var("coy") + coy_without_shadows: ClassVar[Var[Theme]] = construct_theme_var("coyWithoutShadows") + darcula: ClassVar[Var[Theme]] = construct_theme_var("darcula") + dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark") + dracula: ClassVar[Var[Theme]] = construct_theme_var("dracula") + duotone_dark: ClassVar[Var[Theme]] = construct_theme_var("duotoneDark") + duotone_earth: ClassVar[Var[Theme]] = construct_theme_var("duotoneEarth") + duotone_forest: ClassVar[Var[Theme]] = construct_theme_var("duotoneForest") + duotone_light: ClassVar[Var[Theme]] = construct_theme_var("duotoneLight") + duotone_sea: ClassVar[Var[Theme]] = construct_theme_var("duotoneSea") + duotone_space: ClassVar[Var[Theme]] = construct_theme_var("duotoneSpace") + funky: ClassVar[Var[Theme]] = construct_theme_var("funky") + ghcolors: ClassVar[Var[Theme]] = construct_theme_var("ghcolors") + gruvbox_dark: ClassVar[Var[Theme]] = construct_theme_var("gruvboxDark") + gruvbox_light: ClassVar[Var[Theme]] = construct_theme_var("gruvboxLight") + holi_theme: ClassVar[Var[Theme]] = construct_theme_var("holiTheme") + hopscotch: ClassVar[Var[Theme]] = construct_theme_var("hopscotch") + light: ClassVar[Var[Theme]] = construct_theme_var("oneLight") + lucario: ClassVar[Var[Theme]] = construct_theme_var("lucario") + material_dark: ClassVar[Var[Theme]] = construct_theme_var("materialDark") + material_light: ClassVar[Var[Theme]] = construct_theme_var("materialLight") + material_oceanic: ClassVar[Var[Theme]] = construct_theme_var("materialOceanic") + night_owl: ClassVar[Var[Theme]] = construct_theme_var("nightOwl") + nord: ClassVar[Var[Theme]] = construct_theme_var("nord") + okaidia: ClassVar[Var[Theme]] = construct_theme_var("okaidia") + one_dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark") + one_light: ClassVar[Var[Theme]] = construct_theme_var("oneLight") + pojoaque: ClassVar[Var[Theme]] = construct_theme_var("pojoaque") + prism: ClassVar[Var[Theme]] = construct_theme_var("prism") + shades_of_purple: ClassVar[Var[Theme]] = construct_theme_var("shadesOfPurple") + solarized_dark_atom: ClassVar[Var[Theme]] = construct_theme_var("solarizedDarkAtom") + solarizedlight: ClassVar[Var[Theme]] = construct_theme_var("solarizedlight") + synthwave84: ClassVar[Var[Theme]] = construct_theme_var("synthwave84") + tomorrow: ClassVar[Var[Theme]] = construct_theme_var("tomorrow") + twilight: ClassVar[Var[Theme]] = construct_theme_var("twilight") + vs: ClassVar[Var[Theme]] = construct_theme_var("vs") + vs_dark: ClassVar[Var[Theme]] = construct_theme_var("vsDark") + vsc_dark_plus: ClassVar[Var[Theme]] = construct_theme_var("vscDarkPlus") + xonokai: ClassVar[Var[Theme]] = construct_theme_var("xonokai") + z_touch: ClassVar[Var[Theme]] = construct_theme_var("zTouch") + +for theme_name in dir(Theme): + if theme_name.startswith("_"): + continue + setattr(Theme, theme_name, getattr(Theme, theme_name)._replace(_var_type=Theme)) + class CodeBlock(Component): + def add_imports(self) -> ImportDict: ... @overload @classmethod def create( # type: ignore cls, *children, - can_copy: Optional[bool] = False, - copy_button: Optional[Union[bool, Component]] = 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[Theme, Var[Union[Theme, str]], str]] = 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", @@ -743,6 +923,77 @@ 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, + can_copy: Optional[bool] = None, + copy_button: Optional[Union[Component, bool]] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "CodeBlock": + """Create a text component. + + Args: + *children: The children of the component. + 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. + can_copy: Whether a copy button should appear. + copy_button: A custom copy button to override the default one. + 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): ... + +class CodeblockNamespace(ComponentNamespace): + themes = Theme + + @staticmethod + def __call__( + *children, + theme: Optional[Union[Theme, Var[Union[Theme, str]], str]] = None, + language: Optional[ + Union[ Literal[ "abap", "abnf", @@ -1024,6 +1275,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, @@ -1031,66 +1565,36 @@ 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, + can_copy: Optional[bool] = None, + copy_button: Optional[Union[Component, bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = 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. @@ -1099,6 +1603,8 @@ class CodeBlock(Component): 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. + can_copy: Whether a copy button should appear. + copy_button: A custom copy button to override the default one. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1111,6 +1617,5 @@ class CodeBlock(Component): The text component. """ ... - def add_style(self) -> Style | None: ... - @staticmethod - def convert_theme_name(theme) -> str: ... + +code_block = CodeblockNamespace() diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index ce9e3134f..27ca62d93 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -1,16 +1,22 @@ """Data Editor component from glide-data-grid.""" + from __future__ import annotations from enum import Enum -from typing import Any, Callable, Dict, List, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Tuple, Union + +from typing_extensions import TypedDict from reflex.base import Base from reflex.components.component import Component, NoSSRComponent from reflex.components.literals import LiteralRowMarker -from reflex.utils import console, format, imports, types -from reflex.utils.imports import ImportVar +from reflex.event import EventHandler, empty_event, identity_event +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. @@ -103,15 +109,87 @@ class DataEditorTheme(Base): text_medium: Optional[str] = None +class Bounds(TypedDict): + """The bounds of the group header.""" + + x: int + y: int + width: int + height: int + + +class CompatSelection(TypedDict): + """The selection.""" + + items: list + + +class Rectangle(TypedDict): + """The bounds of the group header.""" + + x: int + y: int + width: int + height: int + + +class GridSelectionCurrent(TypedDict): + """The current selection.""" + + cell: tuple[int, int] + range: Rectangle + rangeStack: list[Rectangle] + + +class GridSelection(TypedDict): + """The grid selection.""" + + current: Optional[GridSelectionCurrent] + columns: CompatSelection + rows: CompatSelection + + +class GroupHeaderClickedEventArgs(TypedDict): + """The arguments for the group header clicked event.""" + + kind: str + group: str + location: tuple[int, int] + bounds: Bounds + isEdge: bool + shiftKey: bool + ctrlKey: bool + metaKey: bool + isTouch: bool + localEventX: int + localEventY: int + button: int + buttons: int + scrollEdge: tuple[int, int] + + +class GridCell(TypedDict): + """The grid cell.""" + + span: Optional[List[int]] + + +class GridColumn(TypedDict): + """The grid column.""" + + title: str + group: Optional[str] + + class DataEditor(NoSSRComponent): """The DataEditor Component.""" tag = "DataEditor" is_default = True - library: str = "@glideapps/glide-data-grid@^5.3.0" + library: str = "@glideapps/glide-data-grid@^6.0.3" lib_dependencies: List[str] = [ "lodash@^4.17.21", - "marked@^4.0.10", + "marked@^14.1.2", "react-responsive-carousel@^3.2.7", ] @@ -128,7 +206,7 @@ class DataEditor(NoSSRComponent): get_cell_content: Var[str] # Allow selection for copying. - get_cell_for_selection: Var[bool] + get_cells_for_selection: Var[bool] # Allow paste. on_paste: Var[bool] @@ -205,65 +283,89 @@ class DataEditor(NoSSRComponent): # global theme theme: Var[Union[DataEditorTheme, Dict]] - def _get_imports(self): - return imports.merge_imports( - super()._get_imports(), - { - "": { - ImportVar( - tag=f"{format.format_library_name(self.library)}/dist/index.css" - ) - }, - self.library: {ImportVar(tag="GridCellKind")}, - "/utils/helpers/dataeditor.js": { - ImportVar( - tag=f"formatDataEditorCells", is_default=False, install=False - ), - }, - }, - ) + # Fired when a cell is activated. + on_cell_activated: EventHandler[identity_event(Tuple[int, int])] - def get_event_triggers(self) -> Dict[str, Callable]: - """The event triggers of the component. + # Fired when a cell is clicked. + on_cell_clicked: EventHandler[identity_event(Tuple[int, int])] + + # Fired when a cell is right-clicked. + on_cell_context_menu: EventHandler[identity_event(Tuple[int, int])] + + # Fired when a cell is edited. + on_cell_edited: EventHandler[identity_event(Tuple[int, int], GridCell)] + + # Fired when a group header is clicked. + on_group_header_clicked: EventHandler[identity_event(Tuple[int, int], GridCell)] + + # Fired when a group header is right-clicked. + on_group_header_context_menu: EventHandler[ + identity_event(int, GroupHeaderClickedEventArgs) + ] + + # Fired when a group header is renamed. + on_group_header_renamed: EventHandler[identity_event(str, str)] + + # Fired when a header is clicked. + on_header_clicked: EventHandler[identity_event(Tuple[int, int])] + + # Fired when a header is right-clicked. + on_header_context_menu: EventHandler[identity_event(Tuple[int, int])] + + # Fired when a header menu item is clicked. + on_header_menu_click: EventHandler[identity_event(int, Rectangle)] + + # Fired when an item is hovered. + on_item_hovered: EventHandler[identity_event(Tuple[int, int])] + + # Fired when a selection is deleted. + on_delete: EventHandler[identity_event(GridSelection)] + + # Fired when editing is finished. + on_finished_editing: EventHandler[ + identity_event(Union[GridCell, None], tuple[int, int]) + ] + + # Fired when a row is appended. + on_row_appended: EventHandler[empty_event] + + # Fired when the selection is cleared. + on_selection_cleared: EventHandler[empty_event] + + # Fired when a column is resized. + on_column_resize: EventHandler[identity_event(GridColumn, int)] + + def add_imports(self) -> ImportDict: + """Add imports for the component. Returns: - The dict describing the event triggers. + The import dict. """ - - def edit_sig(pos, data: dict[str, Any]): - return [pos, data] - return { - "on_cell_activated": lambda pos: [pos], - "on_cell_clicked": lambda pos: [pos], - "on_cell_context_menu": lambda pos: [pos], - "on_cell_edited": edit_sig, - "on_group_header_clicked": edit_sig, - "on_group_header_context_menu": lambda grp_idx, data: [grp_idx, data], - "on_group_header_renamed": lambda idx, val: [idx, val], - "on_header_clicked": lambda pos: [pos], - "on_header_context_menu": lambda pos: [pos], - "on_header_menu_click": lambda col, pos: [col, pos], - "on_item_hovered": lambda pos: [pos], - "on_delete": lambda selection: [selection], - "on_finished_editing": lambda new_value, movement: [new_value, movement], - "on_row_appended": lambda: [], - "on_selection_cleared": lambda: [], - "on_column_resize": lambda col, width: [col, width], + "": f"{format.format_library_name(self.library)}/dist/index.css", + self.library: "GridCellKind", + "$/utils/helpers/dataeditor.js": ImportVar( + tag="formatDataEditorCells", is_default=False, install=False + ), } - def _get_hooks(self) -> str | None: + def add_hooks(self) -> list[str]: + """Get the hooks to render. + + Returns: + The hooks to render. + """ # Define the id of the component in case multiple are used in the same page. editor_id = get_unique_variable_name() # 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 = Var.create(data_callback, _var_is_local=False) # 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( [ @@ -272,7 +374,7 @@ class DataEditor(NoSSRComponent): ] ) - return "\n".join(code) + return ["\n".join(code)] @classmethod def create(cls, *children, **props) -> Component: @@ -292,15 +394,15 @@ class DataEditor(NoSSRComponent): columns = props.get("columns", []) data = props.get("data", []) - rows = props.get("rows", None) + rows = props.get("rows") # If rows is not provided, determine from data. if rows is None: - props["rows"] = ( - data.length() # BaseVar.create(value=f"{data}.length()", is_local=False) - if isinstance(data, Var) - else len(data) - ) + 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): if ( @@ -322,7 +424,7 @@ class DataEditor(NoSSRComponent): props["theme"] = DataEditorTheme(**theme) # Allow by default to select a region of cells in the grid. - props.setdefault("get_cell_for_selection", True) + props.setdefault("get_cells_for_selection", True) # Disable on_paste by default if not provided. props.setdefault("on_paste", False) @@ -360,43 +462,6 @@ class DataEditor(NoSSRComponent): } -# try: -# pass - -# # def format_dataframe_values(df: DataFrame) -> list[list[Any]]: -# # """Format dataframe values to a list of lists. - -# # Args: -# # df: The dataframe to format. - -# # Returns: -# # The dataframe as a list of lists. -# # """ -# # return [ -# # [str(d) if isinstance(d, (list, tuple)) else d for d in data] -# # for data in list(df.values.tolist()) -# # ] -# # ... - -# # @serializer -# # def serialize_dataframe(df: DataFrame) -> dict: -# # """Serialize a pandas dataframe. - -# # Args: -# # df: The dataframe to serialize. - -# # Returns: -# # The serialized dataframe. -# # """ -# # return { -# # "columns": df.columns.tolist(), -# # "data": format_dataframe_values(df), -# # } - -# except ImportError: -# pass - - @serializer def serialize_dataeditortheme(theme: DataEditorTheme): """The serializer for the data editor theme. @@ -407,6 +472,10 @@ 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 +data_editor_theme = DataEditorTheme diff --git a/reflex/components/datadisplay/dataeditor.pyi b/reflex/components/datadisplay/dataeditor.pyi index fe8c52aad..b1ff93c38 100644 --- a/reflex/components/datadisplay/dataeditor.pyi +++ b/reflex/components/datadisplay/dataeditor.pyi @@ -1,21 +1,20 @@ """Stub file for reflex/components/datadisplay/dataeditor.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from enum import Enum -from typing import Any, Callable, Dict, List, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Union, overload + +from typing_extensions import TypedDict + from reflex.base import Base -from reflex.components.component import Component, NoSSRComponent -from reflex.components.literals import LiteralRowMarker -from reflex.utils import console, format, imports, types -from reflex.utils.imports import ImportVar +from reflex.components.component import NoSSRComponent +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict from reflex.utils.serializers import serializer -from reflex.vars import Var, get_unique_variable_name +from reflex.vars.base import Var class GridColumnIcons(Enum): Array = "array" @@ -79,8 +78,57 @@ class DataEditorTheme(Base): text_light: Optional[str] text_medium: Optional[str] +class Bounds(TypedDict): + x: int + y: int + width: int + height: int + +class CompatSelection(TypedDict): + items: list + +class Rectangle(TypedDict): + x: int + y: int + width: int + height: int + +class GridSelectionCurrent(TypedDict): + cell: tuple[int, int] + range: Rectangle + rangeStack: list[Rectangle] + +class GridSelection(TypedDict): + current: Optional[GridSelectionCurrent] + columns: CompatSelection + rows: CompatSelection + +class GroupHeaderClickedEventArgs(TypedDict): + kind: str + group: str + location: tuple[int, int] + bounds: Bounds + isEdge: bool + shiftKey: bool + ctrlKey: bool + metaKey: bool + isTouch: bool + localEventX: int + localEventY: int + button: int + buttons: int + scrollEdge: tuple[int, int] + +class GridCell(TypedDict): + span: Optional[List[int]] + +class GridColumn(TypedDict): + title: str + group: Optional[str] + class DataEditor(NoSSRComponent): - def get_event_triggers(self) -> Dict[str, Callable]: ... + def add_imports(self) -> ImportDict: ... + def add_hooks(self) -> list[str]: ... @overload @classmethod def create( # type: ignore @@ -88,11 +136,11 @@ 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, + get_cells_for_selection: Optional[Union[Var[bool], bool]] = None, on_paste: Optional[Union[Var[bool], bool]] = None, draw_focus_ring: Optional[Union[Var[bool], bool]] = None, fixed_shadow_x: Optional[Union[Var[bool], bool]] = None, @@ -106,8 +154,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 +165,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 +175,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]], Union[DataEditorTheme, Dict]] + Union[DataEditorTheme, Dict, Var[Union[DataEditorTheme, Dict]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -135,55 +183,42 @@ class DataEditor(NoSSRComponent): class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_cell_activated: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_cell_clicked: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_cell_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_cell_edited: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_column_resize: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_delete: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, + on_cell_activated: Optional[EventType[tuple[int, int]]] = None, + on_cell_clicked: Optional[EventType[tuple[int, int]]] = None, + on_cell_context_menu: Optional[EventType[tuple[int, int]]] = None, + on_cell_edited: Optional[EventType[tuple[int, int], GridCell]] = None, + on_click: Optional[EventType[[]]] = None, + on_column_resize: Optional[EventType[GridColumn, int]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_delete: Optional[EventType[GridSelection]] = None, + on_double_click: Optional[EventType[[]]] = None, on_finished_editing: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_group_header_clicked: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + EventType[Union[GridCell, None], tuple[int, int]] ] = None, + on_focus: Optional[EventType[[]]] = None, + on_group_header_clicked: Optional[EventType[tuple[int, int], GridCell]] = None, on_group_header_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + EventType[int, GroupHeaderClickedEventArgs] ] = None, - on_group_header_renamed: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_header_clicked: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_header_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_header_menu_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_item_hovered: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_row_appended: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_selection_cleared: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_group_header_renamed: Optional[EventType[str, str]] = None, + on_header_clicked: Optional[EventType[tuple[int, int]]] = None, + on_header_context_menu: Optional[EventType[tuple[int, int]]] = None, + on_header_menu_click: Optional[EventType[int, Rectangle]] = None, + on_item_hovered: Optional[EventType[tuple[int, int]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_row_appended: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_selection_cleared: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataEditor": """Create the DataEditor component. @@ -193,7 +228,7 @@ class DataEditor(NoSSRComponent): columns: Headers of the columns for the data grid. data: The data. get_cell_content: The name of the callback used to find the data to display. - get_cell_for_selection: Allow selection for copying. + get_cells_for_selection: Allow selection for copying. on_paste: Allow paste. draw_focus_ring: Controls the drawing of the focus ring. fixed_shadow_x: Enables or disables the overlay shadow when scrolling horizontally. @@ -218,6 +253,22 @@ class DataEditor(NoSSRComponent): scroll_offset_x: Initial scroll offset on the horizontal axis. scroll_offset_y: Initial scroll offset on the vertical axis. theme: global theme + on_cell_activated: Fired when a cell is activated. + on_cell_clicked: Fired when a cell is clicked. + on_cell_context_menu: Fired when a cell is right-clicked. + on_cell_edited: Fired when a cell is edited. + on_group_header_clicked: Fired when a group header is clicked. + on_group_header_context_menu: Fired when a group header is right-clicked. + on_group_header_renamed: Fired when a group header is renamed. + on_header_clicked: Fired when a header is clicked. + on_header_context_menu: Fired when a header is right-clicked. + on_header_menu_click: Fired when a header menu item is clicked. + on_item_hovered: Fired when an item is hovered. + on_delete: Fired when a selection is deleted. + on_finished_editing: Fired when editing is finished. + on_row_appended: Fired when a row is appended. + on_selection_cleared: Fired when the selection is cleared. + on_column_resize: Fired when a column is resized. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -236,3 +287,6 @@ class DataEditor(NoSSRComponent): @serializer def serialize_dataeditortheme(theme: DataEditorTheme): ... + +data_editor = DataEditor.create +data_editor_theme = DataEditorTheme diff --git a/reflex/components/datadisplay/logo.py b/reflex/components/datadisplay/logo.py index 1a56cfd88..beb9b9d10 100644 --- a/reflex/components/datadisplay/logo.py +++ b/reflex/components/datadisplay/logo.py @@ -1,4 +1,5 @@ """A Reflex logo component.""" + import reflex as rx @@ -11,31 +12,33 @@ def logo(**props): Returns: The logo component. """ - light_mode_logo = """ - - - - - - -""" - dark_mode_logo = """ - - - - - - -""" + def logo_path(d): + return rx.el.svg.path( + d=d, + fill=rx.color_mode_cond("#110F1F", "white"), + ) + + paths = [ + "M0 11.5999V0.399902H8.96V4.8799H6.72V2.6399H2.24V4.8799H6.72V7.1199H2.24V11.5999H0ZM6.72 11.5999V7.1199H8.96V11.5999H6.72Z", + "M11.2 11.5999V0.399902H17.92V2.6399H13.44V4.8799H17.92V7.1199H13.44V9.3599H17.92V11.5999H11.2Z", + "M20.16 11.5999V0.399902H26.88V2.6399H22.4V4.8799H26.88V7.1199H22.4V11.5999H20.16Z", + "M29.12 11.5999V0.399902H31.36V9.3599H35.84V11.5999H29.12Z", + "M38.08 11.5999V0.399902H44.8V2.6399H40.32V4.8799H44.8V7.1199H40.32V9.3599H44.8V11.5999H38.08Z", + "M47.04 4.8799V0.399902H49.28V4.8799H47.04ZM53.76 4.8799V0.399902H56V4.8799H53.76ZM49.28 7.1199V4.8799H53.76V7.1199H49.28ZM47.04 11.5999V7.1199H49.28V11.5999H47.04ZM53.76 11.5999V7.1199H56V11.5999H53.76Z", + ] return rx.center( rx.link( rx.hstack( "Built with ", - rx.color_mode_cond( - rx.html(light_mode_logo), - rx.html(dark_mode_logo), + rx.el.svg( + *[logo_path(d) for d in paths], + width="56", + height="12", + viewBox="0 0 56 12", + fill="none", + xmlns="http://www.w3.org/2000/svg", ), text_align="center", align="center", diff --git a/reflex/components/datadisplay/shiki_code_block.py b/reflex/components/datadisplay/shiki_code_block.py new file mode 100644 index 000000000..07f09c6f6 --- /dev/null +++ b/reflex/components/datadisplay/shiki_code_block.py @@ -0,0 +1,846 @@ +"""Shiki syntax hghlighter component.""" + +from __future__ import annotations + +import re +from collections import defaultdict +from typing import Any, Literal, Optional, Union + +from reflex.base import Base +from reflex.components.component import Component, ComponentNamespace +from reflex.components.core.colors import color +from reflex.components.core.cond import color_mode_cond +from reflex.components.el.elements.forms import Button +from reflex.components.lucide.icon import Icon +from reflex.components.props import NoExtrasAllowedProps +from reflex.components.radix.themes.layout.box import Box +from reflex.event import call_script, set_clipboard +from reflex.style import Style +from reflex.utils.exceptions import VarTypeError +from reflex.utils.imports import ImportVar +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionStringVar +from reflex.vars.sequence import StringVar, string_replace_operation + + +def copy_script() -> Any: + """Copy script for the code block and modify the child SVG element. + + + Returns: + Any: The result of calling the script. + """ + return call_script( + f""" +// Event listener for the parent click +document.addEventListener('click', function(event) {{ + // Find the closest button (parent element) + const parent = event.target.closest('button'); + // If the parent is found + if (parent) {{ + // Find the SVG element within the parent + const svgIcon = parent.querySelector('svg'); + // If the SVG exists, proceed with the script + if (svgIcon) {{ + const originalPath = svgIcon.innerHTML; + const checkmarkPath = ''; // Checkmark SVG path + function transition(element, scale, opacity) {{ + element.style.transform = `scale(${{scale}})`; + element.style.opacity = opacity; + }} + // Animate the SVG + transition(svgIcon, 0, '0'); + setTimeout(() => {{ + svgIcon.innerHTML = checkmarkPath; // Replace content with checkmark + svgIcon.setAttribute('viewBox', '0 0 24 24'); // Adjust viewBox if necessary + transition(svgIcon, 1, '1'); + setTimeout(() => {{ + transition(svgIcon, 0, '0'); + setTimeout(() => {{ + svgIcon.innerHTML = originalPath; // Restore original SVG content + transition(svgIcon, 1, '1'); + }}, 125); + }}, 600); + }}, 125); + }} else {{ + // console.error('SVG element not found within the parent.'); + }} + }} else {{ + // console.error('Parent element not found.'); + }} +}}); +""" + ) + + +SHIKIJS_TRANSFORMER_FNS = { + "transformerNotationDiff", + "transformerNotationHighlight", + "transformerNotationWordHighlight", + "transformerNotationFocus", + "transformerNotationErrorLevel", + "transformerRenderWhitespace", + "transformerMetaHighlight", + "transformerMetaWordHighlight", + "transformerCompactLineOptions", + # TODO: this transformer when included adds a weird behavior which removes other code lines. Need to figure out why. + # "transformerRemoveLineBreak", + "transformerRemoveNotationEscape", +} +LINE_NUMBER_STYLING = { + "code": { + "counter-reset": "step", + "counter-increment": "step 0", + "display": "grid", + "line-height": "1.7", + "font-size": "0.875em", + }, + "code .line::before": { + "content": "counter(step)", + "counter-increment": "step", + "width": "1rem", + "margin-right": "1.5rem", + "display": "inline-block", + "text-align": "right", + "color": "rgba(115,138,148,.4)", + }, +} +BOX_PARENT_STYLING = { + "pre": { + "margin": "0", + "padding": "24px", + "background": "transparent", + "overflow-x": "auto", + "border-radius": "6px", + }, +} + +THEME_MAPPING = { + "light": "one-light", + "dark": "one-dark-pro", + "a11y-dark": "github-dark", +} +LANGUAGE_MAPPING = {"bash": "shellscript"} +LiteralCodeLanguage = Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", +] +LiteralCodeTheme = Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + # rose-pine themes dont work with the current version of shikijs transformers + # https://github.com/shikijs/shiki/issues/730 + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", +] + + +class Position(NoExtrasAllowedProps): + """Position of the decoration.""" + + line: int + character: int + + +class ShikiDecorations(NoExtrasAllowedProps): + """Decorations for the code block.""" + + start: Union[int, Position] + end: Union[int, Position] + tag_name: str = "span" + properties: dict[str, Any] = {} + always_wrap: bool = False + + +class ShikiBaseTransformers(Base): + """Base for creating transformers.""" + + library: str + fns: list[FunctionStringVar] + style: Optional[Style] + + +class ShikiJsTransformer(ShikiBaseTransformers): + """A Wrapped shikijs transformer.""" + + library: str = "@shikijs/transformers" + fns: list[FunctionStringVar] = [ + FunctionStringVar.create(fn) for fn in SHIKIJS_TRANSFORMER_FNS + ] + style: Optional[Style] = Style( + { + "code": {"line-height": "1.7", "font-size": "0.875em", "display": "grid"}, + # Diffs + ".diff": { + "margin": "0 -24px", + "padding": "0 24px", + "width": "calc(100% + 48px)", + "display": "inline-block", + }, + ".diff.add": { + "background-color": "rgba(16, 185, 129, .14)", + "position": "relative", + }, + ".diff.remove": { + "background-color": "rgba(244, 63, 94, .14)", + "opacity": "0.7", + "position": "relative", + }, + ".diff.remove:after": { + "position": "absolute", + "left": "10px", + "content": "'-'", + "color": "#b34e52", + }, + ".diff.add:after": { + "position": "absolute", + "left": "10px", + "content": "'+'", + "color": "#18794e", + }, + # Highlight + ".highlighted": { + "background-color": "rgba(142, 150, 170, .14)", + "margin": "0 -24px", + "padding": "0 24px", + "width": "calc(100% + 48px)", + "display": "inline-block", + }, + ".highlighted.error": { + "background-color": "rgba(244, 63, 94, .14)", + }, + ".highlighted.warning": { + "background-color": "rgba(234, 179, 8, .14)", + }, + # Highlighted Word + ".highlighted-word": { + "background-color": color("gray", 2), + "border": f"1px solid {color('gray', 5)}", + "padding": "1px 3px", + "margin": "-1px -3px", + "border-radius": "4px", + }, + # Focused Lines + ".has-focused .line:not(.focused)": { + "opacity": "0.7", + "filter": "blur(0.095rem)", + "transition": "filter .35s, opacity .35s", + }, + ".has-focused:hover .line:not(.focused)": { + "opacity": "1", + "filter": "none", + }, + # White Space + # ".tab, .space": { + # "position": "relative", + # }, + # ".tab::before": { + # "content": "'⇥'", + # "position": "absolute", + # "opacity": "0.3", + # }, + # ".space::before": { + # "content": "'·'", + # "position": "absolute", + # "opacity": "0.3", + # }, + } + ) + + def __init__(self, **kwargs): + """Initialize the transformer. + + Args: + kwargs: Kwargs to initialize the props. + + """ + fns = kwargs.pop("fns", None) + style = kwargs.pop("style", None) + if fns: + kwargs["fns"] = [ + ( + FunctionStringVar.create(x) + if not isinstance(x, FunctionStringVar) + else x + ) + for x in fns + ] + + if style: + kwargs["style"] = Style(style) + super().__init__(**kwargs) + + +class ShikiCodeBlock(Component): + """A Code block.""" + + library = "/components/shiki/code" + + tag = "Code" + + alias = "ShikiCode" + + lib_dependencies: list[str] = ["shiki"] + + # The language to use. + language: Var[LiteralCodeLanguage] = Var.create("python") + + # The theme to use ("light" or "dark"). + theme: Var[LiteralCodeTheme] = Var.create("one-light") + + # The set of themes to use for different modes. + themes: Var[Union[list[dict[str, Any]], dict[str, str]]] + + # The code to display. + code: Var[str] + + # The transformers to use for the syntax highlighter. + transformers: Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]] = Var.create( + [] + ) + + # The decorations to use for the syntax highlighter. + decorations: Var[list[ShikiDecorations]] = Var.create([]) + + @classmethod + def create( + cls, + *children, + **props, + ) -> Component: + """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/). + + Args: + *children: The children of the component. + **props: The props to pass to the component. + + Returns: + The code block component. + """ + # Separate props for the code block and the wrapper + code_block_props = {} + code_wrapper_props = {} + decorations = props.pop("decorations", []) + + class_props = cls.get_props() + + # Distribute props between the code block and wrapper + for key, value in props.items(): + (code_block_props if key in class_props else code_wrapper_props)[key] = ( + value + ) + + # cast decorations into ShikiDecorations. + decorations = [ + ShikiDecorations(**decoration) + if not isinstance(decoration, ShikiDecorations) + else decoration + for decoration in decorations + ] + code_block_props["decorations"] = decorations + + code_block_props["code"] = children[0] + code_block = super().create(**code_block_props) + + transformer_styles = {} + # Collect styles from transformers and wrapper + for transformer in code_block.transformers._var_value: # type: ignore + if isinstance(transformer, ShikiBaseTransformers) and transformer.style: + transformer_styles.update(transformer.style) + transformer_styles.update(code_wrapper_props.pop("style", {})) + + return Box.create( + code_block, + *children[1:], + style=Style({**transformer_styles, **BOX_PARENT_STYLING}), + **code_wrapper_props, + ) + + def add_imports(self) -> dict[str, list[str]]: + """Add the necessary imports. + We add all referenced transformer functions as imports from their corresponding + libraries. + + Returns: + Imports for the component. + """ + imports = defaultdict(list) + for transformer in self.transformers._var_value: + if isinstance(transformer, ShikiBaseTransformers): + imports[transformer.library].extend( + [ImportVar(tag=str(fn)) for fn in transformer.fns] + ) + ( + self.lib_dependencies.append(transformer.library) + if transformer.library not in self.lib_dependencies + else None + ) + return imports + + @classmethod + def create_transformer(cls, library: str, fns: list[str]) -> ShikiBaseTransformers: + """Create a transformer from a third party library. + + Args: + library: The name of the library. + fns: The str names of the functions/callables to invoke from the library. + + Returns: + A transformer for the specified library. + + Raises: + ValueError: If a supplied function name is not valid str. + """ + if any(not isinstance(fn_name, str) for fn_name in fns): + raise ValueError( + f"the function names should be str names of functions in the specified transformer: {library!r}" + ) + return ShikiBaseTransformers( # type: ignore + library=library, fns=[FunctionStringVar.create(fn) for fn in fns] + ) + + def _render(self, props: dict[str, Any] | None = None): + """Renders the component with the given properties, processing transformers if present. + + Args: + props: Optional properties to pass to the render function. + + Returns: + Rendered component output. + """ + # Ensure props is initialized from class attributes if not provided + props = props or { + attr.rstrip("_"): getattr(self, attr) for attr in self.get_props() + } + + # Extract transformers and apply transformations + transformers = props.get("transformers") + if transformers is not None: + transformed_values = self._process_transformers(transformers._var_value) + props["transformers"] = LiteralVar.create(transformed_values) + + return super()._render(props) + + def _process_transformers(self, transformer_list: list) -> list: + """Processes a list of transformers, applying transformations where necessary. + + Args: + transformer_list: List of transformer objects or values. + + Returns: + list: A list of transformed values. + """ + processed = [] + + for transformer in transformer_list: + if isinstance(transformer, ShikiBaseTransformers): + processed.extend(fn.call() for fn in transformer.fns) + else: + processed.append(transformer) + + return processed + + +class ShikiHighLevelCodeBlock(ShikiCodeBlock): + """High level component for the shiki syntax highlighter.""" + + # If this is enabled, the default transformers(shikijs transformer) will be used. + use_transformers: Var[bool] + + # If this is enabled line numbers will be shown next to the code block. + show_line_numbers: Var[bool] + + # Whether a copy button should appear. + can_copy: bool = False + + # copy_button: A custom copy button to override the default one. + copy_button: Optional[Union[Component, bool]] = None + + @classmethod + def create( + cls, + *children, + **props, + ) -> Component: + """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/). + + Args: + *children: The children of the component. + **props: The props to pass to the component. + + Returns: + The code block component. + """ + use_transformers = props.pop("use_transformers", False) + show_line_numbers = props.pop("show_line_numbers", False) + language = props.pop("language", None) + can_copy = props.pop("can_copy", False) + copy_button = props.pop("copy_button", None) + + if use_transformers: + props["transformers"] = [ShikiJsTransformer()] + + if language is not None: + props["language"] = cls._map_languages(language) + + # line numbers are generated via css + if show_line_numbers: + props["style"] = {**LINE_NUMBER_STYLING, **props.get("style", {})} + + theme = props.pop("theme", None) + props["theme"] = props["theme"] = ( + cls._map_themes(theme) + if theme is not None + else color_mode_cond( # Default color scheme responds to global color mode. + light="one-light", + dark="one-dark-pro", + ) + ) + + if can_copy: + code = children[0] + copy_button = ( # type: ignore + copy_button + if copy_button is not None + else Button.create( + Icon.create(tag="copy", size=16, color=color("gray", 11)), + on_click=[ + set_clipboard(cls._strip_transformer_triggers(code)), # type: ignore + copy_script(), + ], + style=Style( + { + "position": "absolute", + "top": "4px", + "right": "4px", + "background": color("gray", 3), + "border": "1px solid", + "border-color": color("gray", 5), + "border-radius": "6px", + "padding": "5px", + "opacity": "1", + "cursor": "pointer", + "_hover": { + "background": color("gray", 4), + }, + "transition": "background 0.250s ease-out", + "&>svg": { + "transition": "transform 0.250s ease-out, opacity 0.250s ease-out", + }, + "_active": { + "background": color("gray", 5), + }, + } + ), + ) + ) + + if copy_button: + return ShikiCodeBlock.create( + children[0], copy_button, position="relative", **props + ) + else: + return ShikiCodeBlock.create(children[0], **props) + + @staticmethod + def _map_themes(theme: str) -> str: + if isinstance(theme, str) and theme in THEME_MAPPING: + return THEME_MAPPING[theme] + return theme + + @staticmethod + def _map_languages(language: str) -> str: + if isinstance(language, str) and language in LANGUAGE_MAPPING: + return LANGUAGE_MAPPING[language] + return language + + @staticmethod + def _strip_transformer_triggers(code: str | StringVar) -> StringVar | str: + if not isinstance(code, (StringVar, str)): + raise VarTypeError( + f"code should be string literal or a StringVar type. Got {type(code)} instead." + ) + regex_pattern = r"[\/#]+ *\[!code.*?\]" + + if isinstance(code, Var): + return string_replace_operation( + code, StringVar(_js_expr=f"/{regex_pattern}/g", _var_type=str), "" + ) + if isinstance(code, str): + return re.sub(regex_pattern, "", code) + + +class TransformerNamespace(ComponentNamespace): + """Namespace for the Transformers.""" + + shikijs = ShikiJsTransformer + + +class CodeblockNamespace(ComponentNamespace): + """Namespace for the CodeBlock component.""" + + root = staticmethod(ShikiCodeBlock.create) + create_transformer = staticmethod(ShikiCodeBlock.create_transformer) + transformers = TransformerNamespace() + __call__ = staticmethod(ShikiHighLevelCodeBlock.create) + + +code_block = CodeblockNamespace() diff --git a/reflex/components/datadisplay/shiki_code_block.pyi b/reflex/components/datadisplay/shiki_code_block.pyi new file mode 100644 index 000000000..e2475aed5 --- /dev/null +++ b/reflex/components/datadisplay/shiki_code_block.pyi @@ -0,0 +1,2231 @@ +"""Stub file for reflex/components/datadisplay/shiki_code_block.py""" + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from typing import Any, Dict, Literal, Optional, Union, overload + +from reflex.base import Base +from reflex.components.component import Component, ComponentNamespace +from reflex.components.props import NoExtrasAllowedProps +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var +from reflex.vars.function import FunctionStringVar + +def copy_script() -> Any: ... + +SHIKIJS_TRANSFORMER_FNS = { + "transformerNotationDiff", + "transformerNotationHighlight", + "transformerNotationWordHighlight", + "transformerNotationFocus", + "transformerNotationErrorLevel", + "transformerRenderWhitespace", + "transformerMetaHighlight", + "transformerMetaWordHighlight", + "transformerCompactLineOptions", + "transformerRemoveNotationEscape", +} +LINE_NUMBER_STYLING = { + "code": { + "counter-reset": "step", + "counter-increment": "step 0", + "display": "grid", + "line-height": "1.7", + "font-size": "0.875em", + }, + "code .line::before": { + "content": "counter(step)", + "counter-increment": "step", + "width": "1rem", + "margin-right": "1.5rem", + "display": "inline-block", + "text-align": "right", + "color": "rgba(115,138,148,.4)", + }, +} +BOX_PARENT_STYLING = { + "pre": { + "margin": "0", + "padding": "24px", + "background": "transparent", + "overflow-x": "auto", + "border-radius": "6px", + } +} +THEME_MAPPING = { + "light": "one-light", + "dark": "one-dark-pro", + "a11y-dark": "github-dark", +} +LANGUAGE_MAPPING = {"bash": "shellscript"} +LiteralCodeLanguage = Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", +] +LiteralCodeTheme = Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", +] + +class Position(NoExtrasAllowedProps): + line: int + character: int + +class ShikiDecorations(NoExtrasAllowedProps): + start: Union[int, Position] + end: Union[int, Position] + tag_name: str + properties: dict[str, Any] + always_wrap: bool + +class ShikiBaseTransformers(Base): + library: str + fns: list[FunctionStringVar] + style: Optional[Style] + +class ShikiJsTransformer(ShikiBaseTransformers): + library: str + fns: list[FunctionStringVar] + style: Optional[Style] + +class ShikiCodeBlock(Component): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + language: Optional[ + Union[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ], + Var[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ] + ], + ] + ] = None, + theme: Optional[ + Union[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ], + Var[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ] + ], + ] + ] = None, + themes: Optional[ + Union[ + Var[Union[dict[str, str], list[dict[str, Any]]]], + dict[str, str], + list[dict[str, Any]], + ] + ] = None, + code: Optional[Union[Var[str], str]] = None, + transformers: Optional[ + Union[ + Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]], + list[Union[ShikiBaseTransformers, dict[str, Any]]], + ] + ] = None, + decorations: Optional[ + Union[Var[list[ShikiDecorations]], list[ShikiDecorations]] + ] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "ShikiCodeBlock": + """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/). + + Args: + *children: The children of the component. + language: The language to use. + theme: The theme to use ("light" or "dark"). + themes: The set of themes to use for different modes. + code: The code to display. + transformers: The transformers to use for the syntax highlighter. + decorations: The decorations to use for the syntax highlighter. + 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 code block component. + """ + ... + + def add_imports(self) -> dict[str, list[str]]: ... + @classmethod + def create_transformer( + cls, library: str, fns: list[str] + ) -> ShikiBaseTransformers: ... + +class ShikiHighLevelCodeBlock(ShikiCodeBlock): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + use_transformers: Optional[Union[Var[bool], bool]] = None, + show_line_numbers: Optional[Union[Var[bool], bool]] = None, + can_copy: Optional[bool] = None, + copy_button: Optional[Union[Component, bool]] = None, + language: Optional[ + Union[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ], + Var[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ] + ], + ] + ] = None, + theme: Optional[ + Union[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ], + Var[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ] + ], + ] + ] = None, + themes: Optional[ + Union[ + Var[Union[dict[str, str], list[dict[str, Any]]]], + dict[str, str], + list[dict[str, Any]], + ] + ] = None, + code: Optional[Union[Var[str], str]] = None, + transformers: Optional[ + Union[ + Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]], + list[Union[ShikiBaseTransformers, dict[str, Any]]], + ] + ] = None, + decorations: Optional[ + Union[Var[list[ShikiDecorations]], list[ShikiDecorations]] + ] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "ShikiHighLevelCodeBlock": + """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/). + + Args: + *children: The children of the component. + use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used. + show_line_numbers: If this is enabled line numbers will be shown next to the code block. + can_copy: Whether a copy button should appear. + copy_button: copy_button: A custom copy button to override the default one. + language: The language to use. + theme: The theme to use ("light" or "dark"). + themes: The set of themes to use for different modes. + code: The code to display. + transformers: The transformers to use for the syntax highlighter. + decorations: The decorations to use for the syntax highlighter. + 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 code block component. + """ + ... + +class TransformerNamespace(ComponentNamespace): + shikijs = ShikiJsTransformer + +class CodeblockNamespace(ComponentNamespace): + root = staticmethod(ShikiCodeBlock.create) + create_transformer = staticmethod(ShikiCodeBlock.create_transformer) + transformers = TransformerNamespace() + + @staticmethod + def __call__( + *children, + use_transformers: Optional[Union[Var[bool], bool]] = None, + show_line_numbers: Optional[Union[Var[bool], bool]] = None, + can_copy: Optional[bool] = None, + copy_button: Optional[Union[Component, bool]] = None, + language: Optional[ + Union[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ], + Var[ + Literal[ + "abap", + "actionscript-3", + "ada", + "angular-html", + "angular-ts", + "apache", + "apex", + "apl", + "applescript", + "ara", + "asciidoc", + "asm", + "astro", + "awk", + "ballerina", + "bat", + "beancount", + "berry", + "bibtex", + "bicep", + "blade", + "c", + "cadence", + "clarity", + "clojure", + "cmake", + "cobol", + "codeowners", + "codeql", + "coffee", + "common-lisp", + "coq", + "cpp", + "crystal", + "csharp", + "css", + "csv", + "cue", + "cypher", + "d", + "dart", + "dax", + "desktop", + "diff", + "docker", + "dotenv", + "dream-maker", + "edge", + "elixir", + "elm", + "emacs-lisp", + "erb", + "erlang", + "fennel", + "fish", + "fluent", + "fortran-fixed-form", + "fortran-free-form", + "fsharp", + "gdresource", + "gdscript", + "gdshader", + "genie", + "gherkin", + "git-commit", + "git-rebase", + "gleam", + "glimmer-js", + "glimmer-ts", + "glsl", + "gnuplot", + "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "haxe", + "hcl", + "hjson", + "hlsl", + "html", + "html-derivative", + "http", + "hxml", + "hy", + "imba", + "ini", + "java", + "javascript", + "jinja", + "jison", + "json", + "json5", + "jsonc", + "jsonl", + "jsonnet", + "jssm", + "jsx", + "julia", + "kotlin", + "kusto", + "latex", + "lean", + "less", + "liquid", + "log", + "logo", + "lua", + "luau", + "make", + "markdown", + "marko", + "matlab", + "mdc", + "mdx", + "mermaid", + "mojo", + "move", + "narrat", + "nextflow", + "nginx", + "nim", + "nix", + "nushell", + "objective-c", + "objective-cpp", + "ocaml", + "pascal", + "perl", + "php", + "plain", + "plsql", + "po", + "postcss", + "powerquery", + "powershell", + "prisma", + "prolog", + "proto", + "pug", + "puppet", + "purescript", + "python", + "qml", + "qmldir", + "qss", + "r", + "racket", + "raku", + "razor", + "reg", + "regexp", + "rel", + "riscv", + "rst", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "shellsession", + "smalltalk", + "solidity", + "soy", + "sparql", + "splunk", + "sql", + "ssh-config", + "stata", + "stylus", + "svelte", + "swift", + "system-verilog", + "systemd", + "tasl", + "tcl", + "templ", + "terraform", + "tex", + "toml", + "ts-tags", + "tsv", + "tsx", + "turtle", + "twig", + "typescript", + "typespec", + "typst", + "v", + "vala", + "vb", + "verilog", + "vhdl", + "viml", + "vue", + "vue-html", + "vyper", + "wasm", + "wenyan", + "wgsl", + "wikitext", + "wolfram", + "xml", + "xsl", + "yaml", + "zenscript", + "zig", + ] + ], + ] + ] = None, + theme: Optional[ + Union[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ], + Var[ + Literal[ + "andromeeda", + "aurora-x", + "ayu-dark", + "catppuccin-frappe", + "catppuccin-latte", + "catppuccin-macchiato", + "catppuccin-mocha", + "dark-plus", + "dracula", + "dracula-soft", + "everforest-dark", + "everforest-light", + "github-dark", + "github-dark-default", + "github-dark-dimmed", + "github-dark-high-contrast", + "github-light", + "github-light-default", + "github-light-high-contrast", + "houston", + "laserwave", + "light-plus", + "material-theme", + "material-theme-darker", + "material-theme-lighter", + "material-theme-ocean", + "material-theme-palenight", + "min-dark", + "min-light", + "monokai", + "night-owl", + "nord", + "one-dark-pro", + "one-light", + "plastic", + "poimandres", + "red", + "rose-pine", + "rose-pine-dawn", + "rose-pine-moon", + "slack-dark", + "slack-ochin", + "snazzy-light", + "solarized-dark", + "solarized-light", + "synthwave-84", + "tokyo-night", + "vesper", + "vitesse-black", + "vitesse-dark", + "vitesse-light", + ] + ], + ] + ] = None, + themes: Optional[ + Union[ + Var[Union[dict[str, str], list[dict[str, Any]]]], + dict[str, str], + list[dict[str, Any]], + ] + ] = None, + code: Optional[Union[Var[str], str]] = None, + transformers: Optional[ + Union[ + Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]], + list[Union[ShikiBaseTransformers, dict[str, Any]]], + ] + ] = None, + decorations: Optional[ + Union[Var[list[ShikiDecorations]], list[ShikiDecorations]] + ] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "ShikiHighLevelCodeBlock": + """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/). + + Args: + *children: The children of the component. + use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used. + show_line_numbers: If this is enabled line numbers will be shown next to the code block. + can_copy: Whether a copy button should appear. + copy_button: copy_button: A custom copy button to override the default one. + language: The language to use. + theme: The theme to use ("light" or "dark"). + themes: The set of themes to use for different modes. + code: The code to display. + transformers: The transformers to use for the syntax highlighter. + decorations: The decorations to use for the syntax highlighter. + 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 code block component. + """ + ... + +code_block = CodeblockNamespace() diff --git a/reflex/components/dynamic.py b/reflex/components/dynamic.py new file mode 100644 index 000000000..c0e172224 --- /dev/null +++ b/reflex/components/dynamic.py @@ -0,0 +1,190 @@ +"""Components that are dynamically generated on the backend.""" + +from typing import TYPE_CHECKING, Union + +from reflex import constants +from reflex.utils import imports +from reflex.utils.exceptions import DynamicComponentMissingLibrary +from reflex.utils.format import format_library_name +from reflex.utils.serializers import serializer +from reflex.vars import Var, get_unique_variable_name +from reflex.vars.base import VarData, transform + +if TYPE_CHECKING: + from reflex.components.component import Component + + +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" + + +bundled_libraries = {"react", "@radix-ui/themes", "@emotion/react", "next/link"} + + +def bundle_library(component: Union["Component", str]): + """Bundle a library with the component. + + Args: + component: The component to bundle the library with. + + Raises: + DynamicComponentMissingLibrary: Raised when a dynamic component is missing a library. + """ + if isinstance(component, str): + bundled_libraries.add(component) + return + if component.library is None: + raise DynamicComponentMissingLibrary("Component must have a library to bundle.") + bundled_libraries.add(format_library_name(component.library)) + + +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 + from reflex.components.base.bare import Bare + + component = Bare.create(Var.create(component)) + + 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 + + libs_in_window = bundled_libraries + + imports = {} + for lib, names in component._get_all_imports().items(): + formatted_lib_name = format_library_name(lib) + if ( + not lib.startswith((".", "/", "$/")) + and not lib.startswith("http") + and formatted_lib_name not in libs_in_window + ): + 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 or 'from "/' in line: + module_code_lines[ix] = ( + line.replace("import ", "const ", 1).replace( + " from ", " = window['__reflex'][", 1 + ) + + "]" + ) + else: + for lib in libs_in_window: + if f'from "{lib}"' in line: + module_code_lines[ix] = ( + line.replace("import ", "const ", 1) + .replace( + f' from "{lib}"', f" = window.__reflex['{lib}']", 1 + ) + .replace(" as ", ": ") + ) + if line.startswith("export function"): + module_code_lines[ix] = line.replace( + "export function", "export default function", 1 + ) + line_stripped = line.strip() + if line_stripped.startswith("{") and line_stripped.endswith("}"): + module_code_lines[ix] = line_stripped[1:-1] + + module_code_lines.insert(0, "const React = window.__reflex.react;") + + return "\n".join( + [ + "//__reflex_evaluate", + *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 6b6517f77..750e65dba 100644 --- a/reflex/components/el/__init__.py +++ b/reflex/components/el/__init__.py @@ -1,3 +1,18 @@ """The el package exports raw HTML elements.""" -from .elements import * +from __future__ import annotations + +from reflex.utils import lazy_loader + +from . import elements + +_SUBMODULES: set[str] = {"elements"} +_SUBMOD_ATTRS: dict[str, list[str]] = { + f"elements.{k}": v for k, v in elements._MAPPING.items() +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/el/__init__.pyi b/reflex/components/el/__init__.pyi new file mode 100644 index 000000000..4815bcd27 --- /dev/null +++ b/reflex/components/el/__init__.pyi @@ -0,0 +1,225 @@ +"""Stub file for reflex/components/el/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import elements as elements +from .elements.forms import Button as Button +from .elements.forms import Fieldset as Fieldset +from .elements.forms import Form as Form +from .elements.forms import Input as Input +from .elements.forms import Label as Label +from .elements.forms import Legend as Legend +from .elements.forms import Meter as Meter +from .elements.forms import Optgroup as Optgroup +from .elements.forms import Option as Option +from .elements.forms import Output as Output +from .elements.forms import Progress as Progress +from .elements.forms import Select as Select +from .elements.forms import Textarea as Textarea +from .elements.forms import button as button +from .elements.forms import fieldset as fieldset +from .elements.forms import form as form +from .elements.forms import input as input +from .elements.forms import label as label +from .elements.forms import legend as legend +from .elements.forms import meter as meter +from .elements.forms import optgroup as optgroup +from .elements.forms import option as option +from .elements.forms import output as output +from .elements.forms import progress as progress +from .elements.forms import select as select +from .elements.forms import textarea as textarea +from .elements.inline import A as A +from .elements.inline import Abbr as Abbr +from .elements.inline import B as B +from .elements.inline import Bdi as Bdi +from .elements.inline import Bdo as Bdo +from .elements.inline import Br as Br +from .elements.inline import Cite as Cite +from .elements.inline import Code as Code +from .elements.inline import Data as Data +from .elements.inline import Dfn as Dfn +from .elements.inline import Em as Em +from .elements.inline import I as I +from .elements.inline import Kbd as Kbd +from .elements.inline import Mark as Mark +from .elements.inline import Q as Q +from .elements.inline import Rp as Rp +from .elements.inline import Rt as Rt +from .elements.inline import Ruby as Ruby +from .elements.inline import S as S +from .elements.inline import Samp as Samp +from .elements.inline import Small as Small +from .elements.inline import Span as Span +from .elements.inline import Strong as Strong +from .elements.inline import Sub as Sub +from .elements.inline import Sup as Sup +from .elements.inline import Time as Time +from .elements.inline import U as U +from .elements.inline import Wbr as Wbr +from .elements.inline import a as a +from .elements.inline import abbr as abbr +from .elements.inline import b as b +from .elements.inline import bdi as bdi +from .elements.inline import bdo as bdo +from .elements.inline import br as br +from .elements.inline import cite as cite +from .elements.inline import code as code +from .elements.inline import data as data +from .elements.inline import dfn as dfn +from .elements.inline import em as em +from .elements.inline import i as i +from .elements.inline import kbd as kbd +from .elements.inline import mark as mark +from .elements.inline import q as q +from .elements.inline import rp as rp +from .elements.inline import rt as rt +from .elements.inline import ruby as ruby +from .elements.inline import s as s +from .elements.inline import samp as samp +from .elements.inline import small as small +from .elements.inline import span as span +from .elements.inline import strong as strong +from .elements.inline import sub as sub +from .elements.inline import sup as sup +from .elements.inline import time as time +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 Embed as Embed +from .elements.media import Iframe as Iframe +from .elements.media import Img as Img +from .elements.media import Map as Map +from .elements.media import Object as Object +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 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 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 map as map +from .elements.media import object as object +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 svg as svg +from .elements.media import track as track +from .elements.media import video as video +from .elements.metadata import Base as Base +from .elements.metadata import Head as Head +from .elements.metadata import Link as Link +from .elements.metadata import Meta as Meta +from .elements.metadata import Style as Style +from .elements.metadata import Title as Title +from .elements.metadata import base as base +from .elements.metadata import head as head +from .elements.metadata import link as link +from .elements.metadata import meta as meta +from .elements.metadata import style as style +from .elements.metadata import title as title +from .elements.other import Details as Details +from .elements.other import Dialog as Dialog +from .elements.other import Html as Html +from .elements.other import Math as Math +from .elements.other import Slot as Slot +from .elements.other import Summary as Summary +from .elements.other import Template as Template +from .elements.other import details as details +from .elements.other import dialog as dialog +from .elements.other import html as html +from .elements.other import math as math +from .elements.other import slot as slot +from .elements.other import summary as summary +from .elements.other import template as template +from .elements.scripts import Canvas as Canvas +from .elements.scripts import Noscript as Noscript +from .elements.scripts import Script as Script +from .elements.scripts import canvas as canvas +from .elements.scripts import noscript as noscript +from .elements.scripts import script as script +from .elements.sectioning import H1 as H1 +from .elements.sectioning import H2 as H2 +from .elements.sectioning import H3 as H3 +from .elements.sectioning import H4 as H4 +from .elements.sectioning import H5 as H5 +from .elements.sectioning import H6 as H6 +from .elements.sectioning import Address as Address +from .elements.sectioning import Article as Article +from .elements.sectioning import Aside as Aside +from .elements.sectioning import Body as Body +from .elements.sectioning import Footer as Footer +from .elements.sectioning import Header as Header +from .elements.sectioning import Main as Main +from .elements.sectioning import Nav as Nav +from .elements.sectioning import Section as Section +from .elements.sectioning import address as address +from .elements.sectioning import article as article +from .elements.sectioning import aside as aside +from .elements.sectioning import body as body +from .elements.sectioning import footer as footer +from .elements.sectioning import h1 as h1 +from .elements.sectioning import h2 as h2 +from .elements.sectioning import h3 as h3 +from .elements.sectioning import h4 as h4 +from .elements.sectioning import h5 as h5 +from .elements.sectioning import h6 as h6 +from .elements.sectioning import header as header +from .elements.sectioning import main as main +from .elements.sectioning import nav as nav +from .elements.sectioning import section as section +from .elements.tables import Caption as Caption +from .elements.tables import Col as Col +from .elements.tables import Colgroup as Colgroup +from .elements.tables import Table as Table +from .elements.tables import Tbody as Tbody +from .elements.tables import Td as Td +from .elements.tables import Tfoot as Tfoot +from .elements.tables import Th as Th +from .elements.tables import Thead as Thead +from .elements.tables import Tr as Tr +from .elements.tables import caption as caption +from .elements.tables import col as col +from .elements.tables import colgroup as colgroup +from .elements.tables import table as table +from .elements.tables import tbody as tbody +from .elements.tables import td as td +from .elements.tables import tfoot as tfoot +from .elements.tables import th as th +from .elements.tables import thead as thead +from .elements.tables import tr as tr +from .elements.typography import Blockquote as Blockquote +from .elements.typography import Dd as Dd +from .elements.typography import Del as Del +from .elements.typography import Div as Div +from .elements.typography import Dl as Dl +from .elements.typography import Dt as Dt +from .elements.typography import Figcaption as Figcaption +from .elements.typography import Hr as Hr +from .elements.typography import Ins as Ins +from .elements.typography import Li as Li +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 +from .elements.typography import blockquote as blockquote +from .elements.typography import dd as dd +from .elements.typography import del_ as del_ +from .elements.typography import div as div +from .elements.typography import dl as dl +from .elements.typography import dt as dt +from .elements.typography import figcaption as figcaption +from .elements.typography import hr as hr +from .elements.typography import ins as ins +from .elements.typography import li as li +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 diff --git a/reflex/components/el/element.py b/reflex/components/el/element.py index c95965f4a..213cea65a 100644 --- a/reflex/components/el/element.py +++ b/reflex/components/el/element.py @@ -1,6 +1,5 @@ """Base class definition for raw HTML elements.""" - from reflex.components.component import Component diff --git a/reflex/components/el/element.pyi b/reflex/components/el/element.pyi index c6ebaacec..f6d76cd02 100644 --- a/reflex/components/el/element.pyi +++ b/reflex/components/el/element.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/el/element.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Element(Component): @overload @@ -21,52 +22,22 @@ class Element(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Element": """Create the component. diff --git a/reflex/components/el/elements/__init__.py b/reflex/components/el/elements/__init__.py index 240990280..17fdb77ca 100644 --- a/reflex/components/el/elements/__init__.py +++ b/reflex/components/el/elements/__init__.py @@ -1,227 +1,137 @@ """Element classes.""" -from .forms import ( - Button, - Fieldset, - Form, - Input, - Label, - Legend, - Meter, - Optgroup, - Option, - Output, - Progress, - Select, - Textarea, + +from __future__ import annotations + +from reflex.utils import lazy_loader + +_MAPPING = { + "forms": [ + "button", + "fieldset", + "form", + "input", + "label", + "legend", + "meter", + "optgroup", + "option", + "output", + "progress", + "select", + "textarea", + ], + "inline": [ + "a", + "abbr", + "b", + "bdi", + "bdo", + "br", + "cite", + "code", + "data", + "dfn", + "em", + "i", + "kbd", + "mark", + "q", + "rp", + "rt", + "ruby", + "s", + "samp", + "small", + "span", + "strong", + "sub", + "sup", + "time", + "u", + "wbr", + ], + "media": [ + "area", + "audio", + "img", + "image", + "map", + "track", + "video", + "embed", + "iframe", + "object", + "picture", + "portal", + "source", + "svg", + ], + "metadata": [ + "base", + "head", + "link", + "meta", + "title", + "style", + ], + "other": ["details", "dialog", "summary", "slot", "template", "math", "html"], + "scripts": ["canvas", "noscript", "script"], + "sectioning": [ + "address", + "article", + "aside", + "body", + "header", + "footer", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "main", + "nav", + "section", + ], + "tables": [ + "caption", + "col", + "colgroup", + "table", + "td", + "tfoot", + "th", + "thead", + "tr", + "tbody", + ], + "typography": [ + "blockquote", + "dd", + "div", + "dl", + "dt", + "figcaption", + "hr", + "ol", + "li", + "p", + "pre", + "ul", + "ins", + "del_", + "Del", + ], +} + + +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 + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, ) -from .inline import ( - A, - Abbr, - B, - Bdi, - Bdo, - Br, - Cite, - Code, - Data, - Dfn, - Em, - I, - Kbd, - Mark, - Q, - Rp, - Rt, - Ruby, - S, - Samp, - Small, - Span, - Strong, - Sub, - Sup, - Time, - U, - Wbr, -) -from .media import ( - Area, - Audio, - Embed, - Iframe, - Img, - Map, - Object, - Path, - Picture, - Portal, - Source, - Svg, - Track, - Video, -) -from .metadata import Base, Head, Link, Meta, Title -from .other import Details, Dialog, Html, Math, Slot, Summary, Template -from .scripts import Canvas, Noscript, Script -from .sectioning import ( - H1, - H2, - H3, - H4, - H5, - H6, - Address, - Article, - Aside, - Body, - Footer, - Header, - Main, - Nav, - Section, -) -from .tables import Caption, Col, Colgroup, Table, Tbody, Td, Tfoot, Th, Thead, Tr -from .typography import ( - Blockquote, - Dd, - Del, - Div, - Dl, - Dt, - Figcaption, - Hr, - Ins, - Li, - Ol, - P, - Pre, - Ul, -) - -# Forms -button = Button.create -fieldset = Fieldset.create -form = Form.create -input = Input.create -label = Label.create -legend = Legend.create -meter = Meter.create -optgroup = Optgroup.create -option = Option.create -output = Output.create -progress = Progress.create -select = Select.create -textarea = Textarea.create - -# Tables -caption = Caption.create -col = Col.create -colgroup = Colgroup.create -table = Table.create -tbody = Tbody.create -td = Td.create -tfoot = Tfoot.create -th = Th.create -thead = Thead.create -tr = Tr.create - -# Media -area = Area.create -audio = Audio.create -img = Img.create -map = Map.create -track = Track.create -video = Video.create -embed = Embed.create -iframe = Iframe.create -object = Object.create -picture = Picture.create -portal = Portal.create -source = Source.create -svg = Svg.create -path = Path.create - -# Sectioning -address = Address.create -article = Article.create -aside = Aside.create -body = Body.create -header = Header.create -footer = Footer.create - -# Typography -blockquote = Blockquote.create -dd = Dd.create -div = Div.create -dl = Dl.create -dt = Dt.create -figcaption = Figcaption.create -hr = Hr.create -li = Li.create -ol = Ol.create -p = P.create -pre = Pre.create -ul = Ul.create -ins = Ins.create -del_ = Del.create # 'del' is a reserved keyword in Python -h1 = H1.create -h2 = H2.create -h3 = H3.create -h4 = H4.create -h5 = H5.create -h6 = H6.create -main = Main.create -nav = Nav.create -section = Section.create - -# Inline -a = A.create -abbr = Abbr.create -b = B.create -bdi = Bdi.create -bdo = Bdo.create -br = Br.create -cite = Cite.create -code = Code.create -data = Data.create -dfn = Dfn.create -em = Em.create -i = I.create -kbd = Kbd.create -mark = Mark.create -q = Q.create -rp = Rp.create -rt = Rt.create -ruby = Ruby.create -s = S.create -samp = Samp.create -small = Small.create -span = Span.create -strong = Strong.create -sub = Sub.create -sup = Sup.create -time = Time.create -u = U.create -wbr = Wbr.create - -# Metadata -base = Base.create -head = Head.create -link = Link.create -meta = Meta.create -title = Title.create - -# Scripts -canvas = Canvas.create -noscript = Noscript.create -script = Script.create - -# Other -details = Details.create -dialog = Dialog.create -summary = Summary.create -slot = Slot.create -template = Template.create -svg = Svg.create -math = Math.create -html = Html.create diff --git a/reflex/components/el/elements/__init__.pyi b/reflex/components/el/elements/__init__.pyi new file mode 100644 index 000000000..b35e70dd2 --- /dev/null +++ b/reflex/components/el/elements/__init__.pyi @@ -0,0 +1,340 @@ +"""Stub file for reflex/components/el/elements/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .forms import Button as Button +from .forms import Fieldset as Fieldset +from .forms import Form as Form +from .forms import Input as Input +from .forms import Label as Label +from .forms import Legend as Legend +from .forms import Meter as Meter +from .forms import Optgroup as Optgroup +from .forms import Option as Option +from .forms import Output as Output +from .forms import Progress as Progress +from .forms import Select as Select +from .forms import Textarea as Textarea +from .forms import button as button +from .forms import fieldset as fieldset +from .forms import form as form +from .forms import input as input +from .forms import label as label +from .forms import legend as legend +from .forms import meter as meter +from .forms import optgroup as optgroup +from .forms import option as option +from .forms import output as output +from .forms import progress as progress +from .forms import select as select +from .forms import textarea as textarea +from .inline import A as A +from .inline import Abbr as Abbr +from .inline import B as B +from .inline import Bdi as Bdi +from .inline import Bdo as Bdo +from .inline import Br as Br +from .inline import Cite as Cite +from .inline import Code as Code +from .inline import Data as Data +from .inline import Dfn as Dfn +from .inline import Em as Em +from .inline import I as I +from .inline import Kbd as Kbd +from .inline import Mark as Mark +from .inline import Q as Q +from .inline import Rp as Rp +from .inline import Rt as Rt +from .inline import Ruby as Ruby +from .inline import S as S +from .inline import Samp as Samp +from .inline import Small as Small +from .inline import Span as Span +from .inline import Strong as Strong +from .inline import Sub as Sub +from .inline import Sup as Sup +from .inline import Time as Time +from .inline import U as U +from .inline import Wbr as Wbr +from .inline import a as a +from .inline import abbr as abbr +from .inline import b as b +from .inline import bdi as bdi +from .inline import bdo as bdo +from .inline import br as br +from .inline import cite as cite +from .inline import code as code +from .inline import data as data +from .inline import dfn as dfn +from .inline import em as em +from .inline import i as i +from .inline import kbd as kbd +from .inline import mark as mark +from .inline import q as q +from .inline import rp as rp +from .inline import rt as rt +from .inline import ruby as ruby +from .inline import s as s +from .inline import samp as samp +from .inline import small as small +from .inline import span as span +from .inline import strong as strong +from .inline import sub as sub +from .inline import sup as sup +from .inline import time as time +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 Embed as Embed +from .media import Iframe as Iframe +from .media import Img as Img +from .media import Map as Map +from .media import Object as Object +from .media import Picture as Picture +from .media import Portal as Portal +from .media import Source as Source +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 embed as embed +from .media import iframe as iframe +from .media import image as image +from .media import img as img +from .media import map as map +from .media import object as object +from .media import picture as picture +from .media import portal as portal +from .media import source as source +from .media import svg as svg +from .media import track as track +from .media import video as video +from .metadata import Base as Base +from .metadata import Head as Head +from .metadata import Link as Link +from .metadata import Meta as Meta +from .metadata import Style as Style +from .metadata import Title as Title +from .metadata import base as base +from .metadata import head as head +from .metadata import link as link +from .metadata import meta as meta +from .metadata import style as style +from .metadata import title as title +from .other import Details as Details +from .other import Dialog as Dialog +from .other import Html as Html +from .other import Math as Math +from .other import Slot as Slot +from .other import Summary as Summary +from .other import Template as Template +from .other import details as details +from .other import dialog as dialog +from .other import html as html +from .other import math as math +from .other import slot as slot +from .other import summary as summary +from .other import template as template +from .scripts import Canvas as Canvas +from .scripts import Noscript as Noscript +from .scripts import Script as Script +from .scripts import canvas as canvas +from .scripts import noscript as noscript +from .scripts import script as script +from .sectioning import H1 as H1 +from .sectioning import H2 as H2 +from .sectioning import H3 as H3 +from .sectioning import H4 as H4 +from .sectioning import H5 as H5 +from .sectioning import H6 as H6 +from .sectioning import Address as Address +from .sectioning import Article as Article +from .sectioning import Aside as Aside +from .sectioning import Body as Body +from .sectioning import Footer as Footer +from .sectioning import Header as Header +from .sectioning import Main as Main +from .sectioning import Nav as Nav +from .sectioning import Section as Section +from .sectioning import address as address +from .sectioning import article as article +from .sectioning import aside as aside +from .sectioning import body as body +from .sectioning import footer as footer +from .sectioning import h1 as h1 +from .sectioning import h2 as h2 +from .sectioning import h3 as h3 +from .sectioning import h4 as h4 +from .sectioning import h5 as h5 +from .sectioning import h6 as h6 +from .sectioning import header as header +from .sectioning import main as main +from .sectioning import nav as nav +from .sectioning import section as section +from .tables import Caption as Caption +from .tables import Col as Col +from .tables import Colgroup as Colgroup +from .tables import Table as Table +from .tables import Tbody as Tbody +from .tables import Td as Td +from .tables import Tfoot as Tfoot +from .tables import Th as Th +from .tables import Thead as Thead +from .tables import Tr as Tr +from .tables import caption as caption +from .tables import col as col +from .tables import colgroup as colgroup +from .tables import table as table +from .tables import tbody as tbody +from .tables import td as td +from .tables import tfoot as tfoot +from .tables import th as th +from .tables import thead as thead +from .tables import tr as tr +from .typography import Blockquote as Blockquote +from .typography import Dd as Dd +from .typography import Del as Del +from .typography import Div as Div +from .typography import Dl as Dl +from .typography import Dt as Dt +from .typography import Figcaption as Figcaption +from .typography import Hr as Hr +from .typography import Ins as Ins +from .typography import Li as Li +from .typography import Ol as Ol +from .typography import P as P +from .typography import Pre as Pre +from .typography import Ul as Ul +from .typography import blockquote as blockquote +from .typography import dd as dd +from .typography import del_ as del_ +from .typography import div as div +from .typography import dl as dl +from .typography import dt as dt +from .typography import figcaption as figcaption +from .typography import hr as hr +from .typography import ins as ins +from .typography import li as li +from .typography import ol as ol +from .typography import p as p +from .typography import pre as pre +from .typography import ul as ul + +_MAPPING = { + "forms": [ + "button", + "fieldset", + "form", + "input", + "label", + "legend", + "meter", + "optgroup", + "option", + "output", + "progress", + "select", + "textarea", + ], + "inline": [ + "a", + "abbr", + "b", + "bdi", + "bdo", + "br", + "cite", + "code", + "data", + "dfn", + "em", + "i", + "kbd", + "mark", + "q", + "rp", + "rt", + "ruby", + "s", + "samp", + "small", + "span", + "strong", + "sub", + "sup", + "time", + "u", + "wbr", + ], + "media": [ + "area", + "audio", + "img", + "image", + "map", + "track", + "video", + "embed", + "iframe", + "object", + "picture", + "portal", + "source", + "svg", + ], + "metadata": ["base", "head", "link", "meta", "title", "style"], + "other": ["details", "dialog", "summary", "slot", "template", "math", "html"], + "scripts": ["canvas", "noscript", "script"], + "sectioning": [ + "address", + "article", + "aside", + "body", + "header", + "footer", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "main", + "nav", + "section", + ], + "tables": [ + "caption", + "col", + "colgroup", + "table", + "td", + "tfoot", + "th", + "thead", + "tr", + "tbody", + ], + "typography": [ + "blockquote", + "dd", + "div", + "dl", + "dt", + "figcaption", + "hr", + "ol", + "li", + "p", + "pre", + "ul", + "ins", + "del_", + "Del", + ], +} +EXCLUDE = ["del_", "Del", "image"] +for _, v in _MAPPING.items(): + v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE]) diff --git a/reflex/components/el/elements/base.py b/reflex/components/el/elements/base.py index fd2dc8cbb..a9748ae25 100644 --- a/reflex/components/el/elements/base.py +++ b/reflex/components/el/elements/base.py @@ -1,8 +1,9 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + 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 9b6d0d6d8..6e943d0d0 100644 --- a/reflex/components/el/elements/base.pyi +++ b/reflex/components/el/elements/base.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/el/elements/base.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Union from reflex.components.el.element import Element -from reflex.vars import Var as Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class BaseHTML(Element): @overload @@ -17,98 +16,52 @@ class BaseHTML(Element): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "BaseHTML": """Create the component. diff --git a/reflex/components/el/elements/forms.py b/reflex/components/el/elements/forms.py index a98bd47c7..4caf14b41 100644 --- a/reflex/components/el/elements/forms.py +++ b/reflex/components/el/elements/forms.py @@ -3,29 +3,35 @@ from __future__ import annotations from hashlib import md5 -from typing import Any, Dict, Iterator, Set, Union +from typing import Any, Dict, Iterator, Set, Tuple, Union from jinja2 import Environment 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 -from reflex.utils import imports -from reflex.utils.format import format_event_chain -from reflex.vars import BaseVar, Var +from reflex.event import ( + EventChain, + EventHandler, + input_event, + key_event, + prevent_default, +) +from reflex.utils.imports import ImportDict +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var from .base import BaseHTML -FORM_DATA = Var.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() @@ -96,6 +102,24 @@ class Fieldset(Element): name: Var[Union[str, int, bool]] +def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]: + """Event handler spec for the on_submit event. + + Returns: + The event handler spec. + """ + return (FORM_DATA,) + + +def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]: + """Event handler spec for the on_submit event. + + Returns: + The event handler spec. + """ + return (FORM_DATA,) + + class Form(BaseHTML): """Display the form element.""" @@ -134,16 +158,8 @@ class Form(BaseHTML): # The name used to make this form's submit handler function unique. handle_submit_unique_name: Var[str] - def get_event_triggers(self) -> Dict[str, Any]: - """Event triggers for radix form root. - - Returns: - The triggers for event supported by Root. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_SUBMIT: lambda e0: [FORM_DATA], - } + # Fired when the form is submitted + on_submit: EventHandler[on_submit_event_spec, on_submit_string_event_spec] @classmethod def create(cls, *children, **props): @@ -156,6 +172,9 @@ class Form(BaseHTML): Returns: The form component. """ + if "on_submit" not in props: + props["on_submit"] = prevent_default + if "handle_submit_unique_name" in props: return super().create(*children, **props) @@ -169,38 +188,44 @@ class Form(BaseHTML): ).hexdigest() return form - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - { - "react": {imports.ImportVar(tag="useCallback")}, - f"/{Dirs.STATE_PATH}": { - imports.ImportVar(tag="getRefValue"), - imports.ImportVar(tag="getRefValues"), - }, - }, - ) + def add_imports(self) -> ImportDict: + """Add imports needed by the form component. - def _get_hooks(self) -> str | None: + Returns: + The imports for the form component. + """ + return { + "react": "useCallback", + f"$/{Dirs.STATE_PATH}": ["getRefValue", "getRefValues"], + } + + def add_hooks(self) -> list[str]: + """Add hooks for the form. + + Returns: + The hooks for the form. + """ if EventTriggers.ON_SUBMIT not in self.event_triggers: - return - return HANDLE_SUBMIT_JS_JINJA2.render( - handle_submit_unique_name=self.handle_submit_unique_name, - form_data=FORM_DATA, - field_ref_mapping=str(Var.create_safe(self._get_form_refs())), - on_submit_event_chain=format_event_chain( - self.event_triggers[EventTriggers.ON_SUBMIT] - ), - reset_on_submit=self.reset_on_submit, - ) + return [] + return [ + HANDLE_SUBMIT_JS_JINJA2.render( + 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=str( + LiteralVar.create(self.event_triggers[EventTriggers.ON_SUBMIT]) + ), + reset_on_submit=self.reset_on_submit, + ) + ] def _render(self) -> Tag: render_tag = super()._render() if EventTriggers.ON_SUBMIT in self.event_triggers: render_tag.add_props( **{ - EventTriggers.ON_SUBMIT: BaseVar( - _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, ) } @@ -214,15 +239,18 @@ 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 = Var.create_safe(ref[:-3]).as_ref() - form_refs[ref[5:-3]] = Var.create_safe( - f"getRefValues({str(ref_var)})", _var_is_local=False - )._replace(merge_var_data=ref_var._var_data) + 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 = Var.create_safe(ref).as_ref() - form_refs[ref[4:]] = Var.create_safe( - f"getRefValue({str(ref_var)})", _var_is_local=False - )._replace(merge_var_data=ref_var._var_data) + 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)) return form_refs def _get_vars(self, include_children: bool = True) -> Iterator[Var]: @@ -340,20 +368,20 @@ class Input(BaseHTML): # Value of the input value: Var[Union[str, int, float]] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. + # Fired when the input value changes + on_change: EventHandler[input_event] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } + # Fired when the input gains focus + on_focus: EventHandler[input_event] + + # Fired when the input loses focus + on_blur: EventHandler[input_event] + + # Fired when a key is pressed down + on_key_down: EventHandler[key_event] + + # Fired when a key is released + on_key_up: EventHandler[key_event] class Label(BaseHTML): @@ -491,23 +519,15 @@ class Select(BaseHTML): # Number of visible options in a drop-down list size: Var[Union[str, int, bool]] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - } + # Fired when the select value changes + on_change: EventHandler[input_event] 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) { @@ -589,6 +609,57 @@ class Textarea(BaseHTML): # How the text in the textarea is to be wrapped when submitting the form wrap: Var[Union[str, int, bool]] + # Fired when the input value changes + on_change: EventHandler[input_event] + + # Fired when the input gains focus + on_focus: EventHandler[input_event] + + # Fired when the input loses focus + on_blur: EventHandler[input_event] + + # Fired when a key is pressed down + on_key_down: EventHandler[key_event] + + # Fired when a key is released + on_key_up: EventHandler[key_event] + + @classmethod + def create(cls, *children, **props): + """Create a textarea component. + + Args: + *children: The children of the textarea. + **props: The properties of the textarea. + + Returns: + The textarea component. + + Raises: + ValueError: when `enter_key_submit` is combined with `on_key_down`. + """ + enter_key_submit = props.get("enter_key_submit") + auto_height = props.get("auto_height") + custom_attrs = props.setdefault("custom_attrs", {}) + + if enter_key_submit is not None: + enter_key_submit = Var.create(enter_key_submit) + if "on_key_down" in props: + raise ValueError( + "Cannot combine `enter_key_submit` with `on_key_down`.", + ) + custom_attrs["on_key_down"] = Var( + _js_expr=f"(e) => enterKeySubmitOnKeyDown(e, {str(enter_key_submit)})", + _var_data=VarData.merge(enter_key_submit._get_all_var_data()), + ) + if auto_height is not None: + auto_height = Var.create(auto_height) + custom_attrs["on_input"] = Var( + _js_expr=f"(e) => autoHeightOnInput(e, {str(auto_height)})", + _var_data=VarData.merge(auto_height._get_all_var_data()), + ) + return super().create(*children, **props) + def _exclude_props(self) -> list[str]: return super()._exclude_props() + [ "auto_height", @@ -608,39 +679,17 @@ class Textarea(BaseHTML): custom_code.add(ENTER_KEY_SUBMIT_JS) return custom_code - def _render(self) -> Tag: - tag = super()._render() - if self.enter_key_submit is not None: - if "on_key_down" in self.event_triggers: - raise ValueError( - "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, - )._replace(merge_var_data=self.enter_key_submit._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, - )._replace(merge_var_data=self.auto_height._var_data), - ) - return tag - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } +button = Button.create +fieldset = Fieldset.create +form = Form.create +input = Input.create +label = Label.create +legend = Legend.create +meter = Meter.create +optgroup = Optgroup.create +option = Option.create +output = Output.create +progress = Progress.create +select = Select.create +textarea = Textarea.create diff --git a/reflex/components/el/elements/forms.pyi b/reflex/components/el/elements/forms.pyi index 38853ce40..a8e9b6174 100644 --- a/reflex/components/el/elements/forms.pyi +++ b/reflex/components/el/elements/forms.pyi @@ -1,27 +1,23 @@ """Stub file for reflex/components/el/elements/forms.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Tuple, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from hashlib import md5 -from typing import Any, Dict, Iterator, Set, Union from jinja2 import Environment + 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 -from reflex.utils import imports -from reflex.utils.format import format_event_chain -from reflex.vars import BaseVar, Var +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var + from .base import BaseHTML -FORM_DATA = Var.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): @@ -30,123 +26,67 @@ class Button(BaseHTML): def create( # type: ignore cls, *children, - auto_focus: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]]] = None, - form_action: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - form_method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form_target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Button": """Create the component. @@ -198,98 +138,52 @@ class Datalist(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Datalist": """Create the component. @@ -330,63 +224,31 @@ class Fieldset(Element): def create( # type: ignore cls, *children, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Fieldset": """Create the component. @@ -408,135 +270,79 @@ class Fieldset(Element): """ ... +def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]: ... +def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]: ... + class Form(BaseHTML): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - action: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enc_type: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]] ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Form": """Create a form component. @@ -553,6 +359,7 @@ class Form(BaseHTML): target: Where to display the response after submitting the form reset_on_submit: If true, the form will be cleared after submit. handle_submit_unique_name: The name used to make this form's submit handler function unique. + on_submit: Fired when the form is submitted access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -582,189 +389,103 @@ class Form(BaseHTML): """ ... + def add_imports(self) -> ImportDict: ... + def add_hooks(self) -> list[str]: ... + class Input(BaseHTML): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - alt: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - auto_focus: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - capture: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - checked: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - form_action: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - form_method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form_target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - list: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - max: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - max_length: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - min_length: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - min: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - multiple: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - pattern: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - placeholder: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - read_only: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - required: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - size: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - step: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - use_map: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - value: Optional[ - Union[Var[Union[str, int, float]], Union[str, int, float]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[str]] = None, + on_key_down: Optional[EventType[str]] = None, + on_key_up: Optional[EventType[str]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Input": """Create the component. @@ -803,6 +524,11 @@ class Input(BaseHTML): type: Specifies the type of input use_map: Name of the image map used with the input value: Value of the input + on_change: Fired when the input value changes + on_focus: Fired when the input gains focus + on_blur: Fired when the input loses focus + on_key_down: Fired when a key is pressed down + on_key_up: Fired when a key is released access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -838,102 +564,54 @@ class Label(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Label": """Create the component. @@ -976,98 +654,52 @@ class Legend(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Legend": """Create the component. @@ -1108,109 +740,59 @@ class Meter(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - high: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - low: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - max: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - min: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - optimum: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Meter": """Create the component. @@ -1258,104 +840,54 @@ class Optgroup(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - label: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Optgroup": """Create the component. @@ -1398,110 +930,56 @@ class Option(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - label: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - selected: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Option": """Create the component. @@ -1546,103 +1024,55 @@ class Output(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Output": """Create the component. @@ -1686,103 +1116,55 @@ class Progress(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - max: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Progress": """Create the component. @@ -1821,125 +1203,68 @@ class Progress(BaseHTML): ... class Select(BaseHTML): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - auto_focus: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - multiple: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - required: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - size: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Select": """Create the component. @@ -1953,6 +1278,7 @@ class Select(BaseHTML): name: Name of the select, used when submitting the form required: Indicates that the select control must have a selected option size: Number of visible options in a drop-down list + on_change: Fired when the select value changes access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -1982,159 +1308,88 @@ 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): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - auto_focus: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]]] = None, - dirname: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - disabled: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]]] = None, - max_length: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - min_length: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - placeholder: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - read_only: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - required: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - rows: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - wrap: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[str]] = None, + on_key_down: Optional[EventType[str]] = None, + on_key_up: Optional[EventType[str]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Textarea": - """Create the component. + """Create a textarea component. Args: - *children: The children of the component. + *children: The children of the textarea. auto_complete: Whether the form control should have autocomplete enabled auto_focus: Automatically focuses the textarea when the page loads auto_height: Automatically fit the content height to the text (use min-height with this prop) @@ -2152,6 +1407,11 @@ class Textarea(BaseHTML): rows: Visible number of lines in the text control value: The controlled value of the textarea, read only unless used with on_change wrap: How the text in the textarea is to be wrapped when submitting the form + on_change: Fired when the input value changes + on_focus: Fired when the input gains focus + on_blur: Fired when the input loses focus + on_key_down: Fired when a key is pressed down + on_key_up: Fired when a key is released access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -2174,9 +1434,26 @@ class Textarea(BaseHTML): 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 of the component. + **props: The properties of the textarea. Returns: - The component. + The textarea component. + + Raises: + ValueError: when `enter_key_submit` is combined with `on_key_down`. """ ... + +button = Button.create +fieldset = Fieldset.create +form = Form.create +input = Input.create +label = Label.create +legend = Legend.create +meter = Meter.create +optgroup = Optgroup.create +option = Option.create +output = Output.create +progress = Progress.create +select = Select.create +textarea = Textarea.create diff --git a/reflex/components/el/elements/inline.py b/reflex/components/el/elements/inline.py index a8454217b..d1bdf6b87 100644 --- a/reflex/components/el/elements/inline.py +++ b/reflex/components/el/elements/inline.py @@ -1,7 +1,8 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML @@ -208,3 +209,33 @@ class Wbr(BaseHTML): """Display the wbr element.""" tag = "wbr" + + +a = A.create +abbr = Abbr.create +b = B.create +bdi = Bdi.create +bdo = Bdo.create +br = Br.create +cite = Cite.create +code = Code.create +data = Data.create +dfn = Dfn.create +em = Em.create +i = I.create +kbd = Kbd.create +mark = Mark.create +q = Q.create +rp = Rp.create +rt = Rt.create +ruby = Ruby.create +s = S.create +samp = Samp.create +small = Small.create +span = Span.create +strong = Strong.create +sub = Sub.create +sup = Sup.create +time = Time.create +u = U.create +wbr = Wbr.create diff --git a/reflex/components/el/elements/inline.pyi b/reflex/components/el/elements/inline.pyi index a18f86243..336e4d3de 100644 --- a/reflex/components/el/elements/inline.pyi +++ b/reflex/components/el/elements/inline.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/el/elements/inline.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var + from .base import BaseHTML class A(BaseHTML): @@ -17,119 +17,63 @@ class A(BaseHTML): def create( # type: ignore cls, *children, - download: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - href: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - href_lang: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - media: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - ping: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - rel: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - shape: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "A": """Create the component. @@ -179,98 +123,52 @@ class Abbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Abbr": """Create the component. @@ -311,98 +209,52 @@ class B(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "B": """Create the component. @@ -443,98 +295,52 @@ class Bdi(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Bdi": """Create the component. @@ -575,98 +381,52 @@ class Bdo(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Bdo": """Create the component. @@ -707,98 +467,52 @@ class Br(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Br": """Create the component. @@ -839,98 +553,52 @@ class Cite(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Cite": """Create the component. @@ -971,98 +639,52 @@ class Code(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Code": """Create the component. @@ -1103,101 +725,53 @@ class Data(BaseHTML): def create( # type: ignore cls, *children, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Data": """Create the component. @@ -1239,98 +813,52 @@ class Dfn(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Dfn": """Create the component. @@ -1371,98 +899,52 @@ class Em(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Em": """Create the component. @@ -1503,98 +985,52 @@ class I(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "I": """Create the component. @@ -1635,98 +1071,52 @@ class Kbd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Kbd": """Create the component. @@ -1767,98 +1157,52 @@ class Mark(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Mark": """Create the component. @@ -1899,99 +1243,53 @@ class Q(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Q": """Create the component. @@ -2033,98 +1331,52 @@ class Rp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Rp": """Create the component. @@ -2165,98 +1417,52 @@ class Rt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Rt": """Create the component. @@ -2297,98 +1503,52 @@ class Ruby(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Ruby": """Create the component. @@ -2429,98 +1589,52 @@ class S(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "S": """Create the component. @@ -2561,98 +1675,52 @@ class Samp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Samp": """Create the component. @@ -2693,98 +1761,52 @@ class Small(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Small": """Create the component. @@ -2825,98 +1847,52 @@ class Span(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Span": """Create the component. @@ -2957,98 +1933,52 @@ class Strong(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Strong": """Create the component. @@ -3089,98 +2019,52 @@ class Sub(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Sub": """Create the component. @@ -3221,98 +2105,52 @@ class Sup(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Sup": """Create the component. @@ -3353,101 +2191,53 @@ class Time(BaseHTML): def create( # type: ignore cls, *children, - date_time: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Time": """Create the component. @@ -3489,98 +2279,52 @@ class U(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "U": """Create the component. @@ -3621,98 +2365,52 @@ class Wbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Wbr": """Create the component. @@ -3746,3 +2444,32 @@ class Wbr(BaseHTML): The component. """ ... + +a = A.create +abbr = Abbr.create +b = B.create +bdi = Bdi.create +bdo = Bdo.create +br = Br.create +cite = Cite.create +code = Code.create +data = Data.create +dfn = Dfn.create +em = Em.create +i = I.create +kbd = Kbd.create +mark = Mark.create +q = Q.create +rp = Rp.create +rt = Rt.create +ruby = Ruby.create +s = S.create +samp = Samp.create +small = Small.create +span = Span.create +strong = Strong.create +sub = Sub.create +sup = Sup.create +time = Time.create +u = U.create +wbr = Wbr.create diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py index 2865ca66a..9935902ad 100644 --- a/reflex/components/el/elements/media.py +++ b/reflex/components/el/elements/media.py @@ -1,7 +1,10 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Any, Union -from reflex.vars import Var as Var +from reflex import Component, ComponentNamespace +from reflex.constants.colors import Color +from reflex.vars.base import Var from .base import BaseHTML @@ -116,6 +119,24 @@ class Img(BaseHTML): # The name of the map to use with the image use_map: Var[Union[str, int, bool]] + @classmethod + def create(cls, *children, **props) -> Component: + """Override create method to apply source attribute to value if user fails to pass in attribute. + + Args: + *children: The children of the component. + **props: The props of the component. + + Returns: + The component. + + """ + return ( + super().create(src=children[0], **props) + if children + else super().create(*children, **props) + ) + class Map(BaseHTML): """Display the map element.""" @@ -288,6 +309,189 @@ class Svg(BaseHTML): """Display the svg element.""" tag = "svg" + # The width of the svg. + width: Var[Union[str, int]] + # The height of the svg. + height: Var[Union[str, int]] + # The XML namespace declaration. + xmlns: Var[str] + + +class Text(BaseHTML): + """The SVG text component.""" + + tag = "text" + # The x coordinate of the starting point of the text baseline. + x: Var[Union[str, int]] + # The y coordinate of the starting point of the text baseline. + y: Var[Union[str, int]] + # Shifts the text position horizontally from a previous text element. + dx: Var[Union[str, int]] + # Shifts the text position vertically from a previous text element. + dy: Var[Union[str, int]] + # Rotates orientation of each individual glyph. + rotate: Var[Union[str, int]] + # How the text is stretched or compressed to fit the width defined by the text_length attribute. + length_adjust: Var[str] + # A width that the text should be scaled to fit. + text_length: Var[Union[str, int]] + + +class Line(BaseHTML): + """The SVG line component.""" + + tag = "line" + # The x-axis coordinate of the line starting point. + x1: Var[Union[str, int]] + # The x-axis coordinate of the the line ending point. + x2: Var[Union[str, int]] + # The y-axis coordinate of the line starting point. + y1: Var[Union[str, int]] + # The y-axis coordinate of the the line ending point. + y2: Var[Union[str, int]] + # The total path length, in user units. + path_length: Var[int] + + +class Circle(BaseHTML): + """The SVG circle component.""" + + tag = "circle" + # The x-axis coordinate of the center of the circle. + cx: Var[Union[str, int]] + # The y-axis coordinate of the center of the circle. + cy: Var[Union[str, int]] + # The radius of the circle. + r: Var[Union[str, int]] + # The total length for the circle's circumference, in user units. + path_length: Var[int] + + +class Ellipse(BaseHTML): + """The SVG ellipse component.""" + + tag = "ellipse" + # The x position of the center of the ellipse. + cx: Var[Union[str, int]] + # The y position of the center of the ellipse. + cy: Var[Union[str, int]] + # The radius of the ellipse on the x axis. + rx: Var[Union[str, int]] + # The radius of the ellipse on the y axis. + ry: Var[Union[str, int]] + # The total length for the ellipse's circumference, in user units. + path_length: Var[int] + + +class Rect(BaseHTML): + """The SVG rect component.""" + + tag = "rect" + # The x coordinate of the rect. + x: Var[Union[str, int]] + # The y coordinate of the rect. + y: Var[Union[str, int]] + # The width of the rect + width: Var[Union[str, int]] + # The height of the rect. + height: Var[Union[str, int]] + # The horizontal corner radius of the rect. Defaults to ry if it is specified. + rx: Var[Union[str, int]] + # The vertical corner radius of the rect. Defaults to rx if it is specified. + ry: Var[Union[str, int]] + # The total length of the rectangle's perimeter, in user units. + path_length: Var[int] + + +class Polygon(BaseHTML): + """The SVG polygon component.""" + + tag = "polygon" + # defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon. + points: Var[str] + # This prop lets specify the total length for the path, in user units. + path_length: Var[int] + + +class Defs(BaseHTML): + """Display the defs element.""" + + tag = "defs" + + +class LinearGradient(BaseHTML): + """Display the linearGradient element.""" + + tag = "linearGradient" + + # Units for the gradient. + gradient_units: Var[Union[str, bool]] + + # Transform applied to the gradient. + gradient_transform: Var[Union[str, bool]] + + # Method used to spread the gradient. + spread_method: Var[Union[str, bool]] + + # X coordinate of the starting point of the gradient. + x1: Var[Union[str, int, bool]] + + # X coordinate of the ending point of the gradient. + x2: Var[Union[str, int, bool]] + + # Y coordinate of the starting point of the gradient. + y1: Var[Union[str, int, bool]] + + # Y coordinate of the ending point of the gradient. + y2: Var[Union[str, int, bool]] + + +class RadialGradient(BaseHTML): + """Display the radialGradient element.""" + + tag = "radialGradient" + + # The x coordinate of the end circle of the radial gradient. + cx: Var[Union[str, int, bool]] + + # The y coordinate of the end circle of the radial gradient. + cy: Var[Union[str, int, bool]] + + # The radius of the start circle of the radial gradient. + fr: Var[Union[str, int, bool]] + + # The x coordinate of the start circle of the radial gradient. + fx: Var[Union[str, int, bool]] + + # The y coordinate of the start circle of the radial gradient. + fy: Var[Union[str, int, bool]] + + # Units for the gradient. + gradient_units: Var[Union[str, bool]] + + # Transform applied to the gradient. + gradient_transform: Var[Union[str, bool]] + + # The radius of the end circle of the radial gradient. + r: Var[Union[str, int, bool]] + + # Method used to spread the gradient. + spread_method: Var[Union[str, bool]] + + +class Stop(BaseHTML): + """Display the stop element.""" + + tag = "stop" + + # Offset of the gradient stop. + offset: Var[Union[str, float, int]] + + # Color of the gradient stop. + stop_color: Var[Union[str, Color, bool]] + + # Opacity of the gradient stop. + stop_opacity: Var[Union[str, float, int, bool]] class Path(BaseHTML): @@ -295,5 +499,37 @@ class Path(BaseHTML): tag = "path" - # Defines the shape of the path + # Defines the shape of the path. d: Var[Union[str, int, bool]] + + +class SVG(ComponentNamespace): + """SVG component namespace.""" + + text = staticmethod(Text.create) + line = staticmethod(Line.create) + circle = staticmethod(Circle.create) + ellipse = staticmethod(Ellipse.create) + rect = staticmethod(Rect.create) + polygon = staticmethod(Polygon.create) + path = staticmethod(Path.create) + stop = staticmethod(Stop.create) + linear_gradient = staticmethod(LinearGradient.create) + radial_gradient = staticmethod(RadialGradient.create) + defs = staticmethod(Defs.create) + __call__ = staticmethod(Svg.create) + + +area = Area.create +audio = Audio.create +image = img = Img.create +map = Map.create +track = Track.create +video = Video.create +embed = Embed.create +iframe = Iframe.create +object = Object.create +picture = Picture.create +portal = Portal.create +source = Source.create +svg = SVG() diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi index d1aa40978..382f3c79c 100644 --- a/reflex/components/el/elements/media.pyi +++ b/reflex/components/el/elements/media.pyi @@ -1,14 +1,16 @@ """Stub file for reflex/components/el/elements/media.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex import ComponentNamespace +from reflex.constants.colors import Color +from reflex.event import EventType from reflex.style import Style -from typing import Any, Union -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Area(BaseHTML): @@ -17,123 +19,65 @@ class Area(BaseHTML): def create( # type: ignore cls, *children, - alt: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - coords: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - download: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - href: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - href_lang: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - media: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - ping: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - rel: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - shape: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Area": """Create the component. @@ -185,118 +129,62 @@ class Audio(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - buffered: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - controls: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - loop: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - muted: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - preload: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Audio": """Create the component. @@ -345,132 +233,72 @@ class Img(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - alt: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - decoding: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + decoding: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, intrinsicsize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - ismap: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - loading: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - sizes: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Any], Any]] = None, - src_set: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - use_map: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Img": - """Create the component. + """Override create method to apply source attribute to value if user fails to pass in attribute. Args: *children: The children of the component. @@ -512,6 +340,7 @@ class Img(BaseHTML): Returns: The component. + """ ... @@ -521,99 +350,53 @@ class Map(BaseHTML): def create( # type: ignore cls, *children, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Map": """Create the component. @@ -655,109 +438,57 @@ class Track(BaseHTML): def create( # type: ignore cls, *children, - default: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - kind: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - label: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - src_lang: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Track": """Create the component. @@ -803,124 +534,66 @@ class Video(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - buffered: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - controls: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - loop: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - muted: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - poster: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - preload: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Video": """Create the component. @@ -971,100 +644,54 @@ class Embed(BaseHTML): def create( # type: ignore cls, *children, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Embed": """Create the component. @@ -1107,119 +734,63 @@ class Iframe(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - allow: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - csp: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - loading: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - sandbox: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - src_doc: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Iframe": """Create the component. @@ -1269,105 +840,57 @@ class Object(BaseHTML): def create( # type: ignore cls, *children, - data: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - form: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - use_map: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Object": """Create the component. @@ -1413,98 +936,52 @@ class Picture(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Picture": """Create the component. @@ -1545,98 +1022,52 @@ class Portal(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Portal": """Create the component. @@ -1677,109 +1108,57 @@ class Source(BaseHTML): def create( # type: ignore cls, *children, - media: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - sizes: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - src_set: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Source": """Create the component. @@ -1825,103 +1204,1025 @@ class Svg(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = 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]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Svg": """Create the component. Args: *children: The children of the component. + width: The width of the svg. + height: The height of the svg. + xmlns: The XML namespace declaration. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a

element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Text(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, + dx: Optional[Union[Var[Union[int, str]], int, str]] = None, + dy: Optional[Union[Var[Union[int, str]], int, str]] = None, + rotate: Optional[Union[Var[Union[int, str]], int, str]] = None, + length_adjust: Optional[Union[Var[str], str]] = None, + text_length: Optional[Union[Var[Union[int, str]], 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]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Text": + """Create the component. + + Args: + *children: The children of the component. + x: The x coordinate of the starting point of the text baseline. + y: The y coordinate of the starting point of the text baseline. + dx: Shifts the text position horizontally from a previous text element. + dy: Shifts the text position vertically from a previous text element. + rotate: Rotates orientation of each individual glyph. + length_adjust: How the text is stretched or compressed to fit the width defined by the text_length attribute. + text_length: A width that the text should be scaled to fit. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Line(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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, + path_length: Optional[Union[Var[int], int]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Line": + """Create the component. + + Args: + *children: The children of the component. + x1: The x-axis coordinate of the line starting point. + x2: The x-axis coordinate of the the line ending point. + y1: The y-axis coordinate of the line starting point. + y2: The y-axis coordinate of the the line ending point. + path_length: The total path length, in user units. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Circle(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Circle": + """Create the component. + + Args: + *children: The children of the component. + cx: The x-axis coordinate of the center of the circle. + cy: The y-axis coordinate of the center of the circle. + r: The radius of the circle. + path_length: The total length for the circle's circumference, in user units. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Ellipse(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + cx: Optional[Union[Var[Union[int, str]], int, str]] = None, + cy: 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]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Ellipse": + """Create the component. + + Args: + *children: The children of the component. + cx: The x position of the center of the ellipse. + cy: The y position of the center of the ellipse. + rx: The radius of the ellipse on the x axis. + ry: The radius of the ellipse on the y axis. + path_length: The total length for the ellipse's circumference, in user units. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Rect(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Rect": + """Create the component. + + Args: + *children: The children of the component. + x: The x coordinate of the rect. + y: The y coordinate of the rect. + width: The width of the rect + height: The height of the rect. + rx: The horizontal corner radius of the rect. Defaults to ry if it is specified. + ry: The vertical corner radius of the rect. Defaults to rx if it is specified. + path_length: The total length of the rectangle's perimeter, in user units. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Polygon(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *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]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Polygon": + """Create the component. + + Args: + *children: The children of the component. + points: defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon. + path_length: This prop lets specify the total length for the path, in user units. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Defs(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Defs": + """Create the component. + + Args: + *children: The children of the component. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class LinearGradient(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "LinearGradient": + """Create the component. + + Args: + *children: The children of the component. + gradient_units: Units for the gradient. + gradient_transform: Transform applied to the gradient. + spread_method: Method used to spread the gradient. + x1: X coordinate of the starting point of the gradient. + x2: X coordinate of the ending point of the gradient. + y1: Y coordinate of the starting point of the gradient. + y2: Y coordinate of the ending point of the gradient. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class RadialGradient(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + cx: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + cy: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + fr: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + fx: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + fy: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + gradient_units: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + gradient_transform: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + r: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spread_method: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "RadialGradient": + """Create the component. + + Args: + *children: The children of the component. + cx: The x coordinate of the end circle of the radial gradient. + cy: The y coordinate of the end circle of the radial gradient. + fr: The radius of the start circle of the radial gradient. + fx: The x coordinate of the start circle of the radial gradient. + fy: The y coordinate of the start circle of the radial gradient. + gradient_units: Units for the gradient. + gradient_transform: Transform applied to the gradient. + r: The radius of the end circle of the radial gradient. + spread_method: Method used to spread the gradient. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +class Stop(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + offset: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + stop_color: Optional[ + Union[Color, Var[Union[Color, bool, str]], bool, str] + ] = None, + stop_opacity: Optional[ + Union[Var[Union[bool, float, int, str]], bool, 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]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Stop": + """Create the component. + + Args: + *children: The children of the component. + offset: Offset of the gradient stop. + stop_color: Color of the gradient stop. + stop_opacity: Opacity of the gradient stop. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -1957,105 +2258,59 @@ class Path(BaseHTML): def create( # type: ignore cls, *children, - d: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Path": """Create the component. Args: *children: The children of the component. - d: Defines the shape of the path + d: Defines the shape of the path. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -2084,3 +2339,119 @@ class Path(BaseHTML): The component. """ ... + +class SVG(ComponentNamespace): + text = staticmethod(Text.create) + line = staticmethod(Line.create) + circle = staticmethod(Circle.create) + ellipse = staticmethod(Ellipse.create) + rect = staticmethod(Rect.create) + polygon = staticmethod(Polygon.create) + path = staticmethod(Path.create) + stop = staticmethod(Stop.create) + linear_gradient = staticmethod(LinearGradient.create) + radial_gradient = staticmethod(RadialGradient.create) + defs = staticmethod(Defs.create) + + @staticmethod + def __call__( + *children, + 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]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Svg": + """Create the component. + + Args: + *children: The children of the component. + width: The width of the svg. + height: The height of the svg. + xmlns: The XML namespace declaration. + access_key: Provides a hint for generating a keyboard shortcut for the current element. + auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. + content_editable: Indicates whether the element's content is editable. + context_menu: Defines the ID of a element which will serve as the element's context menu. + dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) + draggable: Defines whether the element can be dragged. + enter_key_hint: Hints what media types the media element is able to play. + hidden: Defines whether the element is hidden. + input_mode: Defines the type of the element. + item_prop: Defines the name of the element for metadata purposes. + lang: Defines the language used in the element. + role: Defines the role of the element. + slot: Assigns a slot in a shadow DOM shadow tree to an element. + spell_check: Defines whether the element may be checked for spelling errors. + tab_index: Defines the position of the current element in the tabbing order. + title: Defines a tooltip for the element. + 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 of the component. + + Returns: + The component. + """ + ... + +area = Area.create +audio = Audio.create +image = img = Img.create +map = Map.create +track = Track.create +video = Video.create +embed = Embed.create +iframe = Iframe.create +object = Object.create +picture = Picture.create +portal = Portal.create +source = Source.create +svg = SVG() diff --git a/reflex/components/el/elements/metadata.py b/reflex/components/el/elements/metadata.py index 2ff25755e..983a8f3a0 100644 --- a/reflex/components/el/elements/metadata.py +++ b/reflex/components/el/elements/metadata.py @@ -1,8 +1,9 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" -from typing import 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 @@ -28,24 +29,49 @@ class Link(BaseHTML): # noqa: E742 tag = "link" + # Specifies the CORS settings for the linked resource cross_origin: Var[Union[str, int, bool]] + + # Specifies the URL of the linked document/resource href: Var[Union[str, int, bool]] + + # Specifies the language of the text in the linked document href_lang: Var[Union[str, int, bool]] + + # Allows a browser to check the fetched link for integrity integrity: Var[Union[str, int, bool]] + + # Specifies on what device the linked document will be displayed media: Var[Union[str, int, bool]] + + # Specifies the referrer policy of the linked document referrer_policy: Var[Union[str, int, bool]] + + # Specifies the relationship between the current document and the linked one rel: Var[Union[str, int, bool]] + + # Specifies the sizes of icons for visual media sizes: Var[Union[str, int, bool]] + + # Specifies the MIME type of the linked document type: Var[Union[str, int, bool]] class Meta(BaseHTML): # Inherits common attributes from BaseHTML """Display the meta element.""" - tag = "meta" + tag = "meta" # The HTML tag for this element is + + # Specifies the character encoding for the HTML document char_set: Var[Union[str, int, bool]] + + # Defines the content of the metadata content: Var[Union[str, int, bool]] + + # Provides an HTTP header for the information/value of the content attribute http_equiv: Var[Union[str, int, bool]] + + # Specifies a name for the metadata name: Var[Union[str, int, bool]] @@ -53,3 +79,22 @@ class Title(Element): # noqa: E742 """Display the title element.""" tag = "title" + + +# Had to be named with an underscore so it doesnt conflict with reflex.style Style in pyi +class StyleEl(Element): # noqa: E742 + """Display the style element.""" + + tag = "style" + + media: Var[Union[str, int, bool]] + + special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")] + + +base = Base.create +head = Head.create +link = Link.create +meta = Meta.create +title = Title.create +style = StyleEl.create diff --git a/reflex/components/el/elements/metadata.pyi b/reflex/components/el/elements/metadata.pyi index b9e126a6c..498695a80 100644 --- a/reflex/components/el/elements/metadata.pyi +++ b/reflex/components/el/elements/metadata.pyi @@ -1,15 +1,15 @@ """Stub file for reflex/components/el/elements/metadata.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Union from reflex.components.el.element import Element -from reflex.vars import Var as Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from .base import BaseHTML class Base(BaseHTML): @@ -18,102 +18,54 @@ class Base(BaseHTML): def create( # type: ignore cls, *children, - href: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Base": """Create the component. @@ -154,98 +106,52 @@ class Head(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Head": """Create the component. @@ -287,123 +193,78 @@ class Link(BaseHTML): cls, *children, cross_origin: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - href: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - href_lang: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - integrity: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - media: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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, + 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[str, int, bool]], Union[str, int, bool]] - ] = None, - rel: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - sizes: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Link": """Create the component. Args: *children: The children of the component. + cross_origin: Specifies the CORS settings for the linked resource + href: Specifies the URL of the linked document/resource + href_lang: Specifies the language of the text in the linked document + integrity: Allows a browser to check the fetched link for integrity + media: Specifies on what device the linked document will be displayed + referrer_policy: Specifies the referrer policy of the linked document + rel: Specifies the relationship between the current document and the linked one + sizes: Specifies the sizes of icons for visual media + type: Specifies the MIME type of the linked document access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -439,113 +300,65 @@ class Meta(BaseHTML): def create( # type: ignore cls, *children, - char_set: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - content: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - http_equiv: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Meta": """Create the component. Args: *children: The children of the component. + char_set: Specifies the character encoding for the HTML document + content: Defines the content of the metadata + http_equiv: Provides an HTTP header for the information/value of the content attribute + name: Specifies a name for the metadata access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -587,52 +400,22 @@ class Title(Element): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Title": """Create the component. @@ -650,3 +433,57 @@ class Title(Element): The component. """ ... + +class StyleEl(Element): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "StyleEl": + """Create the component. + + Args: + *children: The children of the component. + 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 of the component. + + Returns: + The component. + """ + ... + +base = Base.create +head = Head.create +link = Link.create +meta = Meta.create +title = Title.create +style = StyleEl.create diff --git a/reflex/components/el/elements/other.py b/reflex/components/el/elements/other.py index 26dbf6050..fa7c6cdec 100644 --- a/reflex/components/el/elements/other.py +++ b/reflex/components/el/elements/other.py @@ -1,7 +1,8 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -59,3 +60,12 @@ class Html(BaseHTML): # Specifies the URL of the document's cache manifest (obsolete in HTML5) manifest: Var[Union[str, int, bool]] + + +details = Details.create +dialog = Dialog.create +summary = Summary.create +slot = Slot.create +template = Template.create +math = Math.create +html = Html.create diff --git a/reflex/components/el/elements/other.pyi b/reflex/components/el/elements/other.pyi index ed89bd745..db884a78b 100644 --- a/reflex/components/el/elements/other.pyi +++ b/reflex/components/el/elements/other.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/el/elements/other.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Details(BaseHTML): @@ -17,99 +17,53 @@ class Details(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Details": """Create the component. @@ -151,99 +105,53 @@ class Dialog(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Dialog": """Create the component. @@ -285,98 +193,52 @@ class Summary(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Summary": """Create the component. @@ -417,98 +279,52 @@ class Slot(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Slot": """Create the component. @@ -549,98 +365,52 @@ class Template(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Template": """Create the component. @@ -681,98 +451,52 @@ class Math(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Math": """Create the component. @@ -813,101 +537,53 @@ class Html(BaseHTML): def create( # type: ignore cls, *children, - manifest: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Html": """Create the component. @@ -942,3 +618,11 @@ class Html(BaseHTML): The component. """ ... + +details = Details.create +dialog = Dialog.create +summary = Summary.create +slot = Slot.create +template = Template.create +math = Math.create +html = Html.create diff --git a/reflex/components/el/elements/scripts.py b/reflex/components/el/elements/scripts.py index a37a32494..b53306e02 100644 --- a/reflex/components/el/elements/scripts.py +++ b/reflex/components/el/elements/scripts.py @@ -1,7 +1,8 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -50,3 +51,8 @@ class Script(BaseHTML): # Specifies the MIME type of the script type: Var[Union[str, int, bool]] + + +canvas = Canvas.create +noscript = Noscript.create +script = Script.create diff --git a/reflex/components/el/elements/scripts.pyi b/reflex/components/el/elements/scripts.pyi index 79363df76..774fcfc22 100644 --- a/reflex/components/el/elements/scripts.pyi +++ b/reflex/components/el/elements/scripts.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/el/elements/scripts.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Canvas(BaseHTML): @@ -17,98 +17,52 @@ class Canvas(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Canvas": """Create the component. @@ -149,98 +103,52 @@ class Noscript(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Noscript": """Create the component. @@ -281,121 +189,65 @@ class Script(BaseHTML): def create( # type: ignore cls, *children, - async_: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - char_set: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - defer: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - integrity: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - language: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - src: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Script": """Create the component. @@ -438,3 +290,7 @@ class Script(BaseHTML): The component. """ ... + +canvas = Canvas.create +noscript = Noscript.create +script = Script.create diff --git a/reflex/components/el/elements/sectioning.py b/reflex/components/el/elements/sectioning.py index ce3549573..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 @@ -93,3 +91,20 @@ class Section(BaseHTML): # noqa: E742 """Display the section element.""" tag = "section" + + +address = Address.create +article = Article.create +aside = Aside.create +body = Body.create +header = Header.create +footer = Footer.create +h1 = H1.create +h2 = H2.create +h3 = H3.create +h4 = H4.create +h5 = H5.create +h6 = H6.create +main = Main.create +nav = Nav.create +section = Section.create diff --git a/reflex/components/el/elements/sectioning.pyi b/reflex/components/el/elements/sectioning.pyi index 26f663e66..963d2d651 100644 --- a/reflex/components/el/elements/sectioning.pyi +++ b/reflex/components/el/elements/sectioning.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/el/elements/sectioning.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Body(BaseHTML): @@ -16,98 +17,52 @@ class Body(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Body": """Create the component. @@ -148,98 +103,52 @@ class Address(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Address": """Create the component. @@ -280,98 +189,52 @@ class Article(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Article": """Create the component. @@ -412,98 +275,52 @@ class Aside(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Aside": """Create the component. @@ -544,98 +361,52 @@ class Footer(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Footer": """Create the component. @@ -676,98 +447,52 @@ class Header(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Header": """Create the component. @@ -808,98 +533,52 @@ class H1(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H1": """Create the component. @@ -940,98 +619,52 @@ class H2(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H2": """Create the component. @@ -1072,98 +705,52 @@ class H3(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H3": """Create the component. @@ -1204,98 +791,52 @@ class H4(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H4": """Create the component. @@ -1336,98 +877,52 @@ class H5(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H5": """Create the component. @@ -1468,98 +963,52 @@ class H6(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "H6": """Create the component. @@ -1600,98 +1049,52 @@ class Main(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Main": """Create the component. @@ -1732,98 +1135,52 @@ class Nav(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Nav": """Create the component. @@ -1864,98 +1221,52 @@ class Section(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Section": """Create the component. @@ -1989,3 +1300,19 @@ class Section(BaseHTML): The component. """ ... + +address = Address.create +article = Article.create +aside = Aside.create +body = Body.create +header = Header.create +footer = Footer.create +h1 = H1.create +h2 = H2.create +h3 = H3.create +h4 = H4.create +h5 = H5.create +h6 = H6.create +main = Main.create +nav = Nav.create +section = Section.create diff --git a/reflex/components/el/elements/tables.py b/reflex/components/el/elements/tables.py index 1277e1bea..8f6cfcba4 100644 --- a/reflex/components/el/elements/tables.py +++ b/reflex/components/el/elements/tables.py @@ -1,7 +1,8 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -124,3 +125,15 @@ class Tr(BaseHTML): # Alignment of the content within the table row align: Var[Union[str, int, bool]] + + +caption = Caption.create +col = Col.create +colgroup = Colgroup.create +table = Table.create +tbody = Tbody.create +td = Td.create +tfoot = Tfoot.create +th = Th.create +thead = Thead.create +tr = Tr.create diff --git a/reflex/components/el/elements/tables.pyi b/reflex/components/el/elements/tables.pyi index 6a81d3fad..4d874f460 100644 --- a/reflex/components/el/elements/tables.pyi +++ b/reflex/components/el/elements/tables.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/el/elements/tables.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Caption(BaseHTML): @@ -17,101 +17,53 @@ class Caption(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Caption": """Create the component. @@ -153,102 +105,54 @@ class Col(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - span: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Col": """Create the component. @@ -291,102 +195,54 @@ class Colgroup(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - span: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Colgroup": """Create the component. @@ -429,104 +285,54 @@ class Table(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - summary: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Table": """Create the component. @@ -569,101 +375,53 @@ class Tbody(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Tbody": """Create the component. @@ -705,110 +463,56 @@ class Td(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - col_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - headers: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - row_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Td": """Create the component. @@ -853,101 +557,53 @@ class Tfoot(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Tfoot": """Create the component. @@ -989,113 +645,57 @@ class Th(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - col_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - headers: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - row_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - scope: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Th": """Create the component. @@ -1141,101 +741,53 @@ class Thead(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Thead": """Create the component. @@ -1277,101 +829,53 @@ class Tr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Tr": """Create the component. @@ -1406,3 +910,14 @@ class Tr(BaseHTML): The component. """ ... + +caption = Caption.create +col = Col.create +colgroup = Colgroup.create +table = Table.create +tbody = Tbody.create +td = Td.create +tfoot = Tfoot.create +th = Th.create +thead = Thead.create +tr = Tr.create diff --git a/reflex/components/el/elements/typography.py b/reflex/components/el/elements/typography.py index f8e3769fa..7c55ecce7 100644 --- a/reflex/components/el/elements/typography.py +++ b/reflex/components/el/elements/typography.py @@ -1,7 +1,8 @@ """Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" + from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -124,3 +125,19 @@ class Del(BaseHTML): # Specifies the date and time of when the text was deleted. date_time: Var[Union[str, int, bool]] + + +blockquote = Blockquote.create +dd = Dd.create +div = Div.create +dl = Dl.create +dt = Dt.create +figcaption = Figcaption.create +hr = Hr.create +li = Li.create +ol = Ol.create +p = P.create +pre = Pre.create +ul = Ul.create +ins = Ins.create +del_ = Del.create # 'del' is a reserved keyword in Python diff --git a/reflex/components/el/elements/typography.pyi b/reflex/components/el/elements/typography.pyi index f6562cacc..548371ce6 100644 --- a/reflex/components/el/elements/typography.pyi +++ b/reflex/components/el/elements/typography.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/el/elements/typography.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var + from .base import BaseHTML class Blockquote(BaseHTML): @@ -17,99 +17,53 @@ class Blockquote(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Blockquote": """Create the component. @@ -151,98 +105,52 @@ class Dd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Dd": """Create the component. @@ -283,98 +191,52 @@ class Div(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Div": """Create the component. @@ -415,98 +277,52 @@ class Dl(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Dl": """Create the component. @@ -547,98 +363,52 @@ class Dt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Dt": """Create the component. @@ -679,98 +449,52 @@ class Figcaption(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Figcaption": """Create the component. @@ -811,101 +535,53 @@ class Hr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Hr": """Create the component. @@ -947,98 +623,52 @@ class Li(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Li": """Create the component. @@ -1079,99 +709,53 @@ class Menu(BaseHTML): def create( # type: ignore cls, *children, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Menu": """Create the component. @@ -1213,105 +797,55 @@ class Ol(BaseHTML): def create( # type: ignore cls, *children, - reversed: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - start: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Ol": """Create the component. @@ -1355,98 +889,52 @@ class P(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "P": """Create the component. @@ -1487,98 +975,52 @@ class Pre(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Pre": """Create the component. @@ -1619,98 +1061,52 @@ class Ul(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Ul": """Create the component. @@ -1751,102 +1147,54 @@ class Ins(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - date_time: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Ins": """Create the component. @@ -1889,102 +1237,54 @@ class Del(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - date_time: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Del": """Create the component. @@ -2020,3 +1320,18 @@ class Del(BaseHTML): The component. """ ... + +blockquote = Blockquote.create +dd = Dd.create +div = Div.create +dl = Dl.create +dt = Dt.create +figcaption = Figcaption.create +hr = Hr.create +li = Li.create +ol = Ol.create +p = P.create +pre = Pre.create +ul = Ul.create +ins = Ins.create +del_ = Del.create diff --git a/reflex/components/gridjs/datatable.py b/reflex/components/gridjs/datatable.py index 6c05dfd81..bd568d84a 100644 --- a/reflex/components/gridjs/datatable.py +++ b/reflex/components/gridjs/datatable.py @@ -6,17 +6,18 @@ from typing import Any, Dict, List, Union from reflex.components.component import Component from reflex.components.tags import Tag -from reflex.utils import imports, types +from reflex.utils import types +from reflex.utils.imports import ImportDict from reflex.utils.serializers import serialize -from reflex.vars import BaseVar, ComputedVar, Var +from reflex.vars.base import LiteralVar, Var, is_computed_var class Gridjs(Component): """A component that wraps a nivo bar component.""" - library = "gridjs-react@6.0.1" + library = "gridjs-react@6.1.1" - lib_dependencies: List[str] = ["gridjs@6.0.6"] + lib_dependencies: List[str] = ["gridjs@6.2.0"] class DataTable(Gridjs): @@ -64,14 +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) 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) + and is_computed_var(columns) and columns._var_type == Any ): raise ValueError( @@ -102,30 +103,31 @@ class DataTable(Gridjs): **props, ) - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - {"": {imports.ImportVar(tag="gridjs/dist/theme/mermaid.css")}}, - ) + def add_imports(self) -> ImportDict: + """Add the imports for the datatable component. + + Returns: + The import dict for the component. + """ + return {"": "gridjs/dist/theme/mermaid.css"} def _render(self) -> Tag: if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type): - self.columns = BaseVar( - _var_name=f"{self.data._var_name}.columns", + self.columns = self.data._replace( + _js_expr=f"{self.data._js_expr}.columns", _var_type=List[Any], - _var_full_name_needs_state_prefix=True, - )._replace(merge_var_data=self.data._var_data) - self.data = BaseVar( - _var_name=f"{self.data._var_name}.data", + ) + self.data = self.data._replace( + _js_expr=f"{self.data._js_expr}.data", _var_type=List[List[Any]], - _var_full_name_needs_state_prefix=True, - )._replace(merge_var_data=self.data._var_data) + ) 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"]) + if not isinstance(data, dict): + raise ValueError("Serialized dataframe should be a dict.") + 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 9a401b63f..ec4a5405a 100644 --- a/reflex/components/gridjs/datatable.pyi +++ b/reflex/components/gridjs/datatable.pyi @@ -1,18 +1,15 @@ """Stub file for reflex/components/gridjs/datatable.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Union from reflex.components.component import Component -from reflex.components.tags import Tag -from reflex.utils import imports, types -from reflex.utils.serializers import serialize -from reflex.vars import BaseVar, ComputedVar, Var +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var class Gridjs(Component): @overload @@ -26,52 +23,22 @@ class Gridjs(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Gridjs": """Create the component. @@ -97,63 +64,33 @@ 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[bool, Dict]], Union[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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataTable": """Create a datatable component. @@ -180,3 +117,5 @@ class DataTable(Gridjs): ValueError: If a pandas dataframe is passed in and columns are also provided. """ ... + + def add_imports(self) -> ImportDict: ... 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 f370185fa..661d91dbe 100644 --- a/reflex/components/lucide/icon.pyi +++ b/reflex/components/lucide/icon.pyi @@ -1,15 +1,14 @@ """Stub file for reflex/components/lucide/icon.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component -from reflex.utils import console, format -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class LucideIconComponent(Component): @overload @@ -23,52 +22,22 @@ class LucideIconComponent(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "LucideIconComponent": """Create the component. @@ -100,52 +69,22 @@ class Icon(LucideIconComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Icon": """Initialize the Icon component. @@ -171,115 +110,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 9ea4a11a7..b790bf7a1 100644 --- a/reflex/components/markdown/markdown.py +++ b/reflex/components/markdown/markdown.py @@ -7,7 +7,6 @@ from functools import lru_cache from hashlib import md5 from typing import Any, Callable, Dict, Union -from reflex.compiler import utils from reflex.components.component import Component, CustomComponent from reflex.components.radix.themes.layout.list import ( ListItem, @@ -18,25 +17,28 @@ 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.utils import imports, types -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.utils import types +from reflex.utils.imports import ImportDict, ImportVar +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import ARRAY_ISARRAY +from reflex.vars.number import ternary_operation # Special vars used in the component map. -_CHILDREN = Var.create_safe("children", _var_is_local=False) -_PROPS = Var.create_safe("...props", _var_is_local=False) -_MOCK_ARG = Var.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 = Var.create_safe("remarkMath", _var_is_local=False) -_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False) -_REMARK_UNWRAP_IMAGES = Var.create_safe("remarkUnwrapImages", _var_is_local=False) -_REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES]) +_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 = Var.create_safe("rehypeKatex", _var_is_local=False) -_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False) -_REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW]) +_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 NO_PROPS_TAGS = ("ul", "ol", "li") @@ -67,7 +69,7 @@ def get_base_component_map() -> dict[str, Callable]: "a": lambda value: Link.create(value), "code": lambda value: Code.create(value), "codeblock": lambda value, **props: CodeBlock.create( - value, margin_y="1em", **props + value, margin_y="1em", wrap_long_lines=True, **props ), } @@ -95,12 +97,16 @@ class Markdown(Component): *children: The children of the component. **props: The properties of the component. + Raises: + ValueError: If the children are not valid. + Returns: The markdown component. """ - assert ( - len(children) == 1 and types._isinstance(children[0], Union[str, Var]) - ), "Markdown component must have exactly one child containing the markdown source." + if len(children) != 1 or not types._isinstance(children[0], Union[str, Var]): + raise ValueError( + "Markdown component must have exactly one child containing the markdown source." + ) # Update the base component map with the custom component map. component_map = {**get_base_component_map(), **props.pop("component_map", {})} @@ -141,47 +147,41 @@ class Markdown(Component): return custom_components - def _get_imports(self) -> imports.ImportDict: - # Import here to avoid circular imports. - from reflex.components.datadisplay.code import CodeBlock + def add_imports(self) -> ImportDict | list[ImportDict]: + """Add imports for the markdown component. + + Returns: + The imports for the markdown component. + """ + from reflex.components.datadisplay.code import CodeBlock, Theme from reflex.components.radix.themes.typography.code import Code - imports = super()._get_imports() - - # Special markdown imports. - imports.update( + return [ { - "": [ImportVar(tag="katex/dist/katex.min.css")], - "remark-math@5.1.1": [ - ImportVar(tag=_REMARK_MATH._var_name, is_default=True) - ], - "remark-gfm@3.0.1": [ - ImportVar(tag=_REMARK_GFM._var_name, is_default=True) - ], - "remark-unwrap-images@4.0.0": [ - ImportVar(tag=_REMARK_UNWRAP_IMAGES._var_name, is_default=True) - ], - "rehype-katex@6.0.3": [ - ImportVar(tag=_REHYPE_KATEX._var_name, is_default=True) - ], - "rehype-raw@6.1.1": [ - ImportVar(tag=_REHYPE_RAW._var_name, is_default=True) - ], - } - ) - - # Get the imports for each component. - for component in self.component_map.values(): - imports = utils.merge_imports( - imports, component(_MOCK_ARG)._get_all_imports() - ) - - # Get the imports for the code components. - imports = utils.merge_imports( - imports, CodeBlock.create(theme="light")._get_imports() - ) - imports = utils.merge_imports(imports, Code.create()._get_imports()) - return imports + "": "katex/dist/katex.min.css", + "remark-math@5.1.1": ImportVar( + tag=_REMARK_MATH._js_expr, is_default=True + ), + "remark-gfm@3.0.1": ImportVar( + tag=_REMARK_GFM._js_expr, is_default=True + ), + "remark-unwrap-images@4.0.0": ImportVar( + tag=_REMARK_UNWRAP_IMAGES._js_expr, is_default=True + ), + "rehype-katex@6.0.3": ImportVar( + tag=_REHYPE_KATEX._js_expr, is_default=True + ), + "rehype-raw@6.1.1": ImportVar( + tag=_REHYPE_RAW._js_expr, is_default=True + ), + }, + *[ + component(_MOCK_ARG)._get_all_imports() # type: ignore + for component in self.component_map.values() + ], + CodeBlock.create(theme=Theme.light)._get_imports(), + Code.create()._get_imports(), + ] def get_component(self, tag: str, **props) -> Component: """Get the component for a tag and props. @@ -200,19 +200,27 @@ class Markdown(Component): if tag not in self.component_map: raise ValueError(f"No markdown component found for tag: {tag}.") - special_props = {_PROPS} - children = [_CHILDREN] + special_props = [_PROPS_IN_TAG] + children = [ + _CHILDREN + if tag != "codeblock" + # For codeblock, the mapping for some cases returns an array of elements. Let's join them into a string. + else ternary_operation( + ARRAY_ISARRAY.call(_CHILDREN), # type: ignore + _CHILDREN.to(list).join("\n"), + _CHILDREN, + ).to(str) + ] # 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)}")) + special_props.append(Var(_js_expr=f"children={{{str(children_prop)}}}")) children = [] - # Get the component. component = self.component_map[tag](*children, **props).set( special_props=special_props @@ -229,21 +237,24 @@ class Markdown(Component): Returns: The formatted component. """ - return str(self.get_component(tag, **props)).replace("\n", " ") + 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) {{ @@ -259,9 +270,10 @@ class Markdown(Component): return inline ? ( {self.format_component("code")} ) : ( - {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False))} + {self.format_component("codeblock", language=Var(_js_expr="language", _var_type=str))} ); - }}}}""".replace("\n", " ") + }})""".replace("\n", " ") + ) return components @@ -286,7 +298,7 @@ class Markdown(Component): function {self._get_component_map_name()} () {{ {formatted_hooks} return ( - {str(Var.create(self.format_component_map()))} + {str(LiteralVar.create(self.format_component_map()))} ) }} """ @@ -298,14 +310,8 @@ class Markdown(Component): .add_props( remark_plugins=_REMARK_PLUGINS, rehype_plugins=_REHYPE_PLUGINS, + components=Var(_js_expr=f"{self._get_component_map_name()}()"), ) .remove_props("componentMap", "componentMapHash") ) - tag.special_props.add( - Var.create_safe( - f"components={{{self._get_component_map_name()}()}}", - _var_is_local=True, - _var_is_string=False, - ), - ) return tag diff --git a/reflex/components/markdown/markdown.pyi b/reflex/components/markdown/markdown.pyi index 9ca8b11b0..1cad04013 100644 --- a/reflex/components/markdown/markdown.pyi +++ b/reflex/components/markdown/markdown.pyi @@ -1,41 +1,28 @@ """Stub file for reflex/components/markdown/markdown.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -import textwrap from functools import lru_cache -from hashlib import md5 -from typing import Any, Callable, Dict, Union -from reflex.compiler import utils -from reflex.components.component import Component, CustomComponent -from reflex.components.radix.themes.layout.list import ( - ListItem, - OrderedList, - UnorderedList, -) -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.utils import imports, types -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from typing import Any, Callable, Dict, Optional, Union, overload -_CHILDREN = Var.create_safe("children", _var_is_local=False) -_PROPS = Var.create_safe("...props", _var_is_local=False) -_MOCK_ARG = Var.create_safe("") -_REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False) -_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False) -_REMARK_UNWRAP_IMAGES = Var.create_safe("remarkUnwrapImages", _var_is_local=False) -_REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES]) -_REHYPE_KATEX = Var.create_safe("rehypeKatex", _var_is_local=False) -_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False) -_REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW]) +from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import LiteralVar, Var + +_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 = Var(_js_expr="rehypeKatex") +_REHYPE_RAW = Var(_js_expr="rehypeRaw") +_REHYPE_PLUGINS = LiteralVar.create([_REHYPE_KATEX, _REHYPE_RAW]) NO_PROPS_TAGS = ("ul", "ol", "li") @lru_cache @@ -55,52 +42,22 @@ class Markdown(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Markdown": """Create a markdown component. @@ -116,10 +73,15 @@ class Markdown(Component): custom_attrs: custom attribute **props: The properties of the component. + Raises: + ValueError: If the children are not valid. + Returns: The 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/media/__init__.py b/reflex/components/media/__init__.py deleted file mode 100644 index ee11c77e0..000000000 --- a/reflex/components/media/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Temporary shim for Chakra icon class.""" diff --git a/reflex/components/media/icon.py b/reflex/components/media/icon.py deleted file mode 100644 index c60905083..000000000 --- a/reflex/components/media/icon.py +++ /dev/null @@ -1,2 +0,0 @@ -"""Shim for reflex.components.chakra.media.icon.""" -from reflex.components.chakra.media.icon import * diff --git a/reflex/components/moment/__init__.py b/reflex/components/moment/__init__.py index f144680fe..9f4987c56 100644 --- a/reflex/components/moment/__init__.py +++ b/reflex/components/moment/__init__.py @@ -1,5 +1,5 @@ """Moment.js component.""" -from .moment import Moment +from .moment import Moment, MomentDelta moment = Moment.create diff --git a/reflex/components/moment/moment.py b/reflex/components/moment/moment.py index 53e199c4e..4ac835b35 100644 --- a/reflex/components/moment/moment.py +++ b/reflex/components/moment/moment.py @@ -1,25 +1,27 @@ """Moment component for humanized date rendering.""" -from typing import Any, Dict, List, Optional +import dataclasses +from typing import List, Optional -from reflex.base import Base -from reflex.components.component import Component, NoSSRComponent -from reflex.utils import imports -from reflex.vars import Var +from reflex.components.component import NoSSRComponent +from reflex.event import EventHandler, identity_event +from reflex.utils.imports import ImportDict +from reflex.vars.base import LiteralVar, 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): @@ -90,38 +92,27 @@ class Moment(NoSSRComponent): # Display the date in the given timezone. tz: Var[str] - def _get_imports(self) -> imports.ImportDict: - merged_imports = super()._get_imports() + # The locale to use when rendering. + locale: Var[str] + + # Fires when the date changes. + on_change: EventHandler[identity_event(str)] + + def add_imports(self) -> ImportDict: + """Add the imports for the Moment component. + + Returns: + The import dict for the component. + """ + imports = {} + + if isinstance(self.locale, LiteralVar): + imports[""] = f"moment/locale/{self.locale._var_value}" + elif self.locale is not None: + # If the user is using a variable for the locale, we can't know the + # value at compile time so import all locales available. + imports[""] = "moment/min/locales" if self.tz is not None: - merged_imports = imports.merge_imports( - merged_imports, - {"moment-timezone": {imports.ImportVar(tag="")}}, - ) - return merged_imports + imports["moment-timezone"] = "" - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - "on_change": lambda date: [date], - } - - @classmethod - def create(cls, *children, **props) -> Component: - """Create a Moment component. - - Args: - *children: The children of the component. - **props: The properties of the component. - - Returns: - The Moment Component. - """ - comp = super().create(*children, **props) - if "tz" in props: - comp.lib_dependencies.append("moment-timezone") - return comp + return imports diff --git a/reflex/components/moment/moment.pyi b/reflex/components/moment/moment.pyi index 73ad8ca5d..16221ff63 100644 --- a/reflex/components/moment/moment.pyi +++ b/reflex/components/moment/moment.pyi @@ -1,19 +1,19 @@ """Stub file for reflex/components/moment/moment.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +import dataclasses +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.component import NoSSRComponent +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Optional -from reflex.base import Base -from reflex.components.component import Component, NoSSRComponent -from reflex.utils import imports -from reflex.vars import Var +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var -class MomentDelta(Base): +@dataclasses.dataclass(frozen=True) +class MomentDelta: years: Optional[int] quarters: Optional[int] months: Optional[int] @@ -25,7 +25,7 @@ class MomentDelta(Base): milliseconds: Optional[int] class Moment(NoSSRComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... + def add_imports(self) -> ImportDict: ... @overload @classmethod def create( # type: ignore @@ -35,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, @@ -51,63 +51,32 @@ class Moment(NoSSRComponent): unix: Optional[Union[Var[bool], bool]] = None, local: Optional[Union[Var[bool], bool]] = None, tz: Optional[Union[Var[str], str]] = None, + locale: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Moment": - """Create a Moment component. + """Create the component. Args: *children: The children of the component. @@ -131,15 +100,17 @@ class Moment(NoSSRComponent): unix: Tells Moment to parse the given date value as a unix timestamp. local: Outputs the result in local time. tz: Display the date in the given timezone. + locale: The locale to use when rendering. + on_change: Fires when the date changes. 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 properties of the component. + **props: The props of the component. Returns: - The Moment Component. + The component. """ ... diff --git a/reflex/components/next/base.py b/reflex/components/next/base.py index f962497d3..1dd3db437 100644 --- a/reflex/components/next/base.py +++ b/reflex/components/next/base.py @@ -1,4 +1,5 @@ """Base for NextJS components.""" + from reflex.components.component import Component diff --git a/reflex/components/next/base.pyi b/reflex/components/next/base.pyi index d18610e16..1d49c5e66 100644 --- a/reflex/components/next/base.pyi +++ b/reflex/components/next/base.pyi @@ -1,13 +1,14 @@ """Stub file for reflex/components/next/base.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class NextComponent(Component): ... @@ -23,52 +24,22 @@ class NextComponent(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "NextComponent": """Create the component. diff --git a/reflex/components/next/image.py b/reflex/components/next/image.py index 10556d5ad..fe74b0935 100644 --- a/reflex/components/next/image.py +++ b/reflex/components/next/image.py @@ -1,9 +1,10 @@ """Image component from next/image.""" -from typing import Any, Dict, Literal, Optional, Union +from typing import Any, Literal, Optional, Union +from reflex.event import EventHandler, empty_event from reflex.utils import types -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent @@ -54,17 +55,11 @@ class Image(NextComponent): # A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur". blurDataURL: Var[str] - def get_event_triggers(self) -> Dict[str, Any]: - """The event triggers of the component. + # Fires when the image has loaded. + on_load: EventHandler[empty_event] - Returns: - The dict describing the event triggers. - """ - return { - **super().get_event_triggers(), - "on_load": lambda: [], - "on_error": lambda: [], - } + # Fires when the image has an error. + on_error: EventHandler[empty_event] @classmethod def create( @@ -107,8 +102,4 @@ class Image(NextComponent): # mysteriously, following `sizes` prop is needed to avoid blury images. props["sizes"] = "100vw" - src = props.get("src", None) - if src is not None and not isinstance(src, (Var)): - props["src"] = Var.create(value=src, _var_is_string=True) - return super().create(*children, **props) diff --git a/reflex/components/next/image.pyi b/reflex/components/next/image.pyi index c1ee16374..405f8ac52 100644 --- a/reflex/components/next/image.pyi +++ b/reflex/components/next/image.pyi @@ -1,36 +1,34 @@ """Stub file for reflex/components/next/image.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, Literal, Optional, Union -from reflex.utils import types -from reflex.vars import Var +from reflex.vars.base import Var + from .base import NextComponent class Image(NextComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - width: Optional[Union[str, int]] = None, - height: Optional[Union[str, int]] = None, - src: Optional[Union[Var[Any], Any]] = None, + width: Optional[Union[int, str]] = None, + height: Optional[Union[int, str]] = 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, @@ -39,58 +37,24 @@ class Image(NextComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_error: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_load: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Image": """Create an Image component from next/image. @@ -108,6 +72,8 @@ class Image(NextComponent): placeholder: A placeholder to use while the image is loading. Possible values are blur, empty, or data:image/.... Defaults to empty. loading: Allows passing CSS styles to the underlying image element. style: Var[Any] The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead. blurDataURL: A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur". + on_load: Fires when the image has loaded. + on_error: Fires when the image has an error. style: The style of the component. key: A unique key for the component. id: The id for the component. 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 e382febdd..fa9ae530f 100644 --- a/reflex/components/next/link.pyi +++ b/reflex/components/next/link.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/next/link.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class NextLink(Component): @overload @@ -24,52 +24,22 @@ class NextLink(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "NextLink": """Create the component. 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 64abc76d0..f8c93b6f1 100644 --- a/reflex/components/next/video.pyi +++ b/reflex/components/next/video.pyi @@ -1,15 +1,15 @@ """Stub file for reflex/components/next/video.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional from reflex.components.component import Component -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from .base import NextComponent class Video(NextComponent): @@ -26,52 +26,22 @@ class Video(NextComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Video": """Create a Video component. diff --git a/reflex/components/plotly/plotly.py b/reflex/components/plotly/plotly.py index 7a0dd835f..c93488d40 100644 --- a/reflex/components/plotly/plotly.py +++ b/reflex/components/plotly/plotly.py @@ -1,45 +1,279 @@ """Component for displaying a plotly graph.""" +from __future__ import annotations + from typing import Any, Dict, List -from reflex.components.component import NoSSRComponent -from reflex.vars import Var +from reflex.base import Base +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.base import LiteralVar, Var try: - from plotly.graph_objects import Figure + from plotly.graph_objects import Figure, layout + + Template = layout.Template except ImportError: + console.warn("Plotly is not installed. Please run `pip install plotly`.") Figure = Any # type: ignore + Template = Any # type: ignore -class PlotlyLib(NoSSRComponent): - """A component that wraps a plotly lib.""" +def _event_data_signature(e0: Var) -> List[Any]: + """For plotly events with event data and no points. + + Args: + e0: The event data. + + Returns: + The event key extracted from the event data (if defined). + """ + return [Var(_js_expr=f"{e0}?.event")] + + +def _event_points_data_signature(e0: Var) -> List[Any]: + """For plotly events with event data containing a point array. + + Args: + e0: The event data. + + Returns: + The event data and the extracted points. + """ + return [ + Var(_js_expr=f"{e0}?.event"), + Var(_js_expr=f"extractPoints({e0}?.points)"), + ] + + +class _ButtonClickData(Base): + """Event data structure for plotly UI buttons.""" + + menu: Any + button: Any + active: Any + + +def _button_click_signature(e0: _ButtonClickData) -> List[Any]: + """For plotly button click events. + + Args: + e0: The button click data. + + Returns: + The menu, button, and active state. + """ + return [e0.menu, e0.button, e0.active] + + +def _passthrough_signature(e0: Var) -> List[Any]: + """For plotly events with arbitrary serializable data, passed through directly. + + Args: + e0: The event data. + + Returns: + The event data. + """ + return [e0] + + +def _null_signature() -> List[Any]: + """For plotly events with no data or non-serializable data. Nothing passed through. + + Returns: + An empty list (nothing passed through). + """ + return [] + + +class Plotly(NoSSRComponent): + """Display a plotly graph.""" library = "react-plotly.js@2.6.0" - lib_dependencies: List[str] = ["plotly.js@2.22.0"] - - -class Plotly(PlotlyLib): - """Display a plotly graph.""" + lib_dependencies: List[str] = ["plotly.js@2.35.2"] tag = "Plot" 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] # type: ignore + # The config of the graph. config: Var[Dict] - # The width of the graph. - width: Var[str] - - # The height of the graph. - height: Var[str] - # If true, the graph will resize when the window is resized. - use_resize_handler: Var[bool] + use_resize_handler: Var[bool] = LiteralVar.create(True) + + # Fired after the plot is redrawn. + on_after_plot: EventHandler[_passthrough_signature] + + # Fired after the plot was animated. + on_animated: EventHandler[_null_signature] + + # Fired while animating a single frame (does not currently pass data through). + on_animating_frame: EventHandler[_null_signature] + + # Fired when an animation is interrupted (to start a new animation for example). + on_animation_interrupted: EventHandler[_null_signature] + + # Fired when the plot is responsively sized. + on_autosize: EventHandler[_event_data_signature] + + # Fired whenever mouse moves over a plot. + on_before_hover: EventHandler[_event_data_signature] + + # Fired when a plotly UI button is clicked. + on_button_clicked: EventHandler[_button_click_signature] + + # Fired when the plot is clicked. + on_click: EventHandler[_event_points_data_signature] + + # Fired when a selection is cleared (via double click). + on_deselect: EventHandler[_null_signature] + + # Fired when the plot is double clicked. + on_double_click: EventHandler[_passthrough_signature] + + # Fired when a plot element is hovered over. + on_hover: EventHandler[_event_points_data_signature] + + # Fired after the plot is layed out (zoom, pan, etc). + on_relayout: EventHandler[_passthrough_signature] + + # Fired while the plot is being layed out. + on_relayouting: EventHandler[_passthrough_signature] + + # Fired after the plot style is changed. + on_restyle: EventHandler[_passthrough_signature] + + # Fired after the plot is redrawn. + on_redraw: EventHandler[_event_data_signature] + + # Fired after selecting plot elements. + on_selected: EventHandler[_event_points_data_signature] + + # Fired while dragging a selection. + on_selecting: EventHandler[_event_points_data_signature] + + # Fired while an animation is occuring. + on_transitioning: EventHandler[_event_data_signature] + + # Fired when a transition is stopped early. + on_transition_interrupted: EventHandler[_event_data_signature] + + # Fired when a hovered element is no longer hovered. + on_unhover: EventHandler[_event_points_data_signature] + + def add_imports(self) -> dict[str, str]: + """Add imports for the plotly component. + + Returns: + The imports for the plotly component. + """ + return { + # For merging plotly data/layout/templates. + "mergician@v2.0.2": "mergician" + } + + def add_custom_code(self) -> list[str]: + """Add custom codes for processing the plotly points data. + + Returns: + Custom code snippets for the module level. + """ + return [ + "const removeUndefined = (obj) => {Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key]); return obj}", + """ +const extractPoints = (points) => { + if (!points) return []; + return points.map(point => { + const bbox = point.bbox ? removeUndefined({ + x0: point.bbox.x0, + x1: point.bbox.x1, + y0: point.bbox.y0, + y1: point.bbox.y1, + z0: point.bbox.y0, + z1: point.bbox.y1, + }) : undefined; + return removeUndefined({ + x: point.x, + y: point.y, + z: point.z, + lat: point.lat, + lon: point.lon, + curveNumber: point.curveNumber, + pointNumber: point.pointNumber, + pointNumbers: point.pointNumbers, + pointIndex: point.pointIndex, + 'marker.color': point['marker.color'], + 'marker.size': point['marker.size'], + bbox: bbox, + }) + }) +} +""", + ] + + @classmethod + def create(cls, *children, **props) -> Component: + """Create the Plotly component. + + Args: + *children: The children of the component. + **props: The properties of the component. + + Returns: + The Plotly component. + """ + from plotly.io import templates + + responsive_template = color_mode_cond( + 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 + responsive_template = responsive_template.to(Template) + props.setdefault("template", responsive_template) + return super().create(*children, **props) + + def _exclude_props(self) -> set[str]: + # These props are handled specially in the _render function + return {"data", "layout", "template"} + + def _render(self): + tag = super()._render() + figure = self.data.to(dict) + merge_dicts = [] # Data will be merged and spread from these dict Vars + if self.layout is not None: + # 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 = LiteralVar.create({"layout": self.layout}) + merge_dicts.append(layout_dict) + if self.template is not None: + template_dict = LiteralVar.create({"layout": {"template": self.template}}) + merge_dicts.append(template_dict.without_data()) + if merge_dicts: + tag.special_props.append( + # Merge all dictionaries and spread the result over props. + 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.append(Var(_js_expr=f"{{...{str(figure)}}}")) + return tag diff --git a/reflex/components/plotly/plotly.pyi b/reflex/components/plotly/plotly.pyi index 7c8068e1e..186b78a68 100644 --- a/reflex/components/plotly/plotly.pyi +++ b/reflex/components/plotly/plotly.pyi @@ -1,108 +1,43 @@ """Stub file for reflex/components/plotly/plotly.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List +from reflex.base import Base from reflex.components.component import NoSSRComponent -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.utils import console +from reflex.vars.base import Var try: - from plotly.graph_objects import Figure # type: ignore + from plotly.graph_objects import Figure, layout + + Template = layout.Template except ImportError: - Figure = Any # type: ignore + console.warn("Plotly is not installed. Please run `pip install plotly`.") + Figure = Any + Template = Any -class PlotlyLib(NoSSRComponent): +class _ButtonClickData(Base): + menu: Any + button: Any + active: Any + +class Plotly(NoSSRComponent): + def add_imports(self) -> dict[str, str]: ... + def add_custom_code(self) -> list[str]: ... @overload @classmethod def create( # type: ignore cls, *children, - 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props - ) -> "PlotlyLib": - """Create the component. - - Args: - *children: The children of the component. - 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 of the component. - - Returns: - The component. - """ - ... - -class Plotly(PlotlyLib): - @overload - @classmethod - def create( # type: ignore - cls, - *children, - data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore - layout: Optional[Union[Var[Dict], Dict]] = None, - config: Optional[Union[Var[Dict], Dict]] = None, - width: Optional[Union[Var[str], str]] = None, - height: Optional[Union[Var[str], str]] = 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, @@ -110,72 +45,79 @@ class Plotly(PlotlyLib): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_after_plot: Optional[EventType] = None, + on_animated: Optional[EventType] = None, + on_animating_frame: Optional[EventType] = None, + on_animation_interrupted: Optional[EventType] = None, + on_autosize: Optional[EventType] = None, + on_before_hover: Optional[EventType] = None, + on_blur: Optional[EventType[[]]] = None, + on_button_clicked: Optional[EventType] = None, + on_click: Optional[EventType] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_deselect: Optional[EventType] = None, + on_double_click: Optional[EventType] = None, + on_focus: Optional[EventType[[]]] = None, + on_hover: Optional[EventType] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_redraw: Optional[EventType] = None, + on_relayout: Optional[EventType] = None, + on_relayouting: Optional[EventType] = None, + on_restyle: Optional[EventType] = None, + on_scroll: Optional[EventType[[]]] = None, + on_selected: Optional[EventType] = None, + on_selecting: Optional[EventType] = None, + on_transition_interrupted: Optional[EventType] = None, + on_transitioning: Optional[EventType] = None, + on_unhover: Optional[EventType] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Plotly": - """Create the component. + """Create the Plotly component. Args: *children: The children of the component. data: The figure to display. This can be a plotly figure or a plotly data json. layout: The layout of the graph. + template: The template for visual appearance of the graph. config: The config of the graph. - width: The width of the graph. - height: The height of the graph. use_resize_handler: If true, the graph will resize when the window is resized. + on_after_plot: Fired after the plot is redrawn. + on_animated: Fired after the plot was animated. + on_animating_frame: Fired while animating a single frame (does not currently pass data through). + on_animation_interrupted: Fired when an animation is interrupted (to start a new animation for example). + on_autosize: Fired when the plot is responsively sized. + on_before_hover: Fired whenever mouse moves over a plot. + on_button_clicked: Fired when a plotly UI button is clicked. + on_click: Fired when the plot is clicked. + on_deselect: Fired when a selection is cleared (via double click). + on_double_click: Fired when the plot is double clicked. + on_hover: Fired when a plot element is hovered over. + on_relayout: Fired after the plot is layed out (zoom, pan, etc). + on_relayouting: Fired while the plot is being layed out. + on_restyle: Fired after the plot style is changed. + on_redraw: Fired after the plot is redrawn. + on_selected: Fired after selecting plot elements. + on_selecting: Fired while dragging a selection. + on_transitioning: Fired while an animation is occuring. + on_transition_interrupted: Fired when a transition is stopped early. + on_unhover: Fired when a hovered element is no longer hovered. 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 of the component. + **props: The properties of the component. Returns: - The component. + The Plotly component. """ ... diff --git a/reflex/components/props.py b/reflex/components/props.py new file mode 100644 index 000000000..adce134fc --- /dev/null +++ b/reflex/components/props.py @@ -0,0 +1,76 @@ +"""A class that holds props to be passed or applied to a component.""" + +from __future__ import annotations + +from pydantic import ValidationError + +from reflex.base import Base +from reflex.utils import format +from reflex.utils.exceptions import InvalidPropValueError +from reflex.vars.object import LiteralObjectVar + + +class PropsBase(Base): + """Base for a class containing props that can be serialized as a JS object.""" + + def json(self) -> str: + """Convert the object to a json-like string. + + Vars will be unwrapped so they can represent actual JS var names and functions. + + Keys will be converted to camelCase. + + Returns: + The object as a Javascript Object literal. + """ + 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() + } + + +class NoExtrasAllowedProps(Base): + """A class that holds props to be passed or applied to a component with no extra props allowed.""" + + def __init__(self, component_name=None, **kwargs): + """Initialize the props. + + Args: + component_name: The custom name of the component. + kwargs: Kwargs to initialize the props. + + Raises: + InvalidPropValueError: If invalid props are passed on instantiation. + """ + component_name = component_name or type(self).__name__ + try: + super().__init__(**kwargs) + except ValidationError as e: + invalid_fields = ", ".join([error["loc"][0] for error in e.errors()]) # type: ignore + supported_props_str = ", ".join(f'"{field}"' for field in self.get_fields()) + raise InvalidPropValueError( + f"Invalid prop(s) {invalid_fields} for {component_name!r}. Supported props are {supported_props_str}" + ) from None + + class Config: + """Pydantic config.""" + + arbitrary_types_allowed = True + use_enum_values = True + extra = "forbid" diff --git a/reflex/components/radix/__init__.py b/reflex/components/radix/__init__.py index 08d1dcfef..6b1673b88 100644 --- a/reflex/components/radix/__init__.py +++ b/reflex/components/radix/__init__.py @@ -1,4 +1,17 @@ """Namespace for components provided by @radix-ui packages.""" -from .primitives import * -from .themes import * +from __future__ import annotations + +from reflex import RADIX_MAPPING +from reflex.utils import lazy_loader + +_SUBMODULES: set[str] = {"themes", "primitives"} + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "".join(k.split("components.radix.")[-1]): v for k, v in RADIX_MAPPING.items() +} +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/__init__.pyi b/reflex/components/radix/__init__.pyi new file mode 100644 index 000000000..f4e81666a --- /dev/null +++ b/reflex/components/radix/__init__.pyi @@ -0,0 +1,70 @@ +"""Stub file for reflex/components/radix/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import primitives as primitives +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 .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 +from .themes.components.alert_dialog import alert_dialog as alert_dialog +from .themes.components.aspect_ratio import aspect_ratio as aspect_ratio +from .themes.components.avatar import avatar as avatar +from .themes.components.badge import badge as badge +from .themes.components.button import button as button +from .themes.components.callout import callout as callout +from .themes.components.card import card as card +from .themes.components.checkbox import checkbox as checkbox +from .themes.components.checkbox_cards import checkbox_cards as checkbox_cards +from .themes.components.checkbox_group import checkbox_group as checkbox_group +from .themes.components.context_menu import context_menu as context_menu +from .themes.components.data_list import data_list as data_list +from .themes.components.dialog import dialog as dialog +from .themes.components.dropdown_menu import dropdown_menu as dropdown_menu +from .themes.components.dropdown_menu import menu as menu +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 +from .themes.components.scroll_area import scroll_area as scroll_area +from .themes.components.segmented_control import segmented_control as segmented_control +from .themes.components.select import select as select +from .themes.components.separator import divider as divider +from .themes.components.separator import separator as separator +from .themes.components.skeleton import skeleton as skeleton +from .themes.components.slider import slider as slider +from .themes.components.spinner import spinner as spinner +from .themes.components.switch import switch as switch +from .themes.components.table import table as table +from .themes.components.tabs import tabs as tabs +from .themes.components.text_area import text_area as text_area +from .themes.components.text_field import input as input +from .themes.components.text_field import text_field as text_field +from .themes.components.tooltip import tooltip as tooltip +from .themes.layout.box import box as box +from .themes.layout.center import center as center +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 +from .themes.layout.spacer import spacer as spacer +from .themes.layout.stack import hstack as hstack +from .themes.layout.stack import stack as stack +from .themes.layout.stack import vstack as vstack +from .themes.typography.blockquote import blockquote as blockquote +from .themes.typography.code import code as code +from .themes.typography.heading import heading as heading +from .themes.typography.link import link as link +from .themes.typography.text import text as text diff --git a/reflex/components/radix/primitives/__init__.py b/reflex/components/radix/primitives/__init__.py index 23070044e..fc45e7e19 100644 --- a/reflex/components/radix/primitives/__init__.py +++ b/reflex/components/radix/primitives/__init__.py @@ -1,7 +1,16 @@ """Radix primitive components (https://www.radix-ui.com/primitives).""" -from .accordion import accordion -from .drawer import drawer -from .form import form -from .progress import progress -from .slider import slider +from __future__ import annotations + +from reflex import RADIX_PRIMITIVES_MAPPING +from reflex.utils import lazy_loader + +_SUBMOD_ATTRS: dict[str, list[str]] = { + "".join(k.split("components.radix.primitives.")[-1]): v + for k, v in RADIX_PRIMITIVES_MAPPING.items() +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/primitives/__init__.pyi b/reflex/components/radix/primitives/__init__.pyi new file mode 100644 index 000000000..e7461e9a7 --- /dev/null +++ b/reflex/components/radix/primitives/__init__.pyi @@ -0,0 +1,9 @@ +"""Stub file for reflex/components/radix/primitives/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .accordion import accordion as accordion +from .drawer import drawer as drawer +from .form import form as form +from .progress import progress as progress diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index 9cadfb35d..272274723 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Any, List, Literal, Tuple, Union from reflex.components.component import Component, ComponentNamespace from reflex.components.core.colors import color @@ -10,9 +10,10 @@ from reflex.components.core.cond import cond 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.style import Style -from reflex.utils import imports -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"] @@ -59,7 +60,7 @@ class AccordionComponent(RadixPrimitiveComponent): # The variant of the component. variant: Var[LiteralAccordionVariant] - def add_style(self) -> Style | None: + def add_style(self): """Add style to the component.""" if self.color_scheme is not None: self.custom_attrs["data-accent-color"] = self.color_scheme @@ -70,6 +71,18 @@ class AccordionComponent(RadixPrimitiveComponent): return ["color_scheme", "variant"] +def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: + """Handle the on_value_change event. + + Args: + value: The value of the event. + + Returns: + The value of the event. + """ + return (value,) + + class AccordionRoot(AccordionComponent): """An accordion component.""" @@ -102,16 +115,19 @@ class AccordionRoot(AccordionComponent): radius: Var[LiteralRadius] # The time in milliseconds to animate open and close - duration: Var[int] = Var.create_safe(DEFAULT_ANIMATION_DURATION) + duration: Var[int] = LiteralVar.create(DEFAULT_ANIMATION_DURATION) # The easing function to use for the animation. - easing: Var[str] = Var.create_safe(DEFAULT_ANIMATION_EASING) + easing: Var[str] = LiteralVar.create(DEFAULT_ANIMATION_EASING) # Whether to show divider lines between items. show_dividers: Var[bool] _valid_children: List[str] = ["AccordionItem"] + # Fired when the opened the accordions changes. + on_value_change: EventHandler[on_value_change] + def _exclude_props(self) -> list[str]: return super()._exclude_props() + [ "radius", @@ -120,17 +136,6 @@ class AccordionRoot(AccordionComponent): "show_dividers", ] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - "on_value_change": lambda e0: [e0], - } - def add_style(self): """Add style to the component. @@ -188,6 +193,11 @@ class AccordionItem(AccordionComponent): # When true, prevents the user from interacting with the item. disabled: Var[bool] + # The header of the accordion item. + header: Var[Union[Component, str]] + # The content of the accordion item. + content: Var[Union[Component, str]] = Var.create(None) + _valid_children: List[str] = [ "AccordionHeader", "AccordionTrigger", @@ -200,21 +210,20 @@ class AccordionItem(AccordionComponent): def create( cls, *children, - header: Optional[Component | Var] = None, - content: Optional[Component | Var] = None, **props, ) -> Component: """Create an accordion item. Args: *children: The list of children to use if header and content are not provided. - header: The header of the accordion item. - content: The content of the accordion item. **props: Additional properties to apply to the accordion item. Returns: The accordion item. """ + header = props.pop("header", None) + content = props.pop("content", None) + # The item requires a value to toggle (use a random unique name if not provided). value = props.pop("value", get_uuid_string_var()) @@ -250,43 +259,44 @@ class AccordionItem(AccordionComponent): return super().create(*children, value=value, **props, class_name=cls_name) - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ divider_style = f"var(--divider-px) solid {color('gray', 6, alpha=True)}" - return Style( - { - "overflow": "hidden", - "width": "100%", - "margin_top": "1px", + return { + "overflow": "hidden", + "width": "100%", + "margin_top": "1px", + "border_top": divider_style, + "&:first-child": { + "margin_top": 0, + "border_top": 0, + "border_top_left_radius": "var(--radius-4)", + "border_top_right_radius": "var(--radius-4)", + }, + "&:last-child": { + "border_bottom_left_radius": "var(--radius-4)", + "border_bottom_right_radius": "var(--radius-4)", + }, + "&:focus-within": { + "position": "relative", + "z_index": 1, + }, + _inherited_variant_selector("ghost", "&:first-child"): { + "border_radius": 0, "border_top": divider_style, - "&:first-child": { - "margin_top": 0, - "border_top": 0, - "border_top_left_radius": "var(--radius-4)", - "border_top_right_radius": "var(--radius-4)", - }, - "&:last-child": { - "border_bottom_left_radius": "var(--radius-4)", - "border_bottom_right_radius": "var(--radius-4)", - }, - "&:focus-within": { - "position": "relative", - "z_index": 1, - }, - _inherited_variant_selector("ghost", "&:first-child"): { - "border_radius": 0, - "border_top": divider_style, - }, - _inherited_variant_selector("ghost", "&:last-child"): { - "border_radius": 0, - "border_bottom": divider_style, - }, - } - ) + }, + _inherited_variant_selector("ghost", "&:last-child"): { + "border_radius": 0, + "border_bottom": divider_style, + }, + } + + def _exclude_props(self) -> list[str]: + return ["header", "content"] class AccordionHeader(AccordionComponent): @@ -314,13 +324,13 @@ class AccordionHeader(AccordionComponent): return super().create(*children, class_name=cls_name, **props) - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style({"display": "flex"}) + return {"display": "flex"} class AccordionTrigger(AccordionComponent): @@ -348,44 +358,42 @@ class AccordionTrigger(AccordionComponent): return super().create(*children, class_name=cls_name, **props) - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "color": color("accent", 11), - "font_size": "1.1em", - "line_height": 1, - "justify_content": "space-between", - "align_items": "center", - "flex": 1, - "display": "flex", - "padding": "var(--space-3) var(--space-4)", - "width": "100%", - "box_shadow": f"0 var(--divider-px) 0 {color('gray', 6, alpha=True)}", - "&[data-state='open'] > .AccordionChevron": { - "transform": "rotate(180deg)", - }, + return { + "color": color("accent", 11), + "font_size": "1.1em", + "line_height": 1, + "justify_content": "space-between", + "align_items": "center", + "flex": 1, + "display": "flex", + "padding": "var(--space-3) var(--space-4)", + "width": "100%", + "box_shadow": f"0 var(--divider-px) 0 {color('gray', 6, alpha=True)}", + "&[data-state='open'] > .AccordionChevron": { + "transform": "rotate(180deg)", + }, + "&:hover": { + "background_color": color("accent", 4), + }, + "& > .AccordionChevron": { + "transition": f"transform var(--animation-duration) var(--animation-easing)", + }, + _inherited_variant_selector("classic"): { + "color": "var(--accent-contrast)", "&:hover": { - "background_color": color("accent", 4), + "background_color": color("accent", 10), }, "& > .AccordionChevron": { - "transition": f"transform var(--animation-duration) var(--animation-easing)", - }, - _inherited_variant_selector("classic"): { "color": "var(--accent-contrast)", - "&:hover": { - "background_color": color("accent", 10), - }, - "& > .AccordionChevron": { - "color": "var(--accent-contrast)", - }, }, - } - ) + }, + } class AccordionIcon(Icon): @@ -417,13 +425,13 @@ class AccordionContent(AccordionComponent): alias = "RadixAccordionContent" - def add_imports(self) -> imports.ImportDict: + def add_imports(self) -> dict: """Add imports to the component. Returns: The imports of the component. """ - return {"@emotion/react": [imports.ImportVar(tag="keyframes")]} + return {"@emotion/react": "keyframes"} @classmethod def create(cls, *children, **props) -> Component: @@ -470,40 +478,36 @@ to { """ ] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - slideDown = Var.create( + slideDown = LiteralVar.create( f"${{slideDown}} var(--animation-duration) var(--animation-easing)", - _var_is_string=True, ) - slideUp = Var.create( + slideUp = LiteralVar.create( f"${{slideUp}} var(--animation-duration) var(--animation-easing)", - _var_is_string=True, ) - return Style( - { - "overflow": "hidden", - "color": color("accent", 11), - "padding_x": "var(--space-4)", - # Apply before and after content to avoid height animation jank. - "&:before, &:after": { - "content": "' '", - "display": "block", - "height": "var(--space-3)", - }, - "&[data-state='open']": {"animation": slideDown}, - "&[data-state='closed']": {"animation": slideUp}, - _inherited_variant_selector("classic"): { - "color": "var(--accent-contrast)", - }, - } - ) + return { + "overflow": "hidden", + "color": color("accent", 11), + "padding_x": "var(--space-4)", + # Apply before and after content to avoid height animation jank. + "&:before, &:after": { + "content": "' '", + "display": "block", + "height": "var(--space-3)", + }, + "&[data-state='open']": {"animation": slideDown}, + "&[data-state='closed']": {"animation": slideUp}, + _inherited_variant_selector("classic"): { + "color": "var(--accent-contrast)", + }, + } class Accordion(ComponentNamespace): diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi index e7ae3ff19..c0047442b 100644 --- a/reflex/components/radix/primitives/accordion.pyi +++ b/reflex/components/radix/primitives/accordion.pyi @@ -1,22 +1,16 @@ """Stub file for reflex/components/radix/primitives/accordion.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Literal, Optional, Union from reflex.components.component import Component, ComponentNamespace -from reflex.components.core.colors import color -from reflex.components.core.cond import cond 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 EventType from reflex.style import Style -from reflex.utils import imports -from reflex.vars import Var, get_uuid_string_var +from reflex.vars.base import Var LiteralAccordionType = Literal["single", "multiple"] LiteralAccordionDir = Literal["ltr", "rtl"] @@ -26,7 +20,7 @@ DEFAULT_ANIMATION_DURATION = 250 DEFAULT_ANIMATION_EASING = "cubic-bezier(0.87, 0, 0.13, 1)" class AccordionComponent(RadixPrimitiveComponent): - def add_style(self) -> Style | None: ... + def add_style(self): ... @overload @classmethod def create( # type: ignore @@ -34,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, @@ -107,52 +101,22 @@ class AccordionComponent(RadixPrimitiveComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionComponent": """Create the component. @@ -174,8 +138,9 @@ class AccordionComponent(RadixPrimitiveComponent): """ ... +def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: ... + class AccordionRoot(AccordionComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... def add_style(self): ... @overload @classmethod @@ -183,27 +148,25 @@ class AccordionRoot(AccordionComponent): cls, *children, type: Optional[ - Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]] - ] = None, - value: Optional[ - Union[Var[Union[str, List[str]]], Union[str, List[str]]] + Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, + value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, default_value: Optional[ - Union[Var[Union[str, List[str]]], Union[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, @@ -211,70 +174,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, @@ -284,55 +247,23 @@ class AccordionRoot(AccordionComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_value_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + on_value_change: Optional[EventType[str | List[str]]] = None, + **props, ) -> "AccordionRoot": """Create the component. @@ -349,6 +280,7 @@ class AccordionRoot(AccordionComponent): duration: The time in milliseconds to animate open and close easing: The easing function to use for the animation. show_dividers: Whether to show divider lines between items. + on_value_change: Fired when the opened the accordions changes. color_scheme: The color scheme of the component. variant: The variant of the component. as_child: Change the default rendered element for the one passed as a child. @@ -371,76 +303,76 @@ class AccordionItem(AccordionComponent): def create( # type: ignore cls, *children, - header: Optional[Union[Component, Var]] = None, - content: Optional[Union[Component, Var]] = None, value: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, + header: Optional[Union[Component, Var[Union[Component, str]], str]] = None, + content: Optional[Union[Component, Var[Union[Component, 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, 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, @@ -450,61 +382,31 @@ class AccordionItem(AccordionComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionItem": """Create an accordion item. Args: *children: The list of children to use if header and content are not provided. - header: The header of the accordion item. - content: The content of the accordion item. value: A unique identifier for the item. disabled: When true, prevents the user from interacting with the item. + header: The header of the accordion item. + content: The content of the accordion item. color_scheme: The color scheme of the component. variant: The variant of the component. as_child: Change the default rendered element for the one passed as a child. @@ -520,7 +422,8 @@ class AccordionItem(AccordionComponent): The accordion item. """ ... - def add_style(self) -> Style | None: ... + + def add_style(self) -> dict[str, Any] | None: ... class AccordionHeader(AccordionComponent): @overload @@ -530,70 +433,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, @@ -603,52 +506,22 @@ class AccordionHeader(AccordionComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionHeader": """Create the Accordion header component. @@ -669,7 +542,8 @@ class AccordionHeader(AccordionComponent): The Accordion header Component. """ ... - def add_style(self) -> Style | None: ... + + def add_style(self) -> dict[str, Any] | None: ... class AccordionTrigger(AccordionComponent): @overload @@ -679,70 +553,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, @@ -752,52 +626,22 @@ class AccordionTrigger(AccordionComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionTrigger": """Create the Accordion trigger component. @@ -818,7 +662,8 @@ class AccordionTrigger(AccordionComponent): The Accordion trigger Component. """ ... - def add_style(self) -> Style | None: ... + + def add_style(self) -> dict[str, Any] | None: ... class AccordionIcon(Icon): @overload @@ -833,52 +678,22 @@ class AccordionIcon(Icon): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionIcon": """Create the Accordion icon component. @@ -899,7 +714,7 @@ class AccordionIcon(Icon): ... class AccordionContent(AccordionComponent): - def add_imports(self) -> imports.ImportDict: ... + def add_imports(self) -> dict: ... @overload @classmethod def create( # type: ignore @@ -907,70 +722,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, @@ -980,52 +795,22 @@ class AccordionContent(AccordionComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AccordionContent": """Create the Accordion content component. @@ -1046,8 +831,9 @@ class AccordionContent(AccordionComponent): The Accordion content Component. """ ... + def add_custom_code(self) -> list[str]: ... - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... class Accordion(ComponentNamespace): content = staticmethod(AccordionContent.create) diff --git a/reflex/components/radix/primitives/base.py b/reflex/components/radix/primitives/base.py index bd1690c3b..479cd2912 100644 --- a/reflex/components/radix/primitives/base.py +++ b/reflex/components/radix/primitives/base.py @@ -1,10 +1,11 @@ """The base component for Radix primitives.""" + 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): @@ -25,7 +26,7 @@ class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent): ._render() .add_props( **{ - "class_name": format.to_title_case(self.tag or ""), + "class_name": f"{format.to_title_case(self.tag or '')} {self.class_name or ''}", } ) ) diff --git a/reflex/components/radix/primitives/base.pyi b/reflex/components/radix/primitives/base.pyi index 7dbdbcbea..3eacd3f07 100644 --- a/reflex/components/radix/primitives/base.pyi +++ b/reflex/components/radix/primitives/base.pyi @@ -1,17 +1,14 @@ """Stub file for reflex/components/radix/primitives/base.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -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.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class RadixPrimitiveComponent(Component): @overload @@ -26,52 +23,22 @@ class RadixPrimitiveComponent(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixPrimitiveComponent": """Create the component. @@ -104,52 +71,22 @@ class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixPrimitiveComponentWithClassName": """Create the component. diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py index a4e582b02..d478dc171 100644 --- a/reflex/components/radix/primitives/drawer.py +++ b/reflex/components/radix/primitives/drawer.py @@ -4,14 +4,15 @@ # Style based on https://ui.shadcn.com/docs/components/drawer from __future__ import annotations -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Any, List, Literal, Optional, Union from reflex.components.component import Component, ComponentNamespace 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.constants import EventTriggers -from reflex.vars import Var +from reflex.event import EventHandler, empty_event, identity_event +from reflex.utils import console +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): @@ -59,16 +60,8 @@ class DrawerRoot(DrawerComponent): # When `True`, it prevents scroll restoration. Defaults to `True`. preventScrollRestoration: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fires when the drawer is opened or closed. + on_open_change: EventHandler[identity_event(bool)] class DrawerTrigger(DrawerComponent): @@ -86,8 +79,8 @@ class DrawerTrigger(DrawerComponent): """Create a new DrawerTrigger instance. Args: - children: The children of the element. - props: The properties of the element. + *children: The children of the element. + **props: The properties of the element. Returns: The new DrawerTrigger instance. @@ -135,22 +128,20 @@ class DrawerContent(DrawerComponent): base_style.update(style) return {"css": base_style} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the drawer content is opened. Deprecated. + on_open_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - # DrawerContent is based on Radix DialogContent - # These are the same triggers as DialogContent - EventTriggers.ON_OPEN_AUTO_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0.target.value], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0.target.value], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0.target.value], - } + # Fired when the drawer content is closed. Deprecated. + on_close_auto_focus: EventHandler[empty_event] + + # Fired when the escape key is pressed. Deprecated. + on_escape_key_down: EventHandler[empty_event] + + # Fired when the pointer is down outside the drawer content. Deprecated. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when interacting outside the drawer content. Deprecated. + on_interact_outside: EventHandler[empty_event] @classmethod def create(cls, *children, **props): @@ -167,6 +158,23 @@ class DrawerContent(DrawerComponent): Returns: The drawer content. """ + deprecated_properties = [ + "on_open_auto_focus", + "on_close_auto_focus", + "on_escape_key_down", + "on_pointer_down_outside", + "on_interact_outside", + ] + + for prop in deprecated_properties: + if prop in props: + console.deprecate( + feature_name="drawer content events", + reason=f"The `{prop}` event is deprecated and will be removed in 0.7.0.", + deprecation_version="0.6.3", + removal_version="0.7.0", + ) + comp = super().create(*children, **props) return Theme.create(comp) diff --git a/reflex/components/radix/primitives/drawer.pyi b/reflex/components/radix/primitives/drawer.pyi index de48f8b86..ea2dd8dcf 100644 --- a/reflex/components/radix/primitives/drawer.pyi +++ b/reflex/components/radix/primitives/drawer.pyi @@ -1,19 +1,15 @@ """Stub file for reflex/components/radix/primitives/drawer.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Literal, Optional, Union -from reflex.components.component import Component, ComponentNamespace +from reflex.components.component import ComponentNamespace 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.constants import EventTriggers -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): @overload @@ -28,52 +24,22 @@ class DrawerComponent(RadixPrimitiveComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerComponent": """Create the component. @@ -96,7 +62,6 @@ class DrawerComponent(RadixPrimitiveComponent): LiteralDirectionType = Literal["top", "bottom", "left", "right"] class DrawerRoot(DrawerComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -105,14 +70,14 @@ class DrawerRoot(DrawerComponent): open: Optional[Union[Var[bool], bool]] = None, should_scale_background: Optional[Union[Var[bool], bool]] = None, close_threshold: Optional[Union[Var[float], float]] = None, - snap_points: Optional[List[Union[str, float]]] = None, + snap_points: Optional[List[Union[float, str]]] = None, fade_from_index: Optional[Union[Var[int], int]] = None, scroll_lock_timeout: Optional[Union[Var[int], int]] = None, 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, @@ -123,55 +88,23 @@ class DrawerRoot(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerRoot": """Create the component. @@ -186,6 +119,7 @@ class DrawerRoot(DrawerComponent): modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. direction: Direction of the drawer. Defaults to `"bottom"` preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`. + on_open_change: Fires when the drawer is opened or closed. as_child: Change the default rendered element for the one passed as a child. style: The style of the component. key: A unique key for the component. @@ -213,58 +147,35 @@ class DrawerTrigger(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerTrigger": """Create a new DrawerTrigger instance. Args: - children: The children of the element. - props: The properties of the element. + *children: The children of the element. + as_child: Change the default rendered element for the one passed as a child. + 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 properties of the element. Returns: The new DrawerTrigger instance. @@ -284,52 +195,22 @@ class DrawerPortal(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerPortal": """Create the component. @@ -350,7 +231,6 @@ class DrawerPortal(DrawerComponent): ... class DrawerContent(DrawerComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -363,67 +243,27 @@ class DrawerContent(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_auto_focus: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerContent": """Create a Drawer Content. We wrap the Drawer content in an `rx.theme` to make radix themes definitions available to @@ -460,52 +300,22 @@ class DrawerOverlay(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerOverlay": """Create the component. @@ -538,58 +348,35 @@ class DrawerClose(DrawerTrigger): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerClose": """Create a new DrawerTrigger instance. Args: - children: The children of the element. - props: The properties of the element. + *children: The children of the element. + as_child: Change the default rendered element for the one passed as a child. + 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 properties of the element. Returns: The new DrawerTrigger instance. @@ -609,52 +396,22 @@ class DrawerTitle(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerTitle": """Create the component. @@ -687,52 +444,22 @@ class DrawerDescription(DrawerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerDescription": """Create the component. @@ -768,14 +495,14 @@ class Drawer(ComponentNamespace): open: Optional[Union[Var[bool], bool]] = None, should_scale_background: Optional[Union[Var[bool], bool]] = None, close_threshold: Optional[Union[Var[float], float]] = None, - snap_points: Optional[List[Union[str, float]]] = None, + snap_points: Optional[List[Union[float, str]]] = None, fade_from_index: Optional[Union[Var[int], int]] = None, scroll_lock_timeout: Optional[Union[Var[int], int]] = None, 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, @@ -786,55 +513,23 @@ class Drawer(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DrawerRoot": """Create the component. @@ -849,6 +544,7 @@ class Drawer(ComponentNamespace): modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. direction: Direction of the drawer. Defaults to `"bottom"` preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`. + on_open_change: Fires when the drawer is opened or closed. as_child: Change the default rendered element for the one passed as a child. style: The style of the component. key: A unique key for the component. diff --git a/reflex/components/radix/primitives/form.py b/reflex/components/radix/primitives/form.py index 3369673da..4d4be7e40 100644 --- a/reflex/components/radix/primitives/form.py +++ b/reflex/components/radix/primitives/form.py @@ -2,14 +2,14 @@ from __future__ import annotations -from typing import Any, Dict, Literal +from typing import Any, Literal from reflex.components.component import ComponentNamespace +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.constants.event import EventTriggers -from reflex.style import Style -from reflex.vars import Var +from reflex.event import EventHandler, empty_event +from reflex.vars.base import Var from .base import RadixPrimitiveComponentWithClassName @@ -17,7 +17,7 @@ from .base import RadixPrimitiveComponentWithClassName class FormComponent(RadixPrimitiveComponentWithClassName): """Base class for all @radix-ui/react-form components.""" - library = "@radix-ui/react-form@^0.0.3" + library = "@radix-ui/react-form@^0.1.0" class FormRoot(FormComponent, HTMLForm): @@ -27,24 +27,16 @@ class FormRoot(FormComponent, HTMLForm): alias = "RadixFormRoot" - def get_event_triggers(self) -> Dict[str, Any]: - """Event triggers for radix form root. + # Fired when the errors are cleared. + on_clear_server_errors: EventHandler[empty_event] - Returns: - The triggers for event supported by Root. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CLEAR_SERVER_ERRORS: lambda: [], - } - - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style({"width": "100%"}) + return {"width": "100%"} class FormField(FormComponent): @@ -60,13 +52,13 @@ class FormField(FormComponent): # Flag to mark the form field as invalid, for server side validation. server_invalid: Var[bool] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style({"display": "grid", "margin_bottom": "10px"}) + return {"display": "grid", "margin_bottom": "10px"} class FormLabel(FormComponent): @@ -76,13 +68,13 @@ class FormLabel(FormComponent): alias = "RadixFormLabel" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style({"font_size": "15px", "font_weight": "500", "line_height": "35px"}) + return {"font_size": "15px", "font_weight": "500", "line_height": "35px"} class FormControl(FormComponent): @@ -112,9 +104,9 @@ class FormControl(FormComponent): f"FormControl can only have at most one child, got {len(children)} children" ) for child in children: - if not isinstance(child, TextFieldRoot): + if not isinstance(child, (TextFieldRoot, DebounceInput)): raise TypeError( - "Only Radix TextFieldRoot is allowed as child of FormControl" + "Only Radix TextFieldRoot and DebounceInput are allowed as children of FormControl" ) return super().create(*children, **props) @@ -149,13 +141,13 @@ class FormMessage(FormComponent): # Forces the message to be shown. This is useful when using server-side validation. force_match: Var[bool] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style({"font_size": "13px", "opacity": "0.8", "color": "white"}) + return {"font_size": "13px", "opacity": "0.8", "color": "white"} class FormValidityState(FormComponent): diff --git a/reflex/components/radix/primitives/form.pyi b/reflex/components/radix/primitives/form.pyi index 8e1631825..72595a933 100644 --- a/reflex/components/radix/primitives/form.pyi +++ b/reflex/components/radix/primitives/form.pyi @@ -1,19 +1,16 @@ """Stub file for reflex/components/radix/primitives/form.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal + from reflex.components.component import ComponentNamespace from reflex.components.el.elements.forms import Form as HTMLForm -from reflex.components.radix.themes.components.text_field import TextFieldRoot -from reflex.constants.event import EventTriggers +from reflex.event import EventType from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var + from .base import RadixPrimitiveComponentWithClassName class FormComponent(RadixPrimitiveComponentWithClassName): @@ -29,52 +26,22 @@ class FormComponent(RadixPrimitiveComponentWithClassName): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormComponent": """Create the component. @@ -95,144 +62,84 @@ class FormComponent(RadixPrimitiveComponentWithClassName): ... class FormRoot(FormComponent, HTMLForm): - def get_event_triggers(self) -> Dict[str, Any]: ... - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - action: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enc_type: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, + on_clear_server_errors: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]] ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormRoot": """Create a form component. Args: *children: The children of the form. + on_clear_server_errors: Fired when the errors are cleared. as_child: Change the default rendered element for the one passed as a child. accept: MIME types the server accepts for file upload accept_charset: Character encodings to be used for form submission @@ -245,6 +152,7 @@ class FormRoot(FormComponent, HTMLForm): target: Where to display the response after submitting the form reset_on_submit: If true, the form will be cleared after submit. handle_submit_unique_name: The name used to make this form's submit handler function unique. + on_submit: Fired when the form is submitted access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -275,7 +183,7 @@ class FormRoot(FormComponent, HTMLForm): ... class FormField(FormComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -290,52 +198,22 @@ class FormField(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormField": """Create the component. @@ -358,7 +236,7 @@ class FormField(FormComponent): ... class FormLabel(FormComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -371,52 +249,22 @@ class FormLabel(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormLabel": """Create the component. @@ -449,52 +297,22 @@ class FormControl(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormControl": """Create a Form Control component. @@ -532,7 +350,7 @@ LiteralMatcher = Literal[ ] class FormMessage(FormComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -541,6 +359,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", @@ -555,18 +385,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, @@ -577,52 +395,22 @@ class FormMessage(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormMessage": """Create the component. @@ -658,52 +446,22 @@ class FormValidityState(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormValidityState": """Create the component. @@ -736,52 +494,22 @@ class FormSubmit(FormComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FormSubmit": """Create the component. @@ -810,136 +538,77 @@ class Form(FormRoot): cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - action: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enc_type: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, + on_clear_server_errors: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]] ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Form": """Create a form component. Args: *children: The children of the form. + on_clear_server_errors: Fired when the errors are cleared. as_child: Change the default rendered element for the one passed as a child. accept: MIME types the server accepts for file upload accept_charset: Character encodings to be used for form submission @@ -952,6 +621,7 @@ class Form(FormRoot): target: Where to display the response after submitting the form reset_on_submit: If true, the form will be cleared after submit. handle_submit_unique_name: The name used to make this form's submit handler function unique. + on_submit: Fired when the form is submitted access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -994,136 +664,77 @@ class FormNamespace(ComponentNamespace): def __call__( *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - action: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - enc_type: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, + on_clear_server_errors: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]] ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Form": """Create a form component. Args: *children: The children of the form. + on_clear_server_errors: Fired when the errors are cleared. as_child: Change the default rendered element for the one passed as a child. accept: MIME types the server accepts for file upload accept_charset: Character encodings to be used for form submission @@ -1136,6 +747,7 @@ class FormNamespace(ComponentNamespace): target: Where to display the response after submitting the form reset_on_submit: If true, the form will be cleared after submit. handle_submit_unique_name: The name used to make this form's submit handler function unique. + on_submit: Fired when the form is submitted access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. diff --git a/reflex/components/radix/primitives/progress.py b/reflex/components/radix/primitives/progress.py index 313d6aeb6..72aee1038 100644 --- a/reflex/components/radix/primitives/progress.py +++ b/reflex/components/radix/primitives/progress.py @@ -2,15 +2,14 @@ from __future__ import annotations -from typing import Optional +from typing import Any, Optional from reflex.components.component import Component, ComponentNamespace 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.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): @@ -28,7 +27,7 @@ class ProgressRoot(ProgressComponent): # Override theme radius for progress bar: "none" | "small" | "medium" | "large" | "full" radius: Var[LiteralRadius] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: @@ -37,17 +36,15 @@ class ProgressRoot(ProgressComponent): if self.radius is not None: self.custom_attrs["data-radius"] = self.radius - return Style( - { - "position": "relative", - "overflow": "hidden", - "background": color("gray", 3, alpha=True), - "border_radius": "max(var(--radius-2), var(--radius-full))", - "width": "100%", - "height": "20px", - "boxShadow": f"inset 0 0 0 1px {color('gray', 5, alpha=True)}", - } - ) + return { + "position": "relative", + "overflow": "hidden", + "background": color("gray", 3, alpha=True), + "border_radius": "max(var(--radius-2), var(--radius-full))", + "width": "100%", + "height": "20px", + "boxShadow": f"inset 0 0 0 1px {color('gray', 5, alpha=True)}", + } def _exclude_props(self) -> list[str]: return ["radius"] @@ -69,7 +66,7 @@ class ProgressIndicator(ProgressComponent): # The color scheme of the progress indicator. color_scheme: Var[LiteralAccentColor] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: @@ -78,19 +75,17 @@ class ProgressIndicator(ProgressComponent): if self.color_scheme is not None: self.custom_attrs["data-accent-color"] = self.color_scheme - return Style( - { - "background_color": color("accent", 9), - "width": "100%", - "height": "100%", + return { + "background_color": color("accent", 9), + "width": "100%", + "height": "100%", + "transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear", + "&[data_state='loading']": { "transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear", - "&[data_state='loading']": { - "transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear", - }, - "transform": f"translateX(calc(-100% + ({self.value} / {self.max} * 100%)))", # type: ignore - "boxShadow": "inset 0 0 0 1px var(--gray-a5)", - } - ) + }, + "transform": f"translateX(calc(-100% + ({self.value} / {self.max} * 100%)))", # type: ignore + "boxShadow": "inset 0 0 0 1px var(--gray-a5)", + } def _exclude_props(self) -> list[str]: return ["color_scheme"] diff --git a/reflex/components/radix/primitives/progress.pyi b/reflex/components/radix/primitives/progress.pyi index eb0149496..c760c0a57 100644 --- a/reflex/components/radix/primitives/progress.pyi +++ b/reflex/components/radix/primitives/progress.pyi @@ -1,20 +1,15 @@ """Stub file for reflex/components/radix/primitives/progress.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Optional -from reflex.components.component import Component, ComponentNamespace -from reflex.components.core.colors import color -from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION + +from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName -from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius +from reflex.event import EventType from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): @overload @@ -29,52 +24,22 @@ class ProgressComponent(RadixPrimitiveComponentWithClassName): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ProgressComponent": """Create the component. @@ -95,7 +60,7 @@ class ProgressComponent(RadixPrimitiveComponentWithClassName): ... class ProgressRoot(ProgressComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -103,8 +68,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, @@ -114,52 +79,22 @@ class ProgressRoot(ProgressComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ProgressRoot": """Create the component. @@ -181,73 +116,73 @@ class ProgressRoot(ProgressComponent): ... class ProgressIndicator(ProgressComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore cls, *children, - value: Optional[Union[Var[Optional[int]], Optional[int]]] = None, - max: Optional[Union[Var[Optional[int]], Optional[int]]] = None, + value: Optional[Union[Var[Optional[int]], int]] = None, + 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, @@ -258,52 +193,22 @@ class ProgressIndicator(ProgressComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ProgressIndicator": """Create the component. @@ -334,72 +239,72 @@ 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, - value: Optional[Union[Var[Optional[int]], Optional[int]]] = None, - max: Optional[Union[Var[Optional[int]], Optional[int]]] = None, + value: Optional[Union[Var[Optional[int]], int]] = None, + 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, @@ -409,52 +314,22 @@ class Progress(ProgressRoot): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Progress": """High-level API for progress bar. @@ -486,72 +361,72 @@ 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, - value: Optional[Union[Var[Optional[int]], Optional[int]]] = None, - max: Optional[Union[Var[Optional[int]], Optional[int]]] = None, + value: Optional[Union[Var[Optional[int]], int]] = None, + 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, @@ -561,52 +436,22 @@ class ProgressNamespace(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Progress": """High-level API for progress bar. diff --git a/reflex/components/radix/primitives/slider.py b/reflex/components/radix/primitives/slider.py index 2e0b1ef49..10a0079a4 100644 --- a/reflex/components/radix/primitives/slider.py +++ b/reflex/components/radix/primitives/slider.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing import Any, Dict, List, Literal +from typing import Any, List, Literal, Tuple from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName -from reflex.style import Style -from reflex.vars import Var +from reflex.event import EventHandler +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] @@ -19,6 +19,20 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): library = "@radix-ui/react-slider@^1.1.2" +def on_value_event_spec( + value: Var[List[int]], +) -> Tuple[Var[List[int]]]: + """Event handler spec for the value event. + + Args: + value: The value of the event. + + Returns: + The event handler spec. + """ + return (value,) # type: ignore + + class SliderRoot(SliderComponent): """The Slider component comtaining all slider parts.""" @@ -47,40 +61,32 @@ class SliderRoot(SliderComponent): min_steps_between_thumbs: Var[int] - def get_event_triggers(self) -> Dict[str, Any]: - """Event triggers for radix slider primitive. + # Fired when the value of a thumb changes. + on_value_change: EventHandler[on_value_event_spec] - Returns: - The triggers for event supported by radix primitives. - """ - return { - **super().get_event_triggers(), - "on_value_change": lambda e0: [e0], # trigger for all change of a thumb - "on_value_commit": lambda e0: [e0], # trigger when thumb is released - } + # Fired when a thumb is released. + on_value_commit: EventHandler[on_value_event_spec] - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "position": "relative", - "display": "flex", - "align_items": "center", - "user_select": "none", - "touch_action": "none", - "width": "200px", - "height": "20px", - "&[data-orientation='vertical']": { - "flex_direction": "column", - "width": "20px", - "height": "100px", - }, - } - ) + return { + "position": "relative", + "display": "flex", + "align_items": "center", + "user_select": "none", + "touch_action": "none", + "width": "200px", + "height": "20px", + "&[data-orientation='vertical']": { + "flex_direction": "column", + "width": "20px", + "height": "100px", + }, + } class SliderTrack(SliderComponent): @@ -89,22 +95,20 @@ class SliderTrack(SliderComponent): tag = "Track" alias = "RadixSliderTrack" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "position": "relative", - "flex_grow": "1", - "background_color": "black", - "border_radius": "9999px", - "height": "3px", - "&[data-orientation='vertical']": {"width": "3px"}, - } - ) + return { + "position": "relative", + "flex_grow": "1", + "background_color": "black", + "border_radius": "9999px", + "height": "3px", + "&[data-orientation='vertical']": {"width": "3px"}, + } class SliderRange(SliderComponent): @@ -113,20 +117,18 @@ class SliderRange(SliderComponent): tag = "Range" alias = "RadixSliderRange" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "position": "absolute", - "background_color": "white", - "height": "100%", - "&[data-orientation='vertical']": {"width": "100%"}, - } - ) + return { + "position": "absolute", + "background_color": "white", + "height": "100%", + "&[data-orientation='vertical']": {"width": "100%"}, + } class SliderThumb(SliderComponent): @@ -135,29 +137,27 @@ class SliderThumb(SliderComponent): tag = "Thumb" alias = "RadixSliderThumb" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "display": "block", - "width": "20px", - "height": "20px", - "background_color": "black", - "box_shadow": "0 2px 10px black", - "border_radius": "10px", - "&:hover": { - "background_color": "gray", - }, - "&:focus": { - "outline": "none", - "box_shadow": "0 0 0 4px gray", - }, - } - ) + return { + "display": "block", + "width": "20px", + "height": "20px", + "background_color": "black", + "box_shadow": "0 2px 10px black", + "border_radius": "10px", + "&:hover": { + "background_color": "gray", + }, + "&:focus": { + "outline": "none", + "box_shadow": "0 0 0 4px gray", + }, + } class Slider(ComponentNamespace): diff --git a/reflex/components/radix/primitives/slider.pyi b/reflex/components/radix/primitives/slider.pyi index 1f837d732..03a30f164 100644 --- a/reflex/components/radix/primitives/slider.pyi +++ b/reflex/components/radix/primitives/slider.pyi @@ -1,17 +1,15 @@ """Stub file for reflex/components/radix/primitives/slider.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Literal from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName +from reflex.event import EventType from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] @@ -29,52 +27,22 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SliderComponent": """Create the component. @@ -94,25 +62,26 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): """ ... +def on_value_event_spec(value: Var[List[int]]) -> Tuple[Var[List[int]]]: ... + class SliderRoot(SliderComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod 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, @@ -125,63 +94,31 @@ class SliderRoot(SliderComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_value_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_value_commit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + on_value_change: Optional[EventType[List[int]]] = None, + on_value_commit: Optional[EventType[List[int]]] = None, + **props, ) -> "SliderRoot": """Create the component. Args: *children: The children of the component. + on_value_change: Fired when the value of a thumb changes. + on_value_commit: Fired when a thumb is released. as_child: Change the default rendered element for the one passed as a child. style: The style of the component. key: A unique key for the component. @@ -197,7 +134,7 @@ class SliderRoot(SliderComponent): ... class SliderTrack(SliderComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -210,52 +147,22 @@ class SliderTrack(SliderComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SliderTrack": """Create the component. @@ -276,7 +183,7 @@ class SliderTrack(SliderComponent): ... class SliderRange(SliderComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -289,52 +196,22 @@ class SliderRange(SliderComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SliderRange": """Create the component. @@ -355,7 +232,7 @@ class SliderRange(SliderComponent): ... class SliderThumb(SliderComponent): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -368,52 +245,22 @@ class SliderThumb(SliderComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SliderThumb": """Create the component. diff --git a/reflex/components/radix/themes/__init__.py b/reflex/components/radix/themes/__init__.py index e1d39fb52..0afd5aa5d 100644 --- a/reflex/components/radix/themes/__init__.py +++ b/reflex/components/radix/themes/__init__.py @@ -1,7 +1,22 @@ """Namespace for components provided by the @radix-ui/themes library.""" -from .base import theme as theme -from .base import theme_panel as theme_panel -from .color_mode import color_mode_var_and_namespace as color_mode -from .components import * -from .layout import * -from .typography import * + +from __future__ import annotations + +from reflex.utils import lazy_loader + +_SUBMODULES: set[str] = {"components", "layout", "typography"} +_SUBMOD_ATTRS: dict[str, list[str]] = { + "base": [ + "theme", + "theme_panel", + ], + "color_mode": [ + "color_mode", + ], +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/themes/__init__.pyi b/reflex/components/radix/themes/__init__.pyi new file mode 100644 index 000000000..91ef2b46c --- /dev/null +++ b/reflex/components/radix/themes/__init__.pyi @@ -0,0 +1,11 @@ +"""Stub file for reflex/components/radix/themes/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from . import components as components +from . import layout as layout +from . import typography as typography +from .base import theme as theme +from .base import theme_panel as theme_panel +from .color_mode import color_mode as color_mode diff --git a/reflex/components/radix/themes/base.py b/reflex/components/radix/themes/base.py index 559d10239..acca1dce8 100644 --- a/reflex/components/radix/themes/base.py +++ b/reflex/components/radix/themes/base.py @@ -6,8 +6,9 @@ from typing import Any, Dict, Literal from reflex.components import Component from reflex.components.tags import Tag -from reflex.utils import imports -from reflex.vars import Var +from reflex.config import get_config +from reflex.utils.imports import ImportDict, ImportVar +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -112,6 +113,11 @@ class RadixThemesComponent(Component): component.alias = "RadixThemes" + ( component.tag or component.__class__.__name__ ) + # value = props.get("value") + # if value is not None and component.alias == "RadixThemesSelect.Root": + # lv = LiteralVar.create(value) + # print(repr(lv)) + # print(f"Warning: Value {value} is not used in {component.alias}.") return component @staticmethod @@ -208,25 +214,29 @@ class Theme(RadixThemesComponent): children = [ThemePanel.create(), *children] return super().create(*children, **props) - def _get_imports(self) -> imports.ImportDict: - return imports.merge_imports( - super()._get_imports(), - { - "": [ - imports.ImportVar(tag="@radix-ui/themes/styles.css", install=False) - ], - "/utils/theme.js": [ - imports.ImportVar(tag="theme", is_default=True), - ], - }, - ) + def add_imports(self) -> ImportDict | list[ImportDict]: + """Add imports for the Theme component. + + Returns: + The import dict. + """ + _imports: ImportDict = { + "$/utils/theme.js": [ImportVar(tag="theme", is_default=True)], + } + if get_config().tailwind is None: + # When tailwind is disabled, import the radix-ui styles directly because they will + # not be included in the tailwind.css file. + _imports[""] = ImportVar( + tag="@radix-ui/themes/styles.css", + install=False, + ) + return _imports def _render(self, props: dict[str, Any] | None = None) -> Tag: tag = super()._render(props) tag.add_props( - css=Var.create( - "{{...theme.styles.global[':root'], ...theme.styles.global.body}}", - _var_is_local=False, + css=Var( + _js_expr=f"{{...theme.styles.global[':root'], ...theme.styles.global.body}}" ), ) return tag @@ -243,32 +253,19 @@ class ThemePanel(RadixThemesComponent): # Whether the panel is open. Defaults to False. default_open: Var[bool] - def _get_imports(self) -> dict[str, list[imports.ImportVar]]: - return imports.merge_imports( - super()._get_imports(), - { - "react": [imports.ImportVar(tag="useEffect")], - }, - ) + def add_imports(self) -> dict[str, str]: + """Add imports for the ThemePanel component. - def _get_hooks(self) -> str | None: - # 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(); - } - }, [])""" + Returns: + The import dict. + """ + return {"react": "useEffect"} class RadixThemesColorModeProvider(Component): """Next-themes integration for radix themes components.""" - library = "/components/reflex/radix_themes_color_mode_provider.js" + library = "$/components/reflex/radix_themes_color_mode_provider.js" tag = "RadixThemesColorModeProvider" is_default = True diff --git a/reflex/components/radix/themes/base.pyi b/reflex/components/radix/themes/base.pyi index d7ee29801..0f0de5401 100644 --- a/reflex/components/radix/themes/base.pyi +++ b/reflex/components/radix/themes/base.pyi @@ -1,17 +1,15 @@ """Stub file for reflex/components/radix/themes/base.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal + from reflex.components import Component -from reflex.components.tags import Tag -from reflex.utils import imports -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -59,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, @@ -105,52 +103,22 @@ class CommonMarginProps(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CommonMarginProps": """Create the component. @@ -189,52 +157,22 @@ class RadixLoadingProp(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixLoadingProp": """Create the component. @@ -266,52 +204,22 @@ class RadixThemesComponent(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixThemesComponent": """Create a new component instance. @@ -345,52 +253,22 @@ class RadixThemesTriggerComponent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixThemesTriggerComponent": """Create a new RadixThemesTriggerComponent instance. @@ -409,96 +287,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, @@ -507,52 +385,22 @@ class Theme(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Theme": """Create a new Radix Theme specification. @@ -580,7 +428,10 @@ class Theme(RadixThemesComponent): """ ... + def add_imports(self) -> ImportDict | list[ImportDict]: ... + class ThemePanel(RadixThemesComponent): + def add_imports(self) -> dict[str, str]: ... @overload @classmethod def create( # type: ignore @@ -593,52 +444,22 @@ class ThemePanel(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ThemePanel": """Create a new component instance. @@ -673,52 +494,22 @@ class RadixThemesColorModeProvider(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadixThemesColorModeProvider": """Create the component. diff --git a/reflex/components/radix/themes/color_mode.py b/reflex/components/radix/themes/color_mode.py index 2329918f4..a01d40e07 100644 --- a/reflex/components/radix/themes/color_mode.py +++ b/reflex/components/radix/themes/color_mode.py @@ -17,16 +17,22 @@ rx.text( from __future__ import annotations -import dataclasses -from typing import Literal, get_args +from typing import Dict, List, Literal, Optional, Union, 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.style import LIGHT_COLOR_MODE, color_mode, toggle_color_mode -from reflex.utils import console -from reflex.vars import BaseVar, Var +from reflex.style import ( + LIGHT_COLOR_MODE, + color_mode, + resolved_color_mode, + set_color_mode, + toggle_color_mode, +) +from reflex.vars.base import Var +from reflex.vars.sequence import LiteralArrayVar from .components.icon_button import IconButton @@ -60,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"], @@ -72,8 +78,8 @@ position_map = { # needed to inverse contains for find -def _find(const, var): - return Var.create_safe(const).contains(var) +def _find(const: List[str], var): + return LiteralArrayVar.create(const).contains(var) def _set_var_default(props, position, prop, default1, default2=""): @@ -90,34 +96,31 @@ def _set_static_default(props, position, prop, default): class ColorModeIconButton(IconButton): """Icon Button for toggling light / dark mode via toggle_color_mode.""" + # The position of the icon button. Follow document flow if None. + position: Optional[Union[LiteralPosition, Var[LiteralPosition]]] = None + + # Allow picking the "system" value for the color mode. + allow_system: bool = False + @classmethod def create( cls, - *children, - position: LiteralPosition | None = None, **props, ): - """Create a icon button component that calls toggle_color_mode on click. + """Create an 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. **props: The props to pass to the component. 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 = props.pop("position", None) + allow_system = props.pop("allow_system", False) # position is used to set nice defaults for positioning the icon button if isinstance(position, Var): - _set_var_default(props, position, "position", "fixed", position) + _set_var_default(props, position, "position", "fixed", position) # type: ignore _set_var_default(props, position, "bottom", "2rem") _set_var_default(props, position, "top", "2rem") _set_var_default(props, position, "left", "2rem") @@ -137,12 +140,35 @@ class ColorModeIconButton(IconButton): props.setdefault("z_index", "20") props.setdefault(":hover", {"cursor": "pointer"}) - return super().create( + if allow_system: + + def color_mode_item(_color_mode): + return dropdown_menu.item( + _color_mode.title(), on_click=set_color_mode(_color_mode) + ) + + return dropdown_menu.root( + dropdown_menu.trigger( + super().create( + ColorModeIcon.create(), + **props, + ) + ), + dropdown_menu.content( + color_mode_item("light"), + color_mode_item("dark"), + color_mode_item("system"), + ), + ) + return IconButton.create( ColorModeIcon.create(), on_click=toggle_color_mode, **props, ) + def _exclude_props(self) -> list[str]: + return ["position", "allow_system"] + class ColorModeSwitch(Switch): """Switch for toggling light / dark mode via toggle_color_mode.""" @@ -160,13 +186,13 @@ class ColorModeSwitch(Switch): """ return Switch.create( *children, - checked=color_mode != LIGHT_COLOR_MODE, + checked=resolved_color_mode != LIGHT_COLOR_MODE, on_change=toggle_color_mode, **props, ) -class ColorModeNamespace(BaseVar): +class ColorModeNamespace(Var): """Namespace for color mode components.""" icon = staticmethod(ColorModeIcon.create) @@ -174,4 +200,8 @@ class ColorModeNamespace(BaseVar): switch = staticmethod(ColorModeSwitch.create) -color_mode_var_and_namespace = ColorModeNamespace(**dataclasses.asdict(color_mode)) +color_mode = color_mode_var_and_namespace = ColorModeNamespace( + _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 e4a2cbcac..a5b7b31ec 100644 --- a/reflex/components/radix/themes/color_mode.pyi +++ b/reflex/components/radix/themes/color_mode.pyi @@ -1,21 +1,22 @@ """Stub file for reflex/components/radix/themes/color_mode.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -import dataclasses -from typing import Literal, get_args from reflex.components.component import BaseComponent -from reflex.components.core.cond import Cond, color_mode_cond, cond +from reflex.components.core.breakpoints import Breakpoints +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.style import LIGHT_COLOR_MODE, color_mode, toggle_color_mode -from reflex.utils import console -from reflex.vars import BaseVar, Var +from reflex.event import EventType +from reflex.style import ( + Style, + color_mode, +) +from reflex.vars.base import Var + from .components.icon_button import IconButton DEFAULT_LIGHT_ICON: Icon @@ -27,7 +28,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, @@ -36,52 +37,22 @@ class ColorModeIcon(Cond): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ColorModeIcon": """Create an icon component based on color_mode. @@ -95,14 +66,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 @@ -111,152 +76,144 @@ class ColorModeIconButton(IconButton): cls, *children, position: Optional[ - Literal["top-left", "top-right", "bottom-left", "bottom-right"] + Union[ + Literal["bottom-left", "bottom-right", "top-left", "top-right"], + Union[ + Literal["bottom-left", "bottom-right", "top-left", "top-right"], + Var[ + Literal["bottom-left", "bottom-right", "top-left", "top-right"] + ], + ], + ] ] = None, + allow_system: Optional[bool] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = 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[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]]] = None, - form_action: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - form_method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form_target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, @@ -264,58 +221,28 @@ class ColorModeIconButton(IconButton): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ColorModeIconButton": - """Create a icon button component that calls toggle_color_mode on click. + """Create an 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. size: Button size "1" - "4" variant: Variant of button: "classic" | "solid" | "soft" | "surface" | "outline" | "ghost" @@ -377,80 +304,88 @@ class ColorModeSwitch(Switch): name: Optional[Union[Var[str], str]] = None, value: Optional[Union[Var[str], str]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -459,55 +394,23 @@ class ColorModeSwitch(Switch): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[bool]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ColorModeSwitch": """Create a switch component bound to color_mode. @@ -525,6 +428,7 @@ class ColorModeSwitch(Switch): color_scheme: Override theme color for switch high_contrast: Whether to render the switch with higher contrast color against background radius: Override theme radius for switch: "none" | "small" | "full" + on_change: Props to rename Fired when the value of the switch changes style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -538,9 +442,13 @@ class ColorModeSwitch(Switch): """ ... -class ColorModeNamespace(BaseVar): +class ColorModeNamespace(Var): icon = staticmethod(ColorModeIcon.create) button = staticmethod(ColorModeIconButton.create) switch = staticmethod(ColorModeSwitch.create) -color_mode_var_and_namespace = ColorModeNamespace(**dataclasses.asdict(color_mode)) +color_mode = color_mode_var_and_namespace = ColorModeNamespace( + _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__.py b/reflex/components/radix/themes/components/__init__.py index 7df1f7707..ffb7a5806 100644 --- a/reflex/components/radix/themes/components/__init__.py +++ b/reflex/components/radix/themes/components/__init__.py @@ -1,83 +1,16 @@ """Radix themes components.""" -from .alert_dialog import alert_dialog as alert_dialog -from .aspect_ratio import aspect_ratio as aspect_ratio -from .avatar import avatar as avatar -from .badge import badge as badge -from .button import button as button -from .callout import callout as callout -from .card import card as card -from .checkbox import checkbox as checkbox -from .checkbox_cards import checkbox_cards as checkbox_cards -from .checkbox_group import checkbox_group as checkbox_group -from .context_menu import context_menu as context_menu -from .data_list import data_list as data_list -from .dialog import dialog as dialog -from .dropdown_menu import dropdown_menu as dropdown_menu -from .dropdown_menu import menu as menu -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 -from .scroll_area import scroll_area as scroll_area -from .segmented_control import segmented_control as segmented_control -from .select import select as select -from .separator import divider as divider -from .separator import separator as separator -from .skeleton import skeleton as skeleton -from .slider import slider as slider -from .spinner import spinner as spinner -from .switch import switch as switch -from .table import table as table -from .tabs import tabs as tabs -from .text_area import text_area as text_area -from .text_field import text_field as text_field -from .tooltip import tooltip as tooltip +from __future__ import annotations -input = text_field +from reflex import RADIX_THEMES_COMPONENTS_MAPPING +from reflex.utils import lazy_loader -__all__ = [ - "alert_dialog", - "aspect_ratio", - "avatar", - "badge", - "button", - "callout", - "card", - "checkbox", - "checkbox_cards", - "checkbox_group", - "context_menu", - "data_list", - "dialog", - "divider", - "dropdown_menu", - "hover_card", - "icon_button", - "input", - "inset", - "menu", - "popover", - # progress is in experimental namespace until https://github.com/radix-ui/themes/pull/492 - # "progress", - "radio", - "radio_cards", - "radio_group", - "scroll_area", - "segmented_control", - "select", - "separator", - "skeleton", - "slider", - "spinner", - "switch", - "table", - "tabs", - "text_area", - "text_field", - "tooltip", -] +_SUBMOD_ATTRS: dict[str, list[str]] = { + "".join(k.split("components.radix.themes.components.")[-1]): v + for k, v in RADIX_THEMES_COMPONENTS_MAPPING.items() +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/themes/components/__init__.pyi b/reflex/components/radix/themes/components/__init__.pyi new file mode 100644 index 000000000..29f15e311 --- /dev/null +++ b/reflex/components/radix/themes/components/__init__.pyi @@ -0,0 +1,43 @@ +"""Stub file for reflex/components/radix/themes/components/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .alert_dialog import alert_dialog as alert_dialog +from .aspect_ratio import aspect_ratio as aspect_ratio +from .avatar import avatar as avatar +from .badge import badge as badge +from .button import button as button +from .callout import callout as callout +from .card import card as card +from .checkbox import checkbox as checkbox +from .checkbox_cards import checkbox_cards as checkbox_cards +from .checkbox_group import checkbox_group as checkbox_group +from .context_menu import context_menu as context_menu +from .data_list import data_list as data_list +from .dialog import dialog as dialog +from .dropdown_menu import dropdown_menu as dropdown_menu +from .dropdown_menu import menu as menu +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 +from .scroll_area import scroll_area as scroll_area +from .segmented_control import segmented_control as segmented_control +from .select import select as select +from .separator import divider as divider +from .separator import separator as separator +from .skeleton import skeleton as skeleton +from .slider import slider as slider +from .spinner import spinner as spinner +from .switch import switch as switch +from .table import table as table +from .tabs import tabs as tabs +from .text_area import text_area as text_area +from .text_field import input as input +from .text_field import text_field as text_field +from .tooltip import tooltip as tooltip diff --git a/reflex/components/radix/themes/components/alert_dialog.py b/reflex/components/radix/themes/components/alert_dialog.py index b8e713bb5..f3c8ec319 100644 --- a/reflex/components/radix/themes/components/alert_dialog.py +++ b/reflex/components/radix/themes/components/alert_dialog.py @@ -1,10 +1,12 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal -from reflex import el +from typing import Literal + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -19,16 +21,8 @@ class AlertDialogRoot(RadixThemesComponent): # The controlled open state of the dialog. open: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class AlertDialogTrigger(RadixThemesTriggerComponent): @@ -37,29 +31,25 @@ class AlertDialogTrigger(RadixThemesTriggerComponent): tag = "AlertDialog.Trigger" -class AlertDialogContent(el.Div, RadixThemesComponent): +class AlertDialogContent(elements.Div, RadixThemesComponent): """Contains the content of the dialog. This component is based on the div element.""" tag = "AlertDialog.Content" # The size of the content. - size: Var[LiteralContentSize] + size: Var[Responsive[LiteralContentSize]] # Whether to force mount the content on open. force_mount: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the dialog is opened. + on_open_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - } + # Fired when the dialog is closed. + on_close_auto_focus: EventHandler[empty_event] + + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] class AlertDialogTitle(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/alert_dialog.pyi b/reflex/components/radix/themes/components/alert_dialog.pyi index a61a5bbbc..f4b674ce2 100644 --- a/reflex/components/radix/themes/components/alert_dialog.pyi +++ b/reflex/components/radix/themes/components/alert_dialog.pyi @@ -1,23 +1,22 @@ """Stub file for reflex/components/radix/themes/components/alert_dialog.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from ..base import RadixThemesComponent, RadixThemesTriggerComponent LiteralContentSize = Literal["1", "2", "3", "4"] class AlertDialogRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -30,55 +29,23 @@ class AlertDialogRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogRoot": """Create a new component instance. @@ -88,6 +55,7 @@ class AlertDialogRoot(RadixThemesComponent): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -113,52 +81,22 @@ class AlertDialogTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -171,118 +109,74 @@ class AlertDialogTrigger(RadixThemesTriggerComponent): """ ... -class AlertDialogContent(el.Div, RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... +class AlertDialogContent(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = None, force_mount: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_auto_focus: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogContent": """Create a new component instance. @@ -293,6 +187,9 @@ class AlertDialogContent(el.Div, RadixThemesComponent): *children: Child components. size: The size of the content. force_mount: Whether to force mount the content on open. + on_open_auto_focus: Fired when the dialog is opened. + on_close_auto_focus: Fired when the dialog is closed. + on_escape_key_down: Fired when the escape key is pressed. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -334,52 +231,22 @@ class AlertDialogTitle(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogTitle": """Create a new component instance. @@ -413,52 +280,22 @@ class AlertDialogDescription(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogDescription": """Create a new component instance. @@ -492,52 +329,22 @@ class AlertDialogAction(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogAction": """Create a new RadixThemesTriggerComponent instance. @@ -562,52 +369,22 @@ class AlertDialogCancel(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AlertDialogCancel": """Create a new RadixThemesTriggerComponent instance. diff --git a/reflex/components/radix/themes/components/aspect_ratio.py b/reflex/components/radix/themes/components/aspect_ratio.py index 1b6847a18..fc8052c85 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.py +++ b/reflex/components/radix/themes/components/aspect_ratio.py @@ -1,7 +1,8 @@ """Interactive components provided by @radix-ui/themes.""" + 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 dc815991f..848d2064a 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.pyi +++ b/reflex/components/radix/themes/components/aspect_ratio.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/radix/themes/components/aspect_ratio.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.event import EventType from reflex.style import Style -from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent class AspectRatio(RadixThemesComponent): @@ -17,59 +17,29 @@ class AspectRatio(RadixThemesComponent): def create( # type: ignore cls, *children, - ratio: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None, + ratio: Optional[Union[Var[Union[float, int]], float, int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AspectRatio": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/avatar.py b/reflex/components/radix/themes/components/avatar.py index 0b64831c3..4f3956e76 100644 --- a/reflex/components/radix/themes/components/avatar.py +++ b/reflex/components/radix/themes/components/avatar.py @@ -2,7 +2,8 @@ from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -22,7 +23,7 @@ class Avatar(RadixThemesComponent): variant: Var[Literal["solid", "soft"]] # The size of the avatar: "1" - "9" - size: Var[LiteralSize] + size: Var[Responsive[LiteralSize]] # Color theme of the avatar color_scheme: Var[LiteralAccentColor] diff --git a/reflex/components/radix/themes/components/avatar.pyi b/reflex/components/radix/themes/components/avatar.pyi index 544522e73..fc42457da 100644 --- a/reflex/components/radix/themes/components/avatar.pyi +++ b/reflex/components/radix/themes/components/avatar.pyi @@ -1,15 +1,16 @@ """Stub file for reflex/components/radix/themes/components/avatar.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralSize = Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] @@ -20,81 +21,89 @@ 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[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + 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, @@ -105,52 +114,22 @@ class Avatar(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Avatar": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/badge.py b/reflex/components/radix/themes/components/badge.py index 587a83030..9391e53c3 100644 --- a/reflex/components/radix/themes/components/badge.py +++ b/reflex/components/radix/themes/components/badge.py @@ -2,8 +2,9 @@ from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -12,7 +13,7 @@ from ..base import ( ) -class Badge(el.Span, RadixThemesComponent): +class Badge(elements.Span, RadixThemesComponent): """A stylized badge element.""" tag = "Badge" @@ -21,7 +22,7 @@ class Badge(el.Span, RadixThemesComponent): variant: Var[Literal["solid", "soft", "surface", "outline"]] # The size of the badge - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Color theme of the badge color_scheme: Var[LiteralAccentColor] diff --git a/reflex/components/radix/themes/components/badge.pyi b/reflex/components/radix/themes/components/badge.pyi index 758630905..405b7b835 100644 --- a/reflex/components/radix/themes/components/badge.pyi +++ b/reflex/components/radix/themes/components/badge.pyi @@ -1,18 +1,19 @@ """Stub file for reflex/components/radix/themes/components/badge.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent -class Badge(el.Span, RadixThemesComponent): +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +class Badge(elements.Span, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -20,174 +21,136 @@ class Badge(el.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[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Badge": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/button.py b/reflex/components/radix/themes/components/button.py index 0e8f95345..cb44ee684 100644 --- a/reflex/components/radix/themes/components/button.py +++ b/reflex/components/radix/themes/components/button.py @@ -2,8 +2,9 @@ from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -16,7 +17,7 @@ from ..base import ( LiteralButtonSize = Literal["1", "2", "3", "4"] -class Button(el.Button, RadixLoadingProp, RadixThemesComponent): +class Button(elements.Button, RadixLoadingProp, RadixThemesComponent): """Trigger an action or event, such as submitting a form or displaying a dialog.""" tag = "Button" @@ -25,7 +26,7 @@ class Button(el.Button, RadixLoadingProp, RadixThemesComponent): as_child: Var[bool] # Button size "1" - "4" - size: Var[LiteralButtonSize] + size: Var[Responsive[LiteralButtonSize]] # Variant of button: "solid" | "soft" | "outline" | "ghost" variant: Var[LiteralVariant] diff --git a/reflex/components/radix/themes/components/button.pyi b/reflex/components/radix/themes/components/button.pyi index 617b7b389..f9702d3b5 100644 --- a/reflex/components/radix/themes/components/button.pyi +++ b/reflex/components/radix/themes/components/button.pyi @@ -1,26 +1,24 @@ """Stub file for reflex/components/radix/themes/components/button.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import ( - LiteralAccentColor, - LiteralRadius, - LiteralVariant, RadixLoadingProp, RadixThemesComponent, ) LiteralButtonSize = Literal["1", "2", "3", "4"] -class Button(el.Button, RadixLoadingProp, RadixThemesComponent): +class Button(elements.Button, RadixLoadingProp, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -28,148 +26,131 @@ class Button(el.Button, RadixLoadingProp, RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = 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[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]]] = None, - form_action: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - form_method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form_target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, @@ -177,52 +158,22 @@ class Button(el.Button, RadixLoadingProp, RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Button": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/callout.py b/reflex/components/radix/themes/components/callout.py index 5eaf1cac0..926e0ad54 100644 --- a/reflex/components/radix/themes/components/callout.py +++ b/reflex/components/radix/themes/components/callout.py @@ -3,10 +3,11 @@ from typing import Literal, Union import reflex as rx -from reflex import el 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, @@ -16,7 +17,7 @@ from ..base import ( CalloutVariant = Literal["soft", "surface", "outline"] -class CalloutRoot(el.Div, RadixThemesComponent): +class CalloutRoot(elements.Div, RadixThemesComponent): """Groups Icon and Text parts of a Callout.""" tag = "Callout.Root" @@ -25,7 +26,7 @@ class CalloutRoot(el.Div, RadixThemesComponent): as_child: Var[bool] # Size "1" - "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button: "soft" | "surface" | "outline" variant: Var[CalloutVariant] @@ -37,13 +38,13 @@ class CalloutRoot(el.Div, RadixThemesComponent): high_contrast: Var[bool] -class CalloutIcon(el.Div, RadixThemesComponent): +class CalloutIcon(elements.Div, RadixThemesComponent): """Provides width and height for the icon associated with the callout.""" tag = "Callout.Icon" -class CalloutText(el.P, RadixThemesComponent): +class CalloutText(elements.P, RadixThemesComponent): """Renders the callout text. This component is based on the p element.""" tag = "Callout.Text" diff --git a/reflex/components/radix/themes/components/callout.pyi b/reflex/components/radix/themes/components/callout.pyi index ff7cf0b00..18ae5a357 100644 --- a/reflex/components/radix/themes/components/callout.pyi +++ b/reflex/components/radix/themes/components/callout.pyi @@ -1,23 +1,22 @@ """Stub file for reflex/components/radix/themes/components/callout.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal, Union -import reflex as rx -from reflex import el -from reflex.components.component import Component, ComponentNamespace -from reflex.components.lucide.icon import Icon -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent CalloutVariant = Literal["soft", "surface", "outline"] -class CalloutRoot(el.Div, RadixThemesComponent): +class CalloutRoot(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -25,169 +24,131 @@ class CalloutRoot(el.Div, RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CalloutRoot": """Create a new component instance. @@ -230,104 +191,58 @@ class CalloutRoot(el.Div, RadixThemesComponent): """ ... -class CalloutIcon(el.Div, RadixThemesComponent): +class CalloutIcon(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CalloutIcon": """Create a new component instance. @@ -365,104 +280,58 @@ class CalloutIcon(el.Div, RadixThemesComponent): """ ... -class CalloutText(el.P, RadixThemesComponent): +class CalloutText(elements.P, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CalloutText": """Create a new component instance. @@ -510,169 +379,131 @@ class Callout(CalloutRoot): icon: Optional[Union[Var[str], str]] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Callout": """Create a callout component. @@ -726,169 +557,131 @@ class CalloutNamespace(ComponentNamespace): icon: Optional[Union[Var[str], str]] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Callout": """Create a callout component. diff --git a/reflex/components/radix/themes/components/card.py b/reflex/components/radix/themes/components/card.py index ab4cf2b88..4983cdd41 100644 --- a/reflex/components/radix/themes/components/card.py +++ b/reflex/components/radix/themes/components/card.py @@ -1,15 +1,17 @@ """Interactive components provided by @radix-ui/themes.""" + from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, ) -class Card(el.Div, RadixThemesComponent): +class Card(elements.Div, RadixThemesComponent): """Container that groups related content and actions.""" tag = "Card" @@ -18,7 +20,7 @@ class Card(el.Div, RadixThemesComponent): as_child: Var[bool] # Card size: "1" - "5" - size: Var[Literal["1", "2", "3", "4", "5"]] + size: Var[Responsive[Literal["1", "2", "3", "4", "5"],]] # Variant of Card: "solid" | "soft" | "outline" | "ghost" variant: Var[Literal["surface", "classic", "ghost"]] diff --git a/reflex/components/radix/themes/components/card.pyi b/reflex/components/radix/themes/components/card.pyi index b6df648cb..dc45bc226 100644 --- a/reflex/components/radix/themes/components/card.pyi +++ b/reflex/components/radix/themes/components/card.pyi @@ -1,18 +1,19 @@ """Stub file for reflex/components/radix/themes/components/card.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent -class Card(el.Div, RadixThemesComponent): +class Card(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -21,107 +22,68 @@ class Card(el.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5"]], Literal["1", "2", "3", "4", "5"] + 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"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Card": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/checkbox.py b/reflex/components/radix/themes/components/checkbox.py index 250a1da4c..2944b1f11 100644 --- a/reflex/components/radix/themes/components/checkbox.py +++ b/reflex/components/radix/themes/components/checkbox.py @@ -1,12 +1,13 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal +from typing import Literal from reflex.components.component import Component, ComponentNamespace +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.constants import EventTriggers -from reflex.vars import Var +from reflex.event import EventHandler, identity_event +from reflex.vars.base import LiteralVar, Var from ..base import ( LiteralAccentColor, @@ -27,7 +28,7 @@ class Checkbox(RadixThemesComponent): as_child: Var[bool] # Checkbox size "1" - "3" - size: Var[LiteralCheckboxSize] + size: Var[Responsive[LiteralCheckboxSize]] # Variant of checkbox: "classic" | "surface" | "soft" variant: Var[LiteralCheckboxVariant] @@ -59,16 +60,8 @@ class Checkbox(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onCheckedChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - } + # Fired when the checkbox is checked or unchecked. + on_change: EventHandler[identity_event(bool)] class HighLevelCheckbox(RadixThemesComponent): @@ -118,19 +111,11 @@ class HighLevelCheckbox(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onCheckedChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - } + # Fired when the checkbox is checked or unchecked. + on_change: EventHandler[identity_event(bool)] @classmethod - def create(cls, text: Var[str] = Var.create_safe(""), **props) -> Component: + def create(cls, text: Var[str] = LiteralVar.create(""), **props) -> Component: """Create a checkbox with a label. Args: diff --git a/reflex/components/radix/themes/components/checkbox.pyi b/reflex/components/radix/themes/components/checkbox.pyi index 229fca26a..8f69a0f73 100644 --- a/reflex/components/radix/themes/components/checkbox.pyi +++ b/reflex/components/radix/themes/components/checkbox.pyi @@ -1,25 +1,22 @@ """Stub file for reflex/components/radix/themes/components/checkbox.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, Literal -from reflex.components.component import Component, ComponentNamespace -from reflex.components.radix.themes.layout.flex import Flex -from reflex.components.radix.themes.typography.text import Text -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralCheckboxSize = Literal["1", "2", "3"] LiteralCheckboxVariant = Literal["classic", "surface", "soft"] class Checkbox(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -27,73 +24,81 @@ class Checkbox(RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -110,55 +115,23 @@ class Checkbox(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[bool]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Checkbox": """Create a new component instance. @@ -178,6 +151,7 @@ class Checkbox(RadixThemesComponent): required: Whether the checkbox is required name: The name of the checkbox control when submitting the form. value: The value of the checkbox control when submitting the form. + on_change: Props to rename Fired when the checkbox is checked or unchecked. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -192,7 +166,6 @@ class Checkbox(RadixThemesComponent): ... class HighLevelCheckbox(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -201,79 +174,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, @@ -290,55 +263,23 @@ class HighLevelCheckbox(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[bool]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelCheckbox": """Create a checkbox with a label. @@ -357,6 +298,7 @@ class HighLevelCheckbox(RadixThemesComponent): required: Whether the checkbox is required name: The name of the checkbox control when submitting the form. value: The value of the checkbox control when submitting the form. + on_change: Props to rename Fired when the checkbox is checked or unchecked. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -377,79 +319,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, @@ -466,55 +408,23 @@ class CheckboxNamespace(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[bool]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelCheckbox": """Create a checkbox with a label. @@ -533,6 +443,7 @@ class CheckboxNamespace(ComponentNamespace): required: Whether the checkbox is required name: The name of the checkbox control when submitting the form. value: The value of the checkbox control when submitting the form. + on_change: Props to rename Fired when the checkbox is checked or unchecked. 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/checkbox_cards.py b/reflex/components/radix/themes/components/checkbox_cards.py index 50e6a2b1d..5f5fc3ae3 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.py +++ b/reflex/components/radix/themes/components/checkbox_cards.py @@ -3,7 +3,8 @@ from types import SimpleNamespace from typing import Literal, Union -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -14,7 +15,7 @@ class CheckboxCardsRoot(RadixThemesComponent): tag = "CheckboxCards.Root" # The size of the checkbox cards: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface"]] @@ -26,10 +27,14 @@ class CheckboxCardsRoot(RadixThemesComponent): high_contrast: Var[bool] # The number of columns: - columns: Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + columns: Var[ + Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + ] # The gap between the checkbox cards: - gap: Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + gap: Var[ + Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + ] class CheckboxCardsItem(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/checkbox_cards.pyi b/reflex/components/radix/themes/components/checkbox_cards.pyi index 535bec92f..062fc1357 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.pyi +++ b/reflex/components/radix/themes/components/checkbox_cards.pyi @@ -1,16 +1,17 @@ """Stub file for reflex/components/radix/themes/components/checkbox_cards.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from types import SimpleNamespace -from typing import Literal, Union -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from typing import Any, Dict, Literal, Optional, Union, overload + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class CheckboxCardsRoot(RadixThemesComponent): @overload @@ -19,84 +20,126 @@ class CheckboxCardsRoot(RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[ - Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]], - Union[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], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + 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"], + str, + ] + ], + str, ] ] = None, gap: Optional[ Union[ - Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]], - Union[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], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + 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"], + str, + ] + ], + str, ] ] = None, style: Optional[Style] = None, @@ -105,52 +148,22 @@ class CheckboxCardsRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CheckboxCardsRoot": """Create a new component instance. @@ -190,52 +203,22 @@ class CheckboxCardsItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CheckboxCardsItem": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/checkbox_group.py b/reflex/components/radix/themes/components/checkbox_group.py index 73bc0f53f..f6379e588 100644 --- a/reflex/components/radix/themes/components/checkbox_group.py +++ b/reflex/components/radix/themes/components/checkbox_group.py @@ -1,9 +1,10 @@ """Components for the CheckboxGroup component of Radix Themes.""" from types import SimpleNamespace -from typing import Literal +from typing import List, Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -11,10 +12,10 @@ from ..base import LiteralAccentColor, RadixThemesComponent class CheckboxGroupRoot(RadixThemesComponent): """Root element for a CheckboxGroup component.""" - tag = "CheckboxGroup" + tag = "CheckboxGroup.Root" - # - size: Var[Literal["1", "2", "3"]] + # Use the size prop to control the checkbox size. + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface", "soft"]] @@ -25,12 +26,24 @@ class CheckboxGroupRoot(RadixThemesComponent): # Uses a higher contrast color for the component. high_contrast: Var[bool] + # determines which checkboxes, if any, are checked by default. + default_value: Var[List[str]] + + # used to assign a name to the entire group of checkboxes + name: Var[str] + class CheckboxGroupItem(RadixThemesComponent): """An item in the CheckboxGroup component.""" tag = "CheckboxGroup.Item" + # specifies the value associated with a particular checkbox option. + value: Var[str] + + # Use the native disabled attribute to create a disabled checkbox. + disabled: Var[bool] + class CheckboxGroup(SimpleNamespace): """CheckboxGroup components namespace.""" diff --git a/reflex/components/radix/themes/components/checkbox_group.pyi b/reflex/components/radix/themes/components/checkbox_group.pyi index b77e48f9c..363be0599 100644 --- a/reflex/components/radix/themes/components/checkbox_group.pyi +++ b/reflex/components/radix/themes/components/checkbox_group.pyi @@ -1,16 +1,17 @@ """Stub file for reflex/components/radix/themes/components/checkbox_group.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from types import SimpleNamespace -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from typing import Any, Dict, List, Literal, Optional, Union, overload + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class CheckboxGroupRoot(RadixThemesComponent): @overload @@ -19,129 +20,109 @@ class CheckboxGroupRoot(RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[List[str], Var[List[str]]]] = None, + name: Optional[Union[Var[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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CheckboxGroupRoot": """Create a new component instance. @@ -150,10 +131,12 @@ class CheckboxGroupRoot(RadixThemesComponent): Args: *children: Child components. - size: + size: Use the size prop to control the checkbox size. variant: Variant of button: "classic" | "surface" | "soft" color_scheme: Override theme color for button high_contrast: Uses a higher contrast color for the component. + default_value: determines which checkboxes, if any, are checked by default. + name: used to assign a name to the entire group of checkboxes style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -173,58 +156,30 @@ class CheckboxGroupItem(RadixThemesComponent): def create( # type: ignore cls, *children, + value: Optional[Union[Var[str], str]] = None, + disabled: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CheckboxGroupItem": """Create a new component instance. @@ -233,6 +188,8 @@ class CheckboxGroupItem(RadixThemesComponent): Args: *children: Child components. + value: specifies the value associated with a particular checkbox option. + disabled: Use the native disabled attribute to create a disabled checkbox. 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/context_menu.py b/reflex/components/radix/themes/components/context_menu.py index 7631d7970..3eb54a457 100644 --- a/reflex/components/radix/themes/components/context_menu.py +++ b/reflex/components/radix/themes/components/context_menu.py @@ -1,9 +1,11 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, List, Literal + +from typing import List, Literal from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -21,16 +23,8 @@ class ContextMenuRoot(RadixThemesComponent): _invalid_children: List[str] = ["ContextMenuItem"] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class ContextMenuTrigger(RadixThemesComponent): @@ -52,7 +46,7 @@ class ContextMenuContent(RadixThemesComponent): tag = "ContextMenu.Content" # Button size "1" - "4" - size: Var[Literal["1", "2"]] + size: Var[Responsive[Literal["1", "2"]]] # Variant of button: "solid" | "soft" | "outline" | "ghost" variant: Var[Literal["solid", "soft"]] @@ -69,20 +63,20 @@ class ContextMenuContent(RadixThemesComponent): # When true, overrides the side and aligns preferences to prevent collisions with boundary edges. avoid_collisions: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the context menu is closed. + on_close_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_FOCUS_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] + + # Fired when a pointer down event happens outside the context menu. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when focus moves outside the context menu. + on_focus_outside: EventHandler[empty_event] + + # Fired when interacting outside the context menu. + on_interact_outside: EventHandler[empty_event] class ContextMenuSub(RadixThemesComponent): @@ -112,19 +106,17 @@ class ContextMenuSubContent(RadixThemesComponent): _valid_parents: List[str] = ["ContextMenuSub"] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_FOCUS_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when a pointer down event happens outside the context menu. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when focus moves outside the context menu. + on_focus_outside: EventHandler[empty_event] + + # Fired when interacting outside the context menu. + on_interact_outside: EventHandler[empty_event] class ContextMenuItem(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/context_menu.pyi b/reflex/components/radix/themes/components/context_menu.pyi index 9e819f911..bfb88b303 100644 --- a/reflex/components/radix/themes/components/context_menu.pyi +++ b/reflex/components/radix/themes/components/context_menu.pyi @@ -1,20 +1,19 @@ """Stub file for reflex/components/radix/themes/components/context_menu.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Literal + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class ContextMenuRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -27,55 +26,23 @@ class ContextMenuRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuRoot": """Create a new component instance. @@ -85,6 +52,7 @@ class ContextMenuRoot(RadixThemesComponent): Args: *children: Child components. modal: The modality of the context menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -111,52 +79,22 @@ class ContextMenuTrigger(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuTrigger": """Create a new component instance. @@ -180,75 +118,80 @@ class ContextMenuTrigger(RadixThemesComponent): ... class ContextMenuContent(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - size: Optional[Union[Var[Literal["1", "2"]], Literal["1", "2"]]] = None, + size: Optional[ + Union[ + 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, @@ -261,67 +204,27 @@ class ContextMenuContent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_focus_outside: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuContent": """Create a new component instance. @@ -336,6 +239,11 @@ class ContextMenuContent(RadixThemesComponent): high_contrast: Whether to render the button with higher contrast color against background align_offset: The vertical distance in pixels from the anchor. avoid_collisions: When true, overrides the side and aligns preferences to prevent collisions with boundary edges. + on_close_auto_focus: Fired when the context menu is closed. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when a pointer down event happens outside the context menu. + on_focus_outside: Fired when focus moves outside the context menu. + on_interact_outside: Fired when interacting outside the context menu. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -361,52 +269,22 @@ class ContextMenuSub(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuSub": """Create a new component instance. @@ -441,52 +319,22 @@ class ContextMenuSubTrigger(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuSubTrigger": """Create a new component instance. @@ -510,7 +358,6 @@ class ContextMenuSubTrigger(RadixThemesComponent): ... class ContextMenuSubContent(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -523,64 +370,26 @@ class ContextMenuSubContent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_focus_outside: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuSubContent": """Create a new component instance. @@ -590,6 +399,10 @@ class ContextMenuSubContent(RadixThemesComponent): Args: *children: Child components. loop: When true, keyboard navigation will loop from last item to first, and vice versa. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when a pointer down event happens outside the context menu. + on_focus_outside: Fired when focus moves outside the context menu. + on_interact_outside: Fired when interacting outside the context menu. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -611,63 +424,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, @@ -678,52 +491,22 @@ class ContextMenuItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuItem": """Create a new component instance. @@ -759,52 +542,22 @@ class ContextMenuSeparator(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ContextMenuSeparator": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/data_list.py b/reflex/components/radix/themes/components/data_list.py index 44d797edd..05d4af074 100644 --- a/reflex/components/radix/themes/components/data_list.py +++ b/reflex/components/radix/themes/components/data_list.py @@ -3,7 +3,8 @@ from types import SimpleNamespace from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -14,13 +15,13 @@ class DataListRoot(RadixThemesComponent): tag = "DataList.Root" # The orientation of the data list item: "horizontal" | "vertical" - orientation: Var[Literal["horizontal", "vertical"]] + orientation: Var[Responsive[Literal["horizontal", "vertical"]]] # The size of the data list item: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Trims the leading whitespace from the start or end of the text. - trim: Var[Literal["normal", "start", "end", "both"]] + trim: Var[Responsive[Literal["normal", "start", "end", "both"]]] class DataListItem(RadixThemesComponent): @@ -28,7 +29,8 @@ class DataListItem(RadixThemesComponent): tag = "DataList.Item" - align: Var[Literal["start", "center", "end", "baseline", "stretch"]] + # The alignment of the data list item within its container. + align: Var[Responsive[Literal["start", "center", "end", "baseline", "stretch"]]] class DataListLabel(RadixThemesComponent): @@ -36,12 +38,16 @@ class DataListLabel(RadixThemesComponent): tag = "DataList.Label" - width: Var[str] + # The width of the component + width: Var[Responsive[str]] - min_width: Var[str] + # The minimum width of the component + min_width: Var[Responsive[str]] - max_width: Var[str] + # The maximum width of the component + max_width: Var[Responsive[str]] + # The color scheme for the DataList component. color_scheme: Var[LiteralAccentColor] diff --git a/reflex/components/radix/themes/components/data_list.pyi b/reflex/components/radix/themes/components/data_list.pyi index 0bf459fa0..342fa6e77 100644 --- a/reflex/components/radix/themes/components/data_list.pyi +++ b/reflex/components/radix/themes/components/data_list.pyi @@ -1,16 +1,17 @@ """Stub file for reflex/components/radix/themes/components/data_list.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from types import SimpleNamespace -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from typing import Any, Dict, Literal, Optional, Union, overload + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class DataListRoot(RadixThemesComponent): @overload @@ -20,17 +21,37 @@ class DataListRoot(RadixThemesComponent): *children, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], + Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[ + Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], + ] + ], ] ] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = None, style: Optional[Style] = None, @@ -39,52 +60,22 @@ class DataListRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataListRoot": """Create a new component instance. @@ -117,8 +108,19 @@ class DataListItem(RadixThemesComponent): *children, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline", "stretch"]], - Literal["start", "center", "end", "baseline", "stretch"], + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], + Var[ + Union[ + Breakpoints[ + str, + Literal["baseline", "center", "end", "start", "stretch"], + ], + Literal["baseline", "center", "end", "start", "stretch"], + ] + ], ] ] = None, style: Optional[Style] = None, @@ -127,52 +129,22 @@ class DataListItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataListItem": """Create a new component instance. @@ -181,6 +153,7 @@ class DataListItem(RadixThemesComponent): Args: *children: Child components. + align: The alignment of the data list item within its container. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -200,68 +173,74 @@ class DataListLabel(RadixThemesComponent): def create( # type: ignore cls, *children, - width: Optional[Union[Var[str], str]] = None, - min_width: Optional[Union[Var[str], str]] = None, - max_width: Optional[Union[Var[str], str]] = None, + width: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + min_width: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + max_width: Optional[ + 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, @@ -271,52 +250,22 @@ class DataListLabel(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataListLabel": """Create a new component instance. @@ -325,6 +274,10 @@ class DataListLabel(RadixThemesComponent): Args: *children: Child components. + width: The width of the component + min_width: The minimum width of the component + max_width: The maximum width of the component + color_scheme: The color scheme for the DataList component. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -350,52 +303,22 @@ class DataListValue(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DataListValue": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/dialog.py b/reflex/components/radix/themes/components/dialog.py index 1f25efd1b..e8da506ed 100644 --- a/reflex/components/radix/themes/components/dialog.py +++ b/reflex/components/radix/themes/components/dialog.py @@ -1,11 +1,12 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal +from typing import Literal -from reflex import el from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, @@ -21,16 +22,8 @@ class DialogRoot(RadixThemesComponent): # The controlled open state of the dialog. open: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class DialogTrigger(RadixThemesTriggerComponent): @@ -45,28 +38,28 @@ class DialogTitle(RadixThemesComponent): tag = "Dialog.Title" -class DialogContent(el.Div, RadixThemesComponent): +class DialogContent(elements.Div, RadixThemesComponent): """Content component to display inside a Dialog modal.""" tag = "Dialog.Content" # DialogContent size "1" - "4" - size: Var[Literal["1", "2", "3", "4"]] + size: Var[Responsive[Literal["1", "2", "3", "4"]]] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the dialog is opened. + on_open_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when the dialog is closed. + on_close_auto_focus: EventHandler[empty_event] + + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] + + # Fired when the pointer is down outside the dialog. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when the pointer interacts outside the dialog. + on_interact_outside: EventHandler[empty_event] class DialogDescription(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/dialog.pyi b/reflex/components/radix/themes/components/dialog.pyi index f3d158418..a277fc775 100644 --- a/reflex/components/radix/themes/components/dialog.pyi +++ b/reflex/components/radix/themes/components/dialog.pyi @@ -1,21 +1,20 @@ """Stub file for reflex/components/radix/themes/components/dialog.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from ..base import RadixThemesComponent, RadixThemesTriggerComponent class DialogRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -28,55 +27,23 @@ class DialogRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogRoot": """Create a new component instance. @@ -86,6 +53,7 @@ class DialogRoot(RadixThemesComponent): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -111,52 +79,22 @@ class DialogTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -181,52 +119,22 @@ class DialogTitle(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogTitle": """Create a new component instance. @@ -248,123 +156,75 @@ class DialogTitle(RadixThemesComponent): """ ... -class DialogContent(el.Div, RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... +class DialogContent(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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"], + ] + ], + ] ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_auto_focus: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogContent": """Create a new component instance. @@ -374,6 +234,11 @@ class DialogContent(el.Div, RadixThemesComponent): Args: *children: Child components. size: DialogContent size "1" - "4" + on_open_auto_focus: Fired when the dialog is opened. + on_close_auto_focus: Fired when the dialog is closed. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when the pointer is down outside the dialog. + on_interact_outside: Fired when the pointer interacts outside the dialog. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -415,52 +280,22 @@ class DialogDescription(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogDescription": """Create a new component instance. @@ -494,52 +329,22 @@ class DialogClose(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogClose": """Create a new RadixThemesTriggerComponent instance. @@ -570,55 +375,23 @@ class Dialog(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DialogRoot": """Create a new component instance. @@ -628,6 +401,7 @@ class Dialog(ComponentNamespace): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. 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/dropdown_menu.py b/reflex/components/radix/themes/components/dropdown_menu.py index 350f15eba..885e8df35 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.py +++ b/reflex/components/radix/themes/components/dropdown_menu.py @@ -1,9 +1,11 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, List, Literal, Union + +from typing import Dict, List, Literal, Union from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -47,16 +49,8 @@ class DropdownMenuRoot(RadixThemesComponent): _invalid_children: List[str] = ["DropdownMenuItem"] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class DropdownMenuTrigger(RadixThemesTriggerComponent): @@ -78,7 +72,7 @@ class DropdownMenuContent(RadixThemesComponent): tag = "DropdownMenu.Content" # Dropdown Menu Content size "1" - "2" - size: Var[LiteralSizeType] + size: Var[Responsive[LiteralSizeType]] # Variant of Dropdown Menu Content: "solid" | "soft" variant: Var[LiteralVariantType] @@ -125,20 +119,20 @@ class DropdownMenuContent(RadixThemesComponent): # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. hide_when_detached: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the dialog is closed. + on_close_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_FOCUS_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] + + # Fired when the pointer is down outside the dialog. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when focus moves outside the dialog. + on_focus_outside: EventHandler[empty_event] + + # Fired when the pointer interacts outside the dialog. + on_interact_outside: EventHandler[empty_event] class DropdownMenuSubTrigger(RadixThemesTriggerComponent): @@ -169,16 +163,8 @@ class DropdownMenuSub(RadixThemesComponent): # The open state of the submenu when it is initially rendered. Use when you do not need to control its open state. default_open: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0.target.value], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class DropdownMenuSubContent(RadixThemesComponent): @@ -218,19 +204,17 @@ class DropdownMenuSubContent(RadixThemesComponent): _valid_parents: List[str] = ["DropdownMenuSub"] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_FOCUS_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when the pointer is down outside the dialog. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when focus moves outside the dialog. + on_focus_outside: EventHandler[empty_event] + + # Fired when the pointer interacts outside the dialog. + on_interact_outside: EventHandler[empty_event] class DropdownMenuItem(RadixThemesComponent): @@ -255,16 +239,8 @@ class DropdownMenuItem(RadixThemesComponent): _valid_parents: List[str] = ["DropdownMenuContent", "DropdownMenuSubContent"] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_SELECT: lambda e0: [e0.target.value], - } + # Fired when the item is selected. + on_select: EventHandler[empty_event] class DropdownMenuSeparator(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/dropdown_menu.pyi b/reflex/components/radix/themes/components/dropdown_menu.pyi index a8fad6d86..ccb2ef347 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.pyi +++ b/reflex/components/radix/themes/components/dropdown_menu.pyi @@ -1,17 +1,17 @@ """Stub file for reflex/components/radix/themes/components/dropdown_menu.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Literal, Union + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent, RadixThemesTriggerComponent +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent, RadixThemesTriggerComponent LiteralDirType = Literal["ltr", "rtl"] LiteralSizeType = Literal["1", "2"] @@ -21,7 +21,6 @@ LiteralAlignType = Literal["start", "center", "end"] LiteralStickyType = Literal["partial", "always"] class DropdownMenuRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -30,62 +29,30 @@ 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuRoot": """Create a new component instance. @@ -98,6 +65,7 @@ class DropdownMenuRoot(RadixThemesComponent): open: The controlled open state of the dropdown menu. Must be used in conjunction with onOpenChange. modal: The modality of the dropdown menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers. Defaults to True. dir: The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -124,52 +92,22 @@ class DropdownMenuTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -183,75 +121,80 @@ class DropdownMenuTrigger(RadixThemesTriggerComponent): ... class DropdownMenuContent(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - size: Optional[Union[Var[Literal["1", "2"]], Literal["1", "2"]]] = None, + size: Optional[ + Union[ + 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, @@ -261,30 +204,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]], Union[float, int]]] = 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]], Union[float, int]]] = None, + align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ - Var[Union[float, int, Dict[str, Union[float, int]]]], - Union[float, int, Dict[str, Union[float, int]]], + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, ] ] = None, - arrow_padding: Optional[ - Union[Var[Union[float, int]], 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, @@ -293,67 +236,27 @@ class DropdownMenuContent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_focus_outside: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuContent": """Create a new component instance. @@ -378,6 +281,11 @@ class DropdownMenuContent(RadixThemesComponent): arrow_padding: The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0. sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False. + on_close_auto_focus: Fired when the dialog is closed. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when the pointer is down outside the dialog. + on_focus_outside: Fired when focus moves outside the dialog. + on_interact_outside: Fired when the pointer interacts outside the dialog. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -406,52 +314,22 @@ class DropdownMenuSubTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuSubTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -465,7 +343,6 @@ class DropdownMenuSubTrigger(RadixThemesTriggerComponent): ... class DropdownMenuSub(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -479,55 +356,23 @@ class DropdownMenuSub(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuSub": """Create a new component instance. @@ -538,6 +383,7 @@ class DropdownMenuSub(RadixThemesComponent): *children: Child components. open: The controlled open state of the submenu. Must be used in conjunction with `on_open_change`. default_open: The open state of the submenu when it is initially rendered. Use when you do not need to control its open state. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -552,7 +398,6 @@ class DropdownMenuSub(RadixThemesComponent): ... class DropdownMenuSubContent(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -561,20 +406,20 @@ class DropdownMenuSubContent(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, loop: Optional[Union[Var[bool], bool]] = None, force_mount: Optional[Union[Var[bool], bool]] = None, - side_offset: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None, - align_offset: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None, + side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, + align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ - Var[Union[float, int, Dict[str, Union[float, int]]]], - Union[float, int, Dict[str, Union[float, int]]], + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, ] ] = None, - arrow_padding: Optional[ - Union[Var[Union[float, int]], 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, @@ -583,64 +428,26 @@ class DropdownMenuSubContent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_focus_outside: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuSubContent": """Create a new component instance. @@ -659,6 +466,10 @@ class DropdownMenuSubContent(RadixThemesComponent): arrow_padding: The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0. sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when the pointer is down outside the dialog. + on_focus_outside: Fired when focus moves outside the dialog. + on_interact_outside: Fired when the pointer interacts outside the dialog. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -673,7 +484,6 @@ class DropdownMenuSubContent(RadixThemesComponent): ... class DropdownMenuItem(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -681,63 +491,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, @@ -751,55 +561,23 @@ class DropdownMenuItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_select: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_select: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuItem": """Create a new component instance. @@ -813,6 +591,7 @@ class DropdownMenuItem(RadixThemesComponent): as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. disabled: When true, prevents the user from interacting with the item. text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. + on_select: Fired when the item is selected. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -838,52 +617,22 @@ class DropdownMenuSeparator(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "DropdownMenuSeparator": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/hover_card.py b/reflex/components/radix/themes/components/hover_card.py index 9b90f98ce..e76184795 100644 --- a/reflex/components/radix/themes/components/hover_card.py +++ b/reflex/components/radix/themes/components/hover_card.py @@ -1,10 +1,12 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal -from reflex import el +from typing import Literal + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.event import EventHandler, identity_event +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, @@ -29,16 +31,8 @@ class HoverCardRoot(RadixThemesComponent): # The duration from when the mouse leaves the trigger until the hover card closes. close_delay: Var[int] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class HoverCardTrigger(RadixThemesTriggerComponent): @@ -47,13 +41,13 @@ class HoverCardTrigger(RadixThemesTriggerComponent): tag = "HoverCard.Trigger" -class HoverCardContent(el.Div, RadixThemesComponent): +class HoverCardContent(elements.Div, RadixThemesComponent): """Contains the content of the open hover card.""" tag = "HoverCard.Content" # The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. - side: Var[Literal["top", "right", "bottom", "left"]] + side: Var[Responsive[Literal["top", "right", "bottom", "left"]]] # The distance in pixels from the trigger. side_offset: Var[int] diff --git a/reflex/components/radix/themes/components/hover_card.pyi b/reflex/components/radix/themes/components/hover_card.pyi index 697ef2cdc..50c646971 100644 --- a/reflex/components/radix/themes/components/hover_card.pyi +++ b/reflex/components/radix/themes/components/hover_card.pyi @@ -1,21 +1,20 @@ """Stub file for reflex/components/radix/themes/components/hover_card.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from ..base import RadixThemesComponent, RadixThemesTriggerComponent class HoverCardRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -31,55 +30,23 @@ class HoverCardRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HoverCardRoot": """Create a new component instance. @@ -92,6 +59,7 @@ class HoverCardRoot(RadixThemesComponent): open: The controlled open state of the hover card. Must be used in conjunction with onOpenChange. open_delay: The duration from when the mouse enters the trigger until the hover card opens. close_delay: The duration from when the mouse leaves the trigger until the hover card closes. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -117,52 +85,22 @@ class HoverCardTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HoverCardTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -175,7 +113,7 @@ class HoverCardTrigger(RadixThemesTriggerComponent): """ ... -class HoverCardContent(el.Div, RadixThemesComponent): +class HoverCardContent(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -183,110 +121,70 @@ class HoverCardContent(el.Div, RadixThemesComponent): *children, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + Literal["bottom", "left", "right", "top"], + Var[ + Union[ + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + 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, avoid_collisions: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HoverCardContent": """Create a new component instance. @@ -346,55 +244,23 @@ class HoverCard(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HoverCardRoot": """Create a new component instance. @@ -407,6 +273,7 @@ class HoverCard(ComponentNamespace): open: The controlled open state of the hover card. Must be used in conjunction with onOpenChange. open_delay: The duration from when the mouse enters the trigger until the hover card opens. close_delay: The duration from when the mouse leaves the trigger until the hover card closes. + on_open_change: Fired when the open state changes. 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/icon_button.py b/reflex/components/radix/themes/components/icon_button.py index 452e37640..2a32afe3a 100644 --- a/reflex/components/radix/themes/components/icon_button.py +++ b/reflex/components/radix/themes/components/icon_button.py @@ -1,14 +1,16 @@ """Interactive components provided by @radix-ui/themes.""" + from __future__ import annotations from typing import Literal -from reflex import el from reflex.components.component import Component +from reflex.components.core.breakpoints import Responsive 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, @@ -21,7 +23,7 @@ from ..base import ( LiteralButtonSize = Literal["1", "2", "3", "4"] -class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): +class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): """A button designed specifically for usage with a single icon.""" tag = "IconButton" @@ -30,7 +32,7 @@ class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): as_child: Var[bool] # Button size "1" - "4" - size: Var[LiteralButtonSize] + size: Var[Responsive[LiteralButtonSize]] # Variant of button: "classic" | "solid" | "soft" | "surface" | "outline" | "ghost" variant: Var[LiteralVariant] diff --git a/reflex/components/radix/themes/components/icon_button.pyi b/reflex/components/radix/themes/components/icon_button.pyi index 3e3657dbf..901c8d6ff 100644 --- a/reflex/components/radix/themes/components/icon_button.pyi +++ b/reflex/components/radix/themes/components/icon_button.pyi @@ -1,30 +1,24 @@ """Stub file for reflex/components/radix/themes/components/icon_button.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.components.component import Component -from reflex.components.core.match import Match -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, - LiteralRadius, - LiteralVariant, RadixLoadingProp, RadixThemesComponent, ) LiteralButtonSize = Literal["1", "2", "3", "4"] -class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): +class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -32,148 +26,131 @@ class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = 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[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]]] = None, - form_action: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - form_method: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - form_target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - name: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - value: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, @@ -181,52 +158,22 @@ class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "IconButton": """Create a IconButton component. @@ -281,6 +228,7 @@ class IconButton(el.Button, RadixLoadingProp, RadixThemesComponent): The IconButton component. """ ... + def add_style(self): ... icon_button = IconButton.create diff --git a/reflex/components/radix/themes/components/inset.py b/reflex/components/radix/themes/components/inset.py index fcdafc6a0..347b9f6b0 100644 --- a/reflex/components/radix/themes/components/inset.py +++ b/reflex/components/radix/themes/components/inset.py @@ -1,8 +1,10 @@ """Interactive components provided by @radix-ui/themes.""" + from typing import Literal, Union -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, @@ -11,37 +13,37 @@ from ..base import ( LiteralButtonSize = Literal["1", "2", "3", "4"] -class Inset(el.Div, RadixThemesComponent): +class Inset(elements.Div, RadixThemesComponent): """Applies a negative margin to allow content to bleed into the surrounding container.""" tag = "Inset" # The side - side: Var[Literal["x", "y", "top", "bottom", "right", "left"]] + side: Var[Responsive[Literal["x", "y", "top", "bottom", "right", "left"]]] # How to clip the element's content: "border-box" | "padding-box" - clip: Var[Literal["border-box", "padding-box"]] + clip: Var[Responsive[Literal["border-box", "padding-box"]]] # Padding - p: Var[Union[int, str]] + p: Var[Responsive[Union[int, str]]] # Padding on the x axis - px: Var[Union[int, str]] + px: Var[Responsive[Union[int, str]]] # Padding on the y axis - py: Var[Union[int, str]] + py: Var[Responsive[Union[int, str]]] # Padding on the top - pt: Var[Union[int, str]] + pt: Var[Responsive[Union[int, str]]] # Padding on the right - pr: Var[Union[int, str]] + pr: Var[Responsive[Union[int, str]]] # Padding on the bottom - pb: Var[Union[int, str]] + pb: Var[Responsive[Union[int, str]]] # Padding on the left - pl: Var[Union[int, str]] + pl: Var[Responsive[Union[int, str]]] inset = Inset.create diff --git a/reflex/components/radix/themes/components/inset.pyi b/reflex/components/radix/themes/components/inset.pyi index 23f212d09..d6b0cce04 100644 --- a/reflex/components/radix/themes/components/inset.pyi +++ b/reflex/components/radix/themes/components/inset.pyi @@ -1,20 +1,21 @@ """Stub file for reflex/components/radix/themes/components/inset.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal, Union -from reflex import el -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent LiteralButtonSize = Literal["1", "2", "3", "4"] -class Inset(el.Div, RadixThemesComponent): +class Inset(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -22,115 +23,132 @@ class Inset(el.Div, RadixThemesComponent): *children, side: Optional[ Union[ - Var[Literal["x", "y", "top", "bottom", "right", "left"]], - Literal["x", "y", "top", "bottom", "right", "left"], + Breakpoints[str, Literal["bottom", "left", "right", "top", "x", "y"]], + Literal["bottom", "left", "right", "top", "x", "y"], + Var[ + Union[ + Breakpoints[ + str, Literal["bottom", "left", "right", "top", "x", "y"] + ], + Literal["bottom", "left", "right", "top", "x", "y"], + ] + ], ] ] = None, clip: Optional[ Union[ - Var[Literal["border-box", "padding-box"]], + 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"], + ] + ], ] ] = None, - p: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - px: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - py: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - pt: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - pr: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - pb: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - pl: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + p: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] ] = None, + px: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + py: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + pt: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + pr: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + pb: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + pl: Optional[ + Union[ + Breakpoints[str, Union[int, str]], + Var[Union[Breakpoints[str, Union[int, str]], int, str]], + int, + str, + ] + ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Inset": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/popover.py b/reflex/components/radix/themes/components/popover.py index 08415ba56..2535a8a22 100644 --- a/reflex/components/radix/themes/components/popover.py +++ b/reflex/components/radix/themes/components/popover.py @@ -1,10 +1,12 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal -from reflex import el +from typing import Literal + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, @@ -23,16 +25,8 @@ class PopoverRoot(RadixThemesComponent): # The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers. modal: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - } + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] class PopoverTrigger(RadixThemesTriggerComponent): @@ -41,13 +35,13 @@ class PopoverTrigger(RadixThemesTriggerComponent): tag = "Popover.Trigger" -class PopoverContent(el.Div, RadixThemesComponent): +class PopoverContent(elements.Div, RadixThemesComponent): """Contains content to be rendered in the open popover.""" tag = "Popover.Content" # Size of the button: "1" | "2" | "3" | "4" - size: Var[Literal["1", "2", "3", "4"]] + size: Var[Responsive[Literal["1", "2", "3", "4"]]] # The preferred side of the anchor to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. side: Var[Literal["top", "right", "bottom", "left"]] @@ -64,21 +58,23 @@ class PopoverContent(el.Div, RadixThemesComponent): # When true, overrides the side andalign preferences to prevent collisions with boundary edges. avoid_collisions: Var[bool] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the dialog is opened. + on_open_auto_focus: EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_FOCUS_OUTSIDE: lambda e0: [e0], - EventTriggers.ON_INTERACT_OUTSIDE: lambda e0: [e0], - } + # Fired when the dialog is closed. + on_close_auto_focus: EventHandler[empty_event] + + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] + + # Fired when the pointer is down outside the dialog. + on_pointer_down_outside: EventHandler[empty_event] + + # Fired when focus moves outside the dialog. + on_focus_outside: EventHandler[empty_event] + + # Fired when the pointer interacts outside the dialog. + on_interact_outside: EventHandler[empty_event] class PopoverClose(RadixThemesTriggerComponent): diff --git a/reflex/components/radix/themes/components/popover.pyi b/reflex/components/radix/themes/components/popover.pyi index 04d705051..35f6854f6 100644 --- a/reflex/components/radix/themes/components/popover.pyi +++ b/reflex/components/radix/themes/components/popover.pyi @@ -1,21 +1,20 @@ """Stub file for reflex/components/radix/themes/components/popover.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from ..base import RadixThemesComponent, RadixThemesTriggerComponent class PopoverRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -29,55 +28,23 @@ class PopoverRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PopoverRoot": """Create a new component instance. @@ -88,6 +55,7 @@ class PopoverRoot(RadixThemesComponent): *children: Child components. open: The controlled open state of the popover. modal: The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers. + on_open_change: Fired when the open state changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -113,52 +81,22 @@ class PopoverTrigger(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PopoverTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -171,141 +109,91 @@ class PopoverTrigger(RadixThemesTriggerComponent): """ ... -class PopoverContent(el.Div, RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... +class PopoverContent(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_focus_outside: Optional[EventType[[]]] = None, + on_interact_outside: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_auto_focus: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PopoverContent": """Create a new component instance. @@ -320,6 +208,12 @@ class PopoverContent(el.Div, RadixThemesComponent): align: The preferred alignment against the anchor. May change when collisions occur. align_offset: The vertical distance in pixels from the anchor. avoid_collisions: When true, overrides the side andalign preferences to prevent collisions with boundary edges. + on_open_auto_focus: Fired when the dialog is opened. + on_close_auto_focus: Fired when the dialog is closed. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when the pointer is down outside the dialog. + on_focus_outside: Fired when focus moves outside the dialog. + on_interact_outside: Fired when the pointer interacts outside the dialog. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -361,52 +255,22 @@ class PopoverClose(RadixThemesTriggerComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PopoverClose": """Create a new RadixThemesTriggerComponent instance. diff --git a/reflex/components/radix/themes/components/progress.py b/reflex/components/radix/themes/components/progress.py index bcd64edb8..e9fe168c6 100644 --- a/reflex/components/radix/themes/components/progress.py +++ b/reflex/components/radix/themes/components/progress.py @@ -3,7 +3,9 @@ from typing import Literal from reflex.components.component import Component -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.style import Style +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -20,7 +22,7 @@ class Progress(RadixThemesComponent): max: Var[int] # The size of the progress bar: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # The variant of the progress bar: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface", "soft"]] @@ -37,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. @@ -49,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 e72b83273..6470842f3 100644 --- a/reflex/components/radix/themes/components/progress.pyi +++ b/reflex/components/radix/themes/components/progress.pyi @@ -1,16 +1,16 @@ """Stub file for reflex/components/radix/themes/components/progress.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.components.component import Component -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class Progress(RadixThemesComponent): @overload @@ -21,136 +21,115 @@ class Progress(RadixThemesComponent): value: Optional[Union[Var[int], int]] = None, max: Optional[Union[Var[int], int]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Progress": """Create a Progress component. @@ -164,6 +143,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 f8939b292..fd24bb6b5 100644 --- a/reflex/components/radix/themes/components/radio.py +++ b/reflex/components/radix/themes/components/radio.py @@ -2,7 +2,8 @@ from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -13,7 +14,7 @@ class Radio(RadixThemesComponent): tag = "Radio" # The size of the radio: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface", "soft"]] diff --git a/reflex/components/radix/themes/components/radio.pyi b/reflex/components/radix/themes/components/radio.pyi index 72e5e90cb..f1a6b131a 100644 --- a/reflex/components/radix/themes/components/radio.pyi +++ b/reflex/components/radix/themes/components/radio.pyi @@ -1,15 +1,16 @@ """Stub file for reflex/components/radix/themes/components/radio.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class Radio(RadixThemesComponent): @overload @@ -18,73 +19,81 @@ class Radio(RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -95,52 +104,22 @@ class Radio(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Radio": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/radio_cards.py b/reflex/components/radix/themes/components/radio_cards.py index aed7f4d11..e0aa2a749 100644 --- a/reflex/components/radix/themes/components/radio_cards.py +++ b/reflex/components/radix/themes/components/radio_cards.py @@ -3,7 +3,9 @@ from types import SimpleNamespace from typing import Literal, Union -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler, identity_event +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -13,8 +15,11 @@ class RadioCardsRoot(RadixThemesComponent): tag = "RadioCards.Root" + # Change the default rendered element for the one passed as a child, merging their props and behavior. + as_child: Var[bool] + # The size of the checkbox cards: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface"]] @@ -26,10 +31,41 @@ class RadioCardsRoot(RadixThemesComponent): high_contrast: Var[bool] # The number of columns: - columns: Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + columns: Var[ + Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + ] # The gap between the checkbox cards: - gap: Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + gap: Var[ + Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]] + ] + + default_value: Var[str] + + # The controlled value of the radio item to check. Should be used in conjunction with onValueChange. + value: Var[str] + + # The name of the group. Submitted with its owning form as part of a name/value pair. + name: Var[str] + + # When true, prevents the user from interacting with radio items. + disabled: Var[bool] + + # When true, indicates that the user must check a radio item before the owning form can be submitted. + required: Var[bool] + + # The orientation of the component. + orientation: Var[Literal["horizontal", "vertical", "undefined"]] + + # The reading direction of the radio group. If omitted, + # inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. + dir: Var[Literal["ltr", "rtl"]] + + # When true, keyboard navigation will loop from last item to first, and vice versa. + loop: Var[bool] + + # Event handler called when the value changes. + on_value_change: EventHandler[identity_event(str)] class RadioCardsItem(RadixThemesComponent): @@ -37,6 +73,18 @@ class RadioCardsItem(RadixThemesComponent): tag = "RadioCards.Item" + # Change the default rendered element for the one passed as a child, merging their props and behavior. + as_child: Var[bool] + + # The value given as data when submitted with a name. + value: Var[str] + + # When true, prevents the user from interacting with the radio item. + disabled: Var[bool] + + # When true, indicates that the user must check the radio item before the owning form can be submitted. + required: Var[bool] + class RadioCards(SimpleNamespace): """RadioCards components namespace.""" diff --git a/reflex/components/radix/themes/components/radio_cards.pyi b/reflex/components/radix/themes/components/radio_cards.pyi index 2985476f3..ac6a645a9 100644 --- a/reflex/components/radix/themes/components/radio_cards.pyi +++ b/reflex/components/radix/themes/components/radio_cards.pyi @@ -1,16 +1,17 @@ """Stub file for reflex/components/radix/themes/components/radio_cards.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from types import SimpleNamespace -from typing import Literal, Union -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from typing import Any, Dict, Literal, Optional, Union, overload + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class RadioCardsRoot(RadixThemesComponent): @overload @@ -18,139 +19,166 @@ class RadioCardsRoot(RadixThemesComponent): def create( # type: ignore cls, *children, + as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[ - Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]], - Union[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], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + 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"], + str, + ] + ], + str, ] ] = None, gap: Optional[ Union[ - Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]], - Union[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], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + 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"], + str, + ] + ], + str, ] ] = None, + default_value: Optional[Union[Var[str], str]] = None, + value: Optional[Union[Var[str], str]] = None, + name: Optional[Union[Var[str], str]] = None, + disabled: Optional[Union[Var[bool], bool]] = None, + required: Optional[Union[Var[bool], bool]] = None, + orientation: Optional[ + Union[ + Literal["horizontal", "undefined", "vertical"], + Var[Literal["horizontal", "undefined", "vertical"]], + ] + ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + on_value_change: Optional[EventType[str]] = None, + **props, ) -> "RadioCardsRoot": """Create a new component instance. @@ -159,12 +187,21 @@ class RadioCardsRoot(RadixThemesComponent): Args: *children: Child components. + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. size: The size of the checkbox cards: "1" | "2" | "3" variant: Variant of button: "classic" | "surface" | "soft" color_scheme: Override theme color for button high_contrast: Uses a higher contrast color for the component. columns: The number of columns: gap: The gap between the checkbox cards: + value: The controlled value of the radio item to check. Should be used in conjunction with onValueChange. + name: The name of the group. Submitted with its owning form as part of a name/value pair. + disabled: When true, prevents the user from interacting with radio items. + required: When true, indicates that the user must check a radio item before the owning form can be submitted. + orientation: The orientation of the component. + dir: The reading direction of the radio group. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. + loop: When true, keyboard navigation will loop from last item to first, and vice versa. + on_value_change: Event handler called when the value changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -184,58 +221,32 @@ class RadioCardsItem(RadixThemesComponent): def create( # type: ignore cls, *children, + as_child: Optional[Union[Var[bool], bool]] = None, + value: Optional[Union[Var[str], str]] = None, + disabled: Optional[Union[Var[bool], bool]] = None, + required: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadioCardsItem": """Create a new component instance. @@ -244,6 +255,10 @@ class RadioCardsItem(RadixThemesComponent): Args: *children: Child components. + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. + value: The value given as data when submitted with a name. + disabled: When true, prevents the user from interacting with the radio item. + required: When true, indicates that the user must check the radio item before the owning form can be submitted. 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_group.py b/reflex/components/radix/themes/components/radio_group.py index 223b04cfe..a55ca3a41 100644 --- a/reflex/components/radix/themes/components/radio_group.py +++ b/reflex/components/radix/themes/components/radio_group.py @@ -1,14 +1,18 @@ """Interactive components provided by @radix-ui/themes.""" + from __future__ import annotations -from typing import Any, Dict, List, Literal, Optional, Union +from typing import List, Literal, Optional, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace +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.constants import EventTriggers -from reflex.vars import Var +from reflex.event import EventHandler, identity_event +from reflex.utils import types +from reflex.vars.base import LiteralVar, Var +from reflex.vars.sequence import StringVar from ..base import ( LiteralAccentColor, @@ -25,10 +29,10 @@ class RadioGroupRoot(RadixThemesComponent): tag = "RadioGroup.Root" # The size of the radio group: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] = LiteralVar.create("2") # The variant of the radio group - variant: Var[Literal["classic", "surface", "soft"]] + variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic") # The color of the radio group color_scheme: Var[LiteralAccentColor] @@ -54,16 +58,8 @@ class RadioGroupRoot(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onValueChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. - - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - } + # Fired when the value of the radio group changes. + on_change: EventHandler[identity_event(str)] class RadioGroupItem(RadixThemesComponent): @@ -88,16 +84,16 @@ class HighLevelRadioGroup(RadixThemesComponent): items: Var[List[str]] # The direction of the radio group. - direction: Var[LiteralFlexDirection] + direction: Var[LiteralFlexDirection] = LiteralVar.create("row") # The gap between the items of the radio group. - spacing: Var[LiteralSpacing] = Var.create_safe("2") + spacing: Var[LiteralSpacing] = LiteralVar.create("2") # The size of the radio group. - size: Var[Literal["1", "2", "3"]] = Var.create_safe("2") + size: Var[Literal["1", "2", "3"]] = LiteralVar.create("2") # The variant of the radio group - variant: Var[Literal["classic", "surface", "soft"]] + variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic") # The color of the radio group color_scheme: Var[LiteralAccentColor] @@ -137,34 +133,51 @@ class HighLevelRadioGroup(RadixThemesComponent): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ - direction = props.pop("direction", "column") + direction = props.pop("direction", "row") spacing = props.pop("spacing", "2") size = props.pop("size", "2") + variant = props.pop("variant", "classic") + 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 # for string literal types. if isinstance(default_value, str) or ( isinstance(default_value, Var) and default_value._var_type is str ): - default_value = Var.create(default_value, _var_is_string=True) # type: ignore + default_value = LiteralVar.create(default_value) # type: ignore else: - default_value = ( - Var.create(default_value).to_string()._replace(_var_is_local=False) # type: ignore - ) + default_value = LiteralVar.create(default_value).to_string() - def radio_group_item(value: str | Var) -> Component: - item_value = Var.create(value) # type: ignore + def radio_group_item(value: Var) -> Component: item_value = rx.cond( - item_value._type() == str, # type: ignore - item_value, - item_value.to_string()._replace(_var_is_local=False), # type: ignore - )._replace(_var_type=str) + value.js_type() == "string", + value, + value.to_string(), + ).to(StringVar) return Text.create( Flex.create( - RadioGroupItem.create(value=item_value), + RadioGroupItem.create( + value=item_value, + disabled=props.get("disabled", LiteralVar.create(False)), + ), item_value, spacing="2", ), @@ -172,8 +185,7 @@ class HighLevelRadioGroup(RadixThemesComponent): as_="label", ) - items = Var.create(items) # type: ignore - children = [rx.foreach(items, radio_group_item)] + children = [rx.foreach(LiteralVar.create(items), radio_group_item)] return RadioGroupRoot.create( Flex.create( @@ -182,6 +194,8 @@ class HighLevelRadioGroup(RadixThemesComponent): spacing=spacing, ), size=size, + variant=variant, + color_scheme=color_scheme, default_value=default_value, **props, ) diff --git a/reflex/components/radix/themes/components/radio_group.pyi b/reflex/components/radix/themes/components/radio_group.pyi index ae6b73389..5ff5d6e7c 100644 --- a/reflex/components/radix/themes/components/radio_group.pyi +++ b/reflex/components/radix/themes/components/radio_group.pyi @@ -1,98 +1,102 @@ """Stub file for reflex/components/radix/themes/components/radio_group.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Literal, Optional, Union -import reflex as rx -from reflex.components.component import Component, ComponentNamespace -from reflex.components.radix.themes.layout.flex import Flex -from reflex.components.radix.themes.typography.text import Text -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"] class RadioGroupRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -108,55 +112,23 @@ class RadioGroupRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadioGroupRoot": """Create a new component instance. @@ -174,6 +146,7 @@ class RadioGroupRoot(RadixThemesComponent): disabled: Whether the radio group is disabled name: The name of the group. Submitted with its owning form as part of a name/value pair. required: Whether the radio group is required + on_change: Props to rename Fired when the value of the radio group changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -202,52 +175,22 @@ class RadioGroupItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadioGroupItem": """Create a new component instance. @@ -278,87 +221,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, @@ -374,52 +317,22 @@ class HighLevelRadioGroup(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelRadioGroup": """Create a radio group component. @@ -447,6 +360,9 @@ class HighLevelRadioGroup(RadixThemesComponent): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ ... @@ -457,87 +373,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, @@ -553,52 +469,22 @@ class RadioGroup(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelRadioGroup": """Create a radio group component. @@ -626,6 +512,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 b7b79286b..bd58118dd 100644 --- a/reflex/components/radix/themes/components/scroll_area.py +++ b/reflex/components/radix/themes/components/scroll_area.py @@ -1,7 +1,8 @@ """Interactive components provided by @radix-ui/themes.""" + 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 721ec97ae..8deeb0fe9 100644 --- a/reflex/components/radix/themes/components/scroll_area.pyi +++ b/reflex/components/radix/themes/components/scroll_area.pyi @@ -1,14 +1,14 @@ """Stub file for reflex/components/radix/themes/components/scroll_area.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent class ScrollArea(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, @@ -36,52 +36,22 @@ class ScrollArea(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ScrollArea": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/segmented_control.py b/reflex/components/radix/themes/components/segmented_control.py index 91d7dc433..22725eaa6 100644 --- a/reflex/components/radix/themes/components/segmented_control.py +++ b/reflex/components/radix/themes/components/segmented_control.py @@ -1,23 +1,42 @@ """SegmentedControl from Radix Themes.""" -from types import SimpleNamespace -from typing import Literal +from __future__ import annotations -from reflex.vars import Var +from types import SimpleNamespace +from typing import List, Literal, Tuple, Union + +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent +def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: + """Handle the on_value_change event. + + Args: + value: The value of the event. + + Returns: + The value of the event. + """ + return (value,) + + class SegmentedControlRoot(RadixThemesComponent): """Root element for a SegmentedControl component.""" - tag = "SegmentedControl" + tag = "SegmentedControl.Root" # The size of the segmented control: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] - # Variant of button: "classic" | "surface" | "soft" - variant: Var[Literal["classic", "surface", "soft"]] + # 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 color_scheme: Var[LiteralAccentColor] @@ -26,7 +45,15 @@ class SegmentedControlRoot(RadixThemesComponent): radius: Var[Literal["none", "small", "medium", "large", "full"]] # The default value of the segmented control. - default_value: Var[str] + 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[on_value_change] + + _rename_props = {"onChange": "onValueChange"} class SegmentedControlItem(RadixThemesComponent): @@ -37,6 +64,8 @@ class SegmentedControlItem(RadixThemesComponent): # The value of the item. value: Var[str] + _valid_parents: List[str] = ["SegmentedControlRoot"] + class SegmentedControl(SimpleNamespace): """SegmentedControl components namespace.""" diff --git a/reflex/components/radix/themes/components/segmented_control.pyi b/reflex/components/radix/themes/components/segmented_control.pyi index 26fce751a..d74c26be9 100644 --- a/reflex/components/radix/themes/components/segmented_control.pyi +++ b/reflex/components/radix/themes/components/segmented_control.pyi @@ -1,16 +1,19 @@ """Stub file for reflex/components/radix/themes/components/segmented_control.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from types import SimpleNamespace -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: ... class SegmentedControlRoot(RadixThemesComponent): @overload @@ -19,135 +22,117 @@ class SegmentedControlRoot(RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, variant: Optional[ - Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], - ] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] + ] = None, + type: Optional[ + 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[str], str]] = None, + default_value: Optional[ + Union[List[str], Var[Union[List[str], str]], 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str | List[str]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SegmentedControlRoot": """Create a new component instance. @@ -157,10 +142,13 @@ class SegmentedControlRoot(RadixThemesComponent): Args: *children: Child components. size: The size of the segmented control: "1" | "2" | "3" - variant: Variant of button: "classic" | "surface" | "soft" + 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. + on_change: Handles the `onChange` event for the SegmentedControl component. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -187,52 +175,22 @@ class SegmentedControlItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SegmentedControlItem": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/select.py b/reflex/components/radix/themes/components/select.py index f63247f1e..47a1eaf3f 100644 --- a/reflex/components/radix/themes/components/select.py +++ b/reflex/components/radix/themes/components/select.py @@ -1,10 +1,12 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, List, Literal, Union + +from typing import List, Literal, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.event import empty_event, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -19,7 +21,7 @@ class SelectRoot(RadixThemesComponent): tag = "Select.Root" # The size of the select: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # The value of the select when initially rendered. Use when you do not need to control the state of the select. default_value: Var[str] @@ -45,17 +47,11 @@ class SelectRoot(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onValueChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the value of the select changes. + on_change: rx.EventHandler[identity_event(str)] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0], - EventTriggers.ON_CHANGE: lambda e0: [e0], - } + # Fired when the select is opened or closed. + on_open_change: rx.EventHandler[identity_event(bool)] class SelectTrigger(RadixThemesComponent): @@ -107,18 +103,14 @@ class SelectContent(RadixThemesComponent): # The vertical distance in pixels from the anchor. Only available when position is set to popper. align_offset: Var[int] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the select content is closed. + on_close_auto_focus: rx.EventHandler[empty_event] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CLOSE_AUTO_FOCUS: lambda e0: [e0], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0], - } + # Fired when the escape key is pressed. + on_escape_key_down: rx.EventHandler[empty_event] + + # Fired when a pointer down event happens outside the select content. + on_pointer_down_outside: rx.EventHandler[empty_event] class SelectGroup(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/select.pyi b/reflex/components/radix/themes/components/select.pyi index a8dfb869d..d43ac7327 100644 --- a/reflex/components/radix/themes/components/select.pyi +++ b/reflex/components/radix/themes/components/select.pyi @@ -1,28 +1,34 @@ """Stub file for reflex/components/radix/themes/components/select.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Literal, Union -import reflex as rx -from reflex.components.component import Component, ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent class SelectRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, default_value: Optional[Union[Var[str], str]] = None, value: Optional[Union[Var[str], str]] = None, @@ -37,58 +43,24 @@ class SelectRoot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectRoot": """Create a new component instance. @@ -105,6 +77,8 @@ class SelectRoot(RadixThemesComponent): name: The name of the select control when submitting the form. disabled: When True, prevents the user from interacting with select. required: When True, indicates that the user must select a value before the owning form can be submitted. + on_change: Props to rename Fired when the value of the select changes. + on_open_change: Fired when the select is opened or closed. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -126,76 +100,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, @@ -205,52 +179,22 @@ class SelectTrigger(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectTrigger": """Create a new component instance. @@ -277,95 +221,94 @@ class SelectTrigger(RadixThemesComponent): ... class SelectContent(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore 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, @@ -375,61 +318,25 @@ class SelectContent(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_close_auto_focus: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectContent": """Create a new component instance. @@ -446,6 +353,9 @@ class SelectContent(RadixThemesComponent): side_offset: The distance in pixels from the anchor. Only available when position is set to popper. align: The preferred alignment against the anchor. May change when collisions occur. Only available when position is set to popper. align_offset: The vertical distance in pixels from the anchor. Only available when position is set to popper. + on_close_auto_focus: Fired when the select content is closed. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when a pointer down event happens outside the select content. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -471,52 +381,22 @@ class SelectGroup(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectGroup": """Create a new component instance. @@ -552,52 +432,22 @@ class SelectItem(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectItem": """Create a new component instance. @@ -633,52 +483,22 @@ class SelectLabel(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectLabel": """Create a new component instance. @@ -712,52 +532,22 @@ class SelectSeparator(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "SelectSeparator": """Create a new component instance. @@ -785,93 +575,101 @@ 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[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, default_value: Optional[Union[Var[str], str]] = None, value: Optional[Union[Var[str], str]] = None, @@ -886,58 +684,24 @@ class HighLevelSelect(SelectRoot): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelSelect": """Create a select component. @@ -960,6 +724,8 @@ class HighLevelSelect(SelectRoot): name: The name of the select control when submitting the form. disabled: When True, prevents the user from interacting with select. required: When True, indicates that the user must select a value before the owning form can be submitted. + on_change: Props to rename Fired when the value of the select changes. + on_open_change: Fired when the select is opened or closed. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -985,93 +751,101 @@ 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[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, default_value: Optional[Union[Var[str], str]] = None, value: Optional[Union[Var[str], str]] = None, @@ -1086,58 +860,24 @@ class Select(ComponentNamespace): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HighLevelSelect": """Create a select component. @@ -1160,6 +900,8 @@ class Select(ComponentNamespace): name: The name of the select control when submitting the form. disabled: When True, prevents the user from interacting with select. required: When True, indicates that the user must select a value before the owning form can be submitted. + on_change: Props to rename Fired when the value of the select changes. + on_open_change: Fired when the select is opened or closed. 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/separator.py b/reflex/components/radix/themes/components/separator.py index 92d2e8b85..1689717d2 100644 --- a/reflex/components/radix/themes/components/separator.py +++ b/reflex/components/radix/themes/components/separator.py @@ -1,7 +1,9 @@ """Interactive components provided by @radix-ui/themes.""" + from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import LiteralVar, Var from ..base import ( LiteralAccentColor, @@ -17,13 +19,13 @@ class Separator(RadixThemesComponent): tag = "Separator" # The size of the select: "1" | "2" | "3" | "4" - size: Var[LiteralSeperatorSize] = Var.create_safe("4") + size: Var[Responsive[LiteralSeperatorSize]] = LiteralVar.create("4") # The color of the select color_scheme: Var[LiteralAccentColor] # The orientation of the separator. - orientation: Var[Literal["horizontal", "vertical"]] + orientation: Var[Responsive[Literal["horizontal", "vertical"]]] # When true, signifies that it is purely visual, carries no semantic meaning, and ensures it is not present in the accessibility tree. decorative: Var[bool] diff --git a/reflex/components/radix/themes/components/separator.pyi b/reflex/components/radix/themes/components/separator.pyi index 6e88bc4dd..0f2895403 100644 --- a/reflex/components/radix/themes/components/separator.pyi +++ b/reflex/components/radix/themes/components/separator.pyi @@ -1,15 +1,16 @@ """Stub file for reflex/components/radix/themes/components/separator.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralSeperatorSize = Literal["1", "2", "3", "4"] @@ -20,74 +21,89 @@ class Separator(RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] + 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"], + ] + ], + ] ] = 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[ - Var[Literal["horizontal", "vertical"]], + Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[ + Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], + ] + ], ] ] = None, decorative: Optional[Union[Var[bool], bool]] = None, @@ -97,52 +113,22 @@ class Separator(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Separator": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/skeleton.py b/reflex/components/radix/themes/components/skeleton.py index 986e7783b..1fb6390a1 100644 --- a/reflex/components/radix/themes/components/skeleton.py +++ b/reflex/components/radix/themes/components/skeleton.py @@ -1,6 +1,7 @@ """Skeleton theme from Radix components.""" -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent @@ -11,22 +12,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): tag = "Skeleton" # The width of the skeleton - width: Var[str] + width: Var[Responsive[str]] # The minimum width of the skeleton - min_width: Var[str] + min_width: Var[Responsive[str]] # The maximum width of the skeleton - max_width: Var[str] + max_width: Var[Responsive[str]] # The height of the skeleton - height: Var[str] + height: Var[Responsive[str]] # The minimum height of the skeleton - min_height: Var[str] + min_height: Var[Responsive[str]] # The maximum height of the skeleton - max_height: Var[str] + max_height: Var[Responsive[str]] skeleton = Skeleton.create diff --git a/reflex/components/radix/themes/components/skeleton.pyi b/reflex/components/radix/themes/components/skeleton.pyi index 23f180791..61b57c275 100644 --- a/reflex/components/radix/themes/components/skeleton.pyi +++ b/reflex/components/radix/themes/components/skeleton.pyi @@ -1,13 +1,15 @@ """Stub file for reflex/components/radix/themes/components/skeleton.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixLoadingProp, RadixThemesComponent class Skeleton(RadixLoadingProp, RadixThemesComponent): @@ -16,12 +18,24 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): def create( # type: ignore cls, *children, - width: Optional[Union[Var[str], str]] = None, - min_width: Optional[Union[Var[str], str]] = None, - max_width: Optional[Union[Var[str], str]] = None, - height: Optional[Union[Var[str], str]] = None, - min_height: Optional[Union[Var[str], str]] = None, - max_height: Optional[Union[Var[str], str]] = None, + width: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + min_width: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + max_width: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + height: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + min_height: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + max_height: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -29,52 +43,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Skeleton": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/slider.py b/reflex/components/radix/themes/components/slider.py index 6d8bd90f1..4f456cdca 100644 --- a/reflex/components/radix/themes/components/slider.py +++ b/reflex/components/radix/themes/components/slider.py @@ -1,15 +1,25 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, List, Literal, Optional, Union + +from __future__ import annotations + +from typing import List, Literal, Optional, Union from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, RadixThemesComponent, ) +on_value_event_spec = ( + identity_event(list[Union[int, float]]), + identity_event(list[int]), + identity_event(list[float]), +) + class Slider(RadixThemesComponent): """Provides user selection from a range of values.""" @@ -20,7 +30,7 @@ class Slider(RadixThemesComponent): as_child: Var[bool] # Button size "1" - "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # Variant of button variant: Var[Literal["classic", "surface", "soft"]] @@ -43,6 +53,9 @@ class Slider(RadixThemesComponent): # The name of the slider. Submitted with its owning form as part of a name/value pair. name: Var[str] + # The width of the slider. + width: Var[Optional[str]] = Var.create("100%") + # The minimum value of the slider. min: Var[Union[float, int]] @@ -61,36 +74,29 @@ class Slider(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onValueChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the value of the slider changes. + on_change: EventHandler[on_value_event_spec] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], - EventTriggers.ON_VALUE_COMMIT: lambda e0: [e0], - } + # Fired when a thumb is released after being dragged. + on_value_commit: EventHandler[on_value_event_spec] @classmethod def create( cls, *children, - width: Optional[str] = "100%", **props, ) -> Component: """Create a Slider component. Args: *children: The children of the component. - width: The width of the slider. **props: The properties of the component. Returns: The component. """ default_value = props.pop("default_value", [50]) + width = props.pop("width", "100%") if isinstance(default_value, Var): if issubclass(default_value._var_type, (int, float)): diff --git a/reflex/components/radix/themes/components/slider.pyi b/reflex/components/radix/themes/components/slider.pyi index 5a170c542..f77573d44 100644 --- a/reflex/components/radix/themes/components/slider.pyi +++ b/reflex/components/radix/themes/components/slider.pyi @@ -1,122 +1,136 @@ """Stub file for reflex/components/radix/themes/components/slider.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType, identity_event from reflex.style import Style -from typing import Any, Dict, List, Literal, Optional, Union -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +on_value_event_spec = ( + identity_event(list[Union[int, float]]), + identity_event(list[int]), + identity_event(list[float]), +) class Slider(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore cls, *children, - width: Optional[str] = "100%", as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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[ + List[Union[float, int]], Var[Union[List[Union[float, int]], float, int]], - 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]], Union[float, int]]] = None, - max: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None, - step: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None, + width: Optional[Union[Var[Optional[str]], str]] = None, + min: Optional[Union[Var[Union[float, int]], float, int]] = None, + max: Optional[Union[Var[Union[float, int]], float, int]] = None, + step: Optional[Union[Var[Union[float, int]], float, int]] = None, 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, @@ -125,64 +139,41 @@ class Slider(RadixThemesComponent): 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, function, BaseVar] - ] = None, + on_blur: Optional[EventType[[]]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[ + EventType[list[Union[int, float]]], + EventType[list[int]], + EventType[list[float]], + ] ] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, on_value_commit: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] + Union[ + EventType[list[Union[int, float]]], + EventType[list[int]], + EventType[list[float]], + ] ] = None, - **props + **props, ) -> "Slider": """Create a Slider component. Args: *children: The children of the component. - width: The width of the slider. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. size: Button size "1" - "3" variant: Variant of button @@ -192,11 +183,14 @@ class Slider(RadixThemesComponent): default_value: The value of the slider when initially rendered. Use when you do not need to control the state of the slider. value: The controlled value of the slider. Must be used in conjunction with onValueChange. name: The name of the slider. Submitted with its owning form as part of a name/value pair. + width: The width of the slider. min: The minimum value of the slider. max: The maximum value of the slider. step: The step value of the slider. disabled: Whether the slider is disabled orientation: The orientation of the slider. + on_change: Props to rename Fired when the value of the slider changes. + on_value_commit: Fired when a thumb is released after being dragged. 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/spinner.py b/reflex/components/radix/themes/components/spinner.py index 4726e95ee..cc29d6091 100644 --- a/reflex/components/radix/themes/components/spinner.py +++ b/reflex/components/radix/themes/components/spinner.py @@ -2,7 +2,8 @@ from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import ( RadixLoadingProp, @@ -20,7 +21,7 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): is_default = False # The size of the spinner. - size: Var[LiteralSpinnerSize] + size: Var[Responsive[LiteralSpinnerSize]] spinner = Spinner.create diff --git a/reflex/components/radix/themes/components/spinner.pyi b/reflex/components/radix/themes/components/spinner.pyi index cbc9ae200..87033f05c 100644 --- a/reflex/components/radix/themes/components/spinner.pyi +++ b/reflex/components/radix/themes/components/spinner.pyi @@ -1,14 +1,15 @@ """Stub file for reflex/components/radix/themes/components/spinner.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixLoadingProp, RadixThemesComponent LiteralSpinnerSize = Literal["1", "2", "3"] @@ -20,7 +21,15 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -29,52 +38,22 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Spinner": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/switch.py b/reflex/components/radix/themes/components/switch.py index 14ac152b2..13be32d83 100644 --- a/reflex/components/radix/themes/components/switch.py +++ b/reflex/components/radix/themes/components/switch.py @@ -1,8 +1,10 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal -from reflex.constants import EventTriggers -from reflex.vars import Var +from typing import Literal + +from reflex.components.core.breakpoints import Responsive +from reflex.event import EventHandler, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -39,7 +41,7 @@ class Switch(RadixThemesComponent): value: Var[str] # Switch size "1" - "4" - size: Var[LiteralSwitchSize] + size: Var[Responsive[LiteralSwitchSize]] # Variant of switch: "classic" | "surface" | "soft" variant: Var[Literal["classic", "surface", "soft"]] @@ -56,16 +58,8 @@ class Switch(RadixThemesComponent): # Props to rename _rename_props = {"onChange": "onCheckedChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger name to the argspec passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda checked: [checked], - } + # Fired when the value of the switch changes + on_change: EventHandler[identity_event(bool)] switch = Switch.create diff --git a/reflex/components/radix/themes/components/switch.pyi b/reflex/components/radix/themes/components/switch.pyi index 0d40928ef..aebeb761e 100644 --- a/reflex/components/radix/themes/components/switch.pyi +++ b/reflex/components/radix/themes/components/switch.pyi @@ -1,21 +1,20 @@ """Stub file for reflex/components/radix/themes/components/switch.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, Literal -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralSwitchSize = Literal["1", "2", "3"] class Switch(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -29,80 +28,88 @@ class Switch(RadixThemesComponent): name: Optional[Union[Var[str], str]] = None, value: Optional[Union[Var[str], str]] = None, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -111,55 +118,23 @@ class Switch(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[bool]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Switch": """Create a new component instance. @@ -180,6 +155,7 @@ class Switch(RadixThemesComponent): color_scheme: Override theme color for switch high_contrast: Whether to render the switch with higher contrast color against background radius: Override theme radius for switch: "none" | "small" | "full" + on_change: Props to rename Fired when the value of the switch changes 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/table.py b/reflex/components/radix/themes/components/table.py index a2b3bada3..e1f03d4e2 100644 --- a/reflex/components/radix/themes/components/table.py +++ b/reflex/components/radix/themes/components/table.py @@ -1,28 +1,30 @@ """Interactive components provided by @radix-ui/themes.""" + from typing import List, Literal -from reflex import el from reflex.components.component import ComponentNamespace -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, ) -class TableRoot(el.Table, RadixThemesComponent): +class TableRoot(elements.Table, RadixThemesComponent): """A semantic table for presenting tabular data.""" tag = "Table.Root" # The size of the table: "1" | "2" | "3" - size: Var[Literal["1", "2", "3"]] + size: Var[Responsive[Literal["1", "2", "3"]]] # The variant of the table variant: Var[Literal["surface", "ghost"]] -class TableHeader(el.Thead, RadixThemesComponent): +class TableHeader(elements.Thead, RadixThemesComponent): """The header of the table defines column names and other non-data elements.""" tag = "Table.Header" @@ -32,7 +34,7 @@ class TableHeader(el.Thead, RadixThemesComponent): _valid_parents: List[str] = ["TableRoot"] -class TableRow(el.Tr, RadixThemesComponent): +class TableRow(elements.Tr, RadixThemesComponent): """A row containing table cells.""" tag = "Table.Row" @@ -43,7 +45,7 @@ class TableRow(el.Tr, RadixThemesComponent): _invalid_children: List[str] = ["TableBody", "TableHeader", "TableRow"] -class TableColumnHeaderCell(el.Th, RadixThemesComponent): +class TableColumnHeaderCell(elements.Th, RadixThemesComponent): """A table cell that is semantically treated as a column header.""" tag = "Table.ColumnHeaderCell" @@ -61,7 +63,7 @@ class TableColumnHeaderCell(el.Th, RadixThemesComponent): ] -class TableBody(el.Tbody, RadixThemesComponent): +class TableBody(elements.Tbody, RadixThemesComponent): """The body of the table contains the data rows.""" tag = "Table.Body" @@ -76,7 +78,7 @@ class TableBody(el.Tbody, RadixThemesComponent): _valid_parents: List[str] = ["TableRoot"] -class TableCell(el.Td, RadixThemesComponent): +class TableCell(elements.Td, RadixThemesComponent): """A cell containing data.""" tag = "Table.Cell" @@ -93,7 +95,7 @@ class TableCell(el.Td, RadixThemesComponent): ] -class TableRowHeaderCell(el.Th, RadixThemesComponent): +class TableRowHeaderCell(elements.Th, RadixThemesComponent): """A table cell that is semantically treated as a row header.""" tag = "Table.RowHeaderCell" diff --git a/reflex/components/radix/themes/components/table.pyi b/reflex/components/radix/themes/components/table.pyi index 5669d717c..8b1ef355f 100644 --- a/reflex/components/radix/themes/components/table.pyi +++ b/reflex/components/radix/themes/components/table.pyi @@ -1,128 +1,87 @@ """Stub file for reflex/components/radix/themes/components/table.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import List, Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.vars import Var +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from ..base import RadixThemesComponent -class TableRoot(el.Table, RadixThemesComponent): +class TableRoot(elements.Table, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, variant: Optional[ - Union[Var[Literal["surface", "ghost"]], Literal["surface", "ghost"]] - ] = None, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - summary: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Literal["ghost", "surface"], Var[Literal["ghost", "surface"]]] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableRoot": """Create a new component instance. @@ -164,107 +123,59 @@ class TableRoot(el.Table, RadixThemesComponent): """ ... -class TableHeader(el.Thead, RadixThemesComponent): +class TableHeader(elements.Thead, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableHeader": """Create a new component instance. @@ -303,7 +214,7 @@ class TableHeader(el.Thead, RadixThemesComponent): """ ... -class TableRow(el.Tr, RadixThemesComponent): +class TableRow(elements.Tr, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -311,102 +222,56 @@ class TableRow(el.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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableRow": """Create a new component instance. @@ -445,7 +310,7 @@ class TableRow(el.Tr, RadixThemesComponent): """ ... -class TableColumnHeaderCell(el.Th, RadixThemesComponent): +class TableColumnHeaderCell(elements.Th, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -453,117 +318,61 @@ class TableColumnHeaderCell(el.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[str, int, bool]], Union[str, int, bool]] - ] = None, - col_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - headers: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - row_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - scope: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableColumnHeaderCell": """Create a new component instance. @@ -607,107 +416,59 @@ class TableColumnHeaderCell(el.Th, RadixThemesComponent): """ ... -class TableBody(el.Tbody, RadixThemesComponent): +class TableBody(elements.Tbody, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - align: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableBody": """Create a new component instance. @@ -746,7 +507,7 @@ class TableBody(el.Tbody, RadixThemesComponent): """ ... -class TableCell(el.Td, RadixThemesComponent): +class TableCell(elements.Td, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -754,114 +515,60 @@ class TableCell(el.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[str, int, bool]], Union[str, int, bool]] - ] = None, - col_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - headers: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - row_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableCell": """Create a new component instance. @@ -904,7 +611,7 @@ class TableCell(el.Td, RadixThemesComponent): """ ... -class TableRowHeaderCell(el.Th, RadixThemesComponent): +class TableRowHeaderCell(elements.Th, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -912,117 +619,61 @@ class TableRowHeaderCell(el.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[str, int, bool]], Union[str, int, bool]] - ] = None, - col_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - headers: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - row_span: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - scope: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TableRowHeaderCell": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/tabs.py b/reflex/components/radix/themes/components/tabs.py index af1b6b521..12359b528 100644 --- a/reflex/components/radix/themes/components/tabs.py +++ b/reflex/components/radix/themes/components/tabs.py @@ -1,17 +1,22 @@ """Interactive components provided by @radix-ui/themes.""" + from __future__ import annotations from typing import Any, Dict, List, Literal from reflex.components.component import Component, ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.core.colors import color +from reflex.event import EventHandler, identity_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, RadixThemesComponent, ) +vertical_orientation_css = "&[data-orientation='vertical']" + class TabsRoot(RadixThemesComponent): """Set of content sections to be displayed one at a time.""" @@ -27,18 +32,28 @@ class TabsRoot(RadixThemesComponent): # The orientation of the tabs. orientation: Var[Literal["horizontal", "vertical"]] + # Reading direction of the tabs. + dir: Var[Literal["ltr", "rtl"]] + + # The mode of activation for the tabs. "automatic" will activate the tab when focused. "manual" will activate the tab when clicked. + activation_mode: Var[Literal["automatic", "manual"]] + # Props to rename _rename_props = {"onChange": "onValueChange"} - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the value of the tabs changes. + on_change: EventHandler[identity_event(str)] + + def add_style(self) -> Dict[str, Any] | None: + """Add style for the component. Returns: - The signatures of the event triggers. + The style to add. """ return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0], + vertical_orientation_css: { + "display": "flex", + } } @@ -48,7 +63,23 @@ class TabsList(RadixThemesComponent): tag = "Tabs.List" # Tabs size "1" - "2" - size: Var[Literal["1", "2"]] + size: Var[Responsive[Literal["1", "2"]]] + + # When true, the tabs will loop when reaching the end. + loop: Var[bool] + + def add_style(self): + """Add style for the component. + + Returns: + The style to add. + """ + return { + vertical_orientation_css: { + "display": "block", + "box_shadow": f"inset -1px 0 0 0 {color('gray', 5, alpha=True)}", + }, + } class TabsTrigger(RadixThemesComponent): @@ -68,7 +99,7 @@ class TabsTrigger(RadixThemesComponent): _valid_parents: List[str] = ["TabsList"] @classmethod - def create(self, *children, **props) -> Component: + def create(cls, *children, **props) -> Component: """Create a TabsTrigger component. Args: @@ -86,6 +117,14 @@ class TabsTrigger(RadixThemesComponent): def _exclude_props(self) -> list[str]: return ["color_scheme"] + def add_style(self) -> Dict[str, Any] | None: + """Add style for the component. + + Returns: + The style to add. + """ + return {vertical_orientation_css: {"width": "100%"}} + class TabsContent(RadixThemesComponent): """Contains the content associated with each trigger.""" @@ -95,6 +134,19 @@ class TabsContent(RadixThemesComponent): # The value of the tab. Must be unique for each tab. value: Var[str] + # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. + force_mount: Var[bool] + + def add_style(self) -> dict[str, Any] | None: + """Add style for the component. + + Returns: + The style to add. + """ + return { + vertical_orientation_css: {"width": "100%", "margin": None}, + } + class Tabs(ComponentNamespace): """Set of content sections to be displayed one at a time.""" diff --git a/reflex/components/radix/themes/components/tabs.pyi b/reflex/components/radix/themes/components/tabs.pyi index a8243554f..ac6109209 100644 --- a/reflex/components/radix/themes/components/tabs.pyi +++ b/reflex/components/radix/themes/components/tabs.pyi @@ -1,20 +1,22 @@ """Stub file for reflex/components/radix/themes/components/tabs.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Literal -from reflex.components.component import Component, ComponentNamespace -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +vertical_orientation_css = "&[data-orientation='vertical']" class TabsRoot(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... + def add_style(self) -> Dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -24,65 +26,37 @@ 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[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, + activation_mode: Optional[ + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] + ] = 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TabsRoot": """Create a new component instance. @@ -94,6 +68,9 @@ class TabsRoot(RadixThemesComponent): default_value: The value of the tab that should be active when initially rendered. Use when you do not need to control the state of the tabs. value: The controlled value of the tab that should be active. Use when you need to control the state of the tabs. orientation: The orientation of the tabs. + dir: Reading direction of the tabs. + activation_mode: The mode of activation for the tabs. "automatic" will activate the tab when focused. "manual" will activate the tab when clicked. + on_change: Props to rename Fired when the value of the tabs changes. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -108,64 +85,42 @@ class TabsRoot(RadixThemesComponent): ... class TabsList(RadixThemesComponent): + def add_style(self): ... @overload @classmethod def create( # type: ignore cls, *children, - size: Optional[Union[Var[Literal["1", "2"]], Literal["1", "2"]]] = None, + size: Optional[ + Union[ + 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TabsList": """Create a new component instance. @@ -175,6 +130,7 @@ class TabsList(RadixThemesComponent): Args: *children: Child components. size: Tabs size "1" - "2" + loop: When true, the tabs will loop when reaching the end. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -198,63 +154,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, @@ -264,52 +220,22 @@ class TabsTrigger(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TabsTrigger": """Create a TabsTrigger component. @@ -331,65 +257,39 @@ class TabsTrigger(RadixThemesComponent): """ ... + def add_style(self) -> Dict[str, Any] | None: ... + class TabsContent(RadixThemesComponent): + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore cls, *children, value: Optional[Union[Var[str], str]] = None, + force_mount: Optional[Union[Var[bool], bool]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TabsContent": """Create a new component instance. @@ -399,6 +299,7 @@ class TabsContent(RadixThemesComponent): Args: *children: Child components. value: The value of the tab. Must be unique for each tab. + force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -425,65 +326,37 @@ 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[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, + activation_mode: Optional[ + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] + ] = 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TabsRoot": """Create a new component instance. @@ -495,6 +368,9 @@ class Tabs(ComponentNamespace): default_value: The value of the tab that should be active when initially rendered. Use when you do not need to control the state of the tabs. value: The controlled value of the tab that should be active. Use when you need to control the state of the tabs. orientation: The orientation of the tabs. + dir: Reading direction of the tabs. + activation_mode: The mode of activation for the tabs. "automatic" will activate the tab when focused. "manual" will activate the tab when clicked. + on_change: Props to rename Fired when the value of the tabs changes. 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/text_area.py b/reflex/components/radix/themes/components/text_area.py index 2eec48631..9f006c2e3 100644 --- a/reflex/components/radix/themes/components/text_area.py +++ b/reflex/components/radix/themes/components/text_area.py @@ -1,34 +1,44 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal, Union -from reflex import el +from typing import Literal, Union + from reflex.components.component import Component +from reflex.components.core.breakpoints import Responsive from reflex.components.core.debounce import DebounceInput -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, + LiteralRadius, RadixThemesComponent, ) LiteralTextAreaSize = Literal["1", "2", "3"] +LiteralTextAreaResize = Literal["none", "vertical", "horizontal", "both"] -class TextArea(RadixThemesComponent, el.Textarea): + +class TextArea(RadixThemesComponent, elements.Textarea): """The input part of a TextArea, may be used by itself.""" tag = "TextArea" # The size of the text area: "1" | "2" | "3" - size: Var[LiteralTextAreaSize] + size: Var[Responsive[LiteralTextAreaSize]] # The variant of the text area variant: Var[Literal["classic", "surface", "soft"]] + # The resize behavior of the text area: "none" | "vertical" | "horizontal" | "both" + resize: Var[Responsive[LiteralTextAreaResize]] + # The color of the text area color_scheme: Var[LiteralAccentColor] + # The radius of the text area: "none" | "small" | "medium" | "large" | "full" + radius: Var[LiteralRadius] + # Whether the form control should have autocomplete enabled auto_complete: Var[bool] @@ -82,25 +92,10 @@ class TextArea(RadixThemesComponent, el.Textarea): Returns: The component. """ - if props.get("value") is not None and props.get("on_change"): + if props.get("value") is not None and props.get("on_change") is not None: # create a debounced input if the user requests full control to avoid typing jank return DebounceInput.create(super().create(*children, **props)) return super().create(*children, **props) - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } - text_area = TextArea.create diff --git a/reflex/components/radix/themes/components/text_area.pyi b/reflex/components/radix/themes/components/text_area.pyi index 48220be54..099a1700a 100644 --- a/reflex/components/radix/themes/components/text_area.pyi +++ b/reflex/components/radix/themes/components/text_area.pyi @@ -1,104 +1,131 @@ """Stub file for reflex/components/radix/themes/components/text_area.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, Literal, Union -from reflex import el -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.constants import EventTriggers -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralTextAreaSize = Literal["1", "2", "3"] +LiteralTextAreaResize = Literal["none", "vertical", "horizontal", "both"] -class TextArea(RadixThemesComponent, el.Textarea): +class TextArea(RadixThemesComponent, elements.Textarea): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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["both", "horizontal", "none", "vertical"] + ], + Literal["both", "horizontal", "none", "vertical"], + ] + ], ] ] = 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[ + 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[str, int, bool]], Union[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, @@ -109,109 +136,57 @@ class TextArea(RadixThemesComponent, el.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[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[str]] = None, + on_key_down: Optional[EventType[str]] = None, + on_key_up: Optional[EventType[str]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TextArea": """Create an Input component. @@ -219,7 +194,9 @@ class TextArea(RadixThemesComponent, el.Textarea): *children: The children of the component. size: The size of the text area: "1" | "2" | "3" variant: The variant of the text area + resize: The resize behavior of the text area: "none" | "vertical" | "horizontal" | "both" color_scheme: The color of the text area + radius: The radius of the text area: "none" | "small" | "medium" | "large" | "full" auto_complete: Whether the form control should have autocomplete enabled auto_focus: Automatically focuses the textarea when the page loads dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted @@ -237,6 +214,11 @@ class TextArea(RadixThemesComponent, el.Textarea): auto_height: Automatically fit the content height to the text (use min-height with this prop) cols: Visible width of the text control, in average character widths enter_key_submit: Enter key submits form (shift-enter adds new line) + on_change: Fired when the input value changes + on_focus: Fired when the input gains focus + on_blur: Fired when the input loses focus + on_key_down: Fired when a key is pressed down + on_key_up: Fired when a key is released access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -265,6 +247,5 @@ class TextArea(RadixThemesComponent, el.Textarea): The component. """ ... - def get_event_triggers(self) -> Dict[str, Any]: ... text_area = TextArea.create diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py index 970b950e3..4277e93e0 100644 --- a/reflex/components/radix/themes/components/text_field.py +++ b/reflex/components/radix/themes/components/text_field.py @@ -1,16 +1,15 @@ """Interactive components provided by @radix-ui/themes.""" + from __future__ import annotations -from typing import Any, Dict, Literal, Union +from typing import Literal, Union -from reflex.components import el -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.constants import EventTriggers -from reflex.style import Style, format_as_emotion -from reflex.utils import console -from reflex.vars import Var +from reflex.components.el import elements +from reflex.event import EventHandler, input_event, key_event +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -22,13 +21,13 @@ LiteralTextFieldSize = Literal["1", "2", "3"] LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(el.Div, RadixThemesComponent): +class TextFieldRoot(elements.Div, RadixThemesComponent): """Captures user input with an optional slot for buttons and icons.""" tag = "TextField.Root" # Text field size "1" - "3" - size: Var[LiteralTextFieldSize] + size: Var[Responsive[LiteralTextFieldSize]] # Variant of text field: "classic" | "surface" | "soft" variant: Var[LiteralTextFieldVariant] @@ -72,6 +71,21 @@ class TextFieldRoot(el.Div, RadixThemesComponent): # Value of the input value: Var[Union[str, int, float]] + # Fired when the value of the textarea changes. + on_change: EventHandler[input_event] + + # Fired when the textarea is focused. + on_focus: EventHandler[input_event] + + # Fired when the textarea is blurred. + on_blur: EventHandler[input_event] + + # Fired when a key is pressed down. + on_key_down: EventHandler[key_event] + + # Fired when a key is released. + on_key_up: EventHandler[key_event] + @classmethod def create(cls, *children, **props) -> Component: """Create an Input component. @@ -84,100 +98,11 @@ class TextFieldRoot(el.Div, RadixThemesComponent): The component. """ component = super().create(*children, **props) - if props.get("value") is not None and props.get("on_change"): + if props.get("value") is not None and props.get("on_change") is not None: # create a debounced input if the user requests full control to avoid typing jank 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": Var.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) - - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_FOCUS: lambda e0: [e0.target.value], - EventTriggers.ON_BLUR: lambda e0: [e0.target.value], - EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key], - EventTriggers.ON_KEY_UP: lambda e0: [e0.key], - } - class TextFieldSlot(RadixThemesComponent): """Contains icons or buttons associated with an Input.""" @@ -191,10 +116,8 @@ 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) -text_field = TextField() +input = text_field = TextField() diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi index c14fb031a..ffe827aff 100644 --- a/reflex/components/radix/themes/components/text_field.pyi +++ b/reflex/components/radix/themes/components/text_field.pyi @@ -1,107 +1,111 @@ """Stub file for reflex/components/radix/themes/components/text_field.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, Literal, Union -from reflex.components import el -from reflex.components.base.fragment import Fragment -from reflex.components.component import Component, ComponentNamespace -from reflex.components.core.debounce import DebounceInput -from reflex.constants import EventTriggers -from reflex.style import Style, format_as_emotion -from reflex.utils import console -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralTextFieldSize = Literal["1", "2", "3"] LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(el.Div, RadixThemesComponent): +class TextFieldRoot(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -114,110 +118,56 @@ class TextFieldRoot(el.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[str, int, float]], Union[str, int, float]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[str]] = None, + on_key_down: Optional[EventType[str]] = None, + on_key_up: Optional[EventType[str]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TextFieldRoot": """Create an Input component. @@ -238,6 +188,11 @@ class TextFieldRoot(el.Div, RadixThemesComponent): required: Indicates that the input is required type: Specifies the type of input value: Value of the input + on_change: Fired when the value of the textarea changes. + on_focus: Fired when the textarea is focused. + on_blur: Fired when the textarea is blurred. + on_key_down: Fired when a key is pressed down. + on_key_up: Fired when a key is released. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -266,11 +221,6 @@ class TextFieldRoot(el.Div, RadixThemesComponent): The component. """ ... - @classmethod - def create_root_deprecated(cls, *children, **props) -> Component: ... - @classmethod - def create_input_deprecated(cls, *children, **props) -> Component: ... - def get_event_triggers(self) -> Dict[str, Any]: ... class TextFieldSlot(RadixThemesComponent): @overload @@ -280,63 +230,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, @@ -346,52 +296,22 @@ class TextFieldSlot(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TextFieldSlot": """Create a new component instance. @@ -415,88 +335,94 @@ class TextFieldSlot(RadixThemesComponent): ... class TextField(ComponentNamespace): - root = staticmethod(TextFieldRoot.create_root_deprecated) - input = staticmethod(TextFieldRoot.create_input_deprecated) slot = staticmethod(TextFieldSlot.create) @staticmethod def __call__( *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], 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, @@ -509,110 +435,56 @@ 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[str, int, float]], Union[str, int, float]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[str]] = None, + on_key_down: Optional[EventType[str]] = None, + on_key_up: Optional[EventType[str]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "TextFieldRoot": """Create an Input component. @@ -633,6 +505,11 @@ class TextField(ComponentNamespace): required: Indicates that the input is required type: Specifies the type of input value: Value of the input + on_change: Fired when the value of the textarea changes. + on_focus: Fired when the textarea is focused. + on_blur: Fired when the textarea is blurred. + on_key_down: Fired when a key is pressed down. + on_key_up: Fired when a key is released. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -662,4 +539,4 @@ class TextField(ComponentNamespace): """ ... -text_field = TextField() +input = text_field = TextField() diff --git a/reflex/components/radix/themes/components/tooltip.py b/reflex/components/radix/themes/components/tooltip.py index 29bac80d0..ac35c86d1 100644 --- a/reflex/components/radix/themes/components/tooltip.py +++ b/reflex/components/radix/themes/components/tooltip.py @@ -1,10 +1,11 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Any, Dict, Literal, Union + +from typing import Dict, Literal, Union from reflex.components.component import Component -from reflex.constants import EventTriggers +from reflex.event import EventHandler, empty_event, identity_event from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( RadixThemesComponent, @@ -83,18 +84,14 @@ class Tooltip(RadixThemesComponent): # By default, screenreaders will announce the content inside the component. If this is not descriptive enough, or you have content that cannot be announced, use aria-label as a more descriptive label. aria_label: Var[str] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the events triggers signatures for the component. + # Fired when the open state changes. + on_open_change: EventHandler[identity_event(bool)] - Returns: - The signatures of the event triggers. - """ - return { - **super().get_event_triggers(), - EventTriggers.ON_OPEN_CHANGE: lambda e0: [e0.target.value], - EventTriggers.ON_ESCAPE_KEY_DOWN: lambda e0: [e0.target.value], - EventTriggers.ON_POINTER_DOWN_OUTSIDE: lambda e0: [e0.target.value], - } + # Fired when the escape key is pressed. + on_escape_key_down: EventHandler[empty_event] + + # Fired when the pointer is down outside the tooltip. + on_pointer_down_outside: EventHandler[empty_event] @classmethod def create(cls, *children, **props) -> Component: diff --git a/reflex/components/radix/themes/components/tooltip.pyi b/reflex/components/radix/themes/components/tooltip.pyi index b9c0feca6..42875e1e5 100644 --- a/reflex/components/radix/themes/components/tooltip.pyi +++ b/reflex/components/radix/themes/components/tooltip.pyi @@ -1,17 +1,16 @@ """Stub file for reflex/components/radix/themes/components/tooltip.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.event import ( + EventType, +) from reflex.style import Style -from typing import Any, Dict, Literal, Union -from reflex.components.component import Component -from reflex.constants import EventTriggers -from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent LiteralSideType = Literal["top", "right", "bottom", "left"] @@ -19,7 +18,6 @@ LiteralAlignType = Literal["start", "center", "end"] LiteralStickyType = Literal["partial", "always"] class Tooltip(RadixThemesComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... @overload @classmethod def create( # type: ignore @@ -30,35 +28,33 @@ 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]], Union[float, int]]] = 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]], Union[float, int]]] = None, + align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ - Var[Union[float, int, Dict[str, Union[float, int]]]], - Union[float, int, Dict[str, Union[float, int]]], + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, ] ] = None, - arrow_padding: Optional[ - Union[Var[Union[float, int]], 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]], Union[float, int]] - ] = None, + delay_duration: Optional[Union[Var[Union[float, int]], float, int]] = None, disable_hoverable_content: Optional[Union[Var[bool], bool]] = None, force_mount: Optional[Union[Var[bool], bool]] = None, aria_label: Optional[Union[Var[str], str]] = None, @@ -68,61 +64,25 @@ class Tooltip(RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_open_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_escape_key_down: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_pointer_down_outside: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Tooltip": """Initialize the Tooltip component. @@ -146,6 +106,9 @@ class Tooltip(RadixThemesComponent): disable_hoverable_content: Prevents Tooltip content from remaining open when hovering. force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. aria_label: By default, screenreaders will announce the content inside the component. If this is not descriptive enough, or you have content that cannot be announced, use aria-label as a more descriptive label. + on_open_change: Fired when the open state changes. + on_escape_key_down: Fired when the escape key is pressed. + on_pointer_down_outside: Fired when the pointer is down outside the tooltip. 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/layout/__init__.py b/reflex/components/radix/themes/layout/__init__.py index 4832c60db..b141146bd 100644 --- a/reflex/components/radix/themes/layout/__init__.py +++ b/reflex/components/radix/themes/layout/__init__.py @@ -1,42 +1,17 @@ """Layout components.""" -from .box import Box -from .center import Center -from .container import Container -from .flex import Flex -from .grid import Grid -from .list import list_ns as list -from .section import Section -from .spacer import Spacer -from .stack import HStack, Stack, VStack +from __future__ import annotations -box = Box.create -center = Center.create -container = Container.create -flex = Flex.create -grid = Grid.create -section = Section.create -spacer = Spacer.create -stack = Stack.create -hstack = HStack.create -vstack = VStack.create -list_item = list.item -ordered_list = list.ordered -unordered_list = list.unordered +from reflex import RADIX_THEMES_LAYOUT_MAPPING +from reflex.utils import lazy_loader -__all__ = [ - "box", - "center", - "container", - "flex", - "grid", - "section", - "spacer", - "stack", - "hstack", - "vstack", - "list", - "list_item", - "ordered_list", - "unordered_list", -] +_SUBMOD_ATTRS: dict[str, list[str]] = { + "".join(k.split("components.radix.themes.layout.")[-1]): v + for k, v in RADIX_THEMES_LAYOUT_MAPPING.items() +} + + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/themes/layout/__init__.pyi b/reflex/components/radix/themes/layout/__init__.pyi new file mode 100644 index 000000000..6712a3068 --- /dev/null +++ b/reflex/components/radix/themes/layout/__init__.pyi @@ -0,0 +1,19 @@ +"""Stub file for reflex/components/radix/themes/layout/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .box import box as box +from .center import center as center +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 +from .spacer import spacer as spacer +from .stack import hstack as hstack +from .stack import stack as stack +from .stack import vstack as vstack diff --git a/reflex/components/radix/themes/layout/base.py b/reflex/components/radix/themes/layout/base.py index 6e202a8c8..3ee78d209 100644 --- a/reflex/components/radix/themes/layout/base.py +++ b/reflex/components/radix/themes/layout/base.py @@ -4,7 +4,8 @@ from __future__ import annotations from typing import Literal -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.vars.base import Var from ..base import ( CommonMarginProps, @@ -22,28 +23,28 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): """ # Padding: "0" - "9" - p: Var[LiteralSpacing] + p: Var[Responsive[LiteralSpacing]] # Padding horizontal: "0" - "9" - px: Var[LiteralSpacing] + px: Var[Responsive[LiteralSpacing]] # Padding vertical: "0" - "9" - py: Var[LiteralSpacing] + py: Var[Responsive[LiteralSpacing]] # Padding top: "0" - "9" - pt: Var[LiteralSpacing] + pt: Var[Responsive[LiteralSpacing]] # Padding right: "0" - "9" - pr: Var[LiteralSpacing] + pr: Var[Responsive[LiteralSpacing]] # Padding bottom: "0" - "9" - pb: Var[LiteralSpacing] + pb: Var[Responsive[LiteralSpacing]] # Padding left: "0" - "9" - pl: Var[LiteralSpacing] + pl: Var[Responsive[LiteralSpacing]] # Whether the element will take up the smallest possible space: "0" | "1" - flex_shrink: Var[LiteralBoolNumber] + flex_shrink: Var[Responsive[LiteralBoolNumber]] # Whether the element will take up the largest possible space: "0" | "1" - flex_grow: Var[LiteralBoolNumber] + flex_grow: Var[Responsive[LiteralBoolNumber]] diff --git a/reflex/components/radix/themes/layout/base.pyi b/reflex/components/radix/themes/layout/base.pyi index 31310928e..df51b07f9 100644 --- a/reflex/components/radix/themes/layout/base.pyi +++ b/reflex/components/radix/themes/layout/base.pyi @@ -1,15 +1,16 @@ """Stub file for reflex/components/radix/themes/layout/base.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex.vars import Var -from ..base import CommonMarginProps, LiteralSpacing, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import CommonMarginProps, RadixThemesComponent LiteralBoolNumber = Literal["0", "1"] @@ -21,88 +22,177 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): *children, p: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, px: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, py: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, pt: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, pr: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, pb: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, pl: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], + ] + ] = None, + flex_shrink: Optional[ + Union[ + Breakpoints[str, Literal["0", "1"]], + Literal["0", "1"], + Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], + ] + ] = None, + flex_grow: Optional[ + Union[ + Breakpoints[str, Literal["0", "1"]], + Literal["0", "1"], + Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], ] ] = None, - flex_shrink: Optional[Union[Var[Literal["0", "1"]], Literal["0", "1"]]] = None, - flex_grow: Optional[Union[Var[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, @@ -111,52 +201,22 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "LayoutComponent": """Create a new component instance. diff --git a/reflex/components/radix/themes/layout/box.py b/reflex/components/radix/themes/layout/box.py index b9bb99107..a8ace5956 100644 --- a/reflex/components/radix/themes/layout/box.py +++ b/reflex/components/radix/themes/layout/box.py @@ -1,12 +1,16 @@ """Declarative layout and common spacing props.""" + from __future__ import annotations -from reflex import el +from reflex.components.el import elements from ..base import RadixThemesComponent -class Box(el.Div, RadixThemesComponent): +class Box(elements.Div, RadixThemesComponent): """A fundamental layout building block, based on `div` element.""" tag = "Box" + + +box = Box.create diff --git a/reflex/components/radix/themes/layout/box.pyi b/reflex/components/radix/themes/layout/box.pyi index 323a88540..895725a35 100644 --- a/reflex/components/radix/themes/layout/box.pyi +++ b/reflex/components/radix/themes/layout/box.pyi @@ -1,113 +1,69 @@ """Stub file for reflex/components/radix/themes/layout/box.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from reflex import el +from reflex.vars.base import Var + from ..base import RadixThemesComponent -class Box(el.Div, RadixThemesComponent): +class Box(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Box": """Create a new component instance. @@ -144,3 +100,5 @@ class Box(el.Div, RadixThemesComponent): A new component instance. """ ... + +box = Box.create diff --git a/reflex/components/radix/themes/layout/center.py b/reflex/components/radix/themes/layout/center.py index 16441876a..3ac4fecb1 100644 --- a/reflex/components/radix/themes/layout/center.py +++ b/reflex/components/radix/themes/layout/center.py @@ -2,7 +2,7 @@ from __future__ import annotations -from reflex.style import Style +from typing import Any from .flex import Flex @@ -10,16 +10,17 @@ from .flex import Flex class Center(Flex): """A center component.""" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style that center the content. Returns: The style of the component. """ - return Style( - { - "display": "flex", - "align_items": "center", - "justify_content": "center", - } - ) + return { + "display": "flex", + "align_items": "center", + "justify_content": "center", + } + + +center = Center.create diff --git a/reflex/components/radix/themes/layout/center.pyi b/reflex/components/radix/themes/layout/center.pyi index 0fd45f940..eb976892e 100644 --- a/reflex/components/radix/themes/layout/center.pyi +++ b/reflex/components/radix/themes/layout/center.pyi @@ -1,17 +1,19 @@ """Stub file for reflex/components/radix/themes/layout/center.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style +from reflex.vars.base import Var + from .flex import Flex class Center(Flex): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -20,126 +22,125 @@ class Center(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[ + Union[ + Breakpoints[ + str, + Literal["column", "column-reverse", "row", "row-reverse"], + ], + Literal["column", "column-reverse", "row", "row-reverse"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline", "stretch"]], - Literal["start", "center", "end", "baseline", "stretch"], + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], + Var[ + Union[ + Breakpoints[ + str, + Literal["baseline", "center", "end", "start", "stretch"], + ], + Literal["baseline", "center", "end", "start", "stretch"], + ] + ], ] ] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Center": """Create a new component instance. @@ -182,3 +183,5 @@ class Center(Flex): A new component instance. """ ... + +center = Center.create diff --git a/reflex/components/radix/themes/layout/container.py b/reflex/components/radix/themes/layout/container.py index 2ab548cdf..b1d2fbed3 100644 --- a/reflex/components/radix/themes/layout/container.py +++ b/reflex/components/radix/themes/layout/container.py @@ -1,18 +1,20 @@ """Declarative layout and common spacing props.""" + from __future__ import annotations from typing import Literal -from reflex import el +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements from reflex.style import STACK_CHILDREN_FULL_WIDTH -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import RadixThemesComponent LiteralContainerSize = Literal["1", "2", "3", "4"] -class Container(el.Div, RadixThemesComponent): +class Container(elements.Div, RadixThemesComponent): """Constrains the maximum width of page content. See https://www.radix-ui.com/themes/docs/components/container @@ -21,7 +23,7 @@ class Container(el.Div, RadixThemesComponent): tag = "Container" # The size of the container: "1" - "4" (default "3") - size: Var[LiteralContainerSize] = Var.create_safe("3") + size: Var[Responsive[LiteralContainerSize]] = LiteralVar.create("3") @classmethod def create( @@ -49,3 +51,6 @@ class Container(el.Div, RadixThemesComponent): padding=padding, **props, ) + + +container = Container.create diff --git a/reflex/components/radix/themes/layout/container.pyi b/reflex/components/radix/themes/layout/container.pyi index a2ea0266f..a5e50b9f3 100644 --- a/reflex/components/radix/themes/layout/container.pyi +++ b/reflex/components/radix/themes/layout/container.pyi @@ -1,21 +1,21 @@ """Stub file for reflex/components/radix/themes/layout/container.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.style import STACK_CHILDREN_FULL_WIDTH -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent LiteralContainerSize = Literal["1", "2", "3", "4"] -class Container(el.Div, RadixThemesComponent): +class Container(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -24,100 +24,63 @@ class Container(el.Div, RadixThemesComponent): padding: Optional[str] = "16px", stack_children_full_width: Optional[bool] = False, size: Optional[ - Union[Var[Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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"], + ] + ], + ] ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Container": """Create the container component. @@ -131,3 +94,5 @@ class Container(el.Div, RadixThemesComponent): The container component. """ ... + +container = Container.create diff --git a/reflex/components/radix/themes/layout/flex.py b/reflex/components/radix/themes/layout/flex.py index ef7aed16c..8be16973d 100644 --- a/reflex/components/radix/themes/layout/flex.py +++ b/reflex/components/radix/themes/layout/flex.py @@ -4,8 +4,9 @@ from __future__ import annotations from typing import Dict, Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAlign, @@ -18,7 +19,7 @@ LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"] LiteralFlexWrap = Literal["nowrap", "wrap", "wrap-reverse"] -class Flex(el.Div, RadixThemesComponent): +class Flex(elements.Div, RadixThemesComponent): """Component for creating flex layouts.""" tag = "Flex" @@ -27,19 +28,22 @@ class Flex(el.Div, RadixThemesComponent): as_child: Var[bool] # How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse" - direction: Var[LiteralFlexDirection] + direction: Var[Responsive[LiteralFlexDirection]] # Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" - align: Var[LiteralAlign] + align: Var[Responsive[LiteralAlign]] # Alignment of children along the cross axis: "start" | "center" | "end" | "between" - justify: Var[LiteralJustify] + justify: Var[Responsive[LiteralJustify]] # Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse" - wrap: Var[LiteralFlexWrap] + wrap: Var[Responsive[LiteralFlexWrap]] # Gap between children: "0" - "9" - spacing: Var[LiteralSpacing] + spacing: Var[Responsive[LiteralSpacing]] # Reflex maps the "spacing" prop to "gap" prop. _rename_props: Dict[str, str] = {"spacing": "gap"} + + +flex = Flex.create diff --git a/reflex/components/radix/themes/layout/flex.pyi b/reflex/components/radix/themes/layout/flex.pyi index 115e1d1ae..aba864f4f 100644 --- a/reflex/components/radix/themes/layout/flex.pyi +++ b/reflex/components/radix/themes/layout/flex.pyi @@ -1,21 +1,22 @@ """Stub file for reflex/components/radix/themes/layout/flex.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Dict, Literal -from reflex import el -from reflex.vars import Var -from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"] LiteralFlexWrap = Literal["nowrap", "wrap", "wrap-reverse"] -class Flex(el.Div, RadixThemesComponent): +class Flex(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -24,126 +25,125 @@ class Flex(el.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[ + Union[ + Breakpoints[ + str, + Literal["column", "column-reverse", "row", "row-reverse"], + ], + Literal["column", "column-reverse", "row", "row-reverse"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline", "stretch"]], - Literal["start", "center", "end", "baseline", "stretch"], + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], + Var[ + Union[ + Breakpoints[ + str, + Literal["baseline", "center", "end", "start", "stretch"], + ], + Literal["baseline", "center", "end", "start", "stretch"], + ] + ], ] ] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Flex": """Create a new component instance. @@ -186,3 +186,5 @@ class Flex(el.Div, RadixThemesComponent): A new component instance. """ ... + +flex = Flex.create diff --git a/reflex/components/radix/themes/layout/grid.py b/reflex/components/radix/themes/layout/grid.py index 565703643..b9ac28d41 100644 --- a/reflex/components/radix/themes/layout/grid.py +++ b/reflex/components/radix/themes/layout/grid.py @@ -4,8 +4,9 @@ from __future__ import annotations from typing import Dict, Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAlign, @@ -17,7 +18,7 @@ from ..base import ( LiteralGridFlow = Literal["row", "column", "dense", "row-dense", "column-dense"] -class Grid(el.Div, RadixThemesComponent): +class Grid(elements.Div, RadixThemesComponent): """Component for creating grid layouts.""" tag = "Grid" @@ -26,28 +27,28 @@ class Grid(el.Div, RadixThemesComponent): as_child: Var[bool] # Number of columns - columns: Var[str] + columns: Var[Responsive[str]] # Number of rows - rows: Var[str] + rows: Var[Responsive[str]] # How the grid items are layed out: "row" | "column" | "dense" | "row-dense" | "column-dense" - flow: Var[LiteralGridFlow] + flow: Var[Responsive[LiteralGridFlow]] # Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" - align: Var[LiteralAlign] + align: Var[Responsive[LiteralAlign]] # Alignment of children along the cross axis: "start" | "center" | "end" | "between" - justify: Var[LiteralJustify] + justify: Var[Responsive[LiteralJustify]] # Gap between children: "0" - "9" - spacing: Var[LiteralSpacing] + spacing: Var[Responsive[LiteralSpacing]] # Gap between children horizontal: "0" - "9" - spacing_x: Var[LiteralSpacing] + spacing_x: Var[Responsive[LiteralSpacing]] # Gap between children vertical: "0" - "9" - spacing_y: Var[LiteralSpacing] + spacing_y: Var[Responsive[LiteralSpacing]] # Reflex maps the "spacing" prop to "gap" prop. _rename_props: Dict[str, str] = { @@ -55,3 +56,6 @@ class Grid(el.Div, RadixThemesComponent): "spacing_x": "gap_x", "spacing_y": "gap_y", } + + +grid = Grid.create diff --git a/reflex/components/radix/themes/layout/grid.pyi b/reflex/components/radix/themes/layout/grid.pyi index cfb9c447e..faf63712e 100644 --- a/reflex/components/radix/themes/layout/grid.pyi +++ b/reflex/components/radix/themes/layout/grid.pyi @@ -1,156 +1,178 @@ """Stub file for reflex/components/radix/themes/layout/grid.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Dict, Literal -from reflex import el -from reflex.vars import Var -from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralGridFlow = Literal["row", "column", "dense", "row-dense", "column-dense"] -class Grid(el.Div, RadixThemesComponent): +class Grid(elements.Div, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - columns: Optional[Union[Var[str], str]] = None, - rows: Optional[Union[Var[str], str]] = None, + columns: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, + rows: Optional[ + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] + ] = None, flow: Optional[ Union[ - Var[Literal["row", "column", "dense", "row-dense", "column-dense"]], - Literal["row", "column", "dense", "row-dense", "column-dense"], + Breakpoints[ + str, Literal["column", "column-dense", "dense", "row", "row-dense"] + ], + Literal["column", "column-dense", "dense", "row", "row-dense"], + Var[ + Union[ + Breakpoints[ + str, + Literal[ + "column", "column-dense", "dense", "row", "row-dense" + ], + ], + Literal["column", "column-dense", "dense", "row", "row-dense"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline", "stretch"]], - Literal["start", "center", "end", "baseline", "stretch"], + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], + Var[ + Union[ + Breakpoints[ + str, + Literal["baseline", "center", "end", "start", "stretch"], + ], + Literal["baseline", "center", "end", "start", "stretch"], + ] + ], ] ] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, spacing_x: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, spacing_y: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Grid": """Create a new component instance. @@ -196,3 +218,5 @@ class Grid(el.Div, RadixThemesComponent): A new component instance. """ ... + +grid = Grid.create diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py index 87b9cf012..d83fd168b 100644 --- a/reflex/components/radix/themes/layout/list.py +++ b/reflex/components/radix/themes/layout/list.py @@ -1,15 +1,15 @@ """List components.""" + from __future__ import annotations -from typing import Iterable, Literal, Optional, Union +from typing import Any, Iterable, Literal, Union from reflex.components.component import Component, ComponentNamespace 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.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal[ "none", @@ -44,33 +44,35 @@ class BaseList(Component): # The style of the list. Default to "none". list_style_type: Var[ Union[LiteralListStyleTypeUnordered, LiteralListStyleTypeOrdered] - ] + ] = Var.create("none") + + # A list of items to add to the list. + items: Var[Iterable] = Var.create([]) @classmethod def create( cls, *children, - items: Optional[Var[Iterable]] = None, **props, ): """Create a list component. Args: *children: The children of the component. - items: A list of items to add to the list. **props: The properties of the component. Returns: The list component. """ + items = props.pop("items", None) list_style_type = props.pop("list_style_type", "none") + if not children and items is not None: if isinstance(items, Var): children = [Foreach.create(items, ListItem.create)] else: children = [ListItem.create(item) for item in items] # type: ignore - props["list_style_position"] = "outside" props["direction"] = "column" style = props.setdefault("style", {}) style["list_style_type"] = list_style_type @@ -78,18 +80,18 @@ class BaseList(Component): style["gap"] = props["gap"] return super().create(*children, **props) - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "direction": "column", - "list_style_position": "inside", - } - ) + return { + "direction": "column", + } + + def _exclude_props(self) -> list[str]: + return ["items", "list_style_type"] class UnorderedList(BaseList, Ul): @@ -101,22 +103,21 @@ class UnorderedList(BaseList, Ul): def create( cls, *children, - items: Optional[Var[Iterable]] = None, - list_style_type: LiteralListStyleTypeUnordered = "disc", **props, ): - """Create a unordered list component. + """Create an unordered list component. Args: *children: The children of the component. - items: A list of items to add to the list. - list_style_type: The style of the list. **props: The properties of the component. Returns: The list component. """ + items = props.pop("items", None) + list_style_type = props.pop("list_style_type", "disc") + props["margin_left"] = props.get("margin_left", "1.5rem") return super().create( *children, items=items, list_style_type=list_style_type, **props @@ -132,22 +133,21 @@ class OrderedList(BaseList, Ol): def create( cls, *children, - items: Optional[Var[Iterable]] = None, - list_style_type: LiteralListStyleTypeOrdered = "decimal", **props, ): """Create an ordered list component. Args: *children: The children of the component. - items: A list of items to add to the list. - list_style_type: The style of the list. **props: The properties of the component. Returns: The list component. """ + items = props.pop("items", None) + list_style_type = props.pop("list_style_type", "decimal") + props["margin_left"] = props.get("margin_left", "1.5rem") return super().create( *children, items=items, list_style_type=list_style_type, **props @@ -187,3 +187,17 @@ class List(ComponentNamespace): list_ns = List() +list_item = list_ns.item +ordered_list = list_ns.ordered +unordered_list = list_ns.unordered + + +def __getattr__(name): + # special case for when accessing list to avoid shadowing + # python's built in list object. + if name == "list": + return list_ns + try: + return globals()[name] + except KeyError: + raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None diff --git a/reflex/components/radix/themes/layout/list.pyi b/reflex/components/radix/themes/layout/list.pyi index a736f106c..1ce6359a4 100644 --- a/reflex/components/radix/themes/layout/list.pyi +++ b/reflex/components/radix/themes/layout/list.pyi @@ -1,20 +1,15 @@ """Stub file for reflex/components/radix/themes/layout/list.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Iterable, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Iterable, Literal, Optional, Union from reflex.components.component import Component, ComponentNamespace -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.event import EventType from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal["none", "disc", "circle", "square"] LiteralListStyleTypeOrdered = Literal[ @@ -40,110 +35,78 @@ class BaseList(Component): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], 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", "disc", "circle", "square"], 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["circle", "disc", "none", "square"], ] ], - Union[ - 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, + items: Optional[Union[Iterable, Var[Iterable]]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "BaseList": """Create a list component. Args: *children: The children of the component. - items: A list of items to add to the list. list_style_type: The style of the list. Default to "none". + items: A list of items to add to the list. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -157,7 +120,8 @@ class BaseList(Component): """ ... - def add_style(self) -> Style | None: ... + + def add_style(self) -> dict[str, Any] | None: ... class UnorderedList(BaseList, Ul): @overload @@ -165,107 +129,102 @@ class UnorderedList(BaseList, Ul): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, - list_style_type: Optional[LiteralListStyleTypeUnordered] = "disc", - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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[ + "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"], + ] + ], + ] ] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "UnorderedList": - """Create a unordered list component. + """Create an unordered list component. Args: *children: The children of the component. + list_style_type: The style of the list. Default to "none". items: A list of items to add to the list. - list_style_type: The style of the list. access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -302,114 +261,105 @@ class OrderedList(BaseList, Ol): def create( # type: ignore cls, *children, - items: Optional[Union[Var[Iterable], Iterable]] = None, - list_style_type: Optional[LiteralListStyleTypeOrdered] = "decimal", - reversed: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - start: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - type: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + 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[ + "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"], + ] + ], + ] ] = None, + items: Optional[Union[Iterable, Var[Iterable]]] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "OrderedList": """Create an ordered list component. Args: *children: The children of the component. + list_style_type: The style of the list. Default to "none". items: A list of items to add to the list. - list_style_type: The style of the list. reversed: Reverses the order of the list. start: Specifies the start value of the first list item in an ordered list. type: Specifies the kind of marker to use in the list (letters or numbers). @@ -449,98 +399,52 @@ class ListItem(Li): def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ListItem": """Create a list item component. @@ -584,110 +488,78 @@ class List(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[Var[Iterable], 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", "disc", "circle", "square"], 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["circle", "disc", "none", "square"], ] ], - Union[ - 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, + items: Optional[Union[Iterable, Var[Iterable]]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "BaseList": """Create a list component. Args: *children: The children of the component. - items: A list of items to add to the list. list_style_type: The style of the list. Default to "none". + items: A list of items to add to the list. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -703,3 +575,6 @@ class List(ComponentNamespace): ... list_ns = List() +list_item = list_ns.item +ordered_list = list_ns.ordered +unordered_list = list_ns.unordered diff --git a/reflex/components/radix/themes/layout/section.py b/reflex/components/radix/themes/layout/section.py index 5f17b270c..68a131751 100644 --- a/reflex/components/radix/themes/layout/section.py +++ b/reflex/components/radix/themes/layout/section.py @@ -1,20 +1,25 @@ """Declarative layout and common spacing props.""" + from __future__ import annotations from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import LiteralVar, Var from ..base import RadixThemesComponent LiteralSectionSize = Literal["1", "2", "3"] -class Section(el.Section, RadixThemesComponent): +class Section(elements.Section, RadixThemesComponent): """Denotes a section of page content.""" tag = "Section" - # The size of the section: "1" - "3" (default "3") - size: Var[LiteralSectionSize] + # The size of the section: "1" - "3" (default "2") + size: Var[Responsive[LiteralSectionSize]] = LiteralVar.create("2") + + +section = Section.create diff --git a/reflex/components/radix/themes/layout/section.pyi b/reflex/components/radix/themes/layout/section.pyi index 5b9ef9c5f..9fb790b9f 100644 --- a/reflex/components/radix/themes/layout/section.pyi +++ b/reflex/components/radix/themes/layout/section.pyi @@ -1,120 +1,83 @@ """Stub file for reflex/components/radix/themes/layout/section.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType from reflex.style import Style -from typing import Literal -from reflex import el -from reflex.vars import Var +from reflex.vars.base import Var + from ..base import RadixThemesComponent LiteralSectionSize = Literal["1", "2", "3"] -class Section(el.Section, RadixThemesComponent): +class Section(elements.Section, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, size: Optional[ - Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Section": """Create a new component instance. @@ -123,7 +86,7 @@ class Section(el.Section, RadixThemesComponent): Args: *children: Child components. - size: The size of the section: "1" - "3" (default "3") + size: The size of the section: "1" - "3" (default "2") access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -152,3 +115,5 @@ class Section(el.Section, RadixThemesComponent): A new component instance. """ ... + +section = Section.create diff --git a/reflex/components/radix/themes/layout/spacer.py b/reflex/components/radix/themes/layout/spacer.py index 6d7ab9aaf..9579b0b27 100644 --- a/reflex/components/radix/themes/layout/spacer.py +++ b/reflex/components/radix/themes/layout/spacer.py @@ -2,7 +2,7 @@ from __future__ import annotations -from reflex.style import Style +from typing import Any from .flex import Flex @@ -10,16 +10,17 @@ from .flex import Flex class Spacer(Flex): """A spacer component.""" - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: The style of the component. """ - return Style( - { - "flex": 1, - "justify_self": "stretch", - "align_self": "stretch", - } - ) + return { + "flex": 1, + "justify_self": "stretch", + "align_self": "stretch", + } + + +spacer = Spacer.create diff --git a/reflex/components/radix/themes/layout/spacer.pyi b/reflex/components/radix/themes/layout/spacer.pyi index 733501489..f83d7a4c9 100644 --- a/reflex/components/radix/themes/layout/spacer.pyi +++ b/reflex/components/radix/themes/layout/spacer.pyi @@ -1,17 +1,19 @@ """Stub file for reflex/components/radix/themes/layout/spacer.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style +from reflex.vars.base import Var + from .flex import Flex class Spacer(Flex): - def add_style(self) -> Style | None: ... + def add_style(self) -> dict[str, Any] | None: ... @overload @classmethod def create( # type: ignore @@ -20,126 +22,125 @@ class Spacer(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[ + Union[ + Breakpoints[ + str, + Literal["column", "column-reverse", "row", "row-reverse"], + ], + Literal["column", "column-reverse", "row", "row-reverse"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline", "stretch"]], - Literal["start", "center", "end", "baseline", "stretch"], + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], + Var[ + Union[ + Breakpoints[ + str, + Literal["baseline", "center", "end", "start", "stretch"], + ], + Literal["baseline", "center", "end", "start", "stretch"], + ] + ], ] ] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, spacing: Optional[ Union[ - Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Spacer": """Create a new component instance. @@ -182,3 +183,5 @@ class Spacer(Flex): A new component instance. """ ... + +spacer = Spacer.create diff --git a/reflex/components/radix/themes/layout/stack.py b/reflex/components/radix/themes/layout/stack.py index 8f0abf433..d11c3488b 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 @@ -12,20 +12,22 @@ from .flex import Flex, LiteralFlexDirection class Stack(Flex): """A stack component.""" + # The spacing between each stack item. + spacing: Var[LiteralSpacing] = Var.create("3") + + # The alignment of the stack items. + align: Var[LiteralAlign] = Var.create("start") + @classmethod def create( cls, *children, - spacing: LiteralSpacing = "3", - align: LiteralAlign = "start", **props, ) -> Component: """Create a new instance of the component. Args: *children: The children of the stack. - spacing: The spacing between each stack item. - align: The alignment of the stack items. **props: The properties of the stack. Returns: @@ -33,14 +35,12 @@ class Stack(Flex): """ # Apply the default classname given_class_name = props.pop("class_name", []) - if isinstance(given_class_name, str): + if not isinstance(given_class_name, list): given_class_name = [given_class_name] props["class_name"] = ["rx-Stack", *given_class_name] return super().create( *children, - spacing=spacing, - align=align, **props, ) @@ -57,3 +57,8 @@ class HStack(Stack): # The direction of the stack. direction: Var[LiteralFlexDirection] = "row" # type: ignore + + +stack = Stack.create +hstack = HStack.create +vstack = VStack.create diff --git a/reflex/components/radix/themes/layout/stack.pyi b/reflex/components/radix/themes/layout/stack.pyi index c35f1dad8..c4b475218 100644 --- a/reflex/components/radix/themes/layout/stack.pyi +++ b/reflex/components/radix/themes/layout/stack.pyi @@ -1,16 +1,16 @@ """Stub file for reflex/components/radix/themes/layout/stack.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec + +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import EventType from reflex.style import Style -from reflex.components.component import Component -from reflex.vars import Var -from ..base import LiteralAlign, LiteralSpacing -from .flex import Flex, LiteralFlexDirection +from reflex.vars.base import Var + +from .flex import Flex class Stack(Flex): @overload @@ -18,126 +18,113 @@ class Stack(Flex): def create( # type: ignore cls, *children, - spacing: Optional[LiteralSpacing] = "3", - align: Optional[LiteralAlign] = "start", + spacing: Optional[ + Union[ + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + ] + ] = None, + align: Optional[ + Union[ + Literal["baseline", "center", "end", "start", "stretch"], + Var[Literal["baseline", "center", "end", "start", "stretch"]], + ] + ] = None, as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ - Var[Literal["row", "column", "row-reverse", "column-reverse"]], - Literal["row", "column", "row-reverse", "column-reverse"], + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], + Var[ + Union[ + Breakpoints[ + str, + Literal["column", "column-reverse", "row", "row-reverse"], + ], + Literal["column", "column-reverse", "row", "row-reverse"], + ] + ], ] ] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Stack": """Create a new instance of the component. Args: *children: The children of the stack. - spacing: The spacing between each stack item. - align: The alignment of the stack items. + spacing: Gap between children: "0" - "9" + align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse" justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between" @@ -177,127 +164,103 @@ class VStack(Stack): def create( # type: ignore cls, *children, - spacing: Optional[LiteralSpacing] = "3", - 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, + spacing: Optional[ + Union[ + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + ] + ] = None, + align: Optional[ + Union[ + Literal["baseline", "center", "end", "start", "stretch"], + Var[Literal["baseline", "center", "end", "start", "stretch"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "VStack": """Create a new instance of the component. Args: *children: The children of the stack. - spacing: The spacing between each stack item. - align: The alignment of the stack items. direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse" + spacing: Gap between children: "0" - "9" + align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between" wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse" @@ -336,127 +299,103 @@ class HStack(Stack): def create( # type: ignore cls, *children, - spacing: Optional[LiteralSpacing] = "3", - 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, + spacing: Optional[ + Union[ + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]], + ] + ] = None, + align: Optional[ + Union[ + Literal["baseline", "center", "end", "start", "stretch"], + Var[Literal["baseline", "center", "end", "start", "stretch"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, justify: Optional[ Union[ - Var[Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + Var[ + Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], + ] + ], ] ] = None, wrap: Optional[ Union[ - Var[Literal["nowrap", "wrap", "wrap-reverse"]], + 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"], + ] + ], ] ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "HStack": """Create a new instance of the component. Args: *children: The children of the stack. - spacing: The spacing between each stack item. - align: The alignment of the stack items. direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse" + spacing: Gap between children: "0" - "9" + align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between" wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse" @@ -488,3 +427,7 @@ class HStack(Stack): The stack component. """ ... + +stack = Stack.create +hstack = HStack.create +vstack = VStack.create diff --git a/reflex/components/radix/themes/typography/__init__.py b/reflex/components/radix/themes/typography/__init__.py index a14e21007..0ea695ac5 100644 --- a/reflex/components/radix/themes/typography/__init__.py +++ b/reflex/components/radix/themes/typography/__init__.py @@ -1,20 +1,16 @@ """Typographic components.""" -from .blockquote import Blockquote -from .code import Code -from .heading import Heading -from .link import Link -from .text import text +from __future__ import annotations -blockquote = Blockquote.create -code = Code.create -heading = Heading.create -link = Link.create +from reflex import RADIX_THEMES_TYPOGRAPHY_MAPPING +from reflex.utils import lazy_loader -__all__ = [ - "blockquote", - "code", - "heading", - "link", - "text", -] +_SUBMOD_ATTRS: dict[str, list[str]] = { + "".join(k.split("components.radix.themes.typography.")[-1]): v + for k, v in RADIX_THEMES_TYPOGRAPHY_MAPPING.items() +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, +) diff --git a/reflex/components/radix/themes/typography/__init__.pyi b/reflex/components/radix/themes/typography/__init__.pyi new file mode 100644 index 000000000..4cc8f01f2 --- /dev/null +++ b/reflex/components/radix/themes/typography/__init__.pyi @@ -0,0 +1,10 @@ +"""Stub file for reflex/components/radix/themes/typography/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .blockquote import blockquote as blockquote +from .code import code as code +from .heading import heading as heading +from .link import link as link +from .text import text as text diff --git a/reflex/components/radix/themes/typography/base.py b/reflex/components/radix/themes/typography/base.py index 8742753b4..354d1b911 100644 --- a/reflex/components/radix/themes/typography/base.py +++ b/reflex/components/radix/themes/typography/base.py @@ -2,6 +2,7 @@ https://www.radix-ui.com/themes/docs/theme/typography """ + from __future__ import annotations from typing import Literal diff --git a/reflex/components/radix/themes/typography/blockquote.py b/reflex/components/radix/themes/typography/blockquote.py index 6525064d5..a60c05471 100644 --- a/reflex/components/radix/themes/typography/blockquote.py +++ b/reflex/components/radix/themes/typography/blockquote.py @@ -2,10 +2,12 @@ https://www.radix-ui.com/themes/docs/theme/typography """ + from __future__ import annotations -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -17,19 +19,22 @@ from .base import ( ) -class Blockquote(el.Blockquote, RadixThemesComponent): +class Blockquote(elements.Blockquote, RadixThemesComponent): """A block level extended quotation.""" tag = "Blockquote" # Text size: "1" - "9" - size: Var[LiteralTextSize] + size: Var[Responsive[LiteralTextSize]] # Thickness of text: "light" | "regular" | "medium" | "bold" - weight: Var[LiteralTextWeight] + weight: Var[Responsive[LiteralTextWeight]] # Overrides the accent color inherited from the Theme. color_scheme: Var[LiteralAccentColor] # Whether to render the text with higher contrast color high_contrast: Var[bool] + + +blockquote = Blockquote.create diff --git a/reflex/components/radix/themes/typography/blockquote.pyi b/reflex/components/radix/themes/typography/blockquote.pyi index 76855b287..3a9ae5c72 100644 --- a/reflex/components/radix/themes/typography/blockquote.pyi +++ b/reflex/components/radix/themes/typography/blockquote.pyi @@ -1,18 +1,19 @@ """Stub file for reflex/components/radix/themes/typography/blockquote.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex import el -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent -from .base import LiteralTextSize, LiteralTextWeight -class Blockquote(el.Blockquote, RadixThemesComponent): +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +class Blockquote(elements.Blockquote, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -20,172 +21,140 @@ class Blockquote(el.Blockquote, RadixThemesComponent): *children, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Blockquote": """Create a new component instance. @@ -227,3 +196,5 @@ class Blockquote(el.Blockquote, RadixThemesComponent): A new component instance. """ ... + +blockquote = Blockquote.create diff --git a/reflex/components/radix/themes/typography/code.py b/reflex/components/radix/themes/typography/code.py index 8ee0d2be2..663f260da 100644 --- a/reflex/components/radix/themes/typography/code.py +++ b/reflex/components/radix/themes/typography/code.py @@ -2,10 +2,12 @@ https://www.radix-ui.com/themes/docs/theme/typography """ + from __future__ import annotations -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -18,7 +20,7 @@ from .base import ( ) -class Code(el.Code, RadixThemesComponent): +class Code(elements.Code, RadixThemesComponent): """A block level extended quotation.""" tag = "Code" @@ -27,13 +29,16 @@ class Code(el.Code, RadixThemesComponent): variant: Var[LiteralVariant] # Text size: "1" - "9" - size: Var[LiteralTextSize] + size: Var[Responsive[LiteralTextSize]] # Thickness of text: "light" | "regular" | "medium" | "bold" - weight: Var[LiteralTextWeight] + weight: Var[Responsive[LiteralTextWeight]] # Overrides the accent color inherited from the Theme. color_scheme: Var[LiteralAccentColor] # Whether to render the text with higher contrast color high_contrast: Var[bool] + + +code = Code.create diff --git a/reflex/components/radix/themes/typography/code.pyi b/reflex/components/radix/themes/typography/code.pyi index 354c31cd1..2cda39ddf 100644 --- a/reflex/components/radix/themes/typography/code.pyi +++ b/reflex/components/radix/themes/typography/code.pyi @@ -1,18 +1,19 @@ """Stub file for reflex/components/radix/themes/typography/code.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex import el -from reflex.vars import Var -from ..base import LiteralAccentColor, LiteralVariant, RadixThemesComponent -from .base import LiteralTextSize, LiteralTextWeight -class Code(el.Code, RadixThemesComponent): +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +class Code(elements.Code, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -20,177 +21,145 @@ class Code(el.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[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Code": """Create a new component instance. @@ -232,3 +201,5 @@ class Code(el.Code, RadixThemesComponent): A new component instance. """ ... + +code = Code.create diff --git a/reflex/components/radix/themes/typography/heading.py b/reflex/components/radix/themes/typography/heading.py index 729d06624..f5fec8bb1 100644 --- a/reflex/components/radix/themes/typography/heading.py +++ b/reflex/components/radix/themes/typography/heading.py @@ -2,10 +2,12 @@ https://www.radix-ui.com/themes/docs/theme/typography """ + from __future__ import annotations -from reflex import el -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -19,7 +21,7 @@ from .base import ( ) -class Heading(el.H1, RadixThemesComponent): +class Heading(elements.H1, RadixThemesComponent): """A foundational text primitive based on the element.""" tag = "Heading" @@ -31,19 +33,22 @@ class Heading(el.H1, RadixThemesComponent): as_: Var[str] # Text size: "1" - "9" - size: Var[LiteralTextSize] + size: Var[Responsive[LiteralTextSize]] # Thickness of text: "light" | "regular" | "medium" | "bold" - weight: Var[LiteralTextWeight] + weight: Var[Responsive[LiteralTextWeight]] # Alignment of text in element: "left" | "center" | "right" - align: Var[LiteralTextAlign] + align: Var[Responsive[LiteralTextAlign]] # Removes the leading trim space: "normal" | "start" | "end" | "both" - trim: Var[LiteralTextTrim] + trim: Var[Responsive[LiteralTextTrim]] # Overrides the accent color inherited from the Theme. color_scheme: Var[LiteralAccentColor] # Whether to render the text with higher contrast color high_contrast: Var[bool] + + +heading = Heading.create diff --git a/reflex/components/radix/themes/typography/heading.pyi b/reflex/components/radix/themes/typography/heading.pyi index b10ea01ca..78ef8ba60 100644 --- a/reflex/components/radix/themes/typography/heading.pyi +++ b/reflex/components/radix/themes/typography/heading.pyi @@ -1,18 +1,19 @@ """Stub file for reflex/components/radix/themes/typography/heading.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from reflex import el -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent -from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight -class Heading(el.H1, RadixThemesComponent): +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent + +class Heading(elements.H1, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -22,183 +23,163 @@ class Heading(el.H1, RadixThemesComponent): as_: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + Var[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + ] + ], ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Heading": """Create a new component instance. @@ -243,3 +224,5 @@ class Heading(el.H1, RadixThemesComponent): A new component instance. """ ... + +heading = Heading.create diff --git a/reflex/components/radix/themes/typography/link.py b/reflex/components/radix/themes/typography/link.py index 7a4e424ed..e51209dce 100644 --- a/reflex/components/radix/themes/typography/link.py +++ b/reflex/components/radix/themes/typography/link.py @@ -8,12 +8,13 @@ from __future__ import annotations from typing import Literal from reflex.components.component import Component, MemoizationLeaf +from reflex.components.core.breakpoints import Responsive from reflex.components.core.colors import color 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 import imports -from reflex.vars import Var +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -39,13 +40,13 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): as_child: Var[bool] # Text size: "1" - "9" - size: Var[LiteralTextSize] + size: Var[Responsive[LiteralTextSize]] # Thickness of text: "light" | "regular" | "medium" | "bold" - weight: Var[LiteralTextWeight] + weight: Var[Responsive[LiteralTextWeight]] # Removes the leading trim space: "normal" | "start" | "end" | "both" - trim: Var[LiteralTextTrim] + trim: Var[Responsive[LiteralTextTrim]] # Sets the visibility of the underline affordance: "auto" | "hover" | "always" | "none" underline: Var[LiteralLinkUnderline] @@ -59,8 +60,13 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): # If True, the link will open in a new tab is_external: Var[bool] - def _get_imports(self) -> imports.ImportDict: - return {**super()._get_imports(), **next_link._get_imports()} + def add_imports(self) -> ImportDict: + """Add imports for the Link component. + + Returns: + The import dict. + """ + return next_link._get_imports() # type: ignore @classmethod def create(cls, *children, **props) -> Component: @@ -102,3 +108,6 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): **props, ) return super().create(*children, **props) + + +link = Link.create diff --git a/reflex/components/radix/themes/typography/link.pyi b/reflex/components/radix/themes/typography/link.pyi index ebcb8dce6..3e3eaf64b 100644 --- a/reflex/components/radix/themes/typography/link.pyi +++ b/reflex/components/radix/themes/typography/link.pyi @@ -1,27 +1,26 @@ """Stub file for reflex/components/radix/themes/typography/link.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal -from reflex.components.component import Component, MemoizationLeaf -from reflex.components.core.colors import color -from reflex.components.core.cond import cond + +from reflex.components.component import MemoizationLeaf +from reflex.components.core.breakpoints import Breakpoints from reflex.components.el.elements.inline import A from reflex.components.next.link import NextLink -from reflex.utils import imports -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent -from .base import LiteralTextSize, LiteralTextTrim, LiteralTextWeight +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralLinkUnderline = Literal["auto", "hover", "always", "none"] next_link = NextLink.create() class Link(RadixThemesComponent, A, MemoizationLeaf): + def add_imports(self) -> ImportDict: ... @overload @classmethod def create( # type: ignore @@ -30,205 +29,169 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - href: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - href_lang: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - media: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - ping: Optional[Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] - ] = None, - rel: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - shape: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - target: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Link": """Create a Link component. @@ -282,3 +245,5 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): Component: The link component """ ... + +link = Link.create diff --git a/reflex/components/radix/themes/typography/text.py b/reflex/components/radix/themes/typography/text.py index 96512fe58..24b09c753 100644 --- a/reflex/components/radix/themes/typography/text.py +++ b/reflex/components/radix/themes/typography/text.py @@ -7,9 +7,10 @@ from __future__ import annotations from typing import Literal -from reflex import el from reflex.components.component import ComponentNamespace -from reflex.vars import Var +from reflex.components.core.breakpoints import Responsive +from reflex.components.el import elements +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -44,7 +45,7 @@ LiteralType = Literal[ ] -class Text(el.Span, RadixThemesComponent): +class Text(elements.Span, RadixThemesComponent): """A foundational text primitive based on the element.""" tag = "Text" @@ -56,16 +57,16 @@ class Text(el.Span, RadixThemesComponent): as_: Var[LiteralType] = "p" # type: ignore # Text size: "1" - "9" - size: Var[LiteralTextSize] + size: Var[Responsive[LiteralTextSize]] # Thickness of text: "light" | "regular" | "medium" | "bold" - weight: Var[LiteralTextWeight] + weight: Var[Responsive[LiteralTextWeight]] # Alignment of text in element: "left" | "center" | "right" - align: Var[LiteralTextAlign] + align: Var[Responsive[LiteralTextAlign]] # Removes the leading trim space: "normal" | "start" | "end" | "both" - trim: Var[LiteralTextTrim] + trim: Var[Responsive[LiteralTextTrim]] # Overrides the accent color inherited from the Theme. color_scheme: Var[LiteralAccentColor] @@ -80,13 +81,13 @@ class Span(Text): as_: Var[LiteralType] = "span" # type: ignore -class Em(el.Em, RadixThemesComponent): +class Em(elements.Em, RadixThemesComponent): """Marks text to stress emphasis.""" tag = "Em" -class Kbd(el.Kbd, RadixThemesComponent): +class Kbd(elements.Kbd, RadixThemesComponent): """Represents keyboard input or a hotkey.""" tag = "Kbd" @@ -95,13 +96,13 @@ class Kbd(el.Kbd, RadixThemesComponent): size: Var[LiteralTextSize] -class Quote(el.Q, RadixThemesComponent): +class Quote(elements.Q, RadixThemesComponent): """A short inline quotation.""" tag = "Quote" -class Strong(el.Strong, RadixThemesComponent): +class Strong(elements.Strong, RadixThemesComponent): """Marks text to signify strong importance.""" tag = "Strong" diff --git a/reflex/components/radix/themes/typography/text.pyi b/reflex/components/radix/themes/typography/text.pyi index ea52eaca1..b4ddc622c 100644 --- a/reflex/components/radix/themes/typography/text.pyi +++ b/reflex/components/radix/themes/typography/text.pyi @@ -1,18 +1,18 @@ """Stub file for reflex/components/radix/themes/typography/text.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal -from reflex import el + from reflex.components.component import ComponentNamespace -from reflex.vars import Var -from ..base import LiteralAccentColor, RadixThemesComponent -from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el import elements +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +from ..base import RadixThemesComponent LiteralType = Literal[ "p", @@ -35,7 +35,7 @@ LiteralType = Literal[ "sup", ] -class Text(el.Span, RadixThemesComponent): +class Text(elements.Span, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -44,229 +44,209 @@ class Text(el.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[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + Var[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + ] + ], ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Text": """Create a new component instance. @@ -320,230 +300,210 @@ 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[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + Var[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + ] + ], ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Span": """Create a new component instance. @@ -589,104 +549,58 @@ class Span(Text): """ ... -class Em(el.Em, RadixThemesComponent): +class Em(elements.Em, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Em": """Create a new component instance. @@ -724,7 +638,7 @@ class Em(el.Em, RadixThemesComponent): """ ... -class Kbd(el.Kbd, RadixThemesComponent): +class Kbd(elements.Kbd, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -732,102 +646,56 @@ class Kbd(el.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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Kbd": """Create a new component instance. @@ -866,105 +734,59 @@ class Kbd(el.Kbd, RadixThemesComponent): """ ... -class Quote(el.Q, RadixThemesComponent): +class Quote(elements.Q, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[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[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Quote": """Create a new component instance. @@ -1003,104 +825,58 @@ class Quote(el.Q, RadixThemesComponent): """ ... -class Strong(el.Strong, RadixThemesComponent): +class Strong(elements.Strong, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Strong": """Create a new component instance. @@ -1151,229 +927,209 @@ 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[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + 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[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], ] ] = None, weight: Optional[ Union[ - Var[Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], ] ] = None, align: Optional[ Union[ - Var[Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + Var[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + ] + ], ] ] = None, trim: Optional[ Union[ - Var[Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], ] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - draggable: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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[str, int, bool]], Union[str, int, bool]] - ] = None, - hidden: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - input_mode: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - item_prop: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, - spell_check: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - tab_index: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] - ] = None, - title: Optional[ - Union[Var[Union[str, int, bool]], Union[str, int, bool]] + Union[Var[Union[bool, int, str]], bool, int, str] ] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Text": """Create a new component instance. diff --git a/reflex/components/react_player/__init__.py b/reflex/components/react_player/__init__.py index 8c4a4486f..3f807b1a0 100644 --- a/reflex/components/react_player/__init__.py +++ b/reflex/components/react_player/__init__.py @@ -1,5 +1,6 @@ """React Player component for audio and video.""" +from . import react_player from .audio import Audio from .video import Video diff --git a/reflex/components/react_player/audio.py b/reflex/components/react_player/audio.py index 359f37b74..49a5aa31e 100644 --- a/reflex/components/react_player/audio.py +++ b/reflex/components/react_player/audio.py @@ -1,4 +1,5 @@ """A audio component.""" + from reflex.components.react_player.react_player import ReactPlayer diff --git a/reflex/components/react_player/audio.pyi b/reflex/components/react_player/audio.pyi index 07591a185..5c8cc85df 100644 --- a/reflex/components/react_player/audio.pyi +++ b/reflex/components/react_player/audio.pyi @@ -1,13 +1,15 @@ """Stub file for reflex/components/react_player/audio.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style +import reflex from reflex.components.react_player.react_player import ReactPlayer +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Audio(ReactPlayer): pass @@ -32,52 +34,40 @@ class Audio(ReactPlayer): 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, function, BaseVar] + on_blur: Optional[EventType[[]]] = None, + on_buffer: Optional[EventType[[]]] = None, + on_buffer_end: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_click_preview: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_disable_pip: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_duration: Optional[EventType[float]] = None, + on_enable_pip: Optional[EventType[[]]] = None, + on_ended: Optional[EventType[[]]] = None, + on_error: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pause: Optional[EventType[[]]] = None, + on_play: Optional[EventType[[]]] = None, + on_playback_quality_change: Optional[EventType[[]]] = None, + on_playback_rate_change: Optional[EventType[[]]] = None, + on_progress: Optional[ + EventType[reflex.components.react_player.react_player.Progress] ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_ready: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_seek: Optional[EventType[float]] = None, + on_start: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Audio": """Create the component. @@ -92,6 +82,22 @@ class Audio(ReactPlayer): muted: Mutes the player width: Set the width of the player: ex:640px height: Set the height of the player: ex:640px + on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately. + on_start: Called when media starts playing. + on_play: Called when media starts or resumes playing after pausing or buffering. + on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 } + on_duration: Callback containing duration of the media, in seconds. + on_pause: Called when media is paused. + on_buffer: Called when media starts buffering. + on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook. + on_seek: Called when media seeks with seconds parameter. + on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths. + on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled). + on_ended: Called when media finishes playing. Does not fire when loop is set to true. + on_error: Called when an error occurs whilst attempting to play media. + on_click_preview: Called when user clicks the light mode preview. + on_enable_pip: Called when picture-in-picture mode is enabled. + on_disable_pip: Called when picture-in-picture mode is disabled. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/react_player/react_player.py b/reflex/components/react_player/react_player.py index 2e09d4bf9..b2c58b754 100644 --- a/reflex/components/react_player/react_player.py +++ b/reflex/components/react_player/react_player.py @@ -2,8 +2,20 @@ from __future__ import annotations +from typing_extensions import TypedDict + from reflex.components.component import NoSSRComponent -from reflex.vars import Var +from reflex.event import EventHandler, empty_event, identity_event +from reflex.vars.base import Var + + +class Progress(TypedDict): + """Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds.""" + + played: float + playedSeconds: float + loaded: float + loadedSeconds: float class ReactPlayer(NoSSRComponent): @@ -11,7 +23,7 @@ class ReactPlayer(NoSSRComponent): reference: https://github.com/cookpete/react-player. """ - library = "react-player@2.12.0" + library = "react-player@2.16.0" tag = "ReactPlayer" @@ -43,3 +55,51 @@ class ReactPlayer(NoSSRComponent): # Set the height of the player: ex:640px height: Var[str] + + # Called when media is loaded and ready to play. If playing is set to true, media will play immediately. + on_ready: EventHandler[empty_event] + + # Called when media starts playing. + on_start: EventHandler[empty_event] + + # Called when media starts or resumes playing after pausing or buffering. + on_play: EventHandler[empty_event] + + # Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 } + on_progress: EventHandler[identity_event(Progress)] + + # Callback containing duration of the media, in seconds. + on_duration: EventHandler[identity_event(float)] + + # Called when media is paused. + on_pause: EventHandler[empty_event] + + # Called when media starts buffering. + on_buffer: EventHandler[empty_event] + + # Called when media has finished buffering. Works for files, YouTube and Facebook. + on_buffer_end: EventHandler[empty_event] + + # Called when media seeks with seconds parameter. + on_seek: EventHandler[identity_event(float)] + + # Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths. + on_playback_rate_change: EventHandler[empty_event] + + # Called when playback quality of the player changed. Only supported by YouTube (if enabled). + on_playback_quality_change: EventHandler[empty_event] + + # Called when media finishes playing. Does not fire when loop is set to true. + on_ended: EventHandler[empty_event] + + # Called when an error occurs whilst attempting to play media. + on_error: EventHandler[empty_event] + + # Called when user clicks the light mode preview. + on_click_preview: EventHandler[empty_event] + + # Called when picture-in-picture mode is enabled. + on_enable_pip: EventHandler[empty_event] + + # Called when picture-in-picture mode is disabled. + on_disable_pip: EventHandler[empty_event] diff --git a/reflex/components/react_player/react_player.pyi b/reflex/components/react_player/react_player.pyi index 16f988460..ebae93f71 100644 --- a/reflex/components/react_player/react_player.pyi +++ b/reflex/components/react_player/react_player.pyi @@ -1,14 +1,22 @@ """Stub file for reflex/components/react_player/react_player.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload + +from typing_extensions import TypedDict -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style from reflex.components.component import NoSSRComponent -from reflex.vars import Var +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + +class Progress(TypedDict): + played: float + playedSeconds: float + loaded: float + loadedSeconds: float class ReactPlayer(NoSSRComponent): @overload @@ -31,52 +39,38 @@ class ReactPlayer(NoSSRComponent): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_buffer: Optional[EventType[[]]] = None, + on_buffer_end: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_click_preview: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_disable_pip: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_duration: Optional[EventType[float]] = None, + on_enable_pip: Optional[EventType[[]]] = None, + on_ended: Optional[EventType[[]]] = None, + on_error: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pause: Optional[EventType[[]]] = None, + on_play: Optional[EventType[[]]] = None, + on_playback_quality_change: Optional[EventType[[]]] = None, + on_playback_rate_change: Optional[EventType[[]]] = None, + on_progress: Optional[EventType[Progress]] = None, + on_ready: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_seek: Optional[EventType[float]] = None, + on_start: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ReactPlayer": """Create the component. @@ -91,6 +85,22 @@ class ReactPlayer(NoSSRComponent): muted: Mutes the player width: Set the width of the player: ex:640px height: Set the height of the player: ex:640px + on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately. + on_start: Called when media starts playing. + on_play: Called when media starts or resumes playing after pausing or buffering. + on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 } + on_duration: Callback containing duration of the media, in seconds. + on_pause: Called when media is paused. + on_buffer: Called when media starts buffering. + on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook. + on_seek: Called when media seeks with seconds parameter. + on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths. + on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled). + on_ended: Called when media finishes playing. Does not fire when loop is set to true. + on_error: Called when an error occurs whilst attempting to play media. + on_click_preview: Called when user clicks the light mode preview. + on_enable_pip: Called when picture-in-picture mode is enabled. + on_disable_pip: Called when picture-in-picture mode is disabled. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/react_player/video.py b/reflex/components/react_player/video.py index 834d1a9ae..0823bfbb5 100644 --- a/reflex/components/react_player/video.py +++ b/reflex/components/react_player/video.py @@ -1,4 +1,5 @@ """A video component.""" + from reflex.components.react_player.react_player import ReactPlayer diff --git a/reflex/components/react_player/video.pyi b/reflex/components/react_player/video.pyi index 4c54b241b..4a6bb81b3 100644 --- a/reflex/components/react_player/video.pyi +++ b/reflex/components/react_player/video.pyi @@ -1,13 +1,15 @@ """Stub file for reflex/components/react_player/video.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style +import reflex from reflex.components.react_player.react_player import ReactPlayer +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Video(ReactPlayer): pass @@ -32,52 +34,40 @@ class Video(ReactPlayer): 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, function, BaseVar] + on_blur: Optional[EventType[[]]] = None, + on_buffer: Optional[EventType[[]]] = None, + on_buffer_end: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_click_preview: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_disable_pip: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_duration: Optional[EventType[float]] = None, + on_enable_pip: Optional[EventType[[]]] = None, + on_ended: Optional[EventType[[]]] = None, + on_error: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_pause: Optional[EventType[[]]] = None, + on_play: Optional[EventType[[]]] = None, + on_playback_quality_change: Optional[EventType[[]]] = None, + on_playback_rate_change: Optional[EventType[[]]] = None, + on_progress: Optional[ + EventType[reflex.components.react_player.react_player.Progress] ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_ready: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_seek: Optional[EventType[float]] = None, + on_start: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Video": """Create the component. @@ -92,6 +82,22 @@ class Video(ReactPlayer): muted: Mutes the player width: Set the width of the player: ex:640px height: Set the height of the player: ex:640px + on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately. + on_start: Called when media starts playing. + on_play: Called when media starts or resumes playing after pausing or buffering. + on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 } + on_duration: Callback containing duration of the media, in seconds. + on_pause: Called when media is paused. + on_buffer: Called when media starts buffering. + on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook. + on_seek: Called when media seeks with seconds parameter. + on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths. + on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled). + on_ended: Called when media finishes playing. Does not fire when loop is set to true. + on_error: Called when an error occurs whilst attempting to play media. + on_click_preview: Called when user clicks the light mode preview. + on_enable_pip: Called when picture-in-picture mode is enabled. + on_disable_pip: Called when picture-in-picture mode is disabled. style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/recharts/__init__.py b/reflex/components/recharts/__init__.py index 327b9b326..5e9e6fc14 100644 --- a/reflex/components/recharts/__init__.py +++ b/reflex/components/recharts/__init__.py @@ -1,108 +1,119 @@ """Recharts components.""" -from .cartesian import ( - Area, - Bar, - Brush, - Cartesian, - CartesianAxis, - CartesianGrid, - ErrorBar, - Funnel, - Line, - ReferenceArea, - ReferenceDot, - ReferenceLine, - Scatter, - XAxis, - YAxis, - ZAxis, +from __future__ import annotations + +from reflex.utils import lazy_loader + +_SUBMOD_ATTRS: dict = { + "cartesian": [ + "area", + "Area", + "bar", + "Bar", + "line", + "Line", + "scatter", + "Scatter", + "x_axis", + "XAxis", + "y_axis", + "YAxis", + "z_axis", + "ZAxis", + "brush", + "Brush", + "cartesian_axis", + "CartesianAxis", + "cartesian_grid", + "CartesianGrid", + "reference_line", + "ReferenceLine", + "reference_dot", + "ReferenceDot", + "reference_area", + "ReferenceArea", + "error_bar", + "ErrorBar", + "funnel", + "Funnel", + ], + "charts": [ + "area_chart", + "AreaChart", + "bar_chart", + "BarChart", + "line_chart", + "LineChart", + "composed_chart", + "ComposedChart", + "pie_chart", + "PieChart", + "radar_chart", + "RadarChart", + "radial_bar_chart", + "RadialBarChart", + "scatter_chart", + "ScatterChart", + "funnel_chart", + "FunnelChart", + "treemap", + "Treemap", + ], + "general": [ + "responsive_container", + "ResponsiveContainer", + "legend", + "Legend", + "graphing_tooltip", + "GraphingTooltip", + "label", + "Label", + "label_list", + "LabelList", + ], + "polar": [ + "pie", + "Pie", + "radar", + "Radar", + "radial_bar", + "RadialBar", + "polar_angle_axis", + "PolarAngleAxis", + "polar_grid", + "PolarGrid", + "polar_radius_axis", + "PolarRadiusAxis", + ], + "recharts": [ + "LiteralAnimationEasing", + "LiteralAreaType", + "LiteralAxisType", + "LiteralBarChartStackOffset", + "LiteralComposedChartBaseValue", + "LiteralDirection", + "LiteralGridType", + "LiteralIconType", + "LiteralIfOverflow", + "LiteralInterval", + "LiteralLayout", + "LiteralLegendAlign", + "LiteralLegendType", + "LiteralLineType", + "LiteralOrientation", + "LiteralOrientationLeftRightMiddle", + "LiteralOrientationTopBottom", + "LiteralOrientationTopBottomLeftRight", + "LiteralPolarRadiusType", + "LiteralScale", + "LiteralShape", + "LiteralStackOffset", + "LiteralSyncMethod", + "LiteralVerticalAlign", + ], +} + +__getattr__, __dir__, __all__ = lazy_loader.attach( + __name__, + submod_attrs=_SUBMOD_ATTRS, ) -from .charts import ( - AreaChart, - BarChart, - ComposedChart, - FunnelChart, - LineChart, - PieChart, - RadarChart, - RadialBarChart, - ScatterChart, - Treemap, -) -from .general import GraphingTooltip, Label, LabelList, Legend, ResponsiveContainer -from .polar import ( - Pie, - PolarAngleAxis, - PolarGrid, - PolarRadiusAxis, - Radar, - RadialBar, -) -from .recharts import ( - LiteralAnimationEasing, - LiteralAreaType, - LiteralAxisType, - LiteralBarChartStackOffset, - LiteralComposedChartBaseValue, - LiteralDirection, - LiteralGridType, - LiteralIconType, - LiteralIfOverflow, - LiteralInterval, - LiteralLayout, - LiteralLegendAlign, - LiteralLegendType, - LiteralLineType, - LiteralOrientation, - LiteralOrientationLeftRightMiddle, - LiteralOrientationTopBottom, - LiteralOrientationTopBottomLeftRight, - LiteralPolarRadiusType, - LiteralScale, - LiteralShape, - LiteralStackOffset, - LiteralSyncMethod, - LiteralVerticalAlign, -) - -area_chart = AreaChart.create -bar_chart = BarChart.create -line_chart = LineChart.create -composed_chart = ComposedChart.create -pie_chart = PieChart.create -radar_chart = RadarChart.create -radial_bar_chart = RadialBarChart.create -scatter_chart = ScatterChart.create -funnel_chart = FunnelChart.create -treemap = Treemap.create - - -area = Area.create -bar = Bar.create -line = Line.create -scatter = Scatter.create -x_axis = XAxis.create -y_axis = YAxis.create -z_axis = ZAxis.create -brush = Brush.create -cartesian_axis = CartesianAxis.create -cartesian_grid = CartesianGrid.create -reference_line = ReferenceLine.create -reference_dot = ReferenceDot.create -reference_area = ReferenceArea.create -error_bar = ErrorBar.create -funnel = Funnel.create - -responsive_container = ResponsiveContainer.create -legend = Legend.create -graphing_tooltip = GraphingTooltip.create -label = Label.create -label_list = LabelList.create - -pie = Pie.create -radar = Radar.create -radial_bar = RadialBar.create -polar_angle_axis = PolarAngleAxis.create -polar_grid = PolarGrid.create -polar_radius_axis = PolarRadiusAxis.create diff --git a/reflex/components/recharts/__init__.pyi b/reflex/components/recharts/__init__.pyi new file mode 100644 index 000000000..8f6c4673f --- /dev/null +++ b/reflex/components/recharts/__init__.pyi @@ -0,0 +1,105 @@ +"""Stub file for reflex/components/recharts/__init__.py""" +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ + +from .cartesian import Area as Area +from .cartesian import Bar as Bar +from .cartesian import Brush as Brush +from .cartesian import CartesianAxis as CartesianAxis +from .cartesian import CartesianGrid as CartesianGrid +from .cartesian import ErrorBar as ErrorBar +from .cartesian import Funnel as Funnel +from .cartesian import Line as Line +from .cartesian import ReferenceArea as ReferenceArea +from .cartesian import ReferenceDot as ReferenceDot +from .cartesian import ReferenceLine as ReferenceLine +from .cartesian import Scatter as Scatter +from .cartesian import XAxis as XAxis +from .cartesian import YAxis as YAxis +from .cartesian import ZAxis as ZAxis +from .cartesian import area as area +from .cartesian import bar as bar +from .cartesian import brush as brush +from .cartesian import cartesian_axis as cartesian_axis +from .cartesian import cartesian_grid as cartesian_grid +from .cartesian import error_bar as error_bar +from .cartesian import funnel as funnel +from .cartesian import line as line +from .cartesian import reference_area as reference_area +from .cartesian import reference_dot as reference_dot +from .cartesian import reference_line as reference_line +from .cartesian import scatter as scatter +from .cartesian import x_axis as x_axis +from .cartesian import y_axis as y_axis +from .cartesian import z_axis as z_axis +from .charts import AreaChart as AreaChart +from .charts import BarChart as BarChart +from .charts import ComposedChart as ComposedChart +from .charts import FunnelChart as FunnelChart +from .charts import LineChart as LineChart +from .charts import PieChart as PieChart +from .charts import RadarChart as RadarChart +from .charts import RadialBarChart as RadialBarChart +from .charts import ScatterChart as ScatterChart +from .charts import Treemap as Treemap +from .charts import area_chart as area_chart +from .charts import bar_chart as bar_chart +from .charts import composed_chart as composed_chart +from .charts import funnel_chart as funnel_chart +from .charts import line_chart as line_chart +from .charts import pie_chart as pie_chart +from .charts import radar_chart as radar_chart +from .charts import radial_bar_chart as radial_bar_chart +from .charts import scatter_chart as scatter_chart +from .charts import treemap as treemap +from .general import GraphingTooltip as GraphingTooltip +from .general import Label as Label +from .general import LabelList as LabelList +from .general import Legend as Legend +from .general import ResponsiveContainer as ResponsiveContainer +from .general import graphing_tooltip as graphing_tooltip +from .general import label as label +from .general import label_list as label_list +from .general import legend as legend +from .general import responsive_container as responsive_container +from .polar import Pie as Pie +from .polar import PolarAngleAxis as PolarAngleAxis +from .polar import PolarGrid as PolarGrid +from .polar import PolarRadiusAxis as PolarRadiusAxis +from .polar import Radar as Radar +from .polar import RadialBar as RadialBar +from .polar import pie as pie +from .polar import polar_angle_axis as polar_angle_axis +from .polar import polar_grid as polar_grid +from .polar import polar_radius_axis as polar_radius_axis +from .polar import radar as radar +from .polar import radial_bar as radial_bar +from .recharts import LiteralAnimationEasing as LiteralAnimationEasing +from .recharts import LiteralAreaType as LiteralAreaType +from .recharts import LiteralAxisType as LiteralAxisType +from .recharts import LiteralBarChartStackOffset as LiteralBarChartStackOffset +from .recharts import LiteralComposedChartBaseValue as LiteralComposedChartBaseValue +from .recharts import LiteralDirection as LiteralDirection +from .recharts import LiteralGridType as LiteralGridType +from .recharts import LiteralIconType as LiteralIconType +from .recharts import LiteralIfOverflow as LiteralIfOverflow +from .recharts import LiteralInterval as LiteralInterval +from .recharts import LiteralLayout as LiteralLayout +from .recharts import LiteralLegendAlign as LiteralLegendAlign +from .recharts import LiteralLegendType as LiteralLegendType +from .recharts import LiteralLineType as LiteralLineType +from .recharts import LiteralOrientation as LiteralOrientation +from .recharts import ( + LiteralOrientationLeftRightMiddle as LiteralOrientationLeftRightMiddle, +) +from .recharts import LiteralOrientationTopBottom as LiteralOrientationTopBottom +from .recharts import ( + LiteralOrientationTopBottomLeftRight as LiteralOrientationTopBottomLeftRight, +) +from .recharts import LiteralPolarRadiusType as LiteralPolarRadiusType +from .recharts import LiteralScale as LiteralScale +from .recharts import LiteralShape as LiteralShape +from .recharts import LiteralStackOffset as LiteralStackOffset +from .recharts import LiteralSyncMethod as LiteralSyncMethod +from .recharts import LiteralVerticalAlign as LiteralVerticalAlign diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index 136bddf9f..865b50a32 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -1,10 +1,13 @@ """Cartesian charts in Recharts.""" + from __future__ import annotations from typing import Any, Dict, List, Union from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.constants.colors import Color +from reflex.event import EventHandler, empty_event +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, @@ -12,13 +15,17 @@ from .recharts import ( LiteralDirection, LiteralIfOverflow, LiteralInterval, + LiteralIntervalAxis, LiteralLayout, + LiteralLegendType, LiteralLineType, + LiteralOrientationLeftRight, LiteralOrientationTopBottom, LiteralOrientationTopBottomLeftRight, LiteralPolarRadiusType, LiteralScale, LiteralShape, + LiteralTextAnchor, Recharts, ) @@ -26,40 +33,49 @@ from .recharts import ( class Axis(Recharts): """A base class for axes in Recharts.""" - # The key of a group of data which should be unique in an area chart. + # The key of data displayed in the axis. data_key: Var[Union[str, int]] - # If set true, the axis do not display in the chart. + # If set true, the axis do not display in the chart. Default: False hide: Var[bool] - # The orientation of axis 'top' | 'bottom' - orientation: Var[LiteralOrientationTopBottom] + # The width of axis which is usually calculated internally. + width: Var[Union[str, int]] + + # The height of axis, which can be setted by user. + height: Var[Union[str, int]] # The type of axis 'number' | 'category' type_: Var[LiteralPolarRadiusType] - # Allow the ticks of XAxis to be decimals or not. + # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + interval: Var[Union[LiteralIntervalAxis, int]] + + # Allow the ticks of Axis to be decimals or not. Default: True allow_decimals: Var[bool] - # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. + # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False allow_data_overflow: Var[bool] - # Allow the axis has duplicated categorys or not when the type of axis is "category". + # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True allow_duplicated_category: Var[bool] - # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. + # The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + domain: Var[List] + + # If set false, no axis line will be drawn. Default: True axis_line: Var[bool] - # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. - tick_line: Var[bool] - - # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. + # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: Var[bool] - # Reverse the ticks or not. + # Reverse the ticks or not. Default: False reversed: Var[bool] - # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function + # The label of axis, which appears next to the axis. + label: Var[Union[str, int, Dict[str, Any]]] + + # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" scale: Var[LiteralScale] # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. @@ -68,20 +84,50 @@ class Axis(Recharts): # The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. name: Var[Union[str, int]] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # Set the values of axis ticks manually. + ticks: Var[List[Union[str, int]]] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # If set false, no ticks will be drawn. + tick: Var[bool] + + # The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_count: Var[int] + + # If set false, no axis tick lines will be drawn. Default: True + tick_line: Var[bool] + + # The length of tick line. Default: 6 + tick_size: Var[int] + + # The minimum gap between two adjacent labels. Default: 5 + min_tick_gap: Var[int] + + # The stroke color of axis. Default: rx.color("gray", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9)) + + # The text anchor of axis. Default: "middle" + text_anchor: Var[LiteralTextAnchor] + + # The customized event handler of click on the ticks of this axis + on_click: EventHandler[empty_event] + + # The customized event handler of mousedown on the ticks of this axis + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the ticks of this axis + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the ticks of this axis + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseout on the ticks of this axis + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the ticks of this axis + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the ticks of this axis + on_mouse_leave: EventHandler[empty_event] class XAxis(Axis): @@ -91,6 +137,21 @@ class XAxis(Axis): alias = "RechartsXAxis" + # The orientation of axis 'top' | 'bottom'. Default: "bottom" + orientation: Var[LiteralOrientationTopBottom] + + # The id of x-axis which is corresponding to the data. Default: 0 + x_axis_id: Var[Union[str, int]] + + # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False + include_hidden: Var[bool] + + # The angle of axis ticks. Default: 0 + angle: Var[int] + + # Specify the padding of x-axis. Default: {"left": 0, "right": 0} + padding: Var[Dict[str, int]] + class YAxis(Axis): """A YAxis component in Recharts.""" @@ -99,8 +160,14 @@ class YAxis(Axis): alias = "RechartsYAxis" - # The key of data displayed in the axis. - data_key: Var[Union[str, int]] + # The orientation of axis 'left' | 'right'. Default: "left" + orientation: Var[LiteralOrientationLeftRight] + + # The id of y-axis which is corresponding to the data. Default: 0 + y_axis_id: Var[Union[str, int]] + + # Specify the padding of y-axis. Default: {"top": 0, "bottom": 0} + padding: Var[Dict[str, int]] class ZAxis(Recharts): @@ -108,12 +175,15 @@ class ZAxis(Recharts): tag = "ZAxis" - alias = "RechartszAxis" + alias = "RechartsZAxis" # The key of data displayed in the axis. data_key: Var[Union[str, int]] - # The range of axis. + # The unique id of z-axis. Default: 0 + z_axis_id: Var[Union[str, int]] + + # The range of axis. Default: [10, 10] range: Var[List[int]] # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. @@ -122,7 +192,7 @@ class ZAxis(Recharts): # The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. name: Var[Union[str, int]] - # If 'auto' set, the scale function is decided by the type of chart, and the props type. + # If 'auto' set, the scale function is decided by the type of chart, and the props type. Default: "auto" scale: Var[LiteralScale] @@ -133,39 +203,48 @@ class Brush(Recharts): alias = "RechartsBrush" - # Stroke color - stroke: Var[str] + # Stroke color. Default: rx.color("gray", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9)) + + # The fill color of brush. Default: rx.color("gray", 2) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 2)) # The key of data displayed in the axis. data_key: Var[Union[str, int]] - # The x-coordinate of brush. + # The x-coordinate of brush. Default: 0 x: Var[int] - # The y-coordinate of brush. + # The y-coordinate of brush. Default: 0 y: Var[int] - # The width of brush. + # The width of brush. Default: 0 width: Var[int] - # The height of brush. + # The height of brush. Default: 40 height: Var[int] - # The data domain of brush, [min, max]. + # The original data of a LineChart, a BarChart or an AreaChart. data: Var[List[Any]] - # The width of each traveller. + # The width of each traveller. Default: 5 traveller_width: Var[int] - # The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time + # The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time. Default: 1 gap: Var[int] - # The default start index of brush. If the option is not set, the start index will be 0. + # The default start index of brush. If the option is not set, the start index will be 0. Default: 0 start_index: Var[int] - # The default end index of brush. If the option is not set, the end index will be 1. + # The default end index of brush. If the option is not set, the end index will be calculated by the length of data. end_index: Var[int] + # The fill color of brush + fill: Var[Union[str, Color]] + + # The stroke color of brush + stroke: Var[Union[str, Color]] + def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -173,7 +252,7 @@ class Brush(Recharts): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CHANGE: lambda: [], + EventTriggers.ON_CHANGE: empty_event, } @@ -186,29 +265,62 @@ class Cartesian(Recharts): # The key of a group of data which should be unique in an area chart. data_key: Var[Union[str, int]] - # The id of x-axis which is corresponding to the data. + # The id of x-axis which is corresponding to the data. Default: 0 x_axis_id: Var[Union[str, int]] - # The id of y-axis which is corresponding to the data. + # The id of y-axis which is corresponding to the data. Default: 0 y_axis_id: Var[Union[str, int]] - # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional - # legend_type: Var[LiteralLegendType] + # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional + legend_type: Var[LiteralLegendType] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # If set false, animation of bar will be disabled. Default: True + is_animation_active: Var[bool] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_begin: Var[int] + + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_duration: Var[int] + + # The type of easing function. Default: "ease" + animation_easing: Var[LiteralAnimationEasing] + + # The unit of data. This option will be used in tooltip. + unit: Var[Union[str, int]] + + # The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively. + name: Var[Union[str, int]] + + # The customized event handler of animation start + on_animation_start: EventHandler[empty_event] + + # The customized event handler of animation end + on_animation_end: EventHandler[empty_event] + + # The customized event handler of click on the component in this group + on_click: EventHandler[empty_event] + + # The customized event handler of mousedown on the component in this group + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the component in this group + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the component in this group + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseover on the component in this group + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the component in this group + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the component in this group + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the component in this group + on_mouse_leave: EventHandler[empty_event] class Area(Cartesian): @@ -218,29 +330,43 @@ class Area(Cartesian): alias = "RechartsArea" - # The color of the line stroke. - stroke: Var[str] + # The color of the line stroke. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # The width of the line stroke. + # The width of the line stroke. Default: 1 stroke_width: Var[int] - # The color of the area fill. - fill: Var[str] + # The color of the area fill. Default: rx.color("accent", 5) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 5)) - # The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' | - type_: Var[LiteralAreaType] + # The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter'. Default: "monotone" + type_: Var[LiteralAreaType] = LiteralVar.create("monotone") - # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. - dot: Var[bool] + # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False + dot: Var[Union[bool, Dict[str, Any]]] - # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - active_dot: Var[bool] + # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)} + active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create( + { + "stroke": Color("accent", 2), + "fill": Color("accent", 10), + } + ) - # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. + # If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False label: Var[bool] - # The stack id of area, when two areas have the same value axis and same stackId, then the two areas area stacked in order. - stack_id: Var[str] + # The value which can describle the line, usually calculated internally. + base_line: Var[Union[str, List[Dict[str, Any]]]] + + # The coordinates of all the points in the area, usually calculated internally. + points: Var[List[Dict[str, Any]]] + + # The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order. + stack_id: Var[Union[str, int]] + + # Whether to connect a graph area across null points. Default: False + connect_nulls: Var[bool] # Valid children components _valid_children: List[str] = ["LabelList"] @@ -254,29 +380,44 @@ class Bar(Cartesian): alias = "RechartsBar" # The color of the line stroke. - stroke: Var[str] + stroke: Var[Union[str, Color]] # The width of the line stroke. stroke_width: Var[int] - # The width of the line stroke. - fill: Var[str] + # The width of the line stroke. Default: Color("accent", 9) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. + # If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. Default: False background: Var[bool] - # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. + # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False label: Var[bool] - # The stack id of bar, when two areas have the same value axis and same stackId, then the two areas area stacked in order. + # The stack id of bar, when two bars have the same value axis and same stack_id, then the two bars are stacked in order. stack_id: Var[str] - # Size of the bar + # The unit of data. This option will be used in tooltip. + unit: Var[Union[str, int]] + + # The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts. + min_point_size: Var[int] + + # The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively. + name: Var[Union[str, int]] + + # Size of the bar (if one bar_size is set then a bar_size must be set for all bars) bar_size: Var[int] # Max size of the bar max_bar_size: Var[int] + # If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0 + radius: Var[Union[int, List[int]]] + + # The active bar is shown when a user enters a bar chart and this chart has tooltip. If set to false, no active bar will be drawn. If set to true, active bar will be drawn with the props calculated internally. If passed an object, active bar will be drawn, and the internally calculated props will be merged with the key value pairs of the passed object. + # active_bar: Var[Union[bool, Dict[str, Any]]] + # Valid children components _valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"] @@ -291,32 +432,51 @@ class Line(Cartesian): # The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area. type_: Var[LiteralAreaType] - # The color of the line stroke. - stroke: Var[str] + # The color of the line stroke. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # The width of the line stroke. - stoke_width: Var[int] + # The width of the line stroke. Default: 1 + stroke_width: Var[int] - # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - dot: Var[bool] + # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)} + dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create( + { + "stroke": Color("accent", 10), + "fill": Color("accent", 4), + } + ) - # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - active_dot: Var[bool] + # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)} + active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create( + { + "stroke": Color("accent", 2), + "fill": Color("accent", 10), + } + ) - # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. + # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False label: Var[bool] - # Hides the line when true, useful when toggling visibility state via legend. + # Hides the line when true, useful when toggling visibility state via legend. Default: False hide: Var[bool] # Whether to connect a graph line across null points. connect_nulls: Var[bool] + # The unit of data. This option will be used in tooltip. + unit: Var[Union[str, int]] + + # The coordinates of all the points in the line, usually calculated internally. + points: Var[List[Dict[str, Any]]] + + # The pattern of dashes and gaps used to paint the line. + stroke_dasharray: Var[str] + # Valid children components _valid_children: List[str] = ["LabelList", "ErrorBar"] -class Scatter(Cartesian): +class Scatter(Recharts): """A Scatter component in Recharts.""" tag = "Scatter" @@ -326,29 +486,71 @@ class Scatter(Cartesian): # The source data, in which each element is an object. data: Var[List[Dict[str, Any]]] - # The id of z-axis which is corresponding to the data. - z_axis_id: Var[str] + # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle" + legend_type: Var[LiteralLegendType] - # If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. + # The id of x-axis which is corresponding to the data. Default: 0 + x_axis_id: Var[Union[str, int]] + + # The id of y-axis which is corresponding to the data. Default: 0 + y_axis_id: Var[Union[str, int]] + + # The id of z-axis which is corresponding to the data. Default: 0 + z_axis_id: Var[Union[str, int]] + + # If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. Default: False line: Var[bool] - # If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' + # If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'. Default: "circle" shape: Var[LiteralShape] - # If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting' + # If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'. Default: "joint" line_type: Var[LiteralLineType] - # The fill - fill: Var[str] - - # the name - name: Var[Union[str, int]] + # The fill color of the scatter. Default: rx.color("accent", 9) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) # Valid children components. _valid_children: List[str] = ["LabelList", "ErrorBar"] + # If set false, animation of bar will be disabled. Default: True in CSR, False in SSR + is_animation_active: Var[bool] -class Funnel(Cartesian): + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_begin: Var[int] + + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_duration: Var[int] + + # The type of easing function. Default: "ease" + animation_easing: Var[LiteralAnimationEasing] + + # The customized event handler of click on the component in this group + on_click: EventHandler[empty_event] + + # The customized event handler of mousedown on the component in this group + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the component in this group + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the component in this group + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseover on the component in this group + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the component in this group + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the component in this group + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the component in this group + on_mouse_leave: EventHandler[empty_event] + + +class Funnel(Recharts): """A Funnel component in Recharts.""" tag = "Funnel" @@ -358,18 +560,66 @@ class Funnel(Cartesian): # The source data, in which each element is an object. data: Var[List[Dict[str, Any]]] - # Specifies when the animation should begin, the unit of this option is ms. + # The key or getter of a group of data which should be unique in a FunnelChart. + data_key: Var[Union[str, int]] + + # The key of each sector's name. Default: "name" + name_key: Var[str] + + # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line" + legend_type: Var[LiteralLegendType] + + # If set false, animation of line will be disabled. Default: True + is_animation_active: Var[bool] + + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 animation_begin: Var[int] - # Specifies the duration of animation, the unit of this option is ms. + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 animation_duration: Var[int] - # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease" animation_easing: Var[LiteralAnimationEasing] + # Stroke color. Default: rx.color("gray", 3) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3)) + + # The coordinates of all the trapezoids in the funnel, usually calculated internally. + trapezoids: Var[List[Dict[str, Any]]] + # Valid children components _valid_children: List[str] = ["LabelList", "Cell"] + # The customized event handler of animation start + on_animation_start: EventHandler[empty_event] + + # The customized event handler of animation end + on_animation_end: EventHandler[empty_event] + + # The customized event handler of click on the component in this group + on_click: EventHandler[empty_event] + + # The customized event handler of mousedown on the component in this group + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the component in this group + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the component in this group + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseover on the component in this group + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the component in this group + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the component in this group + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the component in this group + on_mouse_leave: EventHandler[empty_event] + class ErrorBar(Recharts): """An ErrorBar component in Recharts.""" @@ -378,41 +628,38 @@ class ErrorBar(Recharts): alias = "RechartsErrorBar" - # The direction of error bar. 'x' | 'y' | 'both' + # Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction. direction: Var[LiteralDirection] # The key of a group of data which should be unique in an area chart. data_key: Var[Union[str, int]] - # The width of the error bar ends. + # The width of the error bar ends. Default: 5 width: Var[int] - # The stroke color of error bar. - stroke: Var[str] + # The stroke color of error bar. Default: rx.color("gray", 8) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 8)) - # The stroke width of error bar. - stroke_width: Var[int] + # The stroke width of error bar. Default: 1.5 + stroke_width: Var[Union[int, float]] class Reference(Recharts): """A base class for reference components in Reference.""" - # The id of x-axis which is corresponding to the data. + # The id of x-axis which is corresponding to the data. Default: 0 x_axis_id: Var[Union[str, int]] - # The id of y-axis which is corresponding to the data. + # The id of y-axis which is corresponding to the data. Default: 0 y_axis_id: Var[Union[str, int]] - # If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. - x: Var[str] - - # If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. - y: Var[str] - - # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. + # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" if_overflow: Var[LiteralIfOverflow] - # If set true, the line will be rendered in front of bars in BarChart, etc. + # If set a string or a number, default label will be drawn, and the option is content. + label: Var[Union[str, int]] + + # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False is_front: Var[bool] @@ -423,12 +670,24 @@ class ReferenceLine(Reference): alias = "RechartsReferenceLine" - # The width of the stroke. - stroke_width: Var[int] + # If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. + x: Var[Union[str, int]] + + # If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. + y: Var[Union[str, int]] + + # The color of the reference line. + stroke: Var[Union[str, Color]] + + # The width of the stroke. Default: 1 + stroke_width: Var[Union[str, int]] # Valid children components _valid_children: List[str] = ["Label"] + # Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine. + segment: List[Any] = [] + class ReferenceDot(Reference): """A ReferenceDot component in Recharts.""" @@ -437,23 +696,47 @@ class ReferenceDot(Reference): alias = "RechartsReferenceDot" + # If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. + x: Var[Union[str, int]] + + # If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. + y: Var[Union[str, int]] + + # The radius of dot. + r: Var[int] + + # The color of the area fill. + fill: Var[Union[str, Color]] + + # The color of the line stroke. + stroke: Var[Union[str, Color]] + # Valid children components _valid_children: List[str] = ["Label"] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # The customized event handler of click on the component in this chart + on_click: EventHandler[empty_event] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # The customized event handler of mousedown on the component in this chart + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the component in this chart + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mouseover on the component in this chart + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the component in this chart + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the component in this chart + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mousemove on the component in this chart + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseleave on the component in this chart + on_mouse_leave: EventHandler[empty_event] class ReferenceArea(Recharts): @@ -464,10 +747,10 @@ class ReferenceArea(Recharts): alias = "RechartsReferenceArea" # Stroke color - stroke: Var[str] + stroke: Var[Union[str, Color]] # Fill color - fill: Var[str] + fill: Var[Union[str, Color]] # The opacity of area. fill_opacity: Var[float] @@ -490,10 +773,10 @@ class ReferenceArea(Recharts): # A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis. y2: Var[Union[str, int]] - # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. + # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" if_overflow: Var[LiteralIfOverflow] - # If set true, the line will be rendered in front of bars in BarChart, etc. + # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False is_front: Var[bool] # Valid children components @@ -503,16 +786,16 @@ class ReferenceArea(Recharts): class Grid(Recharts): """A base class for grid components in Recharts.""" - # The x-coordinate of grid. + # The x-coordinate of grid. Default: 0 x: Var[int] - # The y-coordinate of grid. + # The y-coordinate of grid. Default: 0 y: Var[int] - # The width of grid. + # The width of grid. Default: 0 width: Var[int] - # The height of grid. + # The height of grid. Default: 0 height: Var[int] @@ -523,21 +806,30 @@ class CartesianGrid(Grid): alias = "RechartsCartesianGrid" - # The horizontal line configuration. - horizontal: Var[Dict[str, Any]] + # The horizontal line configuration. Default: True + horizontal: Var[bool] - # The vertical line configuration. - vertical: Var[Dict[str, Any]] + # The vertical line configuration. Default: True + vertical: Var[bool] + + # The x-coordinates in pixel values of all vertical lines. Default: [] + vertical_points: Var[List[Union[str, int]]] + + # The x-coordinates in pixel values of all vertical lines. Default: [] + horizontal_points: Var[List[Union[str, int]]] # The background of grid. - fill: Var[str] + fill: Var[Union[str, Color]] - # The opacity of the background used to fill the space between grid lines + # The opacity of the background used to fill the space between grid lines. fill_opacity: Var[float] - # The pattern of dashes and gaps used to paint the lines of the grid + # The pattern of dashes and gaps used to paint the lines of the grid. stroke_dasharray: Var[str] + # the stroke color of grid. Default: rx.color("gray", 7) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 7)) + class CartesianAxis(Grid): """A CartesianAxis component in Recharts.""" @@ -546,29 +838,49 @@ class CartesianAxis(Grid): alias = "RechartsCartesianAxis" - # The orientation of axis 'top' | 'bottom' | 'left' | 'right' + # The orientation of axis 'top' | 'bottom' | 'left' | 'right'. Default: "bottom" orientation: Var[LiteralOrientationTopBottomLeftRight] - # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. + # The box of viewing area. Default: {"x": 0, "y": 0, "width": 0, "height": 0} + view_box: Var[Dict[str, Any]] + + # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True axis_line: Var[bool] - # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. + # If set false, no ticks will be drawn. + tick: Var[bool] + + # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True tick_line: Var[bool] - # The length of tick line. + # The length of tick line. Default: 6 tick_size: Var[int] - # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. + # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" interval: Var[LiteralInterval] - # If set false, no ticks will be drawn. - ticks: Var[bool] - # If set a string or a number, default label will be drawn, and the option is content. - label: Var[str] + label: Var[Union[str, int]] - # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. + # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: Var[bool] # The margin between tick line and tick. tick_margin: Var[int] + + +area = Area.create +bar = Bar.create +line = Line.create +scatter = Scatter.create +x_axis = XAxis.create +y_axis = YAxis.create +z_axis = ZAxis.create +brush = Brush.create +cartesian_axis = CartesianAxis.create +cartesian_grid = CartesianGrid.create +reference_line = ReferenceLine.create +reference_dot = ReferenceDot.create +reference_area = ReferenceArea.create +error_bar = ErrorBar.create +funnel = Funnel.create diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi index a12994d9e..983de30e3 100644 --- a/reflex/components/recharts/cartesian.pyi +++ b/reflex/components/recharts/cartesian.pyi @@ -1,139 +1,180 @@ """Stub file for reflex/components/recharts/cartesian.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.constants.colors import Color +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Union -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.vars.base import Var + from .recharts import ( - LiteralAnimationEasing, - LiteralAreaType, - LiteralDirection, - LiteralIfOverflow, - LiteralInterval, - LiteralLayout, - LiteralLineType, - LiteralOrientationTopBottom, - LiteralOrientationTopBottomLeftRight, - LiteralPolarRadiusType, - LiteralScale, - LiteralShape, Recharts, ) class Axis(Recharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, hide: Optional[Union[Var[bool], bool]] = None, - orientation: Optional[ - Union[Var[Literal["top", "bottom"]], Literal["top", "bottom"]] - ] = 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, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, - tick_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, + label: Optional[ + 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[str, int]], Union[str, int]]] = None, - name: Optional[Union[Var[Union[str, int]], Union[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[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[Color, Var[Union[Color, str]], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Axis": """Create the component. Args: *children: The children of the component. - data_key: The key of a group of data which should be unique in an area chart. - hide: If set true, the axis do not display in the chart. - orientation: The orientation of axis 'top' | 'bottom' + data_key: The key of data displayed in the axis. + hide: If set true, the axis do not display in the chart. Default: False + width: The width of axis which is usually calculated internally. + height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. - tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. - mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. - reversed: Reverse the ticks or not. - scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False + label: The label of axis, which appears next to the axis. + scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. + ticks: Set the values of axis ticks manually. + tick: If set false, no ticks will be drawn. + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" + on_click: The customized event handler of click on the ticks of this axis + on_mouse_down: The customized event handler of mousedown on the ticks of this axis + on_mouse_up: The customized event handler of mouseup on the ticks of this axis + on_mouse_move: The customized event handler of mousemove on the ticks of this axis + on_mouse_out: The customized event handler of mouseout on the ticks of this axis + on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis + on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -153,107 +194,173 @@ class XAxis(Axis): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - hide: Optional[Union[Var[bool], bool]] = None, 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]], int, str]] = None, + include_hidden: Optional[Union[Var[bool], bool]] = None, + angle: Optional[Union[Var[int], int]] = None, + padding: Optional[Union[Dict[str, int], Var[Dict[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]], 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, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, - tick_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, + label: Optional[ + 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[str, int]], Union[str, int]]] = None, - name: Optional[Union[Var[Union[str, int]], Union[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[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[Color, Var[Union[Color, str]], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "XAxis": """Create the component. Args: *children: The children of the component. - data_key: The key of a group of data which should be unique in an area chart. - hide: If set true, the axis do not display in the chart. - orientation: The orientation of axis 'top' | 'bottom' + orientation: The orientation of axis 'top' | 'bottom'. Default: "bottom" + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + include_hidden: Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False + angle: The angle of axis ticks. Default: 0 + padding: Specify the padding of x-axis. Default: {"left": 0, "right": 0} + data_key: The key of data displayed in the axis. + hide: If set true, the axis do not display in the chart. Default: False + width: The width of axis which is usually calculated internally. + height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. - tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. - mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. - reversed: Reverse the ticks or not. - scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False + label: The label of axis, which appears next to the axis. + scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. + ticks: Set the values of axis ticks manually. + tick: If set false, no ticks will be drawn. + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" + on_click: The customized event handler of click on the ticks of this axis + on_mouse_down: The customized event handler of mousedown on the ticks of this axis + on_mouse_up: The customized event handler of mouseup on the ticks of this axis + on_mouse_move: The customized event handler of mousemove on the ticks of this axis + on_mouse_out: The customized event handler of mouseout on the ticks of this axis + on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis + on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -273,107 +380,169 @@ class YAxis(Axis): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - hide: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ - Union[Var[Literal["top", "bottom"]], Literal["top", "bottom"]] + Union[Literal["left", "right"], Var[Literal["left", "right"]]] ] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + padding: Optional[Union[Dict[str, int], Var[Dict[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]], 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, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, - tick_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, + label: Optional[ + 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[str, int]], Union[str, int]]] = None, - name: Optional[Union[Var[Union[str, int]], Union[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[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[Color, Var[Union[Color, str]], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "YAxis": """Create the component. Args: *children: The children of the component. - data_key: The key of a group of data which should be unique in an area chart. - hide: If set true, the axis do not display in the chart. - orientation: The orientation of axis 'top' | 'bottom' + orientation: The orientation of axis 'left' | 'right'. Default: "left" + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + padding: Specify the padding of y-axis. Default: {"top": 0, "bottom": 0} + data_key: The key of data displayed in the axis. + hide: If set true, the axis do not display in the chart. Default: False + width: The width of axis which is usually calculated internally. + height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. - tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. - mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. - reversed: Reverse the ticks or not. - scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False + label: The label of axis, which appears next to the axis. + scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. + ticks: Set the values of axis ticks manually. + tick: If set false, no ticks will be drawn. + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" + on_click: The customized event handler of click on the ticks of this axis + on_mouse_down: The customized event handler of mousedown on the ticks of this axis + on_mouse_up: The customized event handler of mouseup on the ticks of this axis + on_mouse_move: The customized event handler of mousemove on the ticks of this axis + on_mouse_out: The customized event handler of mouseout on the ticks of this axis + on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis + on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -393,48 +562,49 @@ class ZAxis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - range: Optional[Union[Var[List[int]], List[int]]] = None, - unit: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - name: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + z_axis_id: 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, @@ -443,62 +613,33 @@ class ZAxis(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ZAxis": """Create the component. Args: *children: The children of the component. data_key: The key of data displayed in the axis. - range: The range of axis. + z_axis_id: The unique id of z-axis. Default: 0 + range: The range of axis. Default: [10, 10] unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. - scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. + scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. Default: "auto" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -519,13 +660,14 @@ class Brush(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[str], str]] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[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, @@ -536,26 +678,25 @@ class Brush(Recharts): class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_change: Optional[EventType[[]]] = None, + **props, ) -> "Brush": """Create the component. Args: *children: The children of the component. - stroke: Stroke color + stroke: The stroke color of brush + fill: The fill color of brush data_key: The key of data displayed in the axis. - x: The x-coordinate of brush. - y: The y-coordinate of brush. - width: The width of brush. - height: The height of brush. - data: The data domain of brush, [min, max]. - traveller_width: The width of each traveller. - gap: The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time - start_index: The default start index of brush. If the option is not set, the start index will be 0. - end_index: The default end index of brush. If the option is not set, the end index will be 1. + x: The x-coordinate of brush. Default: 0 + y: The y-coordinate of brush. Default: 0 + width: The width of brush. Default: 0 + height: The height of brush. Default: 40 + data: The original data of a LineChart, a BarChart or an AreaChart. + traveller_width: The width of each traveller. Default: 5 + gap: The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time. Default: 1 + start_index: The default start index of brush. If the option is not set, the start index will be 0. Default: 0 + end_index: The default end index of brush. If the option is not set, the end index will be calculated by the length of data. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -570,7 +711,6 @@ class Brush(Recharts): ... class Cartesian(Recharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore @@ -578,38 +718,80 @@ 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[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[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[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = 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[ + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], + ] + ] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Cartesian": """Create the component. @@ -617,9 +799,26 @@ class Cartesian(Recharts): *children: The children of the component. layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional + is_animation_active: If set false, animation of bar will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + unit: The unit of data. This option will be used in tooltip. + name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively. + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -638,105 +837,176 @@ class Area(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[str], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[str], str]] = 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", ] ], + ] + ] = None, + dot: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + active_dot: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + label: Optional[Union[Var[bool], bool]] = None, + base_line: Optional[ + Union[List[Dict[str, Any]], Var[Union[List[Dict[str, Any]], str]], str] + ] = None, + points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + stack_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + connect_nulls: Optional[Union[Var[bool], bool]] = None, + layout: Optional[ + Union[ + Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], + ] + ] = 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[ Literal[ - "basis", - "basisClosed", - "basisOpen", - "bumpX", - "bumpY", - "bump", - "linear", - "linearClosed", - "natural", - "monotoneX", - "monotoneY", - "monotone", - "step", - "stepBefore", - "stepAfter", + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, - dot: Optional[Union[Var[bool], bool]] = None, - active_dot: Optional[Union[Var[bool], bool]] = None, - label: Optional[Union[Var[bool], bool]] = None, - stack_id: Optional[Union[Var[str], str]] = None, - layout: Optional[ + 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["horizontal", "vertical"]], - Literal["horizontal", "vertical"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Area": """Create the component. Args: *children: The children of the component. - stroke: The color of the line stroke. - stroke_width: The width of the line stroke. - fill: The color of the area fill. - type_: The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' | - dot: If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. - active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. - stack_id: The stack id of area, when two areas have the same value axis and same stackId, then the two areas area stacked in order. + stroke: The color of the line stroke. Default: rx.color("accent", 9) + stroke_width: The width of the line stroke. Default: 1 + fill: The color of the area fill. Default: rx.color("accent", 5) + type_: The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter'. Default: "monotone" + dot: If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False + active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)} + label: If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False + base_line: The value which can describle the line, usually calculated internally. + points: The coordinates of all the points in the area, usually calculated internally. + stack_id: The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order. + connect_nulls: Whether to connect a graph area across null points. Default: False layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional + is_animation_active: If set false, animation of bar will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + unit: The unit of data. This option will be used in tooltip. + name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively. + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -755,48 +1025,92 @@ class Bar(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[str], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[str], str]] = 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]], int, str]] = None, + min_point_size: Optional[Union[Var[int], 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, + radius: Optional[Union[List[int], Var[Union[List[int], int]], int]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], + ] + ] = 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[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = 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[ + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Bar": """Create the component. @@ -804,17 +1118,36 @@ class Bar(Cartesian): *children: The children of the component. stroke: The color of the line stroke. stroke_width: The width of the line stroke. - fill: The width of the line stroke. - background: If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. - label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. - stack_id: The stack id of bar, when two areas have the same value axis and same stackId, then the two areas area stacked in order. - bar_size: Size of the bar + fill: The width of the line stroke. Default: Color("accent", 9) + background: If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. Default: False + label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False + stack_id: The stack id of bar, when two bars have the same value axis and same stack_id, then the two bars are stacked in order. + unit: The unit of data. This option will be used in tooltip. + min_point_size: The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts. + name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively. + bar_size: Size of the bar (if one bar_size is set then a bar_size must be set for all bars) max_bar_size: Max size of the bar + radius: If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0 layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional + is_animation_active: If set false, animation of bar will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -835,103 +1168,170 @@ 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[str], str]] = None, - stoke_width: Optional[Union[Var[int], int]] = None, - dot: Optional[Union[Var[bool], bool]] = None, - active_dot: Optional[Union[Var[bool], bool]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke_width: Optional[Union[Var[int], int]] = None, + dot: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + active_dot: Optional[ + 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]], int, str]] = None, + points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + stroke_dasharray: Optional[Union[Var[str], str]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[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[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = 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[ + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], + ] + ] = None, + name: Optional[Union[Var[Union[int, str]], int, 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Line": """Create the component. Args: *children: The children of the component. type_: The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area. - stroke: The color of the line stroke. - stoke_width: The width of the line stroke. - dot: The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. - label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. - hide: Hides the line when true, useful when toggling visibility state via legend. + stroke: The color of the line stroke. Default: rx.color("accent", 9) + stroke_width: The width of the line stroke. Default: 1 + dot: The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)} + active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)} + label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False + hide: Hides the line when true, useful when toggling visibility state via legend. Default: False connect_nulls: Whether to connect a graph line across null points. + unit: The unit of data. This option will be used in tooltip. + points: The coordinates of all the points in the line, usually calculated internally. + stroke_dasharray: The pattern of dashes and gaps used to paint the line. layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional + is_animation_active: If set false, animation of bar will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively. + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -944,89 +1344,129 @@ class Line(Cartesian): """ ... -class Scatter(Cartesian): +class Scatter(Recharts): @overload @classmethod def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - z_axis_id: Optional[Union[Var[str], str]] = None, - line: Optional[Union[Var[bool], bool]] = None, - shape: Optional[ + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + legend_type: Optional[ Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], Var[ Literal[ - "square", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", ] ], + ] + ] = 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[Union[int, str]], int, str]] = None, + line: Optional[Union[Var[bool], bool]] = None, + shape: Optional[ + Union[ Literal[ - "square", "circle", "cross", "diamond", "star", "triangle", "wye" + "circle", "cross", "diamond", "square", "star", "triangle", "wye" + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "square", + "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[str], str]] = None, - name: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ + fill: Optional[Union[Color, Var[Union[Color, str]], 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["horizontal", "vertical"]], - Literal["horizontal", "vertical"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Scatter": """Create the component. Args: *children: The children of the component. data: The source data, in which each element is an object. - z_axis_id: The id of z-axis which is corresponding to the data. - line: If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. - shape: If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' - line_type: If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting' - fill: The fill - name: the name - layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' - data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle" + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + z_axis_id: The id of z-axis which is corresponding to the data. Default: 0 + line: If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. Default: False + shape: If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'. Default: "circle" + line_type: If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'. Default: "joint" + fill: The fill color of the scatter. Default: rx.color("accent", 9) + is_animation_active: If set false, animation of bar will be disabled. Default: True in CSR, False in SSR + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -1039,69 +1479,110 @@ class Scatter(Cartesian): """ ... -class Funnel(Cartesian): +class Funnel(Recharts): @overload @classmethod 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, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + name_key: Optional[Union[Var[str], str]] = None, + legend_type: Optional[ + Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = 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, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + trapezoids: Optional[ + Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Funnel": """Create the component. Args: *children: The children of the component. data: The source data, in which each element is an object. - animation_begin: Specifies when the animation should begin, the unit of this option is ms. - animation_duration: Specifies the duration of animation, the unit of this option is ms. - animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' - layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' - data_key: The key of a group of data which should be unique in an area chart. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - style: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional legend_type: Var[LiteralLegendType] The style of the component. + data_key: The key or getter of a group of data which should be unique in a FunnelChart. + name_key: The key of each sector's name. Default: "name" + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line" + is_animation_active: If set false, animation of line will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease" + stroke: Stroke color. Default: rx.color("gray", 3) + trapezoids: The coordinates of all the trapezoids in the funnel, usually calculated internally. + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end + on_click: The customized event handler of click on the component in this group + on_mouse_down: The customized event handler of mousedown on the component in this group + on_mouse_up: The customized event handler of mouseup on the component in this group + on_mouse_move: The customized event handler of mousemove on the component in this group + on_mouse_over: The customized event handler of mouseover on the component in this group + on_mouse_out: The customized event handler of mouseout on the component in this group + on_mouse_enter: The customized event handler of mouseenter on the component in this group + on_mouse_leave: The customized event handler of mouseleave on the component in this group + 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. @@ -1120,75 +1601,43 @@ class ErrorBar(Recharts): def create( # type: ignore cls, *children, - direction: Optional[ - Union[Var[Literal["x", "y", "both"]], Literal["x", "y", "both"]] - ] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, + direction: Optional[Union[Literal["x", "y"], Var[Literal["x", "y"]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, width: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[str], str]] = None, - stroke_width: Optional[Union[Var[int], int]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke_width: Optional[Union[Var[Union[float, int]], float, int]] = 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ErrorBar": """Create the component. Args: *children: The children of the component. - direction: The direction of error bar. 'x' | 'y' | 'both' + direction: Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction. data_key: The key of a group of data which should be unique in an area chart. - width: The width of the error bar ends. - stroke: The stroke color of error bar. - stroke_width: The stroke width of error bar. + width: The width of the error bar ends. Default: 5 + stroke: The stroke color of error bar. Default: rx.color("gray", 8) + stroke_width: The stroke width of error bar. Default: 1.5 style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1208,16 +1657,15 @@ class Reference(Recharts): def create( # type: ignore cls, *children, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x: Optional[Union[Var[str], str]] = None, - y: Optional[Union[Var[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]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1225,63 +1673,32 @@ class Reference(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Reference": """Create the component. Args: *children: The children of the component. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. - x: If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. - y: If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. - if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. - is_front: If set true, the line will be rendered in front of bars in BarChart, etc. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" + label: If set a string or a number, default label will be drawn, and the option is content. + is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1301,17 +1718,20 @@ class ReferenceLine(Reference): def create( # type: ignore cls, *children, - stroke_width: Optional[Union[Var[int], int]] = None, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x: Optional[Union[Var[str], str]] = None, - y: Optional[Union[Var[str], str]] = 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]], 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]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1319,64 +1739,37 @@ class ReferenceLine(Reference): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ReferenceLine": """Create the component. Args: *children: The children of the component. - stroke_width: The width of the stroke. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. x: If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. y: If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. - if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. - is_front: If set true, the line will be rendered in front of bars in BarChart, etc. + stroke: The color of the reference line. + stroke_width: The width of the stroke. Default: 1 + segment: Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine. + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" + label: If set a string or a number, default label will be drawn, and the option is content. + is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1391,22 +1784,25 @@ class ReferenceLine(Reference): ... class ReferenceDot(Reference): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - x_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x: Optional[Union[Var[str], str]] = None, - y: Optional[Union[Var[str], str]] = 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[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]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1414,36 +1810,45 @@ class ReferenceDot(Reference): class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ReferenceDot": """Create the component. Args: *children: The children of the component. - x_axis_id: The id of x-axis which is corresponding to the data. - y_axis_id: The id of y-axis which is corresponding to the data. x: If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn. y: If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn. - if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. - is_front: If set true, the line will be rendered in front of bars in BarChart, etc. + r: The radius of dot. + fill: The color of the area fill. + stroke: The color of the line stroke. + on_click: The customized event handler of click on the component in this chart + on_mouse_down: The customized event handler of mousedown on the component in this chart + on_mouse_up: The customized event handler of mouseup on the component in this chart + on_mouse_over: The customized event handler of mouseover on the component in this chart + on_mouse_out: The customized event handler of mouseout on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart + x_axis_id: The id of x-axis which is corresponding to the data. Default: 0 + y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 + if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" + label: If set a string or a number, default label will be drawn, and the option is content. + is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1463,19 +1868,19 @@ class ReferenceArea(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[str], str]] = None, - fill: Optional[Union[Var[str], str]] = 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[str, int]], Union[str, int]]] = None, - y_axis_id: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x1: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - x2: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y1: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - y2: Optional[Union[Var[Union[str, int]], Union[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, @@ -1485,52 +1890,22 @@ class ReferenceArea(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ReferenceArea": """Create the component. @@ -1545,8 +1920,8 @@ class ReferenceArea(Recharts): x2: A boundary value of the area. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys. If one of x1 or x2 is invalidate, the area will cover along x-axis. y1: A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis. y2: A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis. - if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. - is_front: If set true, the line will be rendered in front of bars in BarChart, etc. + if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard" + is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1576,61 +1951,31 @@ class Grid(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Grid": """Create the component. Args: *children: The children of the component. - x: The x-coordinate of grid. - y: The y-coordinate of grid. - width: The width of grid. - height: The height of grid. + x: The x-coordinate of grid. Default: 0 + y: The y-coordinate of grid. Default: 0 + width: The width of grid. Default: 0 + height: The height of grid. Default: 0 style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1650,11 +1995,18 @@ class CartesianGrid(Grid): def create( # type: ignore cls, *children, - horizontal: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - vertical: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - fill: Optional[Union[Var[str], str]] = None, + horizontal: Optional[Union[Var[bool], bool]] = None, + vertical: Optional[Union[Var[bool], bool]] = None, + vertical_points: Optional[ + Union[List[Union[int, str]], Var[List[Union[int, str]]]] + ] = None, + horizontal_points: Optional[ + Union[List[Union[int, str]], Var[List[Union[int, str]]]] + ] = 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[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, @@ -1665,66 +2017,39 @@ class CartesianGrid(Grid): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CartesianGrid": """Create the component. Args: *children: The children of the component. - horizontal: The horizontal line configuration. - vertical: The vertical line configuration. + horizontal: The horizontal line configuration. Default: True + vertical: The vertical line configuration. Default: True + vertical_points: The x-coordinates in pixel values of all vertical lines. Default: [] + horizontal_points: The x-coordinates in pixel values of all vertical lines. Default: [] fill: The background of grid. - fill_opacity: The opacity of the background used to fill the space between grid lines - stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid - x: The x-coordinate of grid. - y: The y-coordinate of grid. - width: The width of grid. - height: The height of grid. + fill_opacity: The opacity of the background used to fill the space between grid lines. + stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid. + stroke: the stroke color of grid. Default: rx.color("gray", 7) + x: The x-coordinate of grid. Default: 0 + y: The y-coordinate of grid. Default: 0 + width: The width of grid. Default: 0 + height: The height of grid. Default: 0 style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1746,21 +2071,22 @@ 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, + view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, + tick: Optional[Union[Var[bool], bool]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, 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, - label: Optional[Union[Var[str], str]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, mirror: Optional[Union[Var[bool], bool]] = None, tick_margin: Optional[Union[Var[int], int]] = None, x: Optional[Union[Var[int], int]] = None, @@ -1773,70 +2099,41 @@ class CartesianAxis(Grid): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "CartesianAxis": """Create the component. Args: *children: The children of the component. - orientation: The orientation of axis 'top' | 'bottom' | 'left' | 'right' - axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. - tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. - tick_size: The length of tick line. - interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. - ticks: If set false, no ticks will be drawn. + orientation: The orientation of axis 'top' | 'bottom' | 'left' | 'right'. Default: "bottom" + view_box: The box of viewing area. Default: {"x": 0, "y": 0, "width": 0, "height": 0} + axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True + tick: If set false, no ticks will be drawn. + tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True + tick_size: The length of tick line. Default: 6 + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" label: If set a string or a number, default label will be drawn, and the option is content. - mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False tick_margin: The margin between tick line and tick. - x: The x-coordinate of grid. - y: The y-coordinate of grid. - width: The width of grid. - height: The height of grid. + x: The x-coordinate of grid. Default: 0 + y: The y-coordinate of grid. Default: 0 + width: The width of grid. Default: 0 + height: The height of grid. Default: 0 style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -1849,3 +2146,19 @@ class CartesianAxis(Grid): The component. """ ... + +area = Area.create +bar = Bar.create +line = Line.create +scatter = Scatter.create +x_axis = XAxis.create +y_axis = YAxis.create +z_axis = ZAxis.create +brush = Brush.create +cartesian_axis = CartesianAxis.create +cartesian_grid = CartesianGrid.create +reference_line = ReferenceLine.create +reference_dot = ReferenceDot.create +reference_area = ReferenceArea.create +error_bar = ErrorBar.create +funnel = Funnel.create diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py index 5a29cc2aa..d7e07b2d8 100644 --- a/reflex/components/recharts/charts.py +++ b/reflex/components/recharts/charts.py @@ -1,4 +1,5 @@ """A module that defines the chart components in Recharts.""" + from __future__ import annotations from typing import Any, Dict, List, Union @@ -6,7 +7,9 @@ from typing import Any, Dict, List, Union from reflex.components.component import Component from reflex.components.recharts.general import ResponsiveContainer from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.constants.colors import Color +from reflex.event import EventHandler, empty_event +from reflex.vars.base import Var from .recharts import ( LiteralAnimationEasing, @@ -21,42 +24,23 @@ from .recharts import ( class ChartBase(RechartsCharts): """A component that wraps a Recharts charts.""" - # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] - - # If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_id: Var[str] - - # When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function - sync_method: Var[LiteralSyncMethod] - # The width of chart container. String or Integer width: Var[Union[str, int]] = "100%" # type: ignore # The height of chart container. height: Var[Union[str, int]] = "100%" # type: ignore - # The layout of area in the chart. 'horizontal' | 'vertical' - layout: Var[LiteralLayout] + # The customized event handler of click on the component in this chart + on_click: EventHandler[empty_event] - # The sizes of whitespace around the chart. - margin: Var[Dict[str, Any]] + # The customized event handler of mouseenter on the component in this chart + on_mouse_enter: EventHandler[empty_event] - # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' - stack_offset: Var[LiteralStackOffset] + # The customized event handler of mousemove on the component in this chart + on_mouse_move: EventHandler[empty_event] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # The customized event handler of mouseleave on the component in this chart + on_mouse_leave: EventHandler[empty_event] @staticmethod def _ensure_valid_dimension(name: str, value: Any) -> None: @@ -116,19 +100,38 @@ class ChartBase(RechartsCharts): ) -class AreaChart(ChartBase): +class CategoricalChartBase(ChartBase): + """A component that wraps a Categorical Recharts charts.""" + + # The source data, in which each element is an object. + data: Var[List[Dict[str, Any]]] + + # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + margin: Var[Dict[str, Any]] + + # If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. + sync_id: Var[str] + + # When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + sync_method: Var[LiteralSyncMethod] + + # The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" + layout: Var[LiteralLayout] + + # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + stack_offset: Var[LiteralStackOffset] + + +class AreaChart(CategoricalChartBase): """An Area chart component in Recharts.""" tag = "AreaChart" alias = "RechartsAreaChart" - # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto' + # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto" base_value: Var[Union[int, LiteralComposedChartBaseValue]] - # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. - stack_offset: Var[LiteralStackOffset] - # Valid children components _valid_children: List[str] = [ "XAxis", @@ -141,21 +144,22 @@ class AreaChart(ChartBase): "Legend", "GraphingTooltip", "Area", + "Defs", ] -class BarChart(ChartBase): +class BarChart(CategoricalChartBase): """A Bar chart component in Recharts.""" tag = "BarChart" alias = "RechartsBarChart" - # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number - bar_category_gap: Var[Union[str, int]] # type: ignore + # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" + bar_category_gap: Var[Union[str, int]] - # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number - bar_gap: Var[Union[str, int]] # type: ignore + # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4 + bar_gap: Var[Union[str, int]] # The width of all the bars in the chart. Number bar_size: Var[int] @@ -163,10 +167,10 @@ class BarChart(ChartBase): # The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart. max_bar_size: Var[int] - # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. + # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. Default: "none" stack_offset: Var[LiteralStackOffset] - # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) + # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) Default: False reverse_stack_order: Var[bool] # Valid children components @@ -184,7 +188,7 @@ class BarChart(ChartBase): ] -class LineChart(ChartBase): +class LineChart(CategoricalChartBase): """A Line chart component in Recharts.""" tag = "LineChart" @@ -206,26 +210,26 @@ class LineChart(ChartBase): ] -class ComposedChart(ChartBase): +class ComposedChart(CategoricalChartBase): """A Composed chart component in Recharts.""" tag = "ComposedChart" alias = "RechartsComposedChart" - # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto' + # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto" base_value: Var[Union[int, LiteralComposedChartBaseValue]] - # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number - bar_category_gap: Var[Union[str, int]] # type: ignore + # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" + bar_category_gap: Var[Union[str, int]] - # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number + # The gap between two bars in the same category. Default: 4 bar_gap: Var[int] - # The width of all the bars in the chart. Number + # The width or height of each bar. If the barSize is not specified, the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups. bar_size: Var[int] - # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) + # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position). Default: False reverse_stack_order: Var[bool] # Valid children components @@ -252,6 +256,9 @@ class PieChart(ChartBase): alias = "RechartsPieChart" + # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + margin: Var[Dict[str, Any]] + # Valid children components _valid_children: List[str] = [ "PolarAngleAxis", @@ -262,17 +269,17 @@ class PieChart(ChartBase): "Pie", ] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # The customized event handler of mousedown on the sectors in this group + on_mouse_down: EventHandler[empty_event] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # The customized event handler of mouseup on the sectors in this group + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mouseover on the sectors in this group + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the sectors in this group + on_mouse_out: EventHandler[empty_event] class RadarChart(ChartBase): @@ -282,22 +289,28 @@ class RadarChart(ChartBase): alias = "RechartsRadarChart" - # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage + # The source data, in which each element is an object. + data: Var[List[Dict[str, Any]]] + + # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. Default: {"top": 0, "right": 0, "left": 0, "bottom": 0} + margin: Var[Dict[str, Any]] + + # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%" cx: Var[Union[int, str]] - # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage + # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%" cy: Var[Union[int, str]] - # The angle of first radial direction line. + # The angle of first radial direction line. Default: 90 start_angle: Var[int] - # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. + # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: -270 end_angle: Var[int] - # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage + # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: 0 inner_radius: Var[Union[int, str]] - # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage + # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "80%" outer_radius: Var[Union[int, str]] # Valid children components @@ -317,10 +330,9 @@ class RadarChart(ChartBase): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, } @@ -331,28 +343,34 @@ class RadialBarChart(ChartBase): alias = "RechartsRadialBarChart" - # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage + # The source data which each element is an object. + data: Var[List[Dict[str, Any]]] + + # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "left": 5 "bottom": 5} + margin: Var[Dict[str, Any]] + + # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%" cx: Var[Union[int, str]] - # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage + # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%" cy: Var[Union[int, str]] - # The angle of first radial direction line. + # The angle of first radial direction line. Default: 0 start_angle: Var[int] - # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. + # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: 360 end_angle: Var[int] - # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage + # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "30%" inner_radius: Var[Union[int, str]] - # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage + # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "100%" outer_radius: Var[Union[int, str]] - # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number + # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" bar_category_gap: Var[Union[int, str]] - # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number + # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4 bar_gap: Var[str] # The size of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups. @@ -368,19 +386,6 @@ class RadialBarChart(ChartBase): "RadialBar", ] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } - class ScatterChart(ChartBase): """A Scatter chart component in Recharts.""" @@ -389,6 +394,9 @@ class ScatterChart(ChartBase): alias = "RechartsScatterChart" + # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} + margin: Var[Dict[str, Any]] + # Valid children components _valid_children: List[str] = [ "XAxis", @@ -411,65 +419,36 @@ class ScatterChart(ChartBase): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_MOUSE_DOWN: empty_event, + EventTriggers.ON_MOUSE_UP: empty_event, + EventTriggers.ON_MOUSE_MOVE: empty_event, + EventTriggers.ON_MOUSE_OVER: empty_event, + EventTriggers.ON_MOUSE_OUT: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, } -class FunnelChart(RechartsCharts): +class FunnelChart(ChartBase): """A Funnel chart component in Recharts.""" tag = "FunnelChart" alias = "RechartsFunnelChart" - # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] + # The layout of bars in the chart. Default: "centric" + layout: Var[str] - # If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_id: Var[str] - - # When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function - sync_method: Var[str] - - # The width of chart container. String or Integer - width: Var[Union[str, int]] = "100%" # type: ignore - - # The height of chart container. - height: Var[Union[str, int]] = "100%" # type: ignore - - # The layout of area in the chart. 'horizontal' | 'vertical' - layout: Var[LiteralLayout] - - # The sizes of whitespace around the chart. + # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} margin: Var[Dict[str, Any]] - # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' - stack_offset: Var[LiteralStackOffset] - - # The layout of bars in the chart. centeric - layout: Var[str] + # The stroke color of each bar. String | Object + stroke: Var[Union[str, Color]] # Valid children components _valid_children: List[str] = ["Legend", "GraphingTooltip", "Funnel"] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. - - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } - class Treemap(RechartsCharts): """A Treemap chart component in Recharts.""" @@ -478,33 +457,42 @@ class Treemap(RechartsCharts): alias = "RechartsTreemap" - # The width of chart container. String or Integer + # The width of chart container. String or Integer. Default: "100%" width: Var[Union[str, int]] = "100%" # type: ignore - # The height of chart container. + # The height of chart container. String or Integer. Default: "100%" height: Var[Union[str, int]] = "100%" # type: ignore # data of treemap. Array data: Var[List[Dict[str, Any]]] - # The key of a group of data which should be unique in a treemap. String | Number | Function + # The key of a group of data which should be unique in a treemap. String | Number. Default: "value" data_key: Var[Union[str, int]] + # The key of each sector's name. String. Default: "name" + name_key: Var[str] + # The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. Number aspect_ratio: Var[int] - # If set false, animation of area will be disabled. + # If set false, animation of area will be disabled. Default: True is_animation_active: Var[bool] - # Specifies when the animation should begin, the unit of this option is ms. + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 animation_begin: Var[int] - # Specifies the duration of animation, the unit of this option is ms. + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 animation_duration: Var[int] - # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" animation_easing: Var[LiteralAnimationEasing] + # The customized event handler of animation start + on_animation_start: EventHandler[empty_event] + + # The customized event handler of animation end + on_animation_end: EventHandler[empty_event] + @classmethod def create(cls, *children, **props) -> Component: """Create a chart component. @@ -521,3 +509,15 @@ class Treemap(RechartsCharts): width=props.pop("width", "100%"), height=props.pop("height", "100%"), ) + + +area_chart = AreaChart.create +bar_chart = BarChart.create +line_chart = LineChart.create +composed_chart = ComposedChart.create +pie_chart = PieChart.create +radar_chart = RadarChart.create +radial_bar_chart = RadialBarChart.create +scatter_chart = ScatterChart.create +funnel_chart = FunnelChart.create +treemap = Treemap.create diff --git a/reflex/components/recharts/charts.pyi b/reflex/components/recharts/charts.pyi index e8562ee4d..2c6d7fffa 100644 --- a/reflex/components/recharts/charts.pyi +++ b/reflex/components/recharts/charts.pyi @@ -1,85 +1,60 @@ """Stub file for reflex/components/recharts/charts.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.constants.colors import Color +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Union -from reflex.components.component import Component -from reflex.components.recharts.general import ResponsiveContainer -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.vars.base import Var + from .recharts import ( - LiteralAnimationEasing, - LiteralComposedChartBaseValue, - LiteralLayout, - LiteralStackOffset, - LiteralSyncMethod, RechartsCharts, ) class ChartBase(RechartsCharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ChartBase": """Create a chart component. Args: *children: The children of the chart component. - data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -93,7 +68,85 @@ class ChartBase(RechartsCharts): """ ... -class AreaChart(ChartBase): +class CategoricalChartBase(ChartBase): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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[Literal["index", "value"], Var[Literal["index", "value"]]] + ] = None, + layout: Optional[ + Union[ + Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], + ] + ] = None, + stack_offset: Optional[ + Union[ + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], + ] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "CategoricalChartBase": + """Create a chart component. + + Args: + *children: The children of the chart component. + data: The source data, in which each element is an object. + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. + sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" + stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + width: The width of chart container. String or Integer + height: The height of chart container. + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart + 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 properties of the chart component. + + Returns: + The chart component wrapped in a responsive container. + """ + ... + +class AreaChart(CategoricalChartBase): @overload @classmethod def create( # type: ignore @@ -101,63 +154,71 @@ class AreaChart(ChartBase): *children, base_value: Optional[ Union[ - Var[Union[int, Literal["dataMin", "dataMax", "auto"]]], - Union[int, Literal["dataMin", "dataMax", "auto"]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], + int, + ] + ] = 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[Literal["index", "value"], Var[Literal["index", "value"]]] + ] = None, + layout: Optional[ + Union[ + 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, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "AreaChart": """Create a chart component. Args: *children: The children of the chart component. - base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto' - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto" data: The source data, in which each element is an object. + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" + stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -171,74 +232,81 @@ class AreaChart(ChartBase): """ ... -class BarChart(ChartBase): +class BarChart(CategoricalChartBase): @overload @classmethod def create( # type: ignore cls, *children, - bar_category_gap: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - bar_gap: Optional[Union[Var[Union[str, int]], Union[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, + 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, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - margin: Optional[Union[Var[Dict[str, Any]], 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "BarChart": """Create a chart component. Args: *children: The children of the chart component. - bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number - bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number + bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" + bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4 bar_size: The width of all the bars in the chart. Number max_bar_size: The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart. stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' - reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) + reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) Default: False data: The source data, in which each element is an object. + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -252,64 +320,71 @@ class BarChart(ChartBase): """ ... -class LineChart(ChartBase): +class LineChart(CategoricalChartBase): @overload @classmethod 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, + 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, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = 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]], 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "LineChart": """Create a chart component. Args: *children: The children of the chart component. data: The source data, in which each element is an object. + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" + stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -323,7 +398,7 @@ class LineChart(ChartBase): """ ... -class ComposedChart(ChartBase): +class ComposedChart(CategoricalChartBase): @overload @classmethod def create( # type: ignore @@ -331,71 +406,79 @@ class ComposedChart(ChartBase): *children, base_value: Optional[ Union[ - Var[Union[int, Literal["dataMin", "dataMax", "auto"]]], - Union[int, Literal["dataMin", "dataMax", "auto"]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], + int, ] ] = None, - bar_category_gap: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, + bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_gap: Optional[Union[Var[int], int]] = 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, + 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, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = 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]], 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ComposedChart": """Create a chart component. Args: *children: The children of the chart component. - base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto' - bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number - bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number - bar_size: The width of all the bars in the chart. Number - reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) + base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto" + bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" + bar_gap: The gap between two bars in the same category. Default: 4 + bar_size: The width or height of each bar. If the barSize is not specified, the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups. + reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position). Default: False data: The source data, in which each element is an object. + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index" + layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal" + stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -410,61 +493,52 @@ class ComposedChart(ChartBase): ... class PieChart(ChartBase): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PieChart": """Create a chart component. Args: *children: The children of the chart component. - data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + on_mouse_down: The customized event handler of mousedown on the sectors in this group + on_mouse_up: The customized event handler of mouseup on the sectors in this group + on_mouse_over: The customized event handler of mouseover on the sectors in this group + on_mouse_out: The customized event handler of mouseout on the sectors in this group width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -485,70 +559,44 @@ class RadarChart(ChartBase): def create( # type: ignore cls, *children, - cx: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = 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]], Union[int, str]]] = None, - outer_radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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]], 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_click: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + **props, ) -> "RadarChart": """Create a chart component. Args: *children: The children of the chart component. - cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage - cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage - start_angle: The angle of first radial direction line. - end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. - inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage - outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. Default: {"top": 0, "right": 0, "left": 0, "bottom": 0} + cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%" + cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%" + start_angle: The angle of first radial direction line. Default: 90 + end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: -270 + inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: 0 + outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "80%" width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -563,82 +611,68 @@ class RadarChart(ChartBase): ... class RadialBarChart(ChartBase): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - cx: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = 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]], Union[int, str]]] = None, - outer_radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - bar_category_gap: Optional[Union[Var[Union[int, str]], Union[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, + 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, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RadialBarChart": """Create a chart component. Args: *children: The children of the chart component. - cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage - cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage - start_angle: The angle of first radial direction line. - end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. - inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage - outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage - bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number - bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number + data: The source data which each element is an object. + margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "left": 5 "bottom": 5} + cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%" + cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%" + start_angle: The angle of first radial direction line. Default: 0 + end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: 360 + inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "30%" + outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "100%" + bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%" + bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4 bar_size: The size of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups. - data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -659,64 +693,36 @@ class ScatterChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] - ] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_click: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + **props, ) -> "ScatterChart": """Create a chart component. Args: *children: The children of the chart component. - data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of area in the chart. 'horizontal' | 'vertical' - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -730,68 +736,63 @@ class ScatterChart(ChartBase): """ ... -class FunnelChart(RechartsCharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... +class FunnelChart(ChartBase): @overload @classmethod def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - sync_id: Optional[Union[Var[str], str]] = None, - sync_method: Optional[Union[Var[str], str]] = None, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, layout: Optional[Union[Var[str], str]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stack_offset: Optional[ - Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], - ] - ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "FunnelChart": - """Create a new memoization leaf component. + """Create a chart component. Args: - *children: The children of the component. - data: The source data, in which each element is an object. - sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush. - sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function + *children: The children of the chart component. + layout: The layout of bars in the chart. Default: "centric" + margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} + stroke: The stroke color of each bar. String | Object width: The width of chart container. String or Integer height: The height of chart container. - layout: The layout of bars in the chart. centeric - margin: The sizes of whitespace around the chart. - stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette' + on_click: The customized event handler of click on the component in this chart + on_mouse_enter: The customized event handler of mouseenter on the component in this chart + on_mouse_move: The customized event handler of mousemove on the component in this chart + on_mouse_leave: The customized event handler of mouseleave on the component in this chart 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 of the component. + **props: The properties of the chart component. Returns: - The memoization leaf + The chart component wrapped in a responsive container. """ ... @@ -801,18 +802,19 @@ class Treemap(RechartsCharts): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - height: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[str, int]], Union[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, + name_key: Optional[Union[Var[str], 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, @@ -821,66 +823,41 @@ class Treemap(RechartsCharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Treemap": """Create a chart component. Args: *children: The children of the chart component. - width: The width of chart container. String or Integer - height: The height of chart container. + width: The width of chart container. String or Integer. Default: "100%" + height: The height of chart container. String or Integer. Default: "100%" data: data of treemap. Array - data_key: The key of a group of data which should be unique in a treemap. String | Number | Function + data_key: The key of a group of data which should be unique in a treemap. String | Number. Default: "value" + name_key: The key of each sector's name. String. Default: "name" aspect_ratio: The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. Number - is_animation_active: If set false, animation of area will be disabled. - animation_begin: Specifies when the animation should begin, the unit of this option is ms. - animation_duration: Specifies the duration of animation, the unit of this option is ms. - animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' + is_animation_active: If set false, animation of area will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" + on_animation_start: The customized event handler of animation start + on_animation_end: The customized event handler of animation end style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -893,3 +870,14 @@ class Treemap(RechartsCharts): The Treemap component wrapped in a responsive container. """ ... + +area_chart = AreaChart.create +bar_chart = BarChart.create +line_chart = LineChart.create +composed_chart = ComposedChart.create +pie_chart = PieChart.create +radar_chart = RadarChart.create +radial_bar_chart = RadialBarChart.create +scatter_chart = ScatterChart.create +funnel_chart = FunnelChart.create +treemap = Treemap.create diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py index ad23204d6..641e1562a 100644 --- a/reflex/components/recharts/general.py +++ b/reflex/components/recharts/general.py @@ -1,13 +1,16 @@ """General components for Recharts.""" + from __future__ import annotations from typing import Any, Dict, List, Union from reflex.components.component import MemoizationLeaf -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.constants.colors import Color +from reflex.event import EventHandler, empty_event +from reflex.vars.base import LiteralVar, Var from .recharts import ( + LiteralAnimationEasing, LiteralIconType, LiteralLayout, LiteralLegendAlign, @@ -27,21 +30,24 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): # The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number aspect: Var[int] - # The width of chart container. Can be a number or string + # The width of chart container. Can be a number or string. Default: "100%" width: Var[Union[int, str]] - # The height of chart container. Number + # The height of chart container. Can be a number or string. Default: "100%" height: Var[Union[int, str]] - # The minimum width of chart container. + # The minimum width of chart container. Number min_width: Var[int] # The minimum height of chart container. Number min_height: Var[int] - # If specified a positive number, debounced function will be used to handle the resize event. + # If specified a positive number, debounced function will be used to handle the resize event. Default: 0 debounce: Var[int] + # If specified provides a callback providing the updated chart width and height values. + on_resize: EventHandler[empty_event] + # Valid children components _valid_children: List[str] = [ "AreaChart", @@ -53,6 +59,7 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): "ScatterChart", "Treemap", "ComposedChart", + "FunnelChart", ] @@ -69,21 +76,24 @@ class Legend(Recharts): # The height of legend container. Number height: Var[int] - # The layout of legend items. 'horizontal' | 'vertical' + # The layout of legend items. 'horizontal' | 'vertical'. Default: "horizontal" layout: Var[LiteralLayout] - # The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. + # The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. Default: "center" align: Var[LiteralLegendAlign] - # The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. + # The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. Default: "bottom" vertical_align: Var[LiteralVerticalAlign] - # The size of icon in each legend item. + # The size of icon in each legend item. Default: 14 icon_size: Var[int] # The type of icon in each legend item. 'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' icon_type: Var[LiteralIconType] + # The source data of the content to be displayed in the legend, usually calculated internally. Default: [] + payload: Var[List[Dict[str, Any]]] + # The width of chart container, usually calculated internally. chart_width: Var[int] @@ -93,20 +103,29 @@ class Legend(Recharts): # The margin of chart container, usually calculated internally. margin: Var[Dict[str, Any]] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # The customized event handler of click on the items in this group + on_click: EventHandler[empty_event] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # The customized event handler of mousedown on the items in this group + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the items in this group + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the items in this group + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseover on the items in this group + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the items in this group + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of mouseenter on the items in this group + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the items in this group + on_mouse_leave: EventHandler[empty_event] class GraphingTooltip(Recharts): @@ -126,11 +145,42 @@ class GraphingTooltip(Recharts): filter_null: Var[bool] # If set false, no cursor will be drawn when tooltip is active. - cursor: Var[bool] + cursor: Var[Union[Dict[str, Any], bool]] = LiteralVar.create( + { + "strokeWidth": 1, + "fill": Color("gray", 3), + } + ) # The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally. view_box: Var[Dict[str, Any]] + # The style of default tooltip content item which is a li element. DEFAULT: {} + item_style: Var[Dict[str, Any]] = LiteralVar.create( + { + "color": Color("gray", 12), + } + ) + + # The style of tooltip wrapper which is a dom element. DEFAULT: {} + wrapper_style: Var[Dict[str, Any]] + # The style of tooltip content which is a dom element. DEFAULT: {} + content_style: Var[Dict[str, Any]] = LiteralVar.create( + { + "background": Color("gray", 1), + "borderColor": Color("gray", 4), + "borderRadius": "8px", + } + ) + + # The style of default tooltip label which is a p element. DEFAULT: {} + label_style: Var[Dict[str, Any]] = LiteralVar.create({"color": Color("gray", 11)}) + + # This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false } + allow_escape_view_box: Var[Dict[str, bool]] = LiteralVar.create( + {"x": False, "y": False} + ) + # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. active: Var[bool] @@ -140,6 +190,15 @@ class GraphingTooltip(Recharts): # The coordinate of tooltip which is usually calculated internally. coordinate: Var[Dict[str, Any]] + # If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR + is_animation_active: Var[bool] + + # Specifies the duration of animation, the unit of this option is ms. DEFAULT: 1500 + animation_duration: Var[int] + + # The type of easing function. DEFAULT: 'ease' + animation_easing: Var[LiteralAnimationEasing] + class Label(Recharts): """A Label component in Recharts.""" @@ -171,14 +230,21 @@ class LabelList(Recharts): # The key of a group of label values in data. data_key: Var[Union[str, int]] - # The position of each label relative to it view box。"Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center" + # The position of each label relative to it view box. "Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center" position: Var[LiteralPosition] - # The offset to the specified "position" + # The offset to the specified "position". Default: 5 offset: Var[int] - # Color of the fill - fill: Var[str] + # The fill color of each label. Default: rx.color("gray", 10) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) - # Color of the stroke - stroke: Var[str] + # The stroke color of each label. Default: "none" + stroke: Var[Union[str, Color]] = LiteralVar.create("none") + + +responsive_container = ResponsiveContainer.create +legend = Legend.create +graphing_tooltip = GraphingTooltip.create +label = Label.create +label_list = LabelList.create diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi index 5b59acba6..affe362bb 100644 --- a/reflex/components/recharts/general.pyi +++ b/reflex/components/recharts/general.pyi @@ -1,22 +1,17 @@ """Stub file for reflex/components/recharts/general.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Any, Dict, List, Union from reflex.components.component import MemoizationLeaf -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.constants.colors import Color +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var + from .recharts import ( - LiteralIconType, - LiteralLayout, - LiteralLegendAlign, - LiteralPosition, - LiteralVerticalAlign, Recharts, ) @@ -27,8 +22,8 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): cls, *children, aspect: Optional[Union[Var[int], int]] = None, - width: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - height: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, min_width: Optional[Union[Var[int], int]] = None, min_height: Optional[Union[Var[int], int]] = None, debounce: Optional[Union[Var[int], int]] = None, @@ -38,63 +33,35 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_resize: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "ResponsiveContainer": """Create a new memoization leaf component. Args: *children: The children of the component. aspect: The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number - width: The width of chart container. Can be a number or string - height: The height of chart container. Number - min_width: The minimum width of chart container. + width: The width of chart container. Can be a number or string. Default: "100%" + height: The height of chart container. Can be a number or string. Default: "100%" + min_width: The minimum width of chart container. Number min_height: The minimum height of chart container. Number - debounce: If specified a positive number, debounced function will be used to handle the resize event. + debounce: If specified a positive number, debounced function will be used to handle the resize event. Default: 0 + on_resize: If specified provides a callback providing the updated chart width and height values. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -109,7 +76,6 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): ... class Legend(Recharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore @@ -119,81 +85,81 @@ 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, + payload: Optional[ + Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] + ] = 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, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Legend": """Create the component. @@ -201,14 +167,23 @@ class Legend(Recharts): *children: The children of the component. width: The width of legend container. Number height: The height of legend container. Number - layout: The layout of legend items. 'horizontal' | 'vertical' - align: The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. - vertical_align: The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. - icon_size: The size of icon in each legend item. + layout: The layout of legend items. 'horizontal' | 'vertical'. Default: "horizontal" + align: The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. Default: "center" + vertical_align: The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. Default: "bottom" + icon_size: The size of icon in each legend item. Default: 14 icon_type: The type of icon in each legend item. 'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' + payload: The source data of the content to be displayed in the legend, usually calculated internally. Default: [] chart_width: The width of chart container, usually calculated internally. chart_height: The height of chart container, usually calculated internally. margin: The margin of chart container, usually calculated internally. + on_click: The customized event handler of click on the items in this group + on_mouse_down: The customized event handler of mousedown on the items in this group + on_mouse_up: The customized event handler of mouseup on the items in this group + on_mouse_move: The customized event handler of mousemove on the items in this group + on_mouse_over: The customized event handler of mouseover on the items in this group + on_mouse_out: The customized event handler of mouseout on the items in this group + on_mouse_enter: The customized event handler of mouseenter on the items in this group + on_mouse_leave: The customized event handler of mouseleave on the items in this group style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -231,63 +206,50 @@ class GraphingTooltip(Recharts): separator: Optional[Union[Var[str], str]] = None, offset: Optional[Union[Var[int], int]] = None, filter_null: Optional[Union[Var[bool], bool]] = None, - cursor: Optional[Union[Var[bool], bool]] = None, - view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + cursor: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = 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[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[ + 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "GraphingTooltip": """Create the component. @@ -298,9 +260,17 @@ class GraphingTooltip(Recharts): filter_null: When an item of the payload has value null or undefined, this item won't be displayed. cursor: If set false, no cursor will be drawn when tooltip is active. view_box: The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally. + item_style: The style of default tooltip content item which is a li element. DEFAULT: {} + wrapper_style: The style of tooltip wrapper which is a dom element. DEFAULT: {} + content_style: The style of tooltip content which is a dom element. DEFAULT: {} + label_style: The style of default tooltip label which is a p element. DEFAULT: {} + allow_escape_view_box: This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false } active: If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. position: If this field is set, the tooltip position will be fixed and will not move anymore. coordinate: The coordinate of tooltip which is usually calculated internally. + is_animation_active: If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR + animation_duration: Specifies the duration of animation, the unit of this option is ms. DEFAULT: 1500 + animation_easing: The type of easing function. DEFAULT: 'ease' style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -320,52 +290,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, @@ -375,52 +345,22 @@ class Label(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Label": """Create the component. @@ -449,118 +389,88 @@ class LabelList(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[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[str], str]] = None, - stroke: Optional[Union[Var[str], str]] = 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, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "LabelList": """Create the component. Args: *children: The children of the component. data_key: The key of a group of label values in data. - position: The position of each label relative to it view box。"Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center" - offset: The offset to the specified "position" - fill: Color of the fill - stroke: Color of the stroke + position: The position of each label relative to it view box. "Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center" + offset: The offset to the specified "position". Default: 5 + fill: The fill color of each label. Default: rx.color("gray", 10) + stroke: The stroke color of each label. Default: "none" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -573,3 +483,9 @@ class LabelList(Recharts): The component. """ ... + +responsive_container = ResponsiveContainer.create +legend = Legend.create +graphing_tooltip = GraphingTooltip.create +label = Label.create +label_list = LabelList.create diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index 256695740..ccb96f180 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -1,14 +1,19 @@ """Polar charts in Recharts.""" + from __future__ import annotations from typing import Any, Dict, List, Union from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.constants.colors import Color +from reflex.event import EventHandler, empty_event +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, LiteralGridType, + LiteralLegendType, + LiteralOrientationLeftRightMiddle, LiteralPolarRadiusType, LiteralScale, Recharts, @@ -22,56 +27,74 @@ class Pie(Recharts): alias = "RechartsPie" - # data + # The source data which each element is an object. data: Var[List[Dict[str, Any]]] # The key of each sector's value. data_key: Var[Union[str, int]] - # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. + # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. Default: "50%" cx: Var[Union[int, str]] - # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. + # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. Default: "50%" cy: Var[Union[int, str]] - # The inner radius of pie, which can be set to a percent value. + # The inner radius of pie, which can be set to a percent value. Default: 0 inner_radius: Var[Union[int, str]] - # The outer radius of pie, which can be set to a percent value. + # The outer radius of pie, which can be set to a percent value. Default: "80%" outer_radius: Var[Union[int, str]] - # The angle of first sector. + # The angle of first sector. Default: 0 start_angle: Var[int] - # The direction of sectors. 1 means clockwise and -1 means anticlockwise. + # The end angle of last sector, which should be unequal to start_angle. Default: 360 end_angle: Var[int] - # The minimum angle of each unzero data. + # The minimum angle of each unzero data. Default: 0 min_angle: Var[int] - # The angle between two sectors. + # The angle between two sectors. Default: 0 padding_angle: Var[int] - # The key of each sector's name. + # The key of each sector's name. Default: "name" name_key: Var[str] - # The type of icon in legend. If set to 'none', no legend item will be rendered. - legend_type: Var[str] + # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + legend_type: Var[LiteralLegendType] - # If false set, labels will not be drawn. + # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False label: Var[bool] = False # type: ignore - # If false set, label lines will not be drawn. + # If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False label_line: Var[bool] + # The index of active sector in Pie, this option can be changed in mouse event handlers. + data: Var[List[Dict[str, Any]]] + # Valid children components _valid_children: List[str] = ["Cell", "LabelList"] - # fill color - fill: Var[str] + # Stoke color. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # stroke color - stroke: Var[str] + # Fill color. Default: rx.color("accent", 3) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 3)) + + # If set false, animation of tooltip will be disabled. Default: true in CSR, and false in SSR + is_animation_active: Var[bool] + + # Specifies when the animation should begin, the unit of this option is ms. Default: 400 + animation_begin: Var[int] + + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_duration: Var[int] + + # The type of easing function. Default: "ease" + animation_easing: Var[LiteralAnimationEasing] + + # The tabindex of wrapper surrounding the cells. Default: 0 + root_tab_index: Var[int] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -80,12 +103,14 @@ class Pie(Recharts): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_ANIMATION_START: empty_event, + EventTriggers.ON_ANIMATION_END: empty_event, + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_MOUSE_MOVE: empty_event, + EventTriggers.ON_MOUSE_OVER: empty_event, + EventTriggers.ON_MOUSE_OUT: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, } @@ -102,36 +127,50 @@ class Radar(Recharts): # The coordinates of all the vertexes of the radar shape, like [{ x, y }]. points: Var[List[Dict[str, Any]]] - # If false set, dots will not be drawn + # If false set, dots will not be drawn. Default: True dot: Var[bool] - # Stoke color - stroke: Var[str] + # Stoke color. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # Fill color - fill: Var[str] + # Fill color. Default: rx.color("accent", 3) + fill: Var[str] = LiteralVar.create(Color("accent", 3)) - # opacity - fill_opacity: Var[float] + # opacity. Default: 0.6 + fill_opacity: Var[float] = LiteralVar.create(0.6) - # The type of icon in legend. If set to 'none', no legend item will be rendered. - legend_type: Var[str] + # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + legend_type: Var[LiteralLegendType] - # If false set, labels will not be drawn + # If false set, labels will not be drawn. Default: True label: Var[bool] - # Specifies when the animation should begin, the unit of this option is ms. + # If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR + is_animation_active: Var[bool] + + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 animation_begin: Var[int] - # Specifies the duration of animation, the unit of this option is ms. + # Specifies the duration of animation, the unit of this option is ms. Default: 1500 animation_duration: Var[int] - # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" animation_easing: Var[LiteralAnimationEasing] # Valid children components _valid_children: List[str] = ["LabelList"] + def get_event_triggers(self) -> dict[str, Union[Var, Any]]: + """Get the event triggers that pass the component's value to the handler. + + Returns: + A dict mapping the event trigger to the var that is passed to the handler. + """ + return { + EventTriggers.ON_ANIMATION_START: empty_event, + EventTriggers.ON_ANIMATION_END: empty_event, + } + class RadialBar(Recharts): """A RadialBar chart component in Recharts.""" @@ -143,20 +182,35 @@ class RadialBar(Recharts): # The source data which each element is an object. data: Var[List[Dict[str, Any]]] - # Min angle of each bar. A positive value between 0 and 360. + # The key of a group of data which should be unique to show the meaning of angle axis. + data_key: Var[Union[str, int]] + + # Min angle of each bar. A positive value between 0 and 360. Default: 0 min_angle: Var[int] - # Type of legend - legend_type: Var[str] + # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + legend_type: Var[LiteralLegendType] - # If false set, labels will not be drawn. - label: Var[bool] + # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False + label: Var[Union[bool, Dict[str, Any]]] - # If false set, background sector will not be drawn. - background: Var[bool] + # If false set, background sector will not be drawn. Default: False + background: Var[Union[bool, Dict[str, Any]]] + + # If set false, animation of radial bars will be disabled. Default: True + is_animation_active: Var[bool] + + # Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_begin: Var[int] + + # Specifies the duration of animation, the unit of this option is ms. Default 1500 + animation_duration: Var[int] + + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" + animation_easing: Var[LiteralAnimationEasing] # Valid children components - _valid_children: List[str] = ["LabelList"] + _valid_children: List[str] = ["Cell", "LabelList"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -165,12 +219,14 @@ class RadialBar(Recharts): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_MOUSE_MOVE: empty_event, + EventTriggers.ON_MOUSE_OVER: empty_event, + EventTriggers.ON_MOUSE_OUT: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, + EventTriggers.ON_ANIMATION_START: empty_event, + EventTriggers.ON_ANIMATION_END: empty_event, } @@ -193,44 +249,56 @@ class PolarAngleAxis(Recharts): # The outer radius of circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. radius: Var[Union[int, str]] - # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. + # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True axis_line: Var[Union[bool, Dict[str, Any]]] - # The type of axis line. - axis_line_type: Var[str] + # The type of axis line. Default: "polygon" + axis_line_type: Var[LiteralGridType] - # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. - tick_line: Var[Union[bool, Dict[str, Any]]] + # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False + tick_line: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(False) - # The width or height of tick. - tick: Var[Union[int, str]] + # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True + tick: Var[Union[bool, Dict[str, Any]]] # The array of every tick's value and angle. ticks: Var[List[Dict[str, Any]]] - # The orientation of axis text. - orient: Var[str] + # The orientation of axis text. Default: "outer" + orientation: Var[str] - # Allow the axis has duplicated categorys or not when the type of axis is "category". + # The stroke color of axis. Default: rx.color("gray", 10) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) + + # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True allow_duplicated_category: Var[bool] - # Valid children components + # Valid children components. _valid_children: List[str] = ["Label"] - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: - """Get the event triggers that pass the component's value to the handler. + # The customized event handler of click on the ticks of this axis. + on_click: EventHandler[empty_event] - Returns: - A dict mapping the event trigger to the var that is passed to the handler. - """ - return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], - } + # The customized event handler of mousedown on the the ticks of this axis. + on_mouse_down: EventHandler[empty_event] + + # The customized event handler of mouseup on the ticks of this axis. + on_mouse_up: EventHandler[empty_event] + + # The customized event handler of mousemove on the ticks of this axis. + on_mouse_move: EventHandler[empty_event] + + # The customized event handler of mouseover on the ticks of this axis. + on_mouse_over: EventHandler[empty_event] + + # The customized event handler of mouseout on the ticks of this axis. + on_mouse_out: EventHandler[empty_event] + + # The customized event handler of moustenter on the ticks of this axis. + on_mouse_enter: EventHandler[empty_event] + + # The customized event handler of mouseleave on the ticks of this axis. + on_mouse_leave: EventHandler[empty_event] class PolarGrid(Recharts): @@ -240,17 +308,17 @@ class PolarGrid(Recharts): alias = "RechartsPolarGrid" - # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. - cx: Var[Union[int, str]] + # The x-coordinate of center. + cx: Var[int] - # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. - cy: Var[Union[int, str]] + # The y-coordinate of center. + cy: Var[int] # The radius of the inner polar grid. - inner_radius: Var[Union[int, str]] + inner_radius: Var[int] # The radius of the outer polar grid. - outer_radius: Var[Union[int, str]] + outer_radius: Var[int] # The array of every line grid's angle. polar_angles: Var[List[int]] @@ -258,9 +326,12 @@ class PolarGrid(Recharts): # The array of every line grid's radius. polar_radius: Var[List[int]] - # The type of polar grids. 'polygon' | 'circle' + # The type of polar grids. 'polygon' | 'circle'. Default: "polygon" grid_type: Var[LiteralGridType] + # The stroke color of grid. Default: rx.color("gray", 10) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) + # Valid children components _valid_children: List[str] = ["RadarChart", "RadiarBarChart"] @@ -272,42 +343,48 @@ class PolarRadiusAxis(Recharts): alias = "RechartsPolarRadiusAxis" - # The angle of radial direction line to display axis text. + # The angle of radial direction line to display axis text. Default: 0 angle: Var[int] - # The type of axis line. 'number' | 'category' + # The type of axis line. 'number' | 'category'. Default: "category" type_: Var[LiteralPolarRadiusType] - # Allow the axis has duplicated categorys or not when the type of axis is "category". + # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True allow_duplicated_category: Var[bool] # The x-coordinate of center. - cx: Var[Union[int, str]] + cx: Var[int] # The y-coordinate of center. - cy: Var[Union[int, str]] + cy: Var[int] - # If set to true, the ticks of this axis are reversed. + # If set to true, the ticks of this axis are reversed. Default: False reversed: Var[bool] - # The orientation of axis text. - orientation: Var[str] + # The orientation of axis text. Default: "right" + orientation: Var[LiteralOrientationLeftRightMiddle] - # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. + # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True axis_line: Var[Union[bool, Dict[str, Any]]] - # The width or height of tick. - tick: Var[Union[int, str]] + # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True + tick: Var[Union[bool, Dict[str, Any]]] - # The count of ticks. + # The count of axis ticks. Not used if 'type' is 'category'. Default: 5 tick_count: Var[int] - # If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' + # If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" scale: Var[LiteralScale] # Valid children components _valid_children: List[str] = ["Label"] + # The domain of the polar radius axis, specifying the minimum and maximum values. Default: [0, "auto"] + domain: Var[List[Union[int, str]]] + + # The stroke color of axis. Default: rx.color("gray", 10) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) + def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -315,10 +392,18 @@ class PolarRadiusAxis(Recharts): A dict mapping the event trigger to the var that is passed to the handler. """ return { - EventTriggers.ON_CLICK: lambda: [], - EventTriggers.ON_MOUSE_MOVE: lambda: [], - EventTriggers.ON_MOUSE_OVER: lambda: [], - EventTriggers.ON_MOUSE_OUT: lambda: [], - EventTriggers.ON_MOUSE_ENTER: lambda: [], - EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_CLICK: empty_event, + EventTriggers.ON_MOUSE_MOVE: empty_event, + EventTriggers.ON_MOUSE_OVER: empty_event, + EventTriggers.ON_MOUSE_OUT: empty_event, + EventTriggers.ON_MOUSE_ENTER: empty_event, + EventTriggers.ON_MOUSE_LEAVE: empty_event, } + + +pie = Pie.create +radar = Radar.create +radial_bar = RadialBar.create +polar_angle_axis = PolarAngleAxis.create +polar_grid = PolarGrid.create +polar_radius_axis = PolarRadiusAxis.create diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi index e2186eca0..025f8443d 100644 --- a/reflex/components/recharts/polar.pyi +++ b/reflex/components/recharts/polar.pyi @@ -1,20 +1,16 @@ """Stub file for reflex/components/recharts/polar.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec +from reflex.constants.colors import Color +from reflex.event import EventType from reflex.style import Style -from typing import Any, Dict, List, Union -from reflex.constants import EventTriggers -from reflex.vars import Var +from reflex.vars.base import Var + from .recharts import ( - LiteralAnimationEasing, - LiteralGridType, - LiteralPolarRadiusType, - LiteralScale, Recharts, ) @@ -25,68 +21,104 @@ 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[str, int]], Union[str, int]]] = None, - cx: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - inner_radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - outer_radius: Optional[Union[Var[Union[int, str]], Union[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, + 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, + outer_radius: 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, min_angle: Optional[Union[Var[int], int]] = None, padding_angle: Optional[Union[Var[int], int]] = None, name_key: Optional[Union[Var[str], str]] = None, - legend_type: Optional[Union[Var[str], str]] = None, + legend_type: Optional[ + Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + 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, - fill: Optional[Union[Var[str], str]] = None, - stroke: Optional[Union[Var[str], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], 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[ + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], + ] + ] = None, + root_tab_index: Optional[Union[Var[int], int]] = 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + **props, ) -> "Pie": """Create the component. Args: *children: The children of the component. - data: data + data: The index of active sector in Pie, this option can be changed in mouse event handlers. data_key: The key of each sector's value. - cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. - cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. - inner_radius: The inner radius of pie, which can be set to a percent value. - outer_radius: The outer radius of pie, which can be set to a percent value. - start_angle: The angle of first sector. - end_angle: The direction of sectors. 1 means clockwise and -1 means anticlockwise. - min_angle: The minimum angle of each unzero data. - padding_angle: The angle between two sectors. - name_key: The key of each sector's name. - legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. - label: If false set, labels will not be drawn. - label_line: If false set, label lines will not be drawn. - fill: fill color - stroke: stroke color + cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. Default: "50%" + cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. Default: "50%" + inner_radius: The inner radius of pie, which can be set to a percent value. Default: 0 + outer_radius: The outer radius of pie, which can be set to a percent value. Default: "80%" + start_angle: The angle of first sector. Default: 0 + end_angle: The end angle of last sector, which should be unequal to start_angle. Default: 360 + min_angle: The minimum angle of each unzero data. Default: 0 + padding_angle: The angle between two sectors. Default: 0 + name_key: The key of each sector's name. Default: "name" + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False + label_line: If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False + stroke: Stoke color. Default: rx.color("accent", 9) + fill: Fill color. Default: rx.color("accent", 3) + is_animation_active: If set false, animation of tooltip will be disabled. Default: true in CSR, and false in SSR + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 400 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. Default: "ease" + root_tab_index: The tabindex of wrapper surrounding the cells. Default: 0 style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -101,25 +133,58 @@ class Pie(Recharts): ... class Radar(Recharts): + def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[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[str], str]] = 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, + legend_type: Optional[ + Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = None, label: Optional[Union[Var[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, @@ -128,52 +193,9 @@ class Radar(Recharts): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + **props, ) -> "Radar": """Create the component. @@ -181,15 +203,16 @@ class Radar(Recharts): *children: The children of the component. data_key: The key of a group of data which should be unique in a radar chart. points: The coordinates of all the vertexes of the radar shape, like [{ x, y }]. - dot: If false set, dots will not be drawn - stroke: Stoke color - fill: Fill color - fill_opacity: opacity - legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. - label: If false set, labels will not be drawn - animation_begin: Specifies when the animation should begin, the unit of this option is ms. - animation_duration: Specifies the duration of animation, the unit of this option is ms. - animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' + dot: If false set, dots will not be drawn. Default: True + stroke: Stoke color. Default: rx.color("accent", 9) + fill: Fill color. Default: rx.color("accent", 3) + fill_opacity: opacity. Default: 0.6 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + label: If false set, labels will not be drawn. Default: True + is_animation_active: If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500 + animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -210,46 +233,86 @@ class RadialBar(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, + 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[bool], bool]] = None, - background: Optional[Union[Var[bool], bool]] = None, + legend_type: Optional[ + Union[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] + ], + ] + ] = None, + label: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + background: Optional[ + 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[ + 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, 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_animation_end: Optional[EventType[[]]] = None, + on_animation_start: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + **props, ) -> "RadialBar": """Create the component. Args: *children: The children of the component. data: The source data which each element is an object. - min_angle: Min angle of each bar. A positive value between 0 and 360. - legend_type: Type of legend - label: If false set, labels will not be drawn. - background: If false set, background sector will not be drawn. + data_key: The key of a group of data which should be unique to show the meaning of angle axis. + min_angle: Min angle of each bar. A positive value between 0 and 360. Default: 0 + legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect" + label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False + background: If false set, background sector will not be drawn. Default: False + is_animation_active: If set false, animation of radial bars will be disabled. Default: True + animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. Default 1500 + animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -264,26 +327,30 @@ class RadialBar(Recharts): ... class PolarAngleAxis(Recharts): - def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @overload @classmethod def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[str, int]], Union[str, int]]] = None, - cx: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = 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[bool, Dict[str, Any]]], Union[bool, Dict[str, Any]]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + axis_line_type: Optional[ + Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]] ] = None, - axis_line_type: Optional[Union[Var[str], str]] = None, tick_line: Optional[ - Union[Var[Union[bool, Dict[str, Any]]], Union[bool, Dict[str, Any]]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - tick: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - ticks: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - orient: Optional[Union[Var[str], str]] = None, + tick: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + ticks: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + orientation: Optional[Union[Var[str], str]] = 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, @@ -291,25 +358,22 @@ class PolarAngleAxis(Recharts): class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PolarAngleAxis": """Create the component. @@ -319,13 +383,22 @@ class PolarAngleAxis(Recharts): cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. radius: The outer radius of circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. - axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. - axis_line_type: The type of axis line. - tick_line: If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. - tick: The width or height of tick. + axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True + axis_line_type: The type of axis line. Default: "polygon" + tick_line: If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False + tick: If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True ticks: The array of every tick's value and angle. - orient: The orientation of axis text. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". + orientation: The orientation of axis text. Default: "outer" + stroke: The stroke color of axis. Default: rx.color("gray", 10) + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + on_click: The customized event handler of click on the ticks of this axis. + on_mouse_down: The customized event handler of mousedown on the the ticks of this axis. + on_mouse_up: The customized event handler of mouseup on the ticks of this axis. + on_mouse_move: The customized event handler of mousemove on the ticks of this axis. + on_mouse_over: The customized event handler of mouseover on the ticks of this axis. + on_mouse_out: The customized event handler of mouseout on the ticks of this axis. + on_mouse_enter: The customized event handler of moustenter on the ticks of this axis. + on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -345,79 +418,51 @@ class PolarGrid(Recharts): def create( # type: ignore cls, *children, - cx: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - inner_radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - outer_radius: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, - polar_angles: Optional[Union[Var[List[int]], List[int]]] = None, - polar_radius: Optional[Union[Var[List[int]], List[int]]] = None, + cx: Optional[Union[Var[int], int]] = None, + cy: Optional[Union[Var[int], int]] = None, + inner_radius: Optional[Union[Var[int], int]] = None, + outer_radius: Optional[Union[Var[int], 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[Color, Var[Union[Color, 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "PolarGrid": """Create the component. Args: *children: The children of the component. - cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. - cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. + cx: The x-coordinate of center. + cy: The y-coordinate of center. inner_radius: The radius of the inner polar grid. outer_radius: The radius of the outer polar grid. polar_angles: The array of every line grid's angle. polar_radius: The array of every line grid's radius. - grid_type: The type of polar grids. 'polygon' | 'circle' + grid_type: The type of polar grids. 'polygon' | 'circle'. Default: "polygon" + stroke: The stroke color of grid. Default: rx.color("gray", 10) style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -440,99 +485,100 @@ 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]], Union[int, str]]] = None, - cy: Optional[Union[Var[Union[int, str]], Union[int, str]]] = None, + cx: Optional[Union[Var[int], int]] = None, + cy: Optional[Union[Var[int], int]] = None, reversed: Optional[Union[Var[bool], bool]] = None, - orientation: Optional[Union[Var[str], str]] = None, - axis_line: Optional[ - Union[Var[Union[bool, Dict[str, Any]]], Union[bool, Dict[str, Any]]] + orientation: Optional[ + Union[ + Literal["left", "middle", "right"], + Var[Literal["left", "middle", "right"]], + ] + ] = None, + axis_line: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + tick: Optional[ + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - tick: Optional[Union[Var[Union[int, str]], Union[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[List[Union[int, str]], Var[List[Union[int, str]]]] + ] = None, + stroke: Optional[Union[Color, Var[Union[Color, 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_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_click: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + **props, ) -> "PolarRadiusAxis": """Create the component. Args: *children: The children of the component. - angle: The angle of radial direction line to display axis text. - type_: The type of axis line. 'number' | 'category' - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". + angle: The angle of radial direction line to display axis text. Default: 0 + type_: The type of axis line. 'number' | 'category'. Default: "category" + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True cx: The x-coordinate of center. cy: The y-coordinate of center. - reversed: If set to true, the ticks of this axis are reversed. - orientation: The orientation of axis text. - axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. - tick: The width or height of tick. - tick_count: The count of ticks. - scale: If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' + reversed: If set to true, the ticks of this axis are reversed. Default: False + orientation: The orientation of axis text. Default: "right" + axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True + tick: If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + scale: If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto" + domain: The domain of the polar radius axis, specifying the minimum and maximum values. Default: [0, "auto"] + stroke: The stroke color of axis. Default: rx.color("gray", 10) style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -545,3 +591,10 @@ class PolarRadiusAxis(Recharts): The component. """ ... + +pie = Pie.create +radar = Radar.create +radial_bar = RadialBar.create +polar_angle_axis = PolarAngleAxis.create +polar_grid = PolarGrid.create +polar_radius_axis = PolarRadiusAxis.create diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index 28c8a5c8a..a0d683f72 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -1,19 +1,35 @@ """A component that wraps a recharts lib.""" -from typing import Literal + +from typing import Dict, Literal from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent +from reflex.utils import console class Recharts(Component): """A component that wraps a recharts lib.""" - library = "recharts@2.8.0" + library = "recharts@2.13.0" + + def render(self) -> Dict: + """Render the tag. + + Returns: + The rendered tag. + """ + tag = super().render() + if any(p.startswith("css") for p in tag["props"]): + console.warn( + f"CSS props do not work for {self.__class__.__name__}. Consult docs to style it with its own prop." + ) + tag["props"] = [p for p in tag["props"] if not p.startswith("css")] + return tag class RechartsCharts(NoSSRComponent, MemoizationLeaf): """A component that wraps a recharts lib.""" - library = "recharts@2.8.0" + library = "recharts@2.13.0" LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"] @@ -25,6 +41,7 @@ LiteralLineType = Literal["joint", "fitting"] LiteralOrientation = Literal["top", "bottom", "left", "right", "middle"] LiteralOrientationLeftRightMiddle = Literal["left", "right", "middle"] LiteralOrientationTopBottom = Literal["top", "bottom"] +LiteralOrientationLeftRight = Literal["left", "right"] LiteralOrientationTopBottomLeftRight = Literal["top", "bottom", "left", "right"] LiteralScale = Literal[ "auto", @@ -43,6 +60,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -78,7 +96,7 @@ LiteralIconType = Literal[ "triangle", "wye", ] -LiteralLegendType = [ +LiteralLegendType = Literal[ "line", "plainline", "square", @@ -114,6 +132,9 @@ LiteralAreaType = Literal[ "stepBefore", "stepAfter", ] -LiteralDirection = Literal["x", "y", "both"] +LiteralDirection = Literal["x", "y"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] +LiteralIntervalAxis = Literal[ + "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart" +] LiteralSyncMethod = Literal["index", "value"] diff --git a/reflex/components/recharts/recharts.pyi b/reflex/components/recharts/recharts.pyi index ff279a50a..c13519f05 100644 --- a/reflex/components/recharts/recharts.pyi +++ b/reflex/components/recharts/recharts.pyi @@ -1,16 +1,17 @@ """Stub file for reflex/components/recharts/recharts.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal + from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent +from reflex.event import EventType +from reflex.style import Style +from reflex.vars.base import Var class Recharts(Component): + def render(self) -> Dict: ... @overload @classmethod def create( # type: ignore @@ -22,52 +23,22 @@ class Recharts(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Recharts": """Create the component. @@ -98,52 +69,22 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "RechartsCharts": """Create a new memoization leaf component. @@ -171,6 +112,7 @@ LiteralLineType = Literal["joint", "fitting"] LiteralOrientation = Literal["top", "bottom", "left", "right", "middle"] LiteralOrientationLeftRightMiddle = Literal["left", "right", "middle"] LiteralOrientationTopBottom = Literal["top", "bottom"] +LiteralOrientationLeftRight = Literal["left", "right"] LiteralOrientationTopBottomLeftRight = Literal["top", "bottom", "left", "right"] LiteralScale = Literal[ "auto", @@ -189,6 +131,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -224,7 +167,7 @@ LiteralIconType = Literal[ "triangle", "wye", ] -LiteralLegendType = [ +LiteralLegendType = Literal[ "line", "plainline", "square", @@ -260,6 +203,9 @@ LiteralAreaType = Literal[ "stepBefore", "stepAfter", ] -LiteralDirection = Literal["x", "y", "both"] +LiteralDirection = Literal["x", "y"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] +LiteralIntervalAxis = Literal[ + "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart" +] LiteralSyncMethod = Literal["index", "value"] diff --git a/reflex/components/sonner/toast.py b/reflex/components/sonner/toast.py index 8a6c59a54..175c68f63 100644 --- a/reflex/components/sonner/toast.py +++ b/reflex/components/sonner/toast.py @@ -2,17 +2,22 @@ from __future__ import annotations -from typing import Literal +from typing import Any, ClassVar, Literal, Optional, Union from reflex.base import Base from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon -from reflex.event import EventSpec, call_script -from reflex.style import Style, color_mode +from reflex.components.props import NoExtrasAllowedProps, PropsBase +from reflex.event import ( + EventSpec, + call_script, +) +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 -from reflex.vars import Var, VarData +from reflex.utils.serializers import serializer +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var LiteralPosition = Literal[ "top-left", @@ -23,50 +28,74 @@ LiteralPosition = Literal[ "bottom-right", ] - -toast_ref = Var.create_safe("refs['__toast']") +toast_ref = Var(_js_expr="refs['__toast']") -class PropsBase(Base): - """Base class for all props classes.""" +class ToastAction(Base): + """A toast action that render a button in the toast.""" - def json(self) -> str: - """Convert the object to a json string. + label: str + on_click: Any - Returns: - The object as a json string. - """ - from reflex.utils.serializers import serialize - return self.__config__.json_dumps( - {format.to_camel_case(key): value for key, value in self.dict().items()}, - default=serialize, +@serializer +def serialize_action(action: ToastAction) -> dict: + """Serialize a toast action. + + Args: + action: The toast action to serialize. + + Returns: + The serialized toast action with on_click formatted to queue the given event. + """ + return { + "label": action.label, + "onClick": format.format_queue_events(action.on_click), + } + + +def _toast_callback_signature(toast: Var) -> list[Var]: + """The signature for the toast callback, stripping out unserializable keys. + + Args: + toast: The toast variable. + + Returns: + A function call stripping non-serializable members of the toast object. + """ + return [ + Var( + _js_expr=f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {str(toast)}; return rest}})()" ) + ] -class ToastProps(PropsBase): +class ToastProps(PropsBase, NoExtrasAllowedProps): """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: str = "" + description: Optional[Union[str, Var]] # Whether to show the close button. - close_button: bool = False + close_button: Optional[bool] # Dark toast in light mode and vice versa. - invert: bool = False + invert: Optional[bool] # Control the sensitivity of the toast for screen readers - important: bool = False + important: Optional[bool] # Time in milliseconds that should elapse before automatically closing the toast. - duration: int = 4000 + duration: Optional[int] # Position of the toast. - position: LiteralPosition = "bottom-right" + position: Optional[LiteralPosition] # If false, it'll prevent the user from dismissing the toast. - dismissible: bool = True + dismissible: Optional[bool] # TODO: fix serialization of icons for toast? (might not be possible yet) # Icon displayed in front of toast's text, aligned vertically. @@ -74,51 +103,89 @@ class ToastProps(PropsBase): # TODO: fix implementation for action / cancel buttons # Renders a primary button, clicking it will close the toast. - # action: str = "" + action: Optional[ToastAction] # Renders a secondary button, clicking it will close the toast. - # cancel: str = "" + cancel: Optional[ToastAction] # Custom id for the toast. - id: str = "" + id: Optional[Union[str, Var]] # Removes the default styling, which allows for easier customization. - unstyled: bool = False + unstyled: Optional[bool] # Custom style for the toast. - style: Style = Style() + style: Optional[Style] + # XXX: These still do not seem to work # Custom style for the toast primary button. - # action_button_styles: Style = Style() + action_button_styles: Optional[Style] # Custom style for the toast secondary button. - # cancel_button_styles: Style = Style() + cancel_button_styles: Optional[Style] + + # The function gets called when either the close button is clicked, or the toast is swiped. + on_dismiss: Optional[Any] + + # Function that gets called when the toast disappears automatically after it's timeout (duration` prop). + on_auto_close: Optional[Any] + + def dict(self, *args, **kwargs) -> dict[str, Any]: + """Convert the object to a dictionary. + + Args: + *args: The arguments to pass to the base class. + **kwargs: The keyword arguments to pass to the base + + Returns: + The object as a dictionary with ToastAction fields intact. + """ + kwargs.setdefault("exclude_none", True) # type: ignore + d = super().dict(*args, **kwargs) + # Keep these fields as ToastAction so they can be serialized specially + if "action" in d: + d["action"] = self.action + if isinstance(self.action, dict): + d["action"] = ToastAction(**self.action) + if "cancel" in d: + d["cancel"] = self.cancel + if isinstance(self.cancel, dict): + d["cancel"] = ToastAction(**self.cancel) + if "onDismiss" in d: + d["onDismiss"] = format.format_queue_events( + self.on_dismiss, _toast_callback_signature + ) + if "onAutoClose" in d: + d["onAutoClose"] = format.format_queue_events( + self.on_auto_close, _toast_callback_signature + ) + return d class Toaster(Component): """A Toaster Component for displaying toast notifications.""" - library = "sonner@1.4.41" + library: str = "sonner@1.5.0" tag = "Toaster" # the theme of the toast - theme: Var[str] = color_mode + theme: Var[str] = resolved_color_mode # whether to show rich colors - rich_colors: Var[bool] = Var.create_safe(True) + rich_colors: Var[bool] = LiteralVar.create(True) # whether to expand the toast - expand: Var[bool] = Var.create_safe(True) + expand: Var[bool] = LiteralVar.create(True) # the number of toasts that are currently visible visible_toasts: Var[int] # the position of the toast - position: Var[LiteralPosition] = Var.create_safe("bottom-right") + position: Var[LiteralPosition] = LiteralVar.create("bottom-right") # whether to show the close button - close_button: Var[bool] = Var.create_safe(False) + close_button: Var[bool] = LiteralVar.create(False) # offset of the toast offset: Var[str] @@ -144,18 +211,28 @@ class Toaster(Component): # Pauses toast timers when the page is hidden, e.g., when the tab is backgrounded, the browser is minimized, or the OS is locked. pause_when_page_is_hidden: Var[bool] - def _get_hooks(self) -> Var[str]: - hook = Var.create_safe(f"{toast_ref} = toast", _var_is_local=True) - hook._var_data = VarData( # type: ignore - imports={ - "/utils/state": [ImportVar(tag="refs")], - self.library: [ImportVar(tag="toast", install=False)], - } + # Marked True when any Toast component is created. + is_used: ClassVar[bool] = False + + def add_hooks(self) -> list[Var | str]: + """Add hooks for the toaster component. + + Returns: + The hooks for the toaster component. + """ + hook = Var( + _js_expr=f"{toast_ref} = toast", + _var_data=VarData( + imports={ + "$/utils/state": [ImportVar(tag="refs")], + self.library: [ImportVar(tag="toast", install=False)], + } + ), ) - return hook + return [hook] @staticmethod - def send_toast(message: str, level: str | None = None, **props) -> EventSpec: + def send_toast(message: str = "", level: str | None = None, **props) -> EventSpec: """Send a toast message. Args: @@ -163,21 +240,30 @@ class Toaster(Component): level: The level of the toast. **props: The options for the toast. + Raises: + ValueError: If the Toaster component is not created. + Returns: The toast event. """ + if not Toaster.is_used: + raise ValueError( + "Toaster component must be created before sending a toast. (use `rx.toast.provider()`)" + ) toast_command = f"{toast_ref}.{level}" if level is not None else toast_ref + if message == "" and ("title" not in props or "description" not in props): + raise ValueError("Toast message or title or description must be provided.") if props: - args = serialize(ToastProps(**props)) - toast = f"{toast_command}(`{message}`, {args})" + args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # type: ignore + toast = f"{toast_command}(`{message}`, {str(args)})" else: toast = f"{toast_command}(`{message}`)" - toast_action = Var.create(toast, _var_is_string=False, _var_is_local=True) - return call_script(toast_action) # type: ignore + 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: @@ -190,7 +276,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: @@ -203,7 +289,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: @@ -216,7 +302,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: @@ -228,7 +314,8 @@ class Toaster(Component): """ return Toaster.send_toast(message, level="success", **kwargs) - def toast_dismiss(self, id: str | None): + @staticmethod + def toast_dismiss(id: Var | str | None = None): """Dismiss a toast. Args: @@ -237,12 +324,33 @@ class Toaster(Component): Returns: The toast dismiss event. """ - if id is None: - dismiss = f"{toast_ref}.dismiss()" + dismiss_var_data = None + + if isinstance(id, Var): + 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({id})" - dismiss_action = Var.create(dismiss, _var_is_string=False, _var_is_local=True) - return call_script(dismiss_action) # type: ignore + dismiss = f"{toast_ref}.dismiss()" + dismiss_action = Var( + _js_expr=dismiss, _var_data=VarData.merge(dismiss_var_data) + ) + return call_script(dismiss_action) + + @classmethod + def create(cls, *children, **props) -> Component: + """Create a toaster component. + + Args: + *children: The children of the toaster. + **props: The properties of the toaster. + + Returns: + The toaster component. + """ + cls.is_used = True + return super().create(*children, **props) # TODO: figure out why loading toast stay open forever diff --git a/reflex/components/sonner/toast.pyi b/reflex/components/sonner/toast.pyi index 2bf937703..10168257e 100644 --- a/reflex/components/sonner/toast.pyi +++ b/reflex/components/sonner/toast.pyi @@ -1,22 +1,18 @@ """Stub file for reflex/components/sonner/toast.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -from typing import Literal from reflex.base import Base from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon -from reflex.event import EventSpec, call_script -from reflex.style import Style, color_mode -from reflex.utils import format -from reflex.utils.imports import ImportVar -from reflex.utils.serializers import serialize -from reflex.vars import Var, VarData +from reflex.components.props import NoExtrasAllowedProps, PropsBase +from reflex.event import EventSpec, EventType +from reflex.style import Style +from reflex.utils.serializers import serializer +from reflex.vars.base import Var LiteralPosition = Literal[ "top-left", @@ -26,35 +22,54 @@ LiteralPosition = Literal[ "bottom-center", "bottom-right", ] -toast_ref = Var.create_safe("refs['__toast']") +toast_ref = Var(_js_expr="refs['__toast']") -class PropsBase(Base): - def json(self) -> str: ... +class ToastAction(Base): + label: str + on_click: Any -class ToastProps(PropsBase): - description: str - close_button: bool - invert: bool - important: bool - duration: int - position: LiteralPosition - dismissible: bool - id: str - unstyled: bool - style: Style +@serializer +def serialize_action(action: ToastAction) -> dict: ... + +class ToastProps(PropsBase, NoExtrasAllowedProps): + title: Optional[Union[str, Var]] + description: Optional[Union[str, Var]] + close_button: Optional[bool] + invert: Optional[bool] + important: Optional[bool] + duration: Optional[int] + position: Optional[LiteralPosition] + dismissible: Optional[bool] + action: Optional[ToastAction] + cancel: Optional[ToastAction] + id: Optional[Union[str, Var]] + unstyled: Optional[bool] + style: Optional[Style] + action_button_styles: Optional[Style] + cancel_button_styles: Optional[Style] + on_dismiss: Optional[Any] + on_auto_close: Optional[Any] + + def dict(self, *args, **kwargs) -> dict[str, Any]: ... class Toaster(Component): + is_used: ClassVar[bool] = False + + def add_hooks(self) -> list[Var | str]: ... @staticmethod - def send_toast(message: str, level: str | None = None, **props) -> EventSpec: ... + def send_toast( + 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_dismiss(self, id: str | None): ... + def toast_success(message: str = "", **kwargs): ... + @staticmethod + def toast_dismiss(id: Var | str | None = None): ... @overload @classmethod def create( # type: ignore @@ -66,24 +81,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, @@ -91,9 +106,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, @@ -101,57 +116,27 @@ class Toaster(Component): 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, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, ) -> "Toaster": - """Create the component. + """Create a toaster component. Args: - *children: The children of the component. + *children: The children of the toaster. theme: the theme of the toast rich_colors: whether to show rich colors expand: whether to expand the toast @@ -172,10 +157,10 @@ class Toaster(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 of the component. + **props: The properties of the toaster. Returns: - The component. + The toaster component. """ ... @@ -189,7 +174,9 @@ class ToastNamespace(ComponentNamespace): dismiss = staticmethod(Toaster.toast_dismiss) @staticmethod - def __call__(message: str, level: Optional[str], **props) -> "Optional[EventSpec]": + def __call__( + message: str = "", level: Optional[str] = None, **props + ) -> "Optional[EventSpec]": """Send a toast message. Args: @@ -197,6 +184,9 @@ class ToastNamespace(ComponentNamespace): level: The level of the toast. **props: The options for the toast. + Raises: + ValueError: If the Toaster component is not created. + Returns: The toast event. """ diff --git a/reflex/components/suneditor/editor.py b/reflex/components/suneditor/editor.py index 92a1e80c3..3bca8a3f6 100644 --- a/reflex/components/suneditor/editor.py +++ b/reflex/components/suneditor/editor.py @@ -1,15 +1,16 @@ """A Rich Text Editor based on SunEditor.""" + from __future__ import annotations import enum -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Dict, List, Literal, Optional, Tuple, Union from reflex.base import Base from reflex.components.component import Component, NoSSRComponent -from reflex.constants import EventTriggers +from reflex.event import EventHandler, empty_event, identity_event from reflex.utils.format import to_camel_case -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.utils.imports import ImportDict, ImportVar +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): @@ -67,6 +68,35 @@ class EditorOptions(Base): button_list: Optional[List[Union[List[str], str]]] +def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]: + """A helper function to specify the on_blur event handler. + + Args: + e: The event. + content: The content of the editor. + + Returns: + A tuple containing the content of the editor. + """ + return (content,) + + +def on_paste_spec( + e: Var, clean_data: Var[str], max_char_count: Var[bool] +) -> Tuple[Var[str], Var[bool]]: + """A helper function to specify the on_paste event handler. + + Args: + e: The event. + clean_data: The clean data. + max_char_count: The maximum character count. + + Returns: + A tuple containing the clean data and the maximum character count. + """ + return (clean_data, max_char_count) + + class Editor(NoSSRComponent): """A Rich Text Editor component based on SunEditor. Not every JS prop is listed here (some are not easily usable from python), @@ -176,34 +206,41 @@ class Editor(NoSSRComponent): # default: False disable_toolbar: Var[bool] - def _get_imports(self): - imports = super()._get_imports() - imports[""] = [ - ImportVar(tag="suneditor/dist/css/suneditor.min.css", install=False) - ] - return imports + # Fired when the editor content changes. + on_change: EventHandler[identity_event(str)] - def get_event_triggers(self) -> Dict[str, Any]: - """Get the event triggers that pass the component's value to the handler. + # Fired when the something is inputted in the editor. + on_input: EventHandler[empty_event] + + # Fired when the editor loses focus. + on_blur: EventHandler[on_blur_spec] + + # Fired when the editor is loaded. + on_load: EventHandler[identity_event(bool)] + + # Fired when the editor content is copied. + on_copy: EventHandler[empty_event] + + # Fired when the editor content is cut. + on_cut: EventHandler[empty_event] + + # Fired when the editor content is pasted. + on_paste: EventHandler[on_paste_spec] + + # Fired when the code view is toggled. + toggle_code_view: EventHandler[identity_event(bool)] + + # Fired when the full screen mode is toggled. + toggle_full_screen: EventHandler[identity_event(bool)] + + def add_imports(self) -> ImportDict: + """Add imports for the Editor component. Returns: - A dict mapping the event trigger to the var that is passed to the handler. + The import dict. """ return { - **super().get_event_triggers(), - EventTriggers.ON_CHANGE: lambda content: [content], - "on_input": lambda _e: [_e], - EventTriggers.ON_BLUR: lambda _e, content: [content], - "on_load": lambda reload: [reload], - "on_resize_editor": lambda height, prev_height: [height, prev_height], - "on_copy": lambda _e, clipboard_data: [clipboard_data], - "on_cut": lambda _e, clipboard_data: [clipboard_data], - "on_paste": lambda _e, clean_data, max_char_count: [ - clean_data, - max_char_count, - ], - "toggle_code_view": lambda is_code_view: [is_code_view], - "toggle_full_screen": lambda is_full_screen: [is_full_screen], + "": ImportVar(tag="suneditor/dist/css/suneditor.min.css", install=False) } @classmethod diff --git a/reflex/components/suneditor/editor.pyi b/reflex/components/suneditor/editor.pyi index f878ef538..3734d2f16 100644 --- a/reflex/components/suneditor/editor.pyi +++ b/reflex/components/suneditor/editor.pyi @@ -1,20 +1,17 @@ """Stub file for reflex/components/suneditor/editor.py""" + # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style import enum -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload + from reflex.base import Base -from reflex.components.component import Component, NoSSRComponent -from reflex.constants import EventTriggers -from reflex.utils.format import to_camel_case -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.components.component import NoSSRComponent +from reflex.event import EventType +from reflex.style import Style +from reflex.utils.imports import ImportDict +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): BASIC = [["font", "fontSize"], ["fontColor"], ["horizontalRule"], ["link", "image"]] @@ -47,8 +44,13 @@ class EditorOptions(Base): rtl: Optional[bool] button_list: Optional[List[Union[List[str], str]]] +def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]: ... +def on_paste_spec( + e: Var, clean_data: Var[str], max_char_count: Var[bool] +) -> Tuple[Var[str], Var[bool]]: ... + class Editor(NoSSRComponent): - def get_event_triggers(self) -> Dict[str, Any]: ... + def add_imports(self) -> ImportDict: ... @overload @classmethod def create( # type: ignore @@ -56,54 +58,52 @@ 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, ] ], - Union[ - Literal[ - "en", - "da", - "de", - "es", - "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", - "he", - "it", - ], - dict, - ], + dict, ] ] = None, name: Optional[Union[Var[str], str]] = None, @@ -112,7 +112,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, @@ -127,79 +127,30 @@ class Editor(NoSSRComponent): 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, function, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_copy: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_cut: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_input: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_paste: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_resize_editor: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - toggle_code_view: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - toggle_full_screen: Optional[ - Union[EventHandler, EventSpec, list, function, BaseVar] - ] = None, - **props + on_blur: Optional[EventType[str]] = None, + on_change: Optional[EventType[str]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_copy: Optional[EventType[[]]] = None, + on_cut: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_input: Optional[EventType[[]]] = None, + on_load: Optional[EventType[bool]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_paste: Optional[EventType[str, bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + toggle_code_view: Optional[EventType[bool]] = None, + toggle_full_screen: Optional[EventType[bool]] = None, + **props, ) -> "Editor": """Create an instance of Editor. No children allowed. @@ -221,6 +172,15 @@ class Editor(NoSSRComponent): hide: Hide the editor default: False hide_toolbar: Hide the editor toolbar default: False disable_toolbar: Disable the editor toolbar default: False + on_change: Fired when the editor content changes. + on_input: Fired when the something is inputted in the editor. + on_blur: Fired when the editor loses focus. + on_load: Fired when the editor is loaded. + on_copy: Fired when the editor content is copied. + on_cut: Fired when the editor content is cut. + on_paste: Fired when the editor content is pasted. + toggle_code_view: Fired when the code view is toggled. + toggle_full_screen: Fired when the full screen mode is toggled. style: The style of the component. key: A unique key for the component. id: The id for the component. 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 7ca050470..fec27f3d9 100644 --- a/reflex/components/tags/iter_tag.py +++ b/reflex/components/tags/iter_tag.py @@ -1,30 +1,44 @@ """Tag to loop through a list of components.""" + 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.vars import BaseVar, 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. @@ -32,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] is 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] is 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 @@ -52,10 +67,10 @@ class IterTag(Tag): Returns: The index var. """ - return BaseVar( - _var_name=self.index_var_name, + return Var( + _js_expr=self.index_var_name, _var_type=int, - ) + ).guess_type() def get_arg_var(self) -> Var: """Get the arg var for the tag (with curly braces). @@ -65,10 +80,10 @@ class IterTag(Tag): Returns: The arg var. """ - return BaseVar( - _var_name=self.arg_var_name, + return Var( + _js_expr=self.arg_var_name, _var_type=self.get_iterable_var_type(), - ) + ).guess_type() def get_index_var_arg(self) -> Var: """Get the index var for the tag (without curly braces). @@ -78,11 +93,10 @@ class IterTag(Tag): Returns: The index var. """ - return BaseVar( - _var_name=self.index_var_name, + return Var( + _js_expr=self.index_var_name, _var_type=int, - _var_is_local=True, - ) + ).guess_type() def get_arg_var_arg(self) -> Var: """Get the arg var for the tag (without curly braces). @@ -92,15 +106,17 @@ class IterTag(Tag): Returns: The arg var. """ - return BaseVar( - _var_name=self.arg_var_name, + return Var( + _js_expr=self.arg_var_name, _var_type=self.get_iterable_var_type(), - _var_is_local=True, - ) + ).guess_type() def render_component(self) -> Component: """Render the component. + Raises: + ValueError: If the render function takes more than 2 arguments. + Returns: The rendered component. """ @@ -119,7 +135,8 @@ class IterTag(Tag): component = self.render_fn(arg) else: # If the render function takes the index as an argument. - assert len(args) == 2 + if len(args) != 2: + raise ValueError("The render function must take 2 arguments.") component = self.render_fn(arg, index) # Nested foreach components or cond must be wrapped in fragments. 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 27b5dc7c1..0587c61ed 100644 --- a/reflex/components/tags/tag.py +++ b/reflex/components/tags/tag.py @@ -2,48 +2,40 @@ from __future__ import annotations -from typing import Any, Dict, List, Optional, Set, Tuple, Union +import dataclasses +from typing import Any, Dict, List, Optional, Union -from reflex.base import Base from reflex.event import EventChain 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 = "" - # Args to pass to the tag. - 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: Var.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. @@ -53,6 +45,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. @@ -62,14 +77,12 @@ class Tag(Base): Returns: The tag with the props added. """ - from reflex.components.core.colors import Color - self.props.update( { - format.to_camel_case(name, allow_hyphens=True): prop - if types._isinstance(prop, Union[EventChain, dict]) - else Var.create( - prop, _var_is_string=isinstance(prop, Color) + format.to_camel_case(name, allow_hyphens=True): ( + prop + if types._isinstance(prop, Union[EventChain, dict]) + else LiteralVar.create(prop) ) # rx.color is always a string for name, prop in kwargs.items() if self.is_valid_prop(prop) diff --git a/reflex/config.py b/reflex/config.py index 40c2ef8bf..12cc0916a 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -2,12 +2,21 @@ from __future__ import annotations +import dataclasses +import enum import importlib +import inspect import os import sys import urllib.parse +from pathlib import Path from typing import Any, Dict, List, Optional, Set +from typing_extensions import Annotated, get_type_hints + +from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError +from reflex.utils.types import GenericType, is_union, value_inside_optional + try: import pydantic.v1 as pydantic except ModuleNotFoundError: @@ -128,6 +137,258 @@ class DBConfig(Base): return f"{self.engine}://{path}/{self.database}" +def get_default_value_for_field(field: dataclasses.Field) -> Any: + """Get the default value for a field. + + Args: + field: The field. + + Returns: + The default value. + + Raises: + ValueError: If no default value is found. + """ + if field.default != dataclasses.MISSING: + return field.default + elif field.default_factory != dataclasses.MISSING: + return field.default_factory() + else: + raise ValueError( + f"Missing value for environment variable {field.name} and no default value found" + ) + + +# TODO: Change all interpret_.* signatures to value: str, field: dataclasses.Field once we migrate rx.Config to dataclasses +def interpret_boolean_env(value: str, field_name: str) -> bool: + """Interpret a boolean environment variable value. + + Args: + value: The environment variable value. + field_name: The field name. + + Returns: + The interpreted value. + + Raises: + EnvironmentVarValueError: If the value is invalid. + """ + true_values = ["true", "1", "yes", "y"] + false_values = ["false", "0", "no", "n"] + + if value.lower() in true_values: + return True + elif value.lower() in false_values: + return False + raise EnvironmentVarValueError(f"Invalid boolean value: {value} for {field_name}") + + +def interpret_int_env(value: str, field_name: str) -> int: + """Interpret an integer environment variable value. + + Args: + value: The environment variable value. + field_name: The field name. + + Returns: + The interpreted value. + + Raises: + EnvironmentVarValueError: If the value is invalid. + """ + try: + return int(value) + except ValueError as ve: + raise EnvironmentVarValueError( + f"Invalid integer value: {value} for {field_name}" + ) from ve + + +def interpret_existing_path_env(value: str, field_name: str) -> ExistingPath: + """Interpret a path environment variable value as an existing path. + + Args: + value: The environment variable value. + field_name: The field name. + + Returns: + The interpreted value. + + Raises: + EnvironmentVarValueError: If the path does not exist. + """ + path = Path(value) + if not path.exists(): + raise EnvironmentVarValueError(f"Path does not exist: {path} for {field_name}") + return path + + +def interpret_path_env(value: str, field_name: str) -> Path: + """Interpret a path environment variable value. + + Args: + value: The environment variable value. + field_name: The field name. + + Returns: + The interpreted value. + """ + return Path(value) + + +def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any: + """Interpret an enum environment variable value. + + Args: + value: The environment variable value. + field_type: The field type. + field_name: The field name. + + Returns: + The interpreted value. + + Raises: + EnvironmentVarValueError: If the value is invalid. + """ + try: + return field_type(value) + except ValueError as ve: + raise EnvironmentVarValueError( + f"Invalid enum value: {value} for {field_name}" + ) from ve + + +def interpret_env_var_value( + value: str, field_type: GenericType, field_name: str +) -> Any: + """Interpret an environment variable value based on the field type. + + Args: + value: The environment variable value. + field_type: The field type. + field_name: The field name. + + Returns: + The interpreted value. + + Raises: + ValueError: If the value is invalid. + """ + field_type = value_inside_optional(field_type) + + if is_union(field_type): + raise ValueError( + f"Union types are not supported for environment variables: {field_name}." + ) + + if field_type is bool: + return interpret_boolean_env(value, field_name) + elif field_type is str: + return value + elif field_type is int: + return interpret_int_env(value, field_name) + elif field_type is Path: + return interpret_path_env(value, field_name) + elif field_type is ExistingPath: + return interpret_existing_path_env(value, field_name) + elif inspect.isclass(field_type) and issubclass(field_type, enum.Enum): + return interpret_enum_env(value, field_type, field_name) + + else: + raise ValueError( + f"Invalid type for environment variable {field_name}: {field_type}. This is probably an issue in Reflex." + ) + + +class PathExistsFlag: + """Flag to indicate that a path must exist.""" + + +ExistingPath = Annotated[Path, PathExistsFlag] + + +@dataclasses.dataclass(init=False) +class EnvironmentVariables: + """Environment variables class to instantiate environment variables.""" + + # Whether to use npm over bun to install frontend packages. + REFLEX_USE_NPM: bool = False + + # The npm registry to use. + NPM_CONFIG_REGISTRY: Optional[str] = None + + # Whether to use Granian for the backend. Otherwise, use Uvicorn. + REFLEX_USE_GRANIAN: bool = False + + # The username to use for authentication on python package repository. Username and password must both be provided. + TWINE_USERNAME: Optional[str] = None + + # The password to use for authentication on python package repository. Username and password must both be provided. + TWINE_PASSWORD: Optional[str] = None + + # Whether to use the system installed bun. If set to false, bun will be bundled with the app. + REFLEX_USE_SYSTEM_BUN: bool = False + + # Whether to use the system installed node and npm. If set to false, node and npm will be bundled with the app. + REFLEX_USE_SYSTEM_NODE: bool = False + + # The working directory for the next.js commands. + REFLEX_WEB_WORKDIR: Path = Path(constants.Dirs.WEB) + + # Path to the alembic config file + ALEMBIC_CONFIG: ExistingPath = Path(constants.ALEMBIC_CONFIG) + + # Disable SSL verification for HTTPX requests. + SSL_NO_VERIFY: bool = False + + # The directory to store uploaded files. + REFLEX_UPLOADED_FILES_DIR: Path = Path(constants.Dirs.UPLOADED_FILES) + + # Whether to use seperate processes to compile the frontend and how many. If not set, defaults to thread executor. + REFLEX_COMPILE_PROCESSES: Optional[int] = None + + # Whether to use seperate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`. + REFLEX_COMPILE_THREADS: Optional[int] = None + + # The directory to store reflex dependencies. + REFLEX_DIR: Path = Path(constants.Reflex.DIR) + + # Whether to print the SQL queries if the log level is INFO or lower. + SQLALCHEMY_ECHO: bool = False + + # Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration. + REFLEX_IGNORE_REDIS_CONFIG_ERROR: bool = False + + # Whether to skip purging the web directory in dev mode. + REFLEX_PERSIST_WEB_DIR: bool = False + + # The reflex.build frontend host. + REFLEX_BUILD_FRONTEND: str = constants.Templates.REFLEX_BUILD_FRONTEND + + # The reflex.build backend host. + REFLEX_BUILD_BACKEND: str = constants.Templates.REFLEX_BUILD_BACKEND + + def __init__(self): + """Initialize the environment variables.""" + type_hints = get_type_hints(type(self)) + + for field in dataclasses.fields(self): + raw_value = os.getenv(field.name, None) + + field.type = type_hints.get(field.name) or field.type + + value = ( + interpret_env_var_value(raw_value, field.type, field.name) + if raw_value is not None + else get_default_value_for_field(field) + ) + + setattr(self, field.name, value) + + +environment = EnvironmentVariables() + + class Config(Base): """The config defines runtime settings for the app. @@ -158,16 +419,16 @@ class Config(Base): app_name: str # The log level to use. - loglevel: constants.LogLevel = constants.LogLevel.INFO + loglevel: constants.LogLevel = constants.LogLevel.DEFAULT # The port to run the frontend on. NOTE: When running in dev mode, the next available port will be used if this is taken. - frontend_port: int = 3000 + frontend_port: int = constants.DefaultPorts.FRONTEND_PORT # The path to run the frontend on. For example, "/app" will run the frontend on http://localhost:3000/app frontend_path: str = "" # The port to run the backend on. NOTE: When running in dev mode, the next available port will be used if this is taken. - backend_port: int = 8000 + backend_port: int = constants.DefaultPorts.BACKEND_PORT # The backend url the frontend will connect to. This must be updated if the backend is hosted elsewhere, or in production. api_url: str = f"http://localhost:{backend_port}" @@ -188,13 +449,16 @@ class Config(Base): telemetry_enabled: bool = True # The bun path - bun_path: str = constants.Bun.DEFAULT_PATH + bun_path: ExistingPath = constants.Bun.DEFAULT_PATH + + # Timeout to do a production build of a frontend page. + static_page_generation_timeout: int = 60 # List of origins that are allowed to connect to the backend API. cors_allowed_origins: List[str] = ["*"] # Tailwind config. - tailwind: Optional[Dict[str, Any]] = {} + tailwind: Optional[Dict[str, Any]] = {"plugins": ["@tailwindcss/typography"]} # Timeout when launching the gunicorn server. TODO(rename this to backend_timeout?) timeout: int = 120 @@ -202,6 +466,9 @@ class Config(Base): # Whether to enable or disable nextJS gzip compression. next_compression: bool = True + # Whether to use React strict mode in nextJS + react_strict_mode: bool = True + # Additional frontend packages to install. frontend_packages: List[str] = [] @@ -213,15 +480,39 @@ class Config(Base): # The worker class used in production mode gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker" + # Number of gunicorn workers from user + gunicorn_workers: Optional[int] = None + + # Number of requests before a worker is restarted + gunicorn_max_requests: int = 100 + + # Variance limit for max requests; gunicorn only + gunicorn_max_requests_jitter: int = 25 + + # Indicate which type of state manager to use + state_manager_mode: constants.StateManagerMode = constants.StateManagerMode.DISK + + # Maximum expiration lock time for redis state manager + redis_lock_expiration: int = constants.Expiration.LOCK + + # Token expiration time for redis state manager + redis_token_expiration: int = constants.Expiration.TOKEN + # Attributes that were explicitly set by the user. _non_default_attributes: Set[str] = pydantic.PrivateAttr(set()) + # Path to file containing key-values pairs to override in the environment; Dotenv format. + env_file: Optional[str] = None + def __init__(self, *args, **kwargs): """Initialize the config values. Args: *args: The args to pass to the Pydantic init method. **kwargs: The kwargs to pass to the Pydantic init method. + + Raises: + ConfigError: If some values in the config are invalid. """ super().__init__(*args, **kwargs) @@ -235,6 +526,14 @@ class Config(Base): self._non_default_attributes.update(kwargs) self._replace_defaults(**kwargs) + if ( + self.state_manager_mode == constants.StateManagerMode.REDIS + and not self.redis_url + ): + raise ConfigError( + "REDIS_URL is required when using the redis state manager." + ) + @property def module(self) -> str: """Get the module name of the app. @@ -246,14 +545,21 @@ class Config(Base): def update_from_env(self) -> dict[str, Any]: """Update the config values based on set environment variables. + If there is a set env_file, it is loaded first. Returns: The updated config values. - - Raises: - EnvVarValueError: If an environment variable is set to an invalid type. """ - from reflex.utils.exceptions import EnvVarValueError + if self.env_file: + try: + from dotenv import load_dotenv # type: ignore + + # load env file if exists + load_dotenv(self.env_file, override=True) + except ImportError: + console.error( + """The `python-dotenv` package is required to load environment variables from a file. Run `pip install "python-dotenv>=1.0.1"`.""" + ) updated_values = {} # Iterate over the fields. @@ -265,24 +571,15 @@ class Config(Base): if env_var is not None: if key.upper() != "DB_URL": console.info( - f"Overriding config value {key} with env var {key.upper()}={env_var}" + f"Overriding config value {key} with env var {key.upper()}={env_var}", + dedupe=True, ) - # Convert the env var to the expected type. - try: - if issubclass(field.type_, bool): - # special handling for bool values - env_var = env_var.lower() in ["true", "1", "yes"] - else: - env_var = field.type_(env_var) - except ValueError as ve: - console.error( - f"Could not convert {key.upper()}={env_var} to type {field.type_}" - ) - raise EnvVarValueError from ve + # Interpret the value. + value = interpret_env_var_value(env_var, field.outer_type_, field.name) # Set the value. - updated_values[key] = env_var + updated_values[key] = value return updated_values @@ -310,17 +607,22 @@ class Config(Base): ): self.deploy_url = f"http://localhost:{kwargs['frontend_port']}" - # If running in Github Codespaces, override API_URL - codespace_name = os.getenv("CODESPACE_NAME") - if "api_url" not in self._non_default_attributes and codespace_name: + if "api_url" not in self._non_default_attributes: + # If running in Github Codespaces, override API_URL + codespace_name = os.getenv("CODESPACE_NAME") GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN = os.getenv( "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" ) - if codespace_name: + # If running on Replit.com interactively, override API_URL to ensure we maintain the backend_port + replit_dev_domain = os.getenv("REPLIT_DEV_DOMAIN") + backend_port = kwargs.get("backend_port", self.backend_port) + if codespace_name and GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN: self.api_url = ( f"https://{codespace_name}-{kwargs.get('backend_port', self.backend_port)}" f".{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" ) + elif replit_dev_domain and backend_port: + self.api_url = f"https://{replit_dev_domain}:{backend_port}" def _set_persistent(self, **kwargs): """Set values in this config and in the environment so they persist into subprocess. @@ -346,11 +648,14 @@ def get_config(reload: bool = False) -> Config: The app config. """ sys.path.insert(0, os.getcwd()) - try: - rxconfig = __import__(constants.Config.MODULE) - if reload: - importlib.reload(rxconfig) - return rxconfig.config - - except ImportError: - return Config(app_name="") # type: ignore + # only import the module if it exists. If a module spec exists then + # the module exists. + spec = importlib.util.find_spec(constants.Config.MODULE) # type: ignore + if not spec: + # we need this condition to ensure that a ModuleNotFound error is not thrown when + # running unit/integration tests. + return Config(app_name="") + rxconfig = importlib.import_module(constants.Config.MODULE) + if reload: + importlib.reload(rxconfig) + return rxconfig.config diff --git a/reflex/config.pyi b/reflex/config.pyi deleted file mode 100644 index 57ce1123d..000000000 --- a/reflex/config.pyi +++ /dev/null @@ -1,110 +0,0 @@ -""" Generated with stubgen from mypy, then manually edited, do not regen.""" - -from reflex import constants as constants -from reflex.base import Base as Base -from reflex.utils import console as console -from typing import Any, Dict, List, Optional, overload - -class DBConfig(Base): - engine: str - username: Optional[str] - password: Optional[str] - host: Optional[str] - port: Optional[int] - database: str - - def __init__( - self, - database: str, - engine: str, - username: Optional[str] = None, - password: Optional[str] = None, - host: Optional[str] = None, - port: Optional[int] = None, - ): ... - @classmethod - def postgresql( - cls, - database: str, - username: str, - password: str | None = ..., - host: str | None = ..., - port: int | None = ..., - ) -> DBConfig: ... - @classmethod - def postgresql_psycopg2( - cls, - database: str, - username: str, - password: str | None = ..., - host: str | None = ..., - port: int | None = ..., - ) -> DBConfig: ... - @classmethod - def sqlite(cls, database: str) -> DBConfig: ... - def get_url(self) -> str: ... - -class Config(Base): - class Config: - validate_assignment: bool - app_name: str - loglevel: constants.LogLevel - frontend_port: int - frontend_path: str - backend_port: int - api_url: str - deploy_url: Optional[str] - backend_host: str - db_url: Optional[str] - redis_url: Optional[str] - telemetry_enabled: bool - bun_path: str - cors_allowed_origins: List[str] - tailwind: Optional[Dict[str, Any]] - timeout: int - next_compression: bool - event_namespace: Optional[str] - frontend_packages: List[str] - rxdeploy_url: Optional[str] - cp_backend_url: str - cp_web_url: str - username: Optional[str] - gunicorn_worker_class: str - - def __init__( - self, - *args, - app_name: str, - loglevel: Optional[constants.LogLevel] = None, - frontend_port: Optional[int] = None, - frontend_path: Optional[str] = None, - backend_port: Optional[int] = None, - api_url: Optional[str] = None, - deploy_url: Optional[str] = None, - backend_host: Optional[str] = None, - db_url: Optional[str] = None, - redis_url: Optional[str] = None, - telemetry_enabled: Optional[bool] = None, - bun_path: Optional[str] = None, - cors_allowed_origins: Optional[List[str]] = None, - tailwind: Optional[Dict[str, Any]] = None, - timeout: Optional[int] = None, - next_compression: Optional[bool] = None, - event_namespace: Optional[str] = None, - frontend_packages: Optional[List[str]] = None, - rxdeploy_url: Optional[str] = None, - cp_backend_url: Optional[str] = None, - cp_web_url: Optional[str] = None, - username: Optional[str] = None, - gunicorn_worker_class: Optional[str] = None, - **kwargs - ) -> None: ... - @property - def module(self) -> str: ... - @staticmethod - def check_deprecated_values(**kwargs) -> None: ... - def update_from_env(self) -> None: ... - def get_event_namespace(self) -> str: ... - def _set_persistent(self, **kwargs) -> None: ... - -def get_config(reload: bool = ...) -> Config: ... diff --git a/reflex/constants/__init__.py b/reflex/constants/__init__.py index 1f3325a8a..a540805b5 100644 --- a/reflex/constants/__init__.py +++ b/reflex/constants/__init__.py @@ -2,6 +2,8 @@ from .base import ( COOKIES, + ENV_BACKEND_ONLY_ENV_VAR, + ENV_FRONTEND_ONLY_ENV_VAR, ENV_MODE_ENV_VAR, IS_WINDOWS, LOCAL_STORAGE, @@ -10,6 +12,7 @@ from .base import ( REFLEX_VAR_CLOSING_TAG, REFLEX_VAR_OPENING_TAG, RELOAD_CONFIG, + SESSION_STORAGE, SKIP_COMPILE_ENV_VAR, ColorMode, Dirs, @@ -35,8 +38,8 @@ from .compiler import ( ) from .config import ( ALEMBIC_CONFIG, - PRODUCTION_BACKEND_URL, Config, + DefaultPorts, Expiration, GitIgnore, RequirementsTxt, @@ -62,7 +65,8 @@ from .route import ( RouteRegex, RouteVar, ) -from .style import STYLES_DIR, Tailwind +from .state import StateManagerMode +from .style import Tailwind __ALL__ = [ ALEMBIC_CONFIG, @@ -73,6 +77,7 @@ __ALL__ = [ ComponentName, CustomComponents, DefaultPage, + DefaultPorts, Dirs, Endpoint, Env, @@ -87,6 +92,7 @@ __ALL__ = [ Imports, IS_WINDOWS, LOCAL_STORAGE, + SESSION_STORAGE, LogLevel, MemoizationDisposition, MemoizationMode, @@ -99,7 +105,6 @@ __ALL__ = [ Ping, POLLING_MAX_HTTP_BUFFER_SIZE, PYTEST_CURRENT_TEST, - PRODUCTION_BACKEND_URL, Reflex, RELOAD_CONFIG, RequirementsTxt, @@ -113,7 +118,7 @@ __ALL__ = [ SETTER_PREFIX, SKIP_COMPILE_ENV_VAR, SocketEvent, - STYLES_DIR, + StateManagerMode, Tailwind, Templates, CompileVars, diff --git a/reflex/constants/base.py b/reflex/constants/base.py index 733859ad4..bba53d625 100644 --- a/reflex/constants/base.py +++ b/reflex/constants/base.py @@ -2,14 +2,16 @@ from __future__ import annotations -import os import platform from enum import Enum from importlib import metadata +from pathlib import Path from types import SimpleNamespace from platformdirs import PlatformDirs +from .utils import classproperty + IS_WINDOWS = platform.system() == "Windows" @@ -19,32 +21,36 @@ class Dirs(SimpleNamespace): # The frontend directories in a project. # The web folder where the NextJS app is compiled to. WEB = ".web" + # The directory where uploaded files are stored. + UPLOADED_FILES = "uploaded_files" # The name of the assets directory. APP_ASSETS = "assets" + # The name of the assets directory for external ressource (a subfolder of APP_ASSETS). + EXTERNAL_APP_ASSETS = "external" # The name of the utils file. UTILS = "utils" - # The name of the output static directory. - STATIC = "_static" # The name of the state file. STATE_PATH = "/".join([UTILS, "state"]) # The name of the components file. COMPONENTS_PATH = "/".join([UTILS, "components"]) # The name of the contexts file. CONTEXTS_PATH = "/".join([UTILS, "context"]) - # The directory where the app pages are compiled to. - WEB_PAGES = os.path.join(WEB, "pages") - # The directory where the static build is located. - WEB_STATIC = os.path.join(WEB, STATIC) - # The directory where the utils file is located. - WEB_UTILS = os.path.join(WEB, UTILS) - # The directory where the assets are located. - WEB_ASSETS = os.path.join(WEB, "public") - # The env json file. - ENV_JSON = os.path.join(WEB, "env.json") - # The reflex json file. - REFLEX_JSON = os.path.join(WEB, "reflex.json") - # The path to postcss.config.js - POSTCSS_JS = os.path.join(WEB, "postcss.config.js") + # The name of the output static directory. + STATIC = "_static" + # The name of the public html directory served at "/" + PUBLIC = "public" + # The directory where styles are located. + STYLES = "styles" + # The name of the pages directory. + PAGES = "pages" + # The name of the env json file. + ENV_JSON = "env.json" + # The name of the reflex json file. + 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): @@ -57,25 +63,20 @@ class Reflex(SimpleNamespace): VERSION = metadata.version(MODULE_NAME) # The reflex json file. - JSON = os.path.join(Dirs.WEB, "reflex.json") + JSON = "reflex.json" # Files and directories used to init a new project. # The directory to store reflex dependencies. - # Get directory value from enviroment variables if it exists. - _dir = os.environ.get("REFLEX_DIR", "") + # on windows, we use C:/Users//AppData/Local/reflex. + # on macOS, we use ~/Library/Application Support/reflex. + # on linux, we use ~/.local/share/reflex. + # If user sets REFLEX_DIR envroment variable use that instead. + DIR = PlatformDirs(MODULE_NAME, False).user_data_path - DIR = _dir or ( - # on windows, we use C:/Users//AppData/Local/reflex. - # on macOS, we use ~/Library/Application Support/reflex. - # on linux, we use ~/.local/share/reflex. - # If user sets REFLEX_DIR envroment variable use that instead. - PlatformDirs(MODULE_NAME, False).user_data_dir - ) # The root directory of the reflex library. + ROOT_DIR = Path(__file__).parents[2] - ROOT_DIR = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - ) + RELEASES_URL = f"https://api.github.com/repos/reflex-dev/templates/releases" class ReflexHostingCLI(SimpleNamespace): @@ -94,15 +95,62 @@ class Templates(SimpleNamespace): # The default template DEFAULT = "blank" + # The reflex.build frontend host + REFLEX_BUILD_FRONTEND = "https://flexgen.reflex.run" + + # The reflex.build backend host + REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev" + + @classproperty + @classmethod + def REFLEX_BUILD_URL(cls): + """The URL to redirect to reflex.build. + + Returns: + The URL to redirect to reflex.build. + """ + from reflex.config import environment + + return ( + environment.REFLEX_BUILD_FRONTEND + + "/gen?reflex_init_token={reflex_init_token}" + ) + + @classproperty + @classmethod + def REFLEX_BUILD_POLL_URL(cls): + """The URL to poll waiting for the user to select a generation. + + Returns: + The URL to poll waiting for the user to select a generation. + """ + from reflex.config import environment + + return environment.REFLEX_BUILD_BACKEND + "/api/init/{reflex_init_token}" + + @classproperty + @classmethod + def REFLEX_BUILD_CODE_URL(cls): + """The URL to fetch the generation's reflex code. + + Returns: + The URL to fetch the generation's reflex code. + """ + from reflex.config import environment + + return ( + environment.REFLEX_BUILD_BACKEND + "/api/gen/{generation_hash}/refactored" + ) + class Dirs(SimpleNamespace): """Folders used by the template system of Reflex.""" # The template directory used during reflex init. - BASE = os.path.join(Reflex.ROOT_DIR, Reflex.MODULE_NAME, ".templates") + BASE = Reflex.ROOT_DIR / Reflex.MODULE_NAME / ".templates" # The web subdirectory of the template directory. - WEB_TEMPLATE = os.path.join(BASE, "web") + WEB_TEMPLATE = BASE / "web" # The jinja template directory. - JINJA_TEMPLATE = os.path.join(BASE, "jinja") + JINJA_TEMPLATE = BASE / "jinja" # Where the code for the templates is stored. CODE = "code" @@ -113,7 +161,7 @@ class Next(SimpleNamespace): # The NextJS config file CONFIG_FILE = "next.config.js" # The sitemap config file. - SITEMAP_CONFIG_FILE = os.path.join(Dirs.WEB, "next-sitemap.config.js") + SITEMAP_CONFIG_FILE = "next-sitemap.config.js" # The node modules directory. NODE_MODULES = "node_modules" # The package lock file. @@ -126,9 +174,11 @@ class Next(SimpleNamespace): class ColorMode(SimpleNamespace): """Constants related to ColorMode.""" - NAME = "colorMode" + NAME = "rawColorMode" + RESOLVED_NAME = "resolvedColorMode" USE = "useColorMode" TOGGLE = "toggleColorMode" + SET = "setColorMode" # Env modes @@ -144,6 +194,7 @@ class LogLevel(str, Enum): """The log levels.""" DEBUG = "debug" + DEFAULT = "default" INFO = "info" WARNING = "warning" ERROR = "error" @@ -161,6 +212,14 @@ class LogLevel(str, Enum): levels = list(LogLevel) return levels.index(self) <= levels.index(other) + def subprocess_level(self): + """Return the log level for the subprocess. + + Returns: + The log level for the subprocess + """ + return self if self != LogLevel.DEFAULT else LogLevel.WARNING + # Server socket configuration variables POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000 @@ -178,6 +237,7 @@ class Ping(SimpleNamespace): # Keys in the client_side_storage dict COOKIES = "cookies" LOCAL_STORAGE = "local_storage" +SESSION_STORAGE = "session_storage" # If this env var is set to "yes", App.compile will be a no-op SKIP_COMPILE_ENV_VAR = "__REFLEX_SKIP_COMPILE" @@ -185,6 +245,9 @@ SKIP_COMPILE_ENV_VAR = "__REFLEX_SKIP_COMPILE" # This env var stores the execution mode of the app ENV_MODE_ENV_VAR = "REFLEX_ENV_MODE" +ENV_BACKEND_ONLY_ENV_VAR = "REFLEX_BACKEND_ONLY" +ENV_FRONTEND_ONLY_ENV_VAR = "REFLEX_FRONTEND_ONLY" + # Testing variables. # Testing os env set by pytest when running a test case. PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST" diff --git a/reflex/constants/base.pyi b/reflex/constants/base.pyi deleted file mode 100644 index 90804a080..000000000 --- a/reflex/constants/base.pyi +++ /dev/null @@ -1,94 +0,0 @@ -"""Stub file for reflex/constants/base.py""" -# ------------------- DO NOT EDIT ---------------------- -# This file was generated by `reflex/utils/pyi_generator.py`! -# ------------------------------------------------------ - -from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.vars import Var, BaseVar, ComputedVar -from reflex.event import EventChain, EventHandler, EventSpec -from reflex.style import Style -import os -import platform -from enum import Enum -from importlib import metadata -from types import SimpleNamespace -from platformdirs import PlatformDirs - -IS_WINDOWS = platform.system() == "Windows" - -class Dirs(SimpleNamespace): - WEB = ".web" - APP_ASSETS = "assets" - UTILS = "utils" - STATIC = "_static" - STATE_PATH = "/".join([UTILS, "state"]) - COMPONENTS_PATH = "/".join([UTILS, "components"]) - CONTEXTS_PATH = "/".join([UTILS, "context"]) - WEB_PAGES = os.path.join(WEB, "pages") - WEB_STATIC = os.path.join(WEB, STATIC) - WEB_UTILS = os.path.join(WEB, UTILS) - WEB_ASSETS = os.path.join(WEB, "public") - ENV_JSON = os.path.join(WEB, "env.json") - REFLEX_JSON = os.path.join(WEB, "reflex.json") - POSTCSS_JS = os.path.join(WEB, "postcss.config.js") - -class Reflex(SimpleNamespace): - MODULE_NAME = "reflex" - VERSION = metadata.version(MODULE_NAME) - JSON = os.path.join(Dirs.WEB, "reflex.json") - _dir = os.environ.get("REFLEX_DIR", "") - DIR = _dir or PlatformDirs(MODULE_NAME, False).user_data_dir - ROOT_DIR = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - ) - -class ReflexHostingCLI(SimpleNamespace): - MODULE_NAME = "reflex-hosting-cli" - -class Templates(SimpleNamespace): - APP_TEMPLATES_ROUTE = "/app-templates" - DEFAULT = "blank" - - class Dirs(SimpleNamespace): - BASE = os.path.join(Reflex.ROOT_DIR, Reflex.MODULE_NAME, ".templates") - WEB_TEMPLATE = os.path.join(BASE, "web") - JINJA_TEMPLATE = os.path.join(BASE, "jinja") - CODE = "code" - -class Next(SimpleNamespace): - CONFIG_FILE = "next.config.js" - SITEMAP_CONFIG_FILE = os.path.join(Dirs.WEB, "next-sitemap.config.js") - NODE_MODULES = "node_modules" - PACKAGE_LOCK = "package-lock.json" - FRONTEND_LISTENING_REGEX = "Local:[\\s]+(.*)" - -class ColorMode(SimpleNamespace): - NAME = "colorMode" - USE = "useColorMode" - TOGGLE = "toggleColorMode" - -class Env(str, Enum): - DEV = "dev" - PROD = "prod" - -class LogLevel(str, Enum): - DEBUG = "debug" - INFO = "info" - WARNING = "warning" - ERROR = "error" - CRITICAL = "critical" - -POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000 - -class Ping(SimpleNamespace): - INTERVAL = 25 - TIMEOUT = 120 - -COOKIES = "cookies" -LOCAL_STORAGE = "local_storage" -SKIP_COMPILE_ENV_VAR = "__REFLEX_SKIP_COMPILE" -ENV_MODE_ENV_VAR = "REFLEX_ENV_MODE" -PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST" -RELOAD_CONFIG = "__REFLEX_RELOAD_CONFIG" -REFLEX_VAR_OPENING_TAG = "" -REFLEX_VAR_CLOSING_TAG = "" diff --git a/reflex/constants/colors.py b/reflex/constants/colors.py index ddd093f25..60942c775 100644 --- a/reflex/constants/colors.py +++ b/reflex/constants/colors.py @@ -35,7 +35,6 @@ ColorType = Literal[ "amber", "gold", "bronze", - "gray", "accent", "black", "white", diff --git a/reflex/constants/compiler.py b/reflex/constants/compiler.py index b99e31e8c..b7ffef161 100644 --- a/reflex/constants/compiler.py +++ b/reflex/constants/compiler.py @@ -12,7 +12,7 @@ from reflex.utils.imports import ImportVar SETTER_PREFIX = "set_" # The file used to specify no compilation. -NOCOMPILE_FILE = ".web/nocompile" +NOCOMPILE_FILE = "nocompile" class Ext(SimpleNamespace): @@ -62,9 +62,17 @@ class CompileVars(SimpleNamespace): # The name of the function for converting a dict to an event. TO_EVENT = "Event" # The name of the internal on_load event. - ON_LOAD_INTERNAL = "on_load_internal_state.on_load_internal" + ON_LOAD_INTERNAL = "reflex___state____on_load_internal_state.on_load_internal" # The name of the internal event to update generic state vars. - UPDATE_VARS_INTERNAL = "update_vars_internal_state.update_vars_internal" + UPDATE_VARS_INTERNAL = ( + "reflex___state____update_vars_internal_state.update_vars_internal" + ) + # The name of the frontend event exception state + FRONTEND_EXCEPTION_STATE = "reflex___state____frontend_event_exception_state" + # The full name of the frontend exception state + FRONTEND_EXCEPTION_STATE_FULL = ( + f"reflex___state____state.{FRONTEND_EXCEPTION_STATE}" + ) class PageNames(SimpleNamespace): @@ -80,6 +88,8 @@ class PageNames(SimpleNamespace): DOCUMENT_ROOT = "_document" # The name of the theme page. THEME = "theme" + # The module containing components. + COMPONENTS = "components" # The module containing shared stateful components STATEFUL_COMPONENTS = "stateful_components" @@ -103,9 +113,9 @@ class Imports(SimpleNamespace): """Common sets of import vars.""" EVENTS = { - "react": {ImportVar(tag="useContext")}, - f"/{Dirs.CONTEXTS_PATH}": {ImportVar(tag="EventLoopContext")}, - f"/{Dirs.STATE_PATH}": {ImportVar(tag=CompileVars.TO_EVENT)}, + "react": [ImportVar(tag="useContext")], + f"$/{Dirs.CONTEXTS_PATH}": [ImportVar(tag="EventLoopContext")], + f"$/{Dirs.STATE_PATH}": [ImportVar(tag=CompileVars.TO_EVENT)], } @@ -140,3 +150,28 @@ class MemoizationMode(Base): # Whether children of this component should be memoized first. recursive: bool = True + + +class SpecialAttributes(enum.Enum): + """Special attributes for components. + + These are placed in custom_attrs and rendered as-is rather than converting + to a style prop. + """ + + DATA_UNDERSCORE = "data_" + DATA_DASH = "data-" + ARIA_UNDERSCORE = "aria_" + ARIA_DASH = "aria-" + + @classmethod + def is_special(cls, attr: str) -> bool: + """Check if the attribute is special. + + Args: + attr: the attribute to check + + Returns: + True if the attribute is special. + """ + return any(attr.startswith(value.value) for value in cls) diff --git a/reflex/constants/config.py b/reflex/constants/config.py index 298934202..970e67844 100644 --- a/reflex/constants/config.py +++ b/reflex/constants/config.py @@ -1,5 +1,6 @@ """Config constants.""" -import os + +from pathlib import Path from types import SimpleNamespace from reflex.constants.base import Dirs, Reflex @@ -7,7 +8,7 @@ from reflex.constants.base import Dirs, Reflex from .compiler import Ext # Alembic migrations -ALEMBIC_CONFIG = os.environ.get("ALEMBIC_CONFIG", "alembic.ini") +ALEMBIC_CONFIG = "alembic.ini" class Config(SimpleNamespace): @@ -16,9 +17,7 @@ class Config(SimpleNamespace): # The name of the reflex config module. MODULE = "rxconfig" # The python config file. - FILE = f"{MODULE}{Ext.PY}" - # The previous config file. - PREVIOUS_FILE = f"pcconfig{Ext.PY}" + FILE = Path(f"{MODULE}{Ext.PY}") class Expiration(SimpleNamespace): @@ -36,9 +35,9 @@ class GitIgnore(SimpleNamespace): """Gitignore constants.""" # The gitignore file. - FILE = ".gitignore" + FILE = Path(".gitignore") # Files to gitignore. - DEFAULTS = {Dirs.WEB, "*.db", "__pycache__/", "*.py[cod]"} + DEFAULTS = {Dirs.WEB, "*.db", "__pycache__/", "*.py[cod]", "assets/external/"} class RequirementsTxt(SimpleNamespace): @@ -50,5 +49,12 @@ class RequirementsTxt(SimpleNamespace): DEFAULTS_STUB = f"{Reflex.MODULE_NAME}==" +class DefaultPorts(SimpleNamespace): + """Default port constants.""" + + FRONTEND_PORT = 3000 + BACKEND_PORT = 8000 + + # The deployment URL. PRODUCTION_BACKEND_URL = "https://{username}-{app_name}.api.pynecone.app" diff --git a/reflex/constants/custom_components.py b/reflex/constants/custom_components.py index 3ea9cf6ed..d879a01f2 100644 --- a/reflex/constants/custom_components.py +++ b/reflex/constants/custom_components.py @@ -2,6 +2,7 @@ from __future__ import annotations +from pathlib import Path from types import SimpleNamespace @@ -11,9 +12,9 @@ class CustomComponents(SimpleNamespace): # The name of the custom components source directory. SRC_DIR = "custom_components" # The name of the custom components pyproject.toml file. - PYPROJECT_TOML = "pyproject.toml" + PYPROJECT_TOML = Path("pyproject.toml") # The name of the custom components package README file. - PACKAGE_README = "README.md" + PACKAGE_README = Path("README.md") # The name of the custom components package .gitignore file. PACKAGE_GITIGNORE = ".gitignore" # The name of the distribution directory as result of a build. @@ -29,6 +30,6 @@ class CustomComponents(SimpleNamespace): "testpypi": "https://test.pypi.org/legacy/", } # The .gitignore file for the custom component project. - FILE = ".gitignore" + FILE = Path(".gitignore") # Files to gitignore. DEFAULTS = {"__pycache__/", "*.py[cod]", "*.egg-info/", "dist/"} diff --git a/reflex/constants/event.py b/reflex/constants/event.py index aa6f8c713..d454e6ea8 100644 --- a/reflex/constants/event.py +++ b/reflex/constants/event.py @@ -1,4 +1,5 @@ """Event-related constants.""" + from enum import Enum from types import SimpleNamespace @@ -9,6 +10,8 @@ class Endpoint(Enum): PING = "ping" EVENT = "_event" UPLOAD = "_upload" + AUTH_CODESPACE = "auth-codespace" + HEALTH = "_health" def __str__(self) -> str: """Get the string representation of the endpoint. @@ -93,3 +96,5 @@ class EventTriggers(SimpleNamespace): ON_CLEAR_SERVER_ERRORS = "on_clear_server_errors" ON_VALUE_COMMIT = "on_value_commit" ON_SELECT = "on_select" + ON_ANIMATION_START = "on_animation_start" + ON_ANIMATION_END = "on_animation_end" diff --git a/reflex/constants/installer.py b/reflex/constants/installer.py index 5bf9b365e..f720218e3 100644 --- a/reflex/constants/installer.py +++ b/reflex/constants/installer.py @@ -1,11 +1,13 @@ """File for constants related to the installation process. (Bun/FNM/Node).""" + from __future__ import annotations -import os import platform +from pathlib import Path from types import SimpleNamespace -from .base import IS_WINDOWS, Dirs, Reflex +from .base import IS_WINDOWS +from .utils import classproperty def get_fnm_name() -> str | None: @@ -35,22 +37,44 @@ class Bun(SimpleNamespace): """Bun constants.""" # The Bun version. - VERSION = "1.1.6" + VERSION = "1.1.29" + # Min Bun Version MIN_VERSION = "0.7.0" - # The directory to store the bun. - ROOT_PATH = os.path.join(Reflex.DIR, "bun") - # Default bun path. - DEFAULT_PATH = os.path.join( - ROOT_PATH, "bin", "bun" if not IS_WINDOWS else "bun.exe" - ) + # URL to bun install script. - INSTALL_URL = "https://bun.sh/install" + INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/bun_install.sh" + # URL to windows install script. WINDOWS_INSTALL_URL = ( "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/install.ps1" ) + # Path of the bunfig file + CONFIG_PATH = "bunfig.toml" + + @classproperty + @classmethod + def ROOT_PATH(cls): + """The directory to store the bun. + + Returns: + The directory to store the bun. + """ + from reflex.config import environment + + return environment.REFLEX_DIR / "bun" + + @classproperty + @classmethod + def DEFAULT_PATH(cls): + """Default bun path. + + Returns: + The default bun path. + """ + return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe") + # FNM config. class Fnm(SimpleNamespace): @@ -58,40 +82,81 @@ class Fnm(SimpleNamespace): # The FNM version. VERSION = "1.35.1" - # The directory to store fnm. - DIR = os.path.join(Reflex.DIR, "fnm") + FILENAME = get_fnm_name() - # The fnm executable binary. - EXE = os.path.join(DIR, "fnm.exe" if IS_WINDOWS else "fnm") # The URL to the fnm release binary INSTALL_URL = ( f"https://github.com/Schniz/fnm/releases/download/v{VERSION}/{FILENAME}.zip" ) + @classproperty + @classmethod + def DIR(cls) -> Path: + """The directory to store fnm. + + Returns: + The directory to store fnm. + """ + from reflex.config import environment + + return environment.REFLEX_DIR / "fnm" + + @classproperty + @classmethod + def EXE(cls): + """The fnm executable binary. + + Returns: + The fnm executable binary. + """ + return cls.DIR / ("fnm.exe" if IS_WINDOWS else "fnm") + # Node / NPM config class Node(SimpleNamespace): """Node/ NPM constants.""" # The Node version. - VERSION = "18.17.0" + VERSION = "22.11.0" # The minimum required node version. - MIN_VERSION = "18.17.0" + MIN_VERSION = "18.18.0" - # The node bin path. - BIN_PATH = os.path.join( - Fnm.DIR, - "node-versions", - f"v{VERSION}", - "installation", - "bin" if not IS_WINDOWS else "", - ) - # The default path where node is installed. - PATH = os.path.join(BIN_PATH, "node.exe" if IS_WINDOWS else "node") + @classproperty + @classmethod + def BIN_PATH(cls): + """The node bin path. - # The default path where npm is installed. - NPM_PATH = os.path.join(BIN_PATH, "npm") + Returns: + The node bin path. + """ + return ( + Fnm.DIR + / "node-versions" + / f"v{cls.VERSION}" + / "installation" + / ("bin" if not IS_WINDOWS else "") + ) + + @classproperty + @classmethod + def PATH(cls): + """The default path where node is installed. + + Returns: + The default path where node is installed. + """ + return cls.BIN_PATH / ("node.exe" if IS_WINDOWS else "node") + + @classproperty + @classmethod + def NPM_PATH(cls): + """The default path where npm is installed. + + Returns: + The default path where npm is installed. + """ + return cls.BIN_PATH / "npm" class PackageJson(SimpleNamespace): @@ -105,22 +170,24 @@ class PackageJson(SimpleNamespace): EXPORT_SITEMAP = "next build && next-sitemap" PROD = "next start" - PATH = os.path.join(Dirs.WEB, "package.json") + PATH = "package.json" DEPENDENCIES = { - "@emotion/react": "11.11.1", - "axios": "1.6.0", + "@babel/standalone": "7.26.0", + "@emotion/react": "11.13.3", + "axios": "1.7.7", "json5": "2.2.3", - "next": "14.0.1", - "next-sitemap": "4.1.8", - "next-themes": "0.2.1", - "react": "18.2.0", - "react-dom": "18.2.0", - "react-focus-lock": "2.11.3", - "socket.io-client": "4.6.1", - "universal-cookie": "4.0.4", + "next": "15.0.1", + "next-sitemap": "4.2.3", + "next-themes": "0.3.0", + "react": "18.3.1", + "react-dom": "18.3.1", + "react-focus-lock": "2.13.2", + "socket.io-client": "4.8.1", + "universal-cookie": "7.2.1", } DEV_DEPENDENCIES = { - "autoprefixer": "10.4.14", - "postcss": "8.4.31", + "autoprefixer": "10.4.20", + "postcss": "8.4.47", + "postcss-import": "16.1.0", } diff --git a/reflex/constants/state.py b/reflex/constants/state.py new file mode 100644 index 000000000..aa0e2f97f --- /dev/null +++ b/reflex/constants/state.py @@ -0,0 +1,11 @@ +"""State-related constants.""" + +from enum import Enum + + +class StateManagerMode(str, Enum): + """State manager constants.""" + + DISK = "disk" + MEMORY = "memory" + REDIS = "redis" diff --git a/reflex/constants/style.py b/reflex/constants/style.py index d0f72995e..403acd4ba 100644 --- a/reflex/constants/style.py +++ b/reflex/constants/style.py @@ -1,22 +1,16 @@ """Style constants.""" -import os from types import SimpleNamespace -from reflex.constants.base import Dirs - -# The directory where styles are located. -STYLES_DIR = os.path.join(Dirs.WEB, "styles") - class Tailwind(SimpleNamespace): """Tailwind constants.""" # The Tailwindcss version - VERSION = "tailwindcss@3.3.2" + VERSION = "tailwindcss@3.4.14" # The Tailwind config. - CONFIG = os.path.join(Dirs.WEB, "tailwind.config.js") + CONFIG = "tailwind.config.js" # Default Tailwind content paths CONTENT = ["./pages/**/*.{js,ts,jsx,tsx}", "./utils/**/*.{js,ts,jsx,tsx}"] - # Relative tailwind style path to root stylesheet in STYLES_DIR. + # Relative tailwind style path to root stylesheet in Dirs.STYLES. ROOT_STYLE_PATH = "./tailwind.css" diff --git a/reflex/constants/utils.py b/reflex/constants/utils.py new file mode 100644 index 000000000..48797afbf --- /dev/null +++ b/reflex/constants/utils.py @@ -0,0 +1,32 @@ +"""Utility functions for constants.""" + +from typing import Any, Callable, Generic, Type + +from typing_extensions import TypeVar + +T = TypeVar("T") +V = TypeVar("V") + + +class classproperty(Generic[T, V]): + """A class property decorator.""" + + def __init__(self, getter: Callable[[Type[T]], V]) -> None: + """Initialize the class property. + + Args: + getter: The getter function. + """ + self.getter = getattr(getter, "__func__", getter) + + def __get__(self, instance: Any, owner: Type[T]) -> V: + """Get the value of the class property. + + Args: + instance: The instance of the class. + owner: The class itself. + + Returns: + The value of the class property. + """ + return self.getter(owner) diff --git a/reflex/custom_components/custom_components.py b/reflex/custom_components/custom_components.py index ec35fb5c4..ddda3de56 100644 --- a/reflex/custom_components/custom_components.py +++ b/reflex/custom_components/custom_components.py @@ -17,7 +17,7 @@ import typer from tomlkit.exceptions import TOMLKitError from reflex import constants -from reflex.config import get_config +from reflex.config import environment, get_config from reflex.constants import CustomComponents from reflex.utils import console @@ -36,7 +36,7 @@ POST_CUSTOM_COMPONENTS_GALLERY_TIMEOUT = 15 @contextmanager -def set_directory(working_directory: str): +def set_directory(working_directory: str | Path): """Context manager that sets the working directory. Args: @@ -45,7 +45,8 @@ def set_directory(working_directory: str): Yields: Yield to the caller to perform operations in the working directory. """ - current_directory = os.getcwd() + current_directory = Path.cwd() + working_directory = Path(working_directory) try: os.chdir(working_directory) yield @@ -62,12 +63,14 @@ def _create_package_config(module_name: str, package_name: str): """ from reflex.compiler import templates - with open(CustomComponents.PYPROJECT_TOML, "w") as f: - f.write( - templates.CUSTOM_COMPONENTS_PYPROJECT_TOML.render( - module_name=module_name, package_name=package_name - ) + pyproject = Path(CustomComponents.PYPROJECT_TOML) + pyproject.write_text( + templates.CUSTOM_COMPONENTS_PYPROJECT_TOML.render( + module_name=module_name, + package_name=package_name, + reflex_version=constants.Reflex.VERSION, ) + ) def _get_package_config(exit_on_fail: bool = True) -> dict: @@ -82,11 +85,11 @@ def _get_package_config(exit_on_fail: bool = True) -> dict: Raises: Exit: If the pyproject.toml file is not found. """ + pyproject = Path(CustomComponents.PYPROJECT_TOML) try: - with open(CustomComponents.PYPROJECT_TOML, "rb") as f: - return dict(tomlkit.load(f)) + return dict(tomlkit.loads(pyproject.read_bytes())) except (OSError, TOMLKitError) as ex: - console.error(f"Unable to read from pyproject.toml due to {ex}") + console.error(f"Unable to read from {pyproject} due to {ex}") if exit_on_fail: raise typer.Exit(code=1) from ex raise @@ -101,17 +104,17 @@ def _create_readme(module_name: str, package_name: str): """ from reflex.compiler import templates - with open(CustomComponents.PACKAGE_README, "w") as f: - f.write( - templates.CUSTOM_COMPONENTS_README.render( - module_name=module_name, - package_name=package_name, - ) + readme = Path(CustomComponents.PACKAGE_README) + readme.write_text( + templates.CUSTOM_COMPONENTS_README.render( + module_name=module_name, + package_name=package_name, ) + ) def _write_source_and_init_py( - custom_component_src_dir: str, + custom_component_src_dir: Path, component_class_name: str, module_name: str, ): @@ -124,27 +127,17 @@ def _write_source_and_init_py( """ from reflex.compiler import templates - with open( - os.path.join( - custom_component_src_dir, - f"{module_name}.py", - ), - "w", - ) as f: - f.write( - templates.CUSTOM_COMPONENTS_SOURCE.render( - component_class_name=component_class_name, module_name=module_name - ) + module_path = custom_component_src_dir / f"{module_name}.py" + module_path.write_text( + templates.CUSTOM_COMPONENTS_SOURCE.render( + component_class_name=component_class_name, module_name=module_name ) + ) - with open( - os.path.join( - custom_component_src_dir, - CustomComponents.INIT_FILE, - ), - "w", - ) as f: - f.write(templates.CUSTOM_COMPONENTS_INIT_FILE.render(module_name=module_name)) + init_path = custom_component_src_dir / CustomComponents.INIT_FILE + init_path.write_text( + templates.CUSTOM_COMPONENTS_INIT_FILE.render(module_name=module_name) + ) def _populate_demo_app(name_variants: NameVariants): @@ -190,7 +183,7 @@ def _get_default_library_name_parts() -> list[str]: Returns: The parts of default library name. """ - current_dir_name = os.getcwd().split(os.path.sep)[-1] + current_dir_name = Path.cwd().name cleaned_dir_name = re.sub("[^0-9a-zA-Z-_]+", "", current_dir_name).lower() parts = [part for part in re.split("-|_", cleaned_dir_name) if part] @@ -267,7 +260,7 @@ def _validate_library_name(library_name: str | None) -> NameVariants: # Module name is the snake case. module_name = "_".join(name_parts) - custom_component_module_dir = f"reflex_{module_name}" + custom_component_module_dir = Path(f"reflex_{module_name}") console.debug(f"Custom component source directory: {custom_component_module_dir}") # Use the same name for the directory and the app. @@ -343,7 +336,7 @@ def init( console.set_log_level(loglevel) - if os.path.exists(CustomComponents.PYPROJECT_TOML): + if CustomComponents.PYPROJECT_TOML.exists(): console.error(f"A {CustomComponents.PYPROJECT_TOML} already exists. Aborting.") typer.Exit(code=1) @@ -616,15 +609,17 @@ def publish( help="The API token to use for authentication on python package repository. If token is provided, no username/password should be provided at the same time", ), username: Optional[str] = typer.Option( - None, + environment.TWINE_USERNAME, "-u", "--username", + show_default="TWINE_USERNAME environment variable value if set", help="The username to use for authentication on python package repository. Username and password must both be provided.", ), password: Optional[str] = typer.Option( - None, + environment.TWINE_PASSWORD, "-p", "--password", + show_default="TWINE_PASSWORD environment variable value if set", help="The password to use for authentication on python package repository. Username and password must both be provided.", ), build: bool = typer.Option( @@ -667,6 +662,9 @@ def publish( # Validate the credentials. username, password = _validate_credentials(username, password, token) + # Minimal Validation of the pyproject.toml. + _min_validate_project_info() + # Get the version to publish from the pyproject.toml. version_to_publish = _get_version_to_publish() @@ -735,6 +733,34 @@ def _process_entered_list(input: str | None) -> list | None: return [t.strip() for t in (input or "").split(",") if t if input] or None +def _min_validate_project_info(): + """Ensures minimal project information in the pyproject.toml file. + + Raises: + Exit: If the pyproject.toml file is ill-formed. + """ + pyproject_toml = _get_package_config() + + project = pyproject_toml.get("project") + if project is None: + console.error( + f"The project section is not found in {CustomComponents.PYPROJECT_TOML}" + ) + raise typer.Exit(code=1) + + if not project.get("name"): + console.error( + f"The project name is not found in {CustomComponents.PYPROJECT_TOML}" + ) + raise typer.Exit(code=1) + + if not project.get("version"): + console.error( + f"The project version is not found in {CustomComponents.PYPROJECT_TOML}" + ) + raise typer.Exit(code=1) + + def _validate_project_info(): """Validate the project information in the pyproject.toml file. @@ -742,18 +768,10 @@ def _validate_project_info(): Exit: If the pyproject.toml file is ill-formed. """ pyproject_toml = _get_package_config() - - try: - project = pyproject_toml.get("project", {}) - if not project: - console.error("The project section not found in pyproject.toml") - raise typer.Exit(code=1) - console.print( - f'Double check the information before publishing: {project["name"]} version {project["version"]}' - ) - except KeyError as ke: - console.error(f"The pyproject.toml is possibly ill-formed due to {ke}") - raise typer.Exit(code=1) from ke + project = pyproject_toml["project"] + console.print( + f'Double check the information before publishing: {project["name"]} version {project["version"]}' + ) console.print("Update or enter to keep the current information.") project["description"] = console.ask( diff --git a/reflex/event.py b/reflex/event.py index e1ae88076..c2e6955f6 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -2,25 +2,51 @@ from __future__ import annotations +import dataclasses import inspect +import sys +import types +import urllib.parse from base64 import b64encode -from types import FunctionType +from functools import partial from typing import ( Any, Callable, Dict, + Generic, List, Optional, + Sequence, Tuple, + Type, + TypeVar, Union, get_type_hints, + overload, ) +from typing_extensions import ParamSpec, Protocol, get_args, get_origin + from reflex import constants -from reflex.base import Base -from reflex.utils import format -from reflex.utils.types import ArgsSpec -from reflex.vars import BaseVar, Var +from reflex.utils import console, format +from reflex.utils.exceptions import ( + EventFnArgMismatch, + EventHandlerArgMismatch, + EventHandlerArgTypeMismatch, +) +from reflex.utils.types import ArgsSpec, GenericType, typehint_issubclass +from reflex.vars import VarData +from reflex.vars.base import ( + LiteralVar, + Var, +) +from reflex.vars.function import ( + ArgsFunctionOperation, + FunctionStringVar, + FunctionVar, + VarOperationCall, +) +from reflex.vars.object import ObjectVar try: from typing import Annotated @@ -28,7 +54,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. @@ -38,10 +68,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: @@ -57,7 +87,7 @@ class Event(Base): BACKGROUND_TASK_MARKER = "_reflex_background_task" -def background(fn): +def background(fn, *, __internal_reflex_call: bool = False): """Decorator to mark event handler as running in the background. Args: @@ -70,17 +100,28 @@ def background(fn): Raises: TypeError: If the function is not a coroutine function or async generator. """ + if not __internal_reflex_call: + console.deprecate( + "background-decorator", + "Use `rx.event(background=True)` instead.", + "0.6.5", + "0.7.0", + ) if not inspect.iscoroutinefunction(fn) and not inspect.isasyncgenfunction(fn): raise TypeError("Background task must be async function or generator.") setattr(fn, BACKGROUND_TASK_MARKER, True) 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): @@ -89,8 +130,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 @@ -100,8 +142,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): @@ -113,8 +156,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): @@ -126,26 +170,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: @@ -186,7 +229,7 @@ class EventHandler(EventActionsMixin): # Get the function args. fn_args = inspect.getfullargspec(self.fn).args[1:] - fn_args = (Var.create_safe(arg) for arg in fn_args) + fn_args = (Var(_js_expr=arg) for arg in fn_args) # Construct the payload. values = [] @@ -197,7 +240,7 @@ class EventHandler(EventActionsMixin): # Otherwise, convert to JSON. try: - values.append(Var.create(arg, _var_is_string=isinstance(arg, str))) + values.append(LiteralVar.create(arg)) except TypeError as e: raise EventHandlerTypeError( f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." @@ -210,6 +253,10 @@ class EventHandler(EventActionsMixin): ) +@dataclasses.dataclass( + init=True, + frozen=True, +) class EventSpec(EventActionsMixin): """An event specification. @@ -218,19 +265,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. @@ -264,13 +327,13 @@ class EventSpec(EventActionsMixin): # Get the remaining unfilled function args. fn_args = inspect.getfullargspec(self.handler.fn).args[1 + len(self.args) :] - fn_args = (Var.create_safe(arg) for arg in fn_args) + fn_args = (Var(_js_expr=arg) for arg in fn_args) # Construct the payload. values = [] for arg in args: try: - values.append(Var.create(arg, _var_is_string=isinstance(arg, str))) + values.append(LiteralVar.create(arg)) except TypeError as e: raise EventHandlerTypeError( f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." @@ -279,6 +342,9 @@ class EventSpec(EventActionsMixin): 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. @@ -298,10 +364,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) @@ -325,42 +394,200 @@ 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: Sequence[Union[EventSpec, EventVar, EventCallback]] = dataclasses.field( + default_factory=list + ) - args_spec: Optional[Callable] + args_spec: Optional[Union[Callable, Sequence[Callable]]] = dataclasses.field( + default=None + ) + + invocation: Optional[Var] = dataclasses.field(default=None) + + +@dataclasses.dataclass( + init=True, + frozen=True, +) +class JavascriptHTMLInputElement: + """Interface for a Javascript HTMLInputElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement.""" + + value: str = "" + + +@dataclasses.dataclass( + init=True, + frozen=True, +) +class JavascriptInputEvent: + """Interface for a Javascript InputEvent https://developer.mozilla.org/en-US/docs/Web/API/InputEvent.""" + + target: JavascriptHTMLInputElement = JavascriptHTMLInputElement() + + +@dataclasses.dataclass( + init=True, + frozen=True, +) +class JavasciptKeyboardEvent: + """Interface for a Javascript KeyboardEvent https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.""" + + key: str = "" + + +def input_event(e: Var[JavascriptInputEvent]) -> Tuple[Var[str]]: + """Get the value from an input event. + + Args: + e: The input event. + + Returns: + The value from the input event. + """ + return (e.target.value,) + + +def key_event(e: Var[JavasciptKeyboardEvent]) -> Tuple[Var[str]]: + """Get the key from a keyboard event. + + Args: + e: The keyboard event. + + Returns: + The key from the keyboard event. + """ + return (e.key,) + + +def empty_event() -> Tuple[()]: + """Empty event handler. + + Returns: + An empty tuple. + """ + return tuple() # type: ignore # These chains can be used for their side effects when no other events are desired. -stop_propagation = EventChain(events=[], args_spec=lambda: []).stop_propagation -prevent_default = EventChain(events=[], args_spec=lambda: []).prevent_default +stop_propagation = EventChain(events=[], args_spec=empty_event).stop_propagation +prevent_default = EventChain(events=[], args_spec=empty_event).prevent_default -class Target(Base): - """A Javascript event target.""" - - checked: bool = False - value: Any = None +T = TypeVar("T") +U = TypeVar("U") -class FrontendEvent(Base): - """A Javascript event.""" +# def identity_event(event_type: Type[T]) -> Callable[[Var[T]], Tuple[Var[T]]]: +# """A helper function that returns the input event as output. - target: Target = Target() - key: str = "" - value: Any = None +# Args: +# event_type: The type of the event. + +# Returns: +# A function that returns the input event as output. +# """ + +# def inner(ev: Var[T]) -> Tuple[Var[T]]: +# return (ev,) + +# inner.__signature__ = inspect.signature(inner).replace( # type: ignore +# parameters=[ +# inspect.Parameter( +# "ev", +# kind=inspect.Parameter.POSITIONAL_OR_KEYWORD, +# annotation=Var[event_type], +# ) +# ], +# return_annotation=Tuple[Var[event_type]], +# ) +# inner.__annotations__["ev"] = Var[event_type] +# inner.__annotations__["return"] = Tuple[Var[event_type]] + +# return inner -class FileUpload(Base): +class IdentityEventReturn(Generic[T], Protocol): + """Protocol for an identity event return.""" + + def __call__(self, *values: Var[T]) -> Tuple[Var[T], ...]: + """Return the input values. + + Args: + *values: The values to return. + + Returns: + The input values. + """ + return values + + +@overload +def identity_event(event_type: Type[T], /) -> Callable[[Var[T]], Tuple[Var[T]]]: ... # type: ignore + + +@overload +def identity_event( + event_type_1: Type[T], event_type2: Type[U], / +) -> Callable[[Var[T], Var[U]], Tuple[Var[T], Var[U]]]: ... + + +@overload +def identity_event(*event_types: Type[T]) -> IdentityEventReturn[T]: ... + + +def identity_event(*event_types: Type[T]) -> IdentityEventReturn[T]: # type: ignore + """A helper function that returns the input event as output. + + Args: + *event_types: The types of the events. + + Returns: + A function that returns the input event as output. + """ + + def inner(*values: Var[T]) -> Tuple[Var[T], ...]: + return values + + inner_type = tuple(Var[event_type] for event_type in event_types) + return_annotation = Tuple[inner_type] # type: ignore + + inner.__signature__ = inspect.signature(inner).replace( # type: ignore + parameters=[ + inspect.Parameter( + f"ev_{i}", + kind=inspect.Parameter.POSITIONAL_OR_KEYWORD, + annotation=Var[event_type], + ) + for i, event_type in enumerate(event_types) + ], + return_annotation=return_annotation, + ) + for i, event_type in enumerate(event_types): + inner.__annotations__[f"ev_{i}"] = Var[event_type] + inner.__annotations__["return"] = return_annotation + + return inner + + +@dataclasses.dataclass( + init=True, + frozen=True, +) +class FileUpload: """Class to represent a file upload.""" upload_id: Optional[str] = None on_upload_progress: Optional[Union[EventHandler, Callable]] = None @staticmethod - def on_upload_progress_args_spec(_prog: Dict[str, Union[int, float, bool]]): + def on_upload_progress_args_spec(_prog: Var[Dict[str, Union[int, float, bool]]]): """Args spec for on_upload_progress event handler. Returns: @@ -386,17 +613,18 @@ class FileUpload(Base): ) upload_id = self.upload_id or DEFAULT_UPLOAD_ID - spec_args = [ ( - Var.create_safe("files"), - Var.create_safe(f"filesById.{upload_id}")._replace( - _var_data=upload_files_context_var_data - ), + Var(_js_expr="files"), + Var( + _js_expr="filesById", + _var_type=Dict[str, Any], + _var_data=VarData.merge(upload_files_context_var_data), + ).to(ObjectVar)[LiteralVar.create(upload_id)], ), ( - Var.create_safe("upload_id"), - Var.create_safe(upload_id, _var_is_string=True), + Var(_js_expr="upload_id"), + LiteralVar.create(upload_id), ), ] if self.on_upload_progress is not None: @@ -415,18 +643,19 @@ class FileUpload(Base): ) # type: ignore else: raise ValueError(f"{on_upload_progress} is not a valid event handler.") + if isinstance(events, Var): + raise ValueError(f"{on_upload_progress} cannot return a var {events}.") on_upload_progress_chain = EventChain( - events=events, + events=[*events], args_spec=self.on_upload_progress_args_spec, ) formatted_chain = str(format.format_prop(on_upload_progress_chain)) spec_args.append( ( - Var.create_safe("on_upload_progress"), - BaseVar( - _var_name=formatted_chain.strip("{}"), - _var_type=EventChain, - ), + Var(_js_expr="on_upload_progress"), + FunctionStringVar( + formatted_chain.strip("{}"), + ).to(FunctionVar, EventChain), ), ) return EventSpec( @@ -462,24 +691,36 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec: return EventSpec( handler=EventHandler(fn=fn), args=tuple( - (Var.create_safe(k), Var.create_safe(v, _var_is_string=isinstance(v, str))) + ( + Var(_js_expr=k), + LiteralVar.create(v), + ) for k, v in kwargs.items() ), ) -def redirect(path: str | Var[str], external: Optional[bool] = False) -> EventSpec: +def redirect( + path: str | Var[str], + external: Optional[bool] = False, + replace: Optional[bool] = False, +) -> EventSpec: """Redirect to a new path. Args: path: The path to redirect to. external: Whether to open in new tab or not. + replace: If True, the current page will not create a new history entry. Returns: An event to redirect to the path. """ return server_side( - "_redirect", get_fn_signature(redirect), path=path, external=external + "_redirect", + get_fn_signature(redirect), + path=path, + external=external, + replace=replace, ) @@ -495,6 +736,15 @@ def console_log(message: str | Var[str]) -> EventSpec: return server_side("_console", get_fn_signature(console_log), message=message) +def back() -> EventSpec: + """Do a history.back on the browser. + + Returns: + An event to go back one page. + """ + return call_script("window.history.back()") + + def window_alert(message: str | Var[str]) -> EventSpec: """Create a window alert on the browser. @@ -519,22 +769,29 @@ def set_focus(ref: str) -> EventSpec: return server_side( "_set_focus", get_fn_signature(set_focus), - ref=Var.create_safe(format.format_ref(ref), _var_is_string=True), + ref=LiteralVar.create(format.format_ref(ref)), ) -def scroll_to(elem_id: str) -> EventSpec: +def scroll_to(elem_id: str, align_to_top: bool | Var[bool] = True) -> EventSpec: """Select the id of a html element for scrolling into view. Args: - elem_id: the id of the element + elem_id: The id of the element to scroll to. + align_to_top: Whether to scroll to the top (True) or bottom (False) of the element. Returns: An EventSpec to scroll the page to the selected element. """ - js_code = f"document.getElementById('{elem_id}').scrollIntoView();" + get_element_by_id = FunctionStringVar.create("document.getElementById") - return call_script(js_code) + return call_script( + get_element_by_id(elem_id) + .call(elem_id) + .to(ObjectVar) + .scrollIntoView.to(FunctionVar) + .call(align_to_top) + ) def set_value(ref: str, value: Any) -> EventSpec: @@ -550,7 +807,7 @@ def set_value(ref: str, value: Any) -> EventSpec: return server_side( "_set_value", get_fn_signature(set_value), - ref=Var.create_safe(format.format_ref(ref), _var_is_string=True), + ref=LiteralVar.create(format.format_ref(ref)), value=value, ) @@ -603,6 +860,34 @@ def remove_local_storage(key: str) -> EventSpec: ) +def clear_session_storage() -> EventSpec: + """Set a value in the session storage on the frontend. + + Returns: + EventSpec: An event to clear the session storage. + """ + return server_side( + "_clear_session_storage", + get_fn_signature(clear_session_storage), + ) + + +def remove_session_storage(key: str) -> EventSpec: + """Set a value in the session storage on the frontend. + + Args: + key: The key identifying the variable in the session storage to remove. + + Returns: + EventSpec: An event to remove an item based on the provided key in session storage. + """ + return server_side( + "_remove_session_storage", + get_fn_signature(remove_session_storage), + key=key, + ) + + def set_clipboard(content: str) -> EventSpec: """Set the text in content in the clipboard. @@ -657,22 +942,18 @@ def download( if isinstance(data, str): # Caller provided a plain text string to download. - url = "data:text/plain," + data + url = "data:text/plain," + urllib.parse.quote(data) elif isinstance(data, Var): # Need to check on the frontend if the Var already looks like a data: URI. - is_data_url = data._replace( - _var_name=( - f"typeof {data._var_full_name} == 'string' && " - f"{data._var_full_name}.startsWith('data:')" - ), - _var_type=bool, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) + + 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): @@ -705,8 +986,14 @@ def _callback_arg_spec(eval_result): def call_script( - javascript_code: str, - callback: EventHandler | Callable | None = None, + javascript_code: str | Var[str], + callback: ( + EventSpec + | EventHandler + | Callable + | List[EventSpec | EventHandler | Callable] + | None + ) = None, ) -> EventSpec: """Create an event handler that executes arbitrary javascript code. @@ -716,22 +1003,27 @@ def call_script( Returns: EventSpec: An event that will execute the client side javascript. - - Raises: - ValueError: If the callback is not a valid event handler. """ callback_kwargs = {} if callback is not None: - arg_name = parse_args_spec(_callback_arg_spec)[0]._var_name - if isinstance(callback, EventHandler): - event_spec = call_event_handler(callback, _callback_arg_spec) - elif isinstance(callback, FunctionType): - event_spec = call_event_fn(callback, _callback_arg_spec)[0] - else: - raise ValueError("Cannot use {callback!r} as a call_script callback.") callback_kwargs = { - "callback": f"({arg_name}) => queueEvents([{format.format_event(event_spec)}], {constants.CompileVars.SOCKET})" + "callback": str( + format.format_queue_events( + callback, + args_spec=lambda result: [result], + ), + ), } + if isinstance(javascript_code, str): + # When there is VarData, include it and eval the JS code inline on the client. + javascript_code, original_code = ( + LiteralVar.create(javascript_code), + javascript_code, + ) + if not javascript_code._get_all_var_data(): + # Without VarData, cast to string and eval the code in the event loop. + javascript_code = str(Var(_js_expr=original_code)) + return server_side( "_call_script", get_fn_signature(call_script), @@ -767,7 +1059,8 @@ def get_hydrate_event(state) -> str: def call_event_handler( event_handler: EventHandler | EventSpec, - arg_spec: ArgsSpec, + arg_spec: ArgsSpec | Sequence[ArgsSpec], + key: Optional[str] = None, ) -> EventSpec: """Call an event handler to get the event spec. @@ -778,12 +1071,16 @@ def call_event_handler( Args: event_handler: The event handler. arg_spec: The lambda that define the argument(s) to pass to the event handler. + key: The key 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. + + # noqa: DAR401 failure + """ parsed_args = parse_args_spec(arg_spec) # type: ignore @@ -791,18 +1088,152 @@ def call_event_handler( # Handle partial application of EventSpec args return event_handler.add_args(*parsed_args) - args = inspect.getfullargspec(event_handler.fn).args - if len(args) == len(["self", *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(',')}'" + provided_callback_fullspec = inspect.getfullargspec(event_handler.fn) + + provided_callback_n_args = ( + len(provided_callback_fullspec.args) - 1 + ) # subtract 1 for bound self arg + + if provided_callback_n_args != len(parsed_args): + raise EventHandlerArgMismatch( + "The number of arguments accepted by " + f"{event_handler.fn.__qualname__} ({provided_callback_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/" ) + all_arg_spec = [arg_spec] if not isinstance(arg_spec, Sequence) else arg_spec -def parse_args_spec(arg_spec: ArgsSpec): + event_spec_return_types = list( + filter( + lambda event_spec_return_type: event_spec_return_type is not None + and get_origin(event_spec_return_type) is tuple, + (get_type_hints(arg_spec).get("return", None) for arg_spec in all_arg_spec), + ) + ) + + if event_spec_return_types: + failures = [] + + for event_spec_index, event_spec_return_type in enumerate( + event_spec_return_types + ): + args = get_args(event_spec_return_type) + + args_types_without_vars = [ + arg if get_origin(arg) is not Var else get_args(arg)[0] for arg in args + ] + + try: + type_hints_of_provided_callback = get_type_hints(event_handler.fn) + except NameError: + type_hints_of_provided_callback = {} + + failed_type_check = False + + # check that args of event handler are matching the spec if type hints are provided + for i, arg in enumerate(provided_callback_fullspec.args[1:]): + if arg not in type_hints_of_provided_callback: + continue + + try: + compare_result = typehint_issubclass( + args_types_without_vars[i], type_hints_of_provided_callback[arg] + ) + except TypeError: + # TODO: In 0.7.0, remove this block and raise the exception + # raise TypeError( + # f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_handler.fn.__qualname__} provided for {key}." + # ) from e + console.warn( + f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_handler.fn.__qualname__} provided for {key}." + ) + compare_result = False + + if compare_result: + continue + else: + failure = EventHandlerArgTypeMismatch( + f"Event handler {key} expects {args_types_without_vars[i]} for argument {arg} but got {type_hints_of_provided_callback[arg]} as annotated in {event_handler.fn.__qualname__} instead." + ) + failures.append(failure) + failed_type_check = True + break + + if not failed_type_check: + if event_spec_index: + args = get_args(event_spec_return_types[0]) + + args_types_without_vars = [ + arg if get_origin(arg) is not Var else get_args(arg)[0] + for arg in args + ] + + expect_string = ", ".join( + repr(arg) for arg in args_types_without_vars + ).replace("[", "\\[") + + given_string = ", ".join( + repr(type_hints_of_provided_callback.get(arg, Any)) + for arg in provided_callback_fullspec.args[1:] + ).replace("[", "\\[") + + console.warn( + f"Event handler {key} expects ({expect_string}) -> () but got ({given_string}) -> () as annotated in {event_handler.fn.__qualname__} instead. " + f"This may lead to unexpected behavior but is intentionally ignored for {key}." + ) + return event_handler(*parsed_args) + + if failures: + console.deprecate( + "Mismatched event handler argument types", + "\n".join([str(f) for f in failures]), + "0.6.5", + "0.7.0", + ) + + return event_handler(*parsed_args) # type: ignore + + +def unwrap_var_annotation(annotation: GenericType): + """Unwrap a Var annotation or return it as is if it's not Var[X]. + + Args: + annotation: The annotation to unwrap. + + Returns: + The unwrapped annotation. + """ + if get_origin(annotation) is Var and (args := get_args(annotation)): + return args[0] + return annotation + + +def resolve_annotation(annotations: dict[str, Any], arg_name: str): + """Resolve the annotation for the given argument name. + + Args: + annotations: The annotations. + arg_name: The argument name. + + Returns: + The resolved annotation. + """ + annotation = annotations.get(arg_name) + if annotation is None: + console.deprecate( + feature_name="Unannotated event handler arguments", + reason="Provide type annotations for event handler arguments.", + deprecation_version="0.6.3", + removal_version="0.7.0", + ) + # Allow arbitrary attribute access two levels deep until removed. + return Dict[str, dict] + return annotation + + +def parse_args_spec(arg_spec: ArgsSpec | Sequence[ArgsSpec]): """Parse the args provided in the ArgsSpec of an event trigger. Args: @@ -811,68 +1242,105 @@ def parse_args_spec(arg_spec: ArgsSpec): Returns: The parsed args. """ + # if there's multiple, the first is the default + arg_spec = arg_spec[0] if isinstance(arg_spec, Sequence) else arg_spec spec = inspect.getfullargspec(arg_spec) annotations = get_type_hints(arg_spec) - return arg_spec( - *[ - BaseVar( - _var_name=f"_{l_arg}", - _var_type=annotations.get(l_arg, FrontendEvent), - _var_is_local=True, - ) - for l_arg in spec.args - ] + + return list( + arg_spec( + *[ + Var(f"_{l_arg}").to( + unwrap_var_annotation(resolve_annotation(annotations, l_arg)) + ) + for l_arg in spec.args + ] + ) ) -def call_event_fn(fn: Callable, arg: Union[Var, ArgsSpec]) -> list[EventSpec]: +def check_fn_match_arg_spec( + fn: Callable, + arg_spec: ArgsSpec, + key: Optional[str] = None, +) -> List[Var]: + """Ensures that the function signature matches the passed argument specification + or raises an EventFnArgMismatch if they do not. + + Args: + fn: The function to be validated. + arg_spec: The argument specification for the event trigger. + key: The key to pass to the event handler. + + Returns: + The parsed arguments from the argument specification. + + Raises: + EventFnArgMismatch: Raised if the number of mandatory arguments do not match + """ + fn_args = inspect.getfullargspec(fn).args + fn_defaults_args = inspect.getfullargspec(fn).defaults + n_fn_args = len(fn_args) + n_fn_defaults_args = len(fn_defaults_args) if fn_defaults_args else 0 + if isinstance(fn, types.MethodType): + n_fn_args -= 1 # subtract 1 for bound self arg + parsed_args = parse_args_spec(arg_spec) + if not (n_fn_args - n_fn_defaults_args <= len(parsed_args) <= n_fn_args): + raise EventFnArgMismatch( + "The number of mandatory arguments accepted by " + f"{fn} ({n_fn_args - n_fn_defaults_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/" + ) + return parsed_args + + +def call_event_fn( + fn: Callable, + arg_spec: ArgsSpec, + key: Optional[str] = None, +) -> list[EventSpec] | Var: """Call a function to a list of event specs. - The function should return either a single EventSpec or a list of EventSpecs. - If the function takes in an arg, the arg will be passed to the function. - Otherwise, the function will be called with no args. + The function should return a single EventSpec, a list of EventSpecs, or a + single Var. Args: fn: The function to call. - arg: The argument to pass to the function. + arg_spec: The argument spec for the event trigger. + key: The key to pass to the event handler. Returns: - The event specs from calling the function. + The event specs from calling the function or a Var. Raises: - EventHandlerValueError: If the lambda has an invalid signature. + 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 + parsed_args = check_fn_match_arg_spec(fn, arg_spec, key=key) - 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, key=key) # Make sure the event spec is valid. if not isinstance(e, EventSpec): @@ -887,7 +1355,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: @@ -913,6 +1383,9 @@ def fix_events( token: The user token. router_data: The optional router data to set in the event. + Raises: + ValueError: If the event type is not what was expected. + Returns: The fixed events. """ @@ -936,9 +1409,10 @@ def fix_events( # Otherwise, create an event from the event spec. if isinstance(e, EventHandler): e = e() - assert isinstance(e, EventSpec), f"Unexpected event type, {type(e)}." + if not isinstance(e, EventSpec): + raise ValueError(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 = { @@ -973,3 +1447,401 @@ def get_fn_signature(fn: Callable) -> inspect.Signature: "state", inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=Any ) return signature.replace(parameters=(new_param, *signature.parameters.values())) + + +class EventVar(ObjectVar, python_types=EventSpec): + """Base class for event vars.""" + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralEventVar(VarOperationCall, LiteralVar, EventVar): + """A literal event var.""" + + _var_value: EventSpec = dataclasses.field(default=None) # type: ignore + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._js_expr)) + + @classmethod + def create( + cls, + value: EventSpec, + _var_data: VarData | None = None, + ) -> LiteralEventVar: + """Create a new LiteralEventVar instance. + + Args: + value: The value of the var. + _var_data: The data of the var. + + Returns: + The created LiteralEventVar instance. + """ + return cls( + _js_expr="", + _var_type=EventSpec, + _var_data=_var_data, + _var_value=value, + _func=FunctionStringVar("Event"), + _args=( + # event handler name + ".".join( + filter( + None, + format.get_event_handler_parts(value.handler), + ) + ), + # event handler args + {str(name): value for name, value in value.args}, + # event actions + value.event_actions, + # client handler name + *([value.client_handler_name] if value.client_handler_name else []), + ), + ) + + +class EventChainVar(FunctionVar, python_types=EventChain): + """Base class for event chain vars.""" + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +# Note: LiteralVar is second in the inheritance list allowing it act like a +# CachedVarOperation (ArgsFunctionOperation) and get the _js_expr from the +# _cached_var_name property. +class LiteralEventChainVar(ArgsFunctionOperation, LiteralVar, EventChainVar): + """A literal event chain var.""" + + _var_value: EventChain = dataclasses.field(default=None) # type: ignore + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._js_expr)) + + @classmethod + def create( + cls, + value: EventChain, + _var_data: VarData | None = None, + ) -> LiteralEventChainVar: + """Create a new LiteralEventChainVar instance. + + Args: + value: The value of the var. + _var_data: The data of the var. + + Returns: + The created LiteralEventChainVar instance. + """ + arg_spec = ( + value.args_spec[0] + if isinstance(value.args_spec, Sequence) + else value.args_spec + ) + sig = inspect.signature(arg_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") + + if value.invocation is None: + invocation = FunctionStringVar.create("addEvents") + else: + invocation = value.invocation + + return cls( + _js_expr="", + _var_type=EventChain, + _var_data=_var_data, + _args_names=arg_def, + _return_expr=invocation.call( + LiteralVar.create([LiteralVar.create(event) for event in value.events]), + arg_def_expr, + value.event_actions, + ), + _var_value=value, + ) + + +P = ParamSpec("P") +Q = ParamSpec("Q") +T = TypeVar("T") +V = TypeVar("V") +V2 = TypeVar("V2") +V3 = TypeVar("V3") +V4 = TypeVar("V4") +V5 = TypeVar("V5") + +background_event_decorator = background + +if sys.version_info >= (3, 10): + from typing import Concatenate + + class EventCallback(Generic[P, T]): + """A descriptor that wraps a function to be used as an event.""" + + def __init__(self, func: Callable[Concatenate[Any, P], T]): + """Initialize the descriptor with the function to be wrapped. + + Args: + func: The function to be wrapped. + """ + self.func = func + + @property + def prevent_default(self): + """Prevent default behavior. + + Returns: + The event callback with prevent default behavior. + """ + return self + + @property + def stop_propagation(self): + """Stop event propagation. + + Returns: + The event callback with stop propagation behavior. + """ + return self + + @overload + def __call__( + self: EventCallback[Q, T], + ) -> EventCallback[Q, T]: ... + + @overload + def __call__( + self: EventCallback[Concatenate[V, Q], T], value: V | Var[V] + ) -> EventCallback[Q, T]: ... + + @overload + def __call__( + self: EventCallback[Concatenate[V, V2, Q], T], + value: V | Var[V], + value2: V2 | Var[V2], + ) -> EventCallback[Q, T]: ... + + @overload + def __call__( + self: EventCallback[Concatenate[V, V2, V3, Q], T], + value: V | Var[V], + value2: V2 | Var[V2], + value3: V3 | Var[V3], + ) -> EventCallback[Q, T]: ... + + @overload + def __call__( + self: EventCallback[Concatenate[V, V2, V3, V4, Q], T], + value: V | Var[V], + value2: V2 | Var[V2], + value3: V3 | Var[V3], + value4: V4 | Var[V4], + ) -> EventCallback[Q, T]: ... + + def __call__(self, *values) -> EventCallback: # type: ignore + """Call the function with the values. + + Args: + *values: The values to call the function with. + + Returns: + The function with the values. + """ + return self.func(*values) # type: ignore + + @overload + def __get__( + self: EventCallback[P, T], instance: None, owner + ) -> EventCallback[P, T]: ... + + @overload + def __get__(self, instance, owner) -> Callable[P, T]: ... + + def __get__(self, instance, owner) -> Callable: # type: ignore + """Get the function with the instance bound to it. + + Args: + instance: The instance to bind to the function. + owner: The owner of the function. + + Returns: + The function with the instance bound to it + """ + if instance is None: + return self.func # type: ignore + + return partial(self.func, instance) # type: ignore + + +else: + + class EventCallback(Generic[P, T]): + """A descriptor that wraps a function to be used as an event.""" + + +G = ParamSpec("G") + +IndividualEventType = Union[ + EventSpec, EventHandler, Callable[G, Any], EventCallback[G, Any], Var[Any] +] + +ItemOrList = Union[V, List[V]] + +EventType = ItemOrList[IndividualEventType[G]] + + +class EventNamespace(types.SimpleNamespace): + """A namespace for event related classes.""" + + Event = Event + EventHandler = EventHandler + EventSpec = EventSpec + CallableEventSpec = CallableEventSpec + EventChain = EventChain + EventVar = EventVar + LiteralEventVar = LiteralEventVar + EventChainVar = EventChainVar + LiteralEventChainVar = LiteralEventChainVar + EventType = EventType + EventCallback = EventCallback + + if sys.version_info >= (3, 10): + + @overload + @staticmethod + def __call__( + func: None = None, *, background: bool | None = None + ) -> Callable[[Callable[Concatenate[Any, P], T]], EventCallback[P, T]]: ... + + @overload + @staticmethod + def __call__( + func: Callable[Concatenate[Any, P], T], + *, + background: bool | None = None, + ) -> EventCallback[P, T]: ... + + @staticmethod + def __call__( + func: Callable[Concatenate[Any, P], T] | None = None, + *, + background: bool | None = None, + ) -> Union[ + EventCallback[P, T], + Callable[[Callable[Concatenate[Any, P], T]], EventCallback[P, T]], + ]: + """Wrap a function to be used as an event. + + Args: + func: The function to wrap. + background: Whether the event should be run in the background. Defaults to False. + + Returns: + The wrapped function. + """ + + def wrapper(func: Callable[Concatenate[Any, P], T]) -> EventCallback[P, T]: + if background is True: + return background_event_decorator(func, __internal_reflex_call=True) # type: ignore + return func # type: ignore + + if func is not None: + return wrapper(func) + return wrapper + else: + + @overload + @staticmethod + def __call__( + func: None = None, *, background: bool | None = None + ) -> Callable[[Callable[P, T]], Callable[P, T]]: ... + + @overload + @staticmethod + def __call__( + func: Callable[P, T], *, background: bool | None = None + ) -> Callable[P, T]: ... + + @staticmethod + def __call__( + func: Callable[P, T] | None = None, + *, + background: bool | None = None, + ) -> Union[ + Callable[P, T], + Callable[[Callable[P, T]], Callable[P, T]], + ]: + """Wrap a function to be used as an event. + + Args: + func: The function to wrap. + background: Whether the event should be run in the background. Defaults to False. + + Returns: + The wrapped function. + """ + + def wrapper(func: Callable[P, T]) -> Callable[P, T]: + if background is True: + return background_event_decorator(func, __internal_reflex_call=True) # type: ignore + return func # type: ignore + + if func is not None: + return wrapper(func) + return wrapper + + get_event = staticmethod(get_event) + get_hydrate_event = staticmethod(get_hydrate_event) + fix_events = staticmethod(fix_events) + call_event_handler = staticmethod(call_event_handler) + call_event_fn = staticmethod(call_event_fn) + get_handler_args = staticmethod(get_handler_args) + check_fn_match_arg_spec = staticmethod(check_fn_match_arg_spec) + resolve_annotation = staticmethod(resolve_annotation) + parse_args_spec = staticmethod(parse_args_spec) + identity_event = staticmethod(identity_event) + input_event = staticmethod(input_event) + key_event = staticmethod(key_event) + empty_event = staticmethod(empty_event) + server_side = staticmethod(server_side) + redirect = staticmethod(redirect) + console_log = staticmethod(console_log) + back = staticmethod(back) + window_alert = staticmethod(window_alert) + set_focus = staticmethod(set_focus) + scroll_to = staticmethod(scroll_to) + set_value = staticmethod(set_value) + remove_cookie = staticmethod(remove_cookie) + clear_local_storage = staticmethod(clear_local_storage) + remove_local_storage = staticmethod(remove_local_storage) + clear_session_storage = staticmethod(clear_session_storage) + remove_session_storage = staticmethod(remove_session_storage) + set_clipboard = staticmethod(set_clipboard) + download = staticmethod(download) + call_script = staticmethod(call_script) + + +event = EventNamespace() diff --git a/reflex/experimental/__init__.py b/reflex/experimental/__init__.py index 991dffd50..164790fe5 100644 --- a/reflex/experimental/__init__.py +++ b/reflex/experimental/__init__.py @@ -2,11 +2,15 @@ from types import SimpleNamespace +from reflex.components.datadisplay.shiki_code_block import code_block as code_block +from reflex.components.props import PropsBase from reflex.components.radix.themes.components.progress import progress as progress from reflex.components.sonner.toast import toast as toast from ..utils.console import warn from . import hooks as hooks +from .assets import asset as asset +from .client_state import ClientStateVar as ClientStateVar from .layout import layout as layout from .misc import run_in_thread as run_in_thread @@ -14,10 +18,55 @@ warn( "`rx._x` contains experimental features and might be removed at any time in the future .", ) -_x = SimpleNamespace( +_EMITTED_PROMOTION_WARNINGS = set() + + +class ExperimentalNamespace(SimpleNamespace): + """Namespace for experimental features.""" + + @property + def toast(self): + """Temporary property returning the toast namespace. + + Remove this property when toast is fully promoted. + + Returns: + The toast namespace. + """ + 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, - toast=toast, + code_block=code_block, ) diff --git a/reflex/experimental/assets.py b/reflex/experimental/assets.py new file mode 100644 index 000000000..dcf386d8d --- /dev/null +++ b/reflex/experimental/assets.py @@ -0,0 +1,59 @@ +"""Helper functions for adding assets to the app.""" + +import inspect +from pathlib import Path +from typing import Optional + +from reflex import constants + + +def asset(relative_filename: str, subfolder: Optional[str] = None) -> str: + """Add an asset to the app. + Place the file next to your including python file. + Copies the file to the app's external assets directory. + + Example: + ```python + rx.script(src=rx._x.asset("my_custom_javascript.js")) + rx.image(src=rx._x.asset("test_image.png","subfolder")) + ``` + + Args: + relative_filename: The relative filename of the asset. + subfolder: The directory to place the asset in. + + Raises: + FileNotFoundError: If the file does not exist. + ValueError: If the module is None. + + Returns: + The relative URL to the copied asset. + """ + # Determine the file by which the asset is exposed. + calling_file = inspect.stack()[1].filename + module = inspect.getmodule(inspect.stack()[1][0]) + if module is None: + raise ValueError("Module is None") + caller_module_path = module.__name__.replace(".", "/") + + subfolder = f"{caller_module_path}/{subfolder}" if subfolder else caller_module_path + + src_file = Path(calling_file).parent / relative_filename + + assets = constants.Dirs.APP_ASSETS + external = constants.Dirs.EXTERNAL_APP_ASSETS + + if not src_file.exists(): + raise FileNotFoundError(f"File not found: {src_file}") + + # Create the asset folder in the currently compiling app. + asset_folder = Path.cwd() / assets / external / subfolder + asset_folder.mkdir(parents=True, exist_ok=True) + + dst_file = asset_folder / relative_filename + + if not dst_file.exists(): + dst_file.symlink_to(src_file) + + asset_url = f"/{external}/{subfolder}/{relative_filename}" + return asset_url diff --git a/reflex/experimental/client_state.py b/reflex/experimental/client_state.py new file mode 100644 index 000000000..74a25c2cd --- /dev/null +++ b/reflex/experimental/client_state.py @@ -0,0 +1,248 @@ +"""Handle client side state with `useState`.""" + +from __future__ import annotations + +import dataclasses +import re +import sys +from typing import Any, Callable, Union + +from reflex import constants +from reflex.event import EventChain, EventHandler, EventSpec, call_script +from reflex.utils.imports import ImportVar +from reflex.vars import ( + VarData, + get_unique_variable_name, +) +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionVar + +NoValue = object() + + +_refs_import = { + f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")], +} + + +def _client_state_ref(var_name: str) -> str: + """Get the ref path for a ClientStateVar. + + Args: + var_name: The name of the variable. + + Returns: + An accessor for ClientStateVar ref as a string. + """ + return f"refs['_client_state_{var_name}']" + + +@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.""" + + # Track the names of the getters and setters + _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) + + def __hash__(self) -> int: + """Define a hash function for a var. + + Returns: + The hash of the var. + """ + return hash( + (self._js_expr, str(self._var_type), self._getter_name, self._setter_name) + ) + + @classmethod + def create( + cls, + var_name: str | None = None, + default: Any = NoValue, + global_ref: bool = True, + ) -> "ClientStateVar": + """Create a local_state Var that can be accessed and updated on the client. + + The `ClientStateVar` should be included in the highest parent component + that contains the components which will access and manipulate the client + state. It has no visual rendering, including it ensures that the + `useState` hook is called in the correct scope. + + To render the var in a component, use the `value` property. + + To update the var in a component, use the `set` property or `set_value` method. + + To access the var in an event handler, use the `retrieve` method with + `callback` set to the event handler which should receive the value. + + To update the var in an event handler, use the `push` method with the + value to update. + + Args: + var_name: The name of the variable. + default: The default value of the variable. + global_ref: Whether the state should be accessible in any Component and on the backend. + + Raises: + ValueError: If the var_name is not a string. + + Returns: + ClientStateVar + """ + if var_name is None: + var_name = get_unique_variable_name() + if not isinstance(var_name, str): + raise ValueError("var_name must be a string.") + if default is NoValue: + 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({str(default_var)})": None, + } + imports = { + "react": [ImportVar(tag="useState")], + } + if global_ref: + hooks[f"{_client_state_ref(var_name)} = {var_name}"] = None + hooks[f"{_client_state_ref(setter_name)} = {setter_name}"] = None + imports.update(_refs_import) + return cls( + _js_expr="", + _setter_name=setter_name, + _getter_name=var_name, + _global_ref=global_ref, + _var_type=default_var._var_type, + _var_data=VarData.merge( + default_var._var_data, + VarData( + hooks=hooks, + imports=imports, + ), + ), + ) + + @property + def value(self) -> Var: + """Get a placeholder for the Var. + + This property can only be rendered on the frontend. + + To access the value in a backend event handler, see `retrieve`. + + Returns: + an accessor for the client state variable. + """ + return ( + Var( + _js_expr=( + _client_state_ref(self._getter_name) + if self._global_ref + else self._getter_name + ) + ) + .to(self._var_type) + ._replace( + merge_var_data=VarData( # type: ignore + imports=_refs_import if self._global_ref else {} + ) + ) + ) + + def set_value(self, value: Any = NoValue) -> Var: + """Set the value of the client state variable. + + This property can only be attached to a frontend event trigger. + + To set a value from a backend event handler, see `push`. + + Args: + value: The value to set. + + Returns: + A special EventChain Var which will set the value when triggered. + """ + setter = ( + _client_state_ref(self._setter_name) + if self._global_ref + else self._setter_name + ) + _var_data = VarData(imports=_refs_import if self._global_ref else {}) + if value is not NoValue: + # This is a hack to make it work like an EventSpec taking an arg + value_var = LiteralVar.create(value) + _var_data = VarData.merge(_var_data, value_var._get_all_var_data()) + value_str = str(value_var) + + if value_str.startswith("_"): + # remove patterns of ["*"] from the value_str using regex + arg = re.sub(r"\[\".*\"\]", "", value_str) + setter = f"(({arg}) => {setter}({value_str}))" + else: + setter = f"(() => {setter}({value_str}))" + return Var( + _js_expr=setter, + _var_data=_var_data, + ).to(FunctionVar, EventChain) + + @property + def set(self) -> Var: + """Set the value of the client state variable. + + This property can only be attached to a frontend event trigger. + + To set a value from a backend event handler, see `push`. + + Returns: + A special EventChain Var which will set the value when triggered. + """ + return self.set_value() + + def retrieve( + self, callback: Union[EventHandler, Callable, None] = None + ) -> EventSpec: + """Pass the value of the client state variable to a backend EventHandler. + + The event handler must `yield` or `return` the EventSpec to trigger the event. + + Args: + callback: The callback to pass the value to. + + Returns: + An EventSpec which will retrieve the value when triggered. + + Raises: + ValueError: If the ClientStateVar is not global. + """ + if not self._global_ref: + raise ValueError("ClientStateVar must be global to retrieve the value.") + return call_script(_client_state_ref(self._getter_name), callback=callback) + + def push(self, value: Any) -> EventSpec: + """Push a value to the client state variable from the backend. + + The event handler must `yield` or `return` the EventSpec to trigger the event. + + Args: + value: The value to update. + + Returns: + An EventSpec which will push the value when triggered. + + Raises: + ValueError: If the ClientStateVar is not global. + """ + if not self._global_ref: + raise ValueError("ClientStateVar must be global to push the value.") + return call_script(f"{_client_state_ref(self._setter_name)}({value})") diff --git a/reflex/experimental/hooks.py b/reflex/experimental/hooks.py index 9040abd4d..7d648225a 100644 --- a/reflex/experimental/hooks.py +++ b/reflex/experimental/hooks.py @@ -1,22 +1,17 @@ """Add standard Hooks wrapper for React.""" +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 _add_react_import(v: Var | None, tags: str | list): - if v is None: - return - - if isinstance(tags, str): - tags = [tags] - - v._var_data = VarData( # type: ignore - imports={"react": [ImportVar(tag=tag, install=False) for tag in tags]}, - ) +def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]: + return {"react": [ImportVar(tag=tag) for tag in tags]} -def const(name, value) -> Var | None: +def const(name, value) -> Var: """Create a constant Var. Args: @@ -27,11 +22,11 @@ def const(name, value) -> Var | None: The constant Var. """ if isinstance(name, list): - return Var.create(f"const [{', '.join(name)}] = {value}") - return Var.create(f"const {name} = {value}") + return Var(_js_expr=f"const [{', '.join(name)}] = {value}") + return Var(_js_expr=f"const {name} = {value}") -def useCallback(func, deps) -> Var | None: +def useCallback(func, deps) -> Var: """Create a useCallback hook with a function and dependencies. Args: @@ -41,15 +36,13 @@ def useCallback(func, deps) -> Var | None: Returns: The useCallback hook. """ - if deps: - v = Var.create(f"useCallback({func}, {deps})") - else: - v = Var.create(f"useCallback({func})") - _add_react_import(v, "useCallback") - return v + return Var( + _js_expr=f"useCallback({func}, {deps})" if deps else f"useCallback({func})", + _var_data=VarData(imports=_compose_react_imports(["useCallback"])), + ) -def useContext(context) -> Var | None: +def useContext(context) -> Var: """Create a useContext hook with a context. Args: @@ -58,12 +51,13 @@ def useContext(context) -> Var | None: Returns: The useContext hook. """ - v = Var.create(f"useContext({context})") - _add_react_import(v, "useContext") - return v + return Var( + _js_expr=f"useContext({context})", + _var_data=VarData(imports=_compose_react_imports(["useContext"])), + ) -def useRef(default) -> Var | None: +def useRef(default) -> Var: """Create a useRef hook with a default value. Args: @@ -72,12 +66,13 @@ def useRef(default) -> Var | None: Returns: The useRef hook. """ - v = Var.create(f"useRef({default})") - _add_react_import(v, "useRef") - return v + return Var( + _js_expr=f"useRef({default})", + _var_data=VarData(imports=_compose_react_imports(["useRef"])), + ) -def useState(var_name, default=None) -> Var | None: +def useState(var_name, default=None) -> Var: """Create a useState hook with a variable name and setter name. Args: @@ -87,7 +82,10 @@ def useState(var_name, default=None) -> Var | None: Returns: A useState hook. """ - setter_name = f"set{var_name.capitalize()}" - v = const([var_name, setter_name], f"useState({default})") - _add_react_import(v, "useState") - return v + return const( + [var_name, f"set{var_name.capitalize()}"], + 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 5041b9356..a3b76581a 100644 --- a/reflex/experimental/layout.py +++ b/reflex/experimental/layout.py @@ -2,17 +2,21 @@ from __future__ import annotations +from typing import Any, List + from reflex import color, cond from reflex.components.base.fragment import Fragment from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf from reflex.components.radix.primitives.drawer import DrawerRoot, drawer from reflex.components.radix.themes.components.icon_button import IconButton -from reflex.components.radix.themes.layout import Box, Container, HStack +from reflex.components.radix.themes.layout.box import Box +from reflex.components.radix.themes.layout.container import Container +from reflex.components.radix.themes.layout.stack import HStack 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): @@ -40,7 +44,7 @@ class Sidebar(Box, MemoizationLeaf): Box.create(width=props.get("width")), # spacer for layout ) - def add_style(self) -> Style | None: + def add_style(self) -> dict[str, Any] | None: """Add style to the component. Returns: @@ -48,7 +52,11 @@ class Sidebar(Box, MemoizationLeaf): """ sidebar: Component = self.children[-2] # type: ignore spacer: Component = self.children[-1] # type: ignore - open = self.State.open if self.State else Var.create("open") # type: ignore + open = ( + self.State.open # type: ignore + if self.State + else Var(_js_expr="open") + ) sidebar.style["display"] = spacer.style["display"] = cond(open, "block", "none") return Style( @@ -61,8 +69,13 @@ class Sidebar(Box, MemoizationLeaf): } ) - def _get_hooks(self) -> Var | None: - return hooks.useState("open", "true") if not self.State else None + def add_hooks(self) -> List[Var]: + """Get the hooks to render. + + Returns: + The hooks for the sidebar. + """ + return [hooks.useState("open", "true")] if not self.State else [] class StatefulSidebar(ComponentState): @@ -158,7 +171,10 @@ class SidebarTrigger(Fragment): if sidebar.State: open, toggle = sidebar.State.open, sidebar.State.toggle # type: ignore else: - open, toggle = Var.create("open"), call_script(Var.create("setOpen(!open)")) # type: ignore + open, toggle = ( + 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 new file mode 100644 index 000000000..dcdac5b5d --- /dev/null +++ b/reflex/experimental/layout.pyi @@ -0,0 +1,330 @@ +"""Stub file for reflex/experimental/layout.py""" + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from typing import Any, Dict, List, Literal, Optional, Union, overload + +from reflex import color +from reflex.components.base.fragment import Fragment +from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf +from reflex.components.radix.primitives.drawer import DrawerRoot +from reflex.components.radix.themes.layout.box import Box +from reflex.event import EventType +from reflex.state import ComponentState +from reflex.style import Style +from reflex.vars.base import Var + +class Sidebar(Box, MemoizationLeaf): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Sidebar": + """Create the sidebar component. + + Args: + children: The children components. + props: The properties of the sidebar. + + Returns: + The sidebar component. + """ + ... + + def add_style(self) -> dict[str, Any] | None: ... + def add_hooks(self) -> List[Var]: ... + +class StatefulSidebar(ComponentState): + open: bool + + def toggle(self): ... + @classmethod + def get_component(cls, *children, **props): ... + +class DrawerSidebar(DrawerRoot): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + open: Optional[Union[Var[bool], bool]] = None, + should_scale_background: Optional[Union[Var[bool], bool]] = None, + close_threshold: Optional[Union[Var[float], float]] = None, + snap_points: Optional[List[Union[float, str]]] = None, + fade_from_index: Optional[Union[Var[int], int]] = None, + scroll_lock_timeout: Optional[Union[Var[int], int]] = None, + modal: Optional[Union[Var[bool], bool]] = None, + direction: Optional[ + Union[ + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], + ] + ] = None, + preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, + as_child: Optional[Union[Var[bool], bool]] = 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_open_change: Optional[EventType[bool]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "DrawerSidebar": + """Create the sidebar component. + + Args: + children: The children components. + props: The properties of the sidebar. + + Returns: + The drawer sidebar component. + """ + ... + +sidebar_trigger_style = { + "position": "fixed", + "z_index": "15", + "color": color("accent", 12), + "background_color": "transparent", + "padding": "0", +} + +class SidebarTrigger(Fragment): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "SidebarTrigger": + """Create the sidebar trigger component. + + Args: + sidebar: The sidebar component. + props: The properties of the sidebar trigger. + + Returns: + The sidebar trigger component. + """ + ... + +class Layout(Box): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + sidebar: Optional[Component] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Layout": + """Create the layout component. + + Args: + content: The content component. + sidebar: The sidebar component. + props: The properties of the layout. + + Returns: + The layout component. + """ + ... + +class LayoutNamespace(ComponentNamespace): + drawer_sidebar = staticmethod(DrawerSidebar.create) + stateful_sidebar = staticmethod(StatefulSidebar.create) + sidebar = staticmethod(Sidebar.create) + + @staticmethod + def __call__( + *children, + sidebar: Optional[Component] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_capitalize: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + content_editable: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + context_menu: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = 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]], bool, int, str] + ] = 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, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[EventType[[]]] = None, + on_click: Optional[EventType[[]]] = None, + on_context_menu: Optional[EventType[[]]] = None, + on_double_click: Optional[EventType[[]]] = None, + on_focus: Optional[EventType[[]]] = None, + on_mount: Optional[EventType[[]]] = None, + on_mouse_down: Optional[EventType[[]]] = None, + on_mouse_enter: Optional[EventType[[]]] = None, + on_mouse_leave: Optional[EventType[[]]] = None, + on_mouse_move: Optional[EventType[[]]] = None, + on_mouse_out: Optional[EventType[[]]] = None, + on_mouse_over: Optional[EventType[[]]] = None, + on_mouse_up: Optional[EventType[[]]] = None, + on_scroll: Optional[EventType[[]]] = None, + on_unmount: Optional[EventType[[]]] = None, + **props, + ) -> "Layout": + """Create the layout component. + + Args: + content: The content component. + sidebar: The sidebar component. + props: The properties of the layout. + + Returns: + The layout component. + """ + ... + +layout = LayoutNamespace() diff --git a/reflex/experimental/misc.py b/reflex/experimental/misc.py index fec0bb992..a2a5a0615 100644 --- a/reflex/experimental/misc.py +++ b/reflex/experimental/misc.py @@ -1,12 +1,23 @@ """Miscellaneous functions for the experimental package.""" import asyncio +from typing import Any -async def run_in_thread(func): +async def run_in_thread(func) -> Any: """Run a function in a separate thread. + To not block the UI event queue, run_in_thread must be inside inside a rx.event(background=True) decorated method. + Args: - func (callable): The function to run. + func (callable): The non-async function to run. + + Raises: + ValueError: If the function is an async function. + + Returns: + Any: The return value of the function. """ - await asyncio.get_event_loop().run_in_executor(None, func) + if asyncio.coroutines.iscoroutinefunction(func): + raise ValueError("func must be a non-async function") + return await asyncio.get_event_loop().run_in_executor(None, func) diff --git a/reflex/istate/data.py b/reflex/istate/data.py new file mode 100644 index 000000000..9f6e3b3f4 --- /dev/null +++ b/reflex/istate/data.py @@ -0,0 +1,126 @@ +"""This module contains the dataclasses representing the router object.""" + +import dataclasses +from typing import Optional + +from reflex import constants +from reflex.utils import format + + +@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 = "" + sec_websocket_version: str = "" + sec_websocket_key: str = "" + sec_websocket_extensions: str = "" + accept_encoding: str = "" + accept_language: str = "" + + def __init__(self, router_data: Optional[dict] = None): + """Initalize the HeaderData object based on router_data. + + Args: + router_data: the router_data dict. + """ + if router_data: + for k, v in router_data.get(constants.RouteVar.HEADERS, {}).items(): + object.__setattr__(self, format.to_snake_case(k), v) + else: + for k in dataclasses.fields(self): + object.__setattr__(self, k.name, "") + + +@dataclasses.dataclass(frozen=True) +class PageData: + """An object containing page data.""" + + host: str = "" # repeated with self.headers.origin (remove or keep the duplicate?) + path: str = "" + raw_path: str = "" + full_path: str = "" + full_raw_path: str = "" + params: dict = dataclasses.field(default_factory=dict) + + def __init__(self, router_data: Optional[dict] = None): + """Initalize the PageData object based on router_data. + + Args: + router_data: the router_data dict. + """ + if router_data: + 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", {}) + + +@dataclasses.dataclass(frozen=True, init=False) +class SessionData: + """An object containing session data.""" + + client_token: str = "" + client_ip: str = "" + session_id: str = "" + + def __init__(self, router_data: Optional[dict] = None): + """Initalize the SessionData object based on router_data. + + Args: + router_data: the router_data dict. + """ + if router_data: + 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) + + +@dataclasses.dataclass(frozen=True, init=False) +class RouterData: + """An object containing RouterData.""" + + 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. + + Args: + router_data: the router_data dict. + """ + object.__setattr__(self, "session", SessionData(router_data)) + object.__setattr__(self, "headers", HeaderData(router_data)) + object.__setattr__(self, "page", PageData(router_data)) diff --git a/reflex/istate/dynamic.py b/reflex/istate/dynamic.py new file mode 100644 index 000000000..e5da36c26 --- /dev/null +++ b/reflex/istate/dynamic.py @@ -0,0 +1,3 @@ +"""A container for dynamically generated states.""" + +# This page intentionally left blank. diff --git a/reflex/istate/storage.py b/reflex/istate/storage.py new file mode 100644 index 000000000..85e21ffa7 --- /dev/null +++ b/reflex/istate/storage.py @@ -0,0 +1,144 @@ +"""Client-side storage classes for reflex state variables.""" + +from __future__ import annotations + +from typing import Any + +from reflex.utils import format + + +class ClientStorageBase: + """Base class for client-side storage.""" + + def options(self) -> dict[str, Any]: + """Get the options for the storage. + + Returns: + All set options for the storage (not None). + """ + return { + format.to_camel_case(k): v for k, v in vars(self).items() if v is not None + } + + +class Cookie(ClientStorageBase, str): + """Represents a state Var that is stored as a cookie in the browser.""" + + name: str | None + path: str + max_age: int | None + domain: str | None + secure: bool | None + same_site: str + + def __new__( + cls, + object: Any = "", + encoding: str | None = None, + errors: str | None = None, + /, + name: str | None = None, + path: str = "/", + max_age: int | None = None, + domain: str | None = None, + secure: bool | None = None, + same_site: str = "lax", + ): + """Create a client-side Cookie (str). + + Args: + object: The initial object. + encoding: The encoding to use. + errors: The error handling scheme to use. + name: The name of the cookie on the client side. + path: Cookie path. Use / as the path if the cookie should be accessible on all pages. + max_age: Relative max age of the cookie in seconds from when the client receives it. + domain: Domain for the cookie (sub.domain.com or .allsubdomains.com). + secure: Is the cookie only accessible through HTTPS? + same_site: Whether the cookie is sent with third party requests. + One of (true|false|none|lax|strict) + + Returns: + The client-side Cookie object. + + Note: expires (absolute Date) is not supported at this time. + """ + if encoding or errors: + inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict") + else: + inst = super().__new__(cls, object) + inst.name = name + inst.path = path + inst.max_age = max_age + inst.domain = domain + inst.secure = secure + inst.same_site = same_site + return inst + + +class LocalStorage(ClientStorageBase, str): + """Represents a state Var that is stored in localStorage in the browser.""" + + name: str | None + sync: bool = False + + def __new__( + cls, + object: Any = "", + encoding: str | None = None, + errors: str | None = None, + /, + name: str | None = None, + sync: bool = False, + ) -> "LocalStorage": + """Create a client-side localStorage (str). + + Args: + object: The initial object. + encoding: The encoding to use. + errors: The error handling scheme to use. + name: The name of the storage key on the client side. + sync: Whether changes should be propagated to other tabs. + + Returns: + The client-side localStorage object. + """ + if encoding or errors: + inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict") + else: + inst = super().__new__(cls, object) + inst.name = name + inst.sync = sync + return inst + + +class SessionStorage(ClientStorageBase, str): + """Represents a state Var that is stored in sessionStorage in the browser.""" + + name: str | None + + def __new__( + cls, + object: Any = "", + encoding: str | None = None, + errors: str | None = None, + /, + name: str | None = None, + ) -> "SessionStorage": + """Create a client-side sessionStorage (str). + + Args: + object: The initial object. + encoding: The encoding to use. + errors: The error handling scheme to use + name: The name of the storage on the client side + + Returns: + The client-side sessionStorage object. + """ + if encoding or errors: + inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict") + else: + inst = super().__new__(cls, object) + inst.name = name + return inst diff --git a/reflex/middleware/hydrate_middleware.py b/reflex/middleware/hydrate_middleware.py index b1617fca7..2198b82c2 100644 --- a/reflex/middleware/hydrate_middleware.py +++ b/reflex/middleware/hydrate_middleware.py @@ -1,18 +1,20 @@ """Middleware to hydrate the state.""" + from __future__ import annotations +import dataclasses from typing import TYPE_CHECKING, Optional from reflex import constants from reflex.event import Event, get_hydrate_event from reflex.middleware.middleware import Middleware from reflex.state import BaseState, StateUpdate -from reflex.utils import format if TYPE_CHECKING: from reflex.app import App +@dataclasses.dataclass(init=True) class HydrateMiddleware(Middleware): """Middleware to handle initial app hydration.""" @@ -40,7 +42,7 @@ class HydrateMiddleware(Middleware): setattr(state, constants.CompileVars.IS_HYDRATED, False) # Get the initial state. - delta = format.format_state(state.dict()) + delta = state.dict() # since a full dict was captured, clean any dirtiness state._clean() diff --git a/reflex/middleware/middleware.py b/reflex/middleware/middleware.py index f522ff861..ef9de0bde 100644 --- a/reflex/middleware/middleware.py +++ b/reflex/middleware/middleware.py @@ -1,10 +1,10 @@ """Base Reflex middleware.""" + 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 @@ -12,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 088601cae..5f5e8647d 100644 --- a/reflex/model.py +++ b/reflex/model.py @@ -2,9 +2,7 @@ from __future__ import annotations -import os from collections import defaultdict -from pathlib import Path from typing import Any, ClassVar, Optional, Type, Union import alembic.autogenerate @@ -15,16 +13,16 @@ import alembic.runtime.environment import alembic.script import alembic.util import sqlalchemy +import sqlalchemy.exc import sqlalchemy.orm -from reflex import constants from reflex.base import Base -from reflex.config import get_config +from reflex.config import environment, get_config from reflex.utils import console -from reflex.utils.compat import sqlmodel +from reflex.utils.compat import sqlmodel, sqlmodel_field_has_primary_key -def get_engine(url: str | None = None): +def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine: """Get the database engine. Args: @@ -40,17 +38,38 @@ def get_engine(url: str | None = None): url = url or conf.db_url if url is None: raise ValueError("No database url configured") - if not Path(constants.ALEMBIC_CONFIG).exists(): + if not environment.ALEMBIC_CONFIG.exists(): console.warn( "Database is not initialized, run [bold]reflex db init[/bold] first." ) # Print the SQL queries if the log level is INFO or lower. - echo_db_query = os.environ.get("SQLALCHEMY_ECHO") == "True" + echo_db_query = environment.SQLALCHEMY_ECHO # Needed for the admin dash on sqlite. connect_args = {"check_same_thread": False} if url.startswith("sqlite") else {} 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] ] @@ -144,8 +163,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue non_default_primary_key_fields = [ field_name for field_name, field in cls.__fields__.items() - if field_name != "id" - and getattr(field.field_info, "primary_key", None) is True + if field_name != "id" and sqlmodel_field_has_primary_key(field) ] if non_default_primary_key_fields: cls.__fields__.pop("id", None) @@ -213,7 +231,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue Returns: tuple of (config, script_directory) """ - config = alembic.config.Config(constants.ALEMBIC_CONFIG) + config = alembic.config.Config(environment.ALEMBIC_CONFIG) return config, alembic.script.ScriptDirectory( config.get_main_option("script_location", default="version"), ) @@ -248,8 +266,8 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue def alembic_init(cls): """Initialize alembic for the project.""" alembic.command.init( - config=alembic.config.Config(constants.ALEMBIC_CONFIG), - directory=str(Path(constants.ALEMBIC_CONFIG).parent / "alembic"), + config=alembic.config.Config(environment.ALEMBIC_CONFIG), + directory=str(environment.ALEMBIC_CONFIG.parent / "alembic"), ) @classmethod @@ -269,7 +287,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue Returns: True when changes have been detected. """ - if not Path(constants.ALEMBIC_CONFIG).exists(): + if not environment.ALEMBIC_CONFIG.exists(): return False config, script_directory = cls._alembic_config() @@ -370,7 +388,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue True - indicating the process was successful. None - indicating the process was skipped. """ - if not Path(constants.ALEMBIC_CONFIG).exists(): + if not environment.ALEMBIC_CONFIG.exists(): return with cls.get_db_engine().connect() as connection: @@ -396,7 +414,7 @@ ModelRegistry.register(Model) def session(url: str | None = None) -> sqlmodel.Session: - """Get a session to interact with the database. + """Get a sqlmodel session to interact with the database. Args: url: The database url. @@ -405,3 +423,15 @@ def session(url: str | None = None) -> sqlmodel.Session: A database session. """ return sqlmodel.Session(get_engine(url)) + + +def sqla_session(url: str | None = None) -> sqlalchemy.orm.Session: + """Get a bare sqlalchemy session to interact with the database. + + Args: + url: The database url. + + Returns: + A database session. + """ + return sqlalchemy.orm.Session(get_engine(url)) diff --git a/reflex/page.py b/reflex/page.py index 1e5e8603d..87a8c49c2 100644 --- a/reflex/page.py +++ b/reflex/page.py @@ -6,6 +6,7 @@ from collections import defaultdict from typing import Any, Dict, List from reflex.config import get_config +from reflex.event import EventType DECORATED_PAGES: Dict[str, List] = defaultdict(list) @@ -17,7 +18,7 @@ def page( description: str | None = None, meta: list[Any] | None = None, script_tags: list[Any] | None = None, - on_load: Any | list[Any] | None = None, + on_load: EventType[[]] | None = None, ): """Decorate a function as a page. @@ -65,13 +66,20 @@ def page( return decorator -def get_decorated_pages() -> list[dict]: +def get_decorated_pages(omit_implicit_routes=True) -> list[dict[str, Any]]: """Get the decorated pages. + Args: + omit_implicit_routes: Whether to omit pages where the route will be implicitely guessed later. + Returns: The decorated pages. """ return sorted( - [page_data for _, page_data in DECORATED_PAGES[get_config().app_name]], - key=lambda x: x["route"], + [ + page_data + for _, page_data in DECORATED_PAGES[get_config().app_name] + if not omit_implicit_routes or "route" in page_data + ], + key=lambda x: x.get("route", ""), ) diff --git a/reflex/proxy.py b/reflex/proxy.py index c47203bfd..7fbbcd444 100644 --- a/reflex/proxy.py +++ b/reflex/proxy.py @@ -51,14 +51,14 @@ else: @asynccontextmanager async def proxy_middleware( # pyright: ignore[reportGeneralTypeIssues] - api: FastAPI, + app: FastAPI, ) -> AsyncGenerator[None, None]: """A middleware to proxy requests to the separate frontend server. The proxy is installed on the / endpoint of the FastAPI instance. Args: - api: The FastAPI instance. + app: The FastAPI instance. Yields: None @@ -67,7 +67,7 @@ else: backend_port = config.backend_port frontend_host = f"http://localhost:{config.frontend_port}" proxy_context, proxy_app = _get_proxy_app_with_context(frontend_host) - api.mount("/", proxy_app) + app.mount("/", proxy_app) console.debug( f"Proxying '/' requests on port {backend_port} to {frontend_host}" ) diff --git a/reflex/reflex.py b/reflex/reflex.py index 010cceaeb..7bef8b7e5 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -4,7 +4,6 @@ from __future__ import annotations import atexit import os -import webbrowser from pathlib import Path from typing import List, Optional @@ -14,9 +13,10 @@ from reflex_cli.deployments import deployments_cli from reflex_cli.utils import dependency from reflex import constants -from reflex.config import get_config +from reflex.config import environment, get_config from reflex.custom_components.custom_components import custom_components_cli -from reflex.utils import console, telemetry +from reflex.state import reset_disk_state_manager +from reflex.utils import console, redir, telemetry # Disable typer+rich integration for help panels typer.core.rich = False # type: ignore @@ -65,6 +65,7 @@ def _init( name: str, template: str | None = None, loglevel: constants.LogLevel = config.loglevel, + ai: bool = False, ): """Initialize a new Reflex app in the given directory.""" from reflex.utils import exec, prerequisites @@ -84,18 +85,33 @@ def _init( prerequisites.initialize_reflex_user_directory() prerequisites.ensure_reflex_installation_id() - # When upgrading to 0.4, show migration instructions. - if prerequisites.should_show_rx_chakra_migration_instructions(): - prerequisites.show_rx_chakra_migration_instructions() - # Set up the web project. prerequisites.initialize_frontend_dependencies() + # Integrate with reflex.build. + generation_hash = None + if ai: + if template is None: + # If AI is requested and no template specified, redirect the user to reflex.build. + generation_hash = redir.reflex_build_redirect() + elif prerequisites.is_generation_hash(template): + # Otherwise treat the template as a generation hash. + generation_hash = template + else: + console.error( + "Cannot use `--template` option with `--ai` option. Please remove `--template` option." + ) + raise typer.Exit(2) + template = constants.Templates.DEFAULT + # Initialize the app. prerequisites.initialize_app(app_name, template) - # Migrate Pynecone projects to Reflex. - prerequisites.migrate_to_reflex() + # If a reflex.build generation hash is available, download the code and apply it to the main module. + if generation_hash: + prerequisites.initialize_main_module_index_from_generation( + app_name, generation_hash=generation_hash + ) # Initialize the .gitignore. prerequisites.initialize_gitignore() @@ -119,9 +135,13 @@ def init( loglevel: constants.LogLevel = typer.Option( config.loglevel, help="The log level to use." ), + ai: bool = typer.Option( + False, + help="Use AI to create the initial template. Cannot be used with existing app or `--template` option.", + ), ): """Initialize a new Reflex app in the current directory.""" - _init(name, template, loglevel) + _init(name, template, loglevel, ai) def _run( @@ -157,12 +177,19 @@ def _run( if prerequisites.needs_reinit(frontend=frontend): _init(name=config.app_name, loglevel=loglevel) - # Find the next available open port. - if frontend and processes.is_process_on_port(frontend_port): - frontend_port = processes.change_port(frontend_port, "frontend") + # Delete the states folder if it exists. + reset_disk_state_manager() - if backend and processes.is_process_on_port(backend_port): - backend_port = processes.change_port(backend_port, "backend") + # Find the next available open port if applicable. + if frontend: + frontend_port = processes.handle_port( + "frontend", frontend_port, str(constants.DefaultPorts.FRONTEND_PORT) + ) + + if backend: + backend_port = processes.handle_port( + "backend", backend_port, str(constants.DefaultPorts.BACKEND_PORT) + ) # Apply the new ports to the config. if frontend_port != str(config.frontend_port): @@ -198,7 +225,8 @@ def _run( exec.run_frontend_prod, exec.run_backend_prod, ) - assert setup_frontend and frontend_cmd and backend_cmd, "Invalid env" + if not setup_frontend or not frontend_cmd or not backend_cmd: + raise ValueError("Invalid env") # Post a telemetry event. telemetry.send(f"run-{env.value}") @@ -216,13 +244,23 @@ def _run( # In prod mode, run the backend on a separate thread. if backend and env == constants.Env.PROD: - commands.append((backend_cmd, backend_host, backend_port)) + commands.append( + ( + backend_cmd, + backend_host, + backend_port, + loglevel.subprocess_level(), + frontend, + ) + ) # Start the frontend and backend. with processes.run_concurrently_context(*commands): # In dev mode, run the backend on the main thread. if backend and env == constants.Env.DEV: - backend_cmd(backend_host, int(backend_port)) + backend_cmd( + backend_host, int(backend_port), loglevel.subprocess_level(), frontend + ) # The windows uvicorn bug workaround # https://github.com/reflex-dev/reflex/issues/2335 if constants.IS_WINDOWS and exec.frontend_process: @@ -236,9 +274,17 @@ def run( constants.Env.DEV, help="The environment to run the app in." ), frontend: bool = typer.Option( - False, "--frontend-only", help="Execute only frontend." + False, + "--frontend-only", + help="Execute only frontend.", + envvar=constants.ENV_FRONTEND_ONLY_ENV_VAR, + ), + backend: bool = typer.Option( + False, + "--backend-only", + help="Execute only backend.", + envvar=constants.ENV_BACKEND_ONLY_ENV_VAR, ), - backend: bool = typer.Option(False, "--backend-only", help="Execute only backend."), frontend_port: str = typer.Option( config.frontend_port, help="Specify a different frontend port." ), @@ -253,6 +299,12 @@ def run( ), ): """Run the app in the current directory.""" + if frontend and backend: + console.error("Cannot use both --frontend-only and --backend-only options.") + raise typer.Exit(1) + os.environ[constants.ENV_BACKEND_ONLY_ENV_VAR] = str(backend).lower() + os.environ[constants.ENV_FRONTEND_ONLY_ENV_VAR] = str(frontend).lower() + _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel) @@ -294,7 +346,7 @@ def export( backend=backend, zip_dest_dir=zip_dest_dir, upload_db_file=upload_db_file, - loglevel=loglevel, + loglevel=loglevel.subprocess_level(), ) @@ -368,7 +420,7 @@ def db_init(): return # Check the alembic config. - if Path(constants.ALEMBIC_CONFIG).exists(): + if environment.ALEMBIC_CONFIG.exists(): console.error( "Database is already initialized. Use " "[bold]reflex db makemigrations[/bold] to create schema change " @@ -427,17 +479,6 @@ def makemigrations( ) -@script_cli.command( - name="keep-chakra", - help="Change all rx. references to rx.chakra., to preserve Chakra UI usage.", -) -def keep_chakra(): - """Change all rx. references to rx.chakra., to preserve Chakra UI usage.""" - from reflex.utils import prerequisites - - prerequisites.migrate_to_rx_chakra() - - @cli.command() def deploy( key: Optional[str] = typer.Option( @@ -540,7 +581,7 @@ def deploy( frontend=frontend, backend=backend, zipping=zipping, - loglevel=loglevel, + loglevel=loglevel.subprocess_level(), upload_db_file=upload_db_file, ), key=key, @@ -554,22 +595,10 @@ def deploy( interactive=interactive, with_metrics=with_metrics, with_tracing=with_tracing, - loglevel=loglevel.value, + loglevel=loglevel.subprocess_level(), ) -@cli.command() -def demo( - frontend_port: str = typer.Option( - "3001", help="Specify a different frontend port." - ), - backend_port: str = typer.Option("8001", help="Specify a different backend port."), -): - """Run the demo app.""" - # Open the demo app in a terminal. - webbrowser.open("https://demo.reflex.run") - - cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema.") cli.add_typer(script_cli, name="script", help="Subcommands running helper scripts.") cli.add_typer( diff --git a/reflex/state.py b/reflex/state.py index ebe33aa26..cc9dda05b 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -5,17 +5,22 @@ from __future__ import annotations import asyncio import contextlib import copy +import dataclasses import functools import inspect -import traceback +import pickle +import sys import uuid from abc import ABC, abstractmethod from collections import defaultdict +from hashlib import md5 +from pathlib import Path from types import FunctionType, MethodType from typing import ( TYPE_CHECKING, Any, AsyncIterator, + BinaryIO, Callable, ClassVar, Dict, @@ -23,10 +28,33 @@ from typing import ( Optional, Sequence, Set, + Tuple, Type, + TypeVar, + Union, + cast, + get_args, + get_type_hints, ) -import dill +from sqlalchemy.orm import DeclarativeBase +from typing_extensions import Self + +from reflex import event +from reflex.config import get_config +from reflex.istate.data import RouterData +from reflex.istate.storage import ( + ClientStorageBase, +) +from reflex.vars.base import ( + ComputedVar, + DynamicRouteVar, + Var, + computed_var, + dispatch, + get_unique_variable_name, + is_computed_var, +) try: import pydantic.v1 as pydantic @@ -35,22 +63,36 @@ except ModuleNotFoundError: import wrapt from redis.asyncio import Redis +from redis.exceptions import ResponseError +import reflex.istate.dynamic from reflex import constants from reflex.base import Base +from reflex.config import environment from reflex.event import ( BACKGROUND_TASK_MARKER, Event, EventHandler, EventSpec, fix_events, - window_alert, ) -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, + DynamicComponentInvalidSignature, + DynamicRouteArgShadowsStateVar, + EventHandlerShadowsBuiltInStateMethod, + ImmutableStateError, + InvalidStateManagerMode, + LockExpiredError, + SetUndefinedStateVarError, + StateSchemaMismatchError, +) from reflex.utils.exec import is_testing_env -from reflex.utils.serializers import SerializedType, serialize, serializer -from reflex.vars import BaseVar, ComputedVar, Var, computed_var +from reflex.utils.serializers import serializer +from reflex.utils.types import _isinstance, get_origin, override +from reflex.vars import VarData if TYPE_CHECKING: from reflex.components.component import Component @@ -63,98 +105,14 @@ 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): - """An object containing headers data.""" - - host: str = "" - origin: str = "" - upgrade: str = "" - connection: str = "" - pragma: str = "" - cache_control: str = "" - user_agent: str = "" - sec_websocket_version: str = "" - sec_websocket_key: str = "" - sec_websocket_extensions: str = "" - accept_encoding: str = "" - accept_language: str = "" - - def __init__(self, router_data: Optional[dict] = None): - """Initalize the HeaderData object based on router_data. - - 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) - - -class PageData(Base): - """An object containing page data.""" - - host: str = "" # repeated with self.headers.origin (remove or keep the duplicate?) - path: str = "" - raw_path: str = "" - full_path: str = "" - full_raw_path: str = "" - params: dict = {} - - def __init__(self, router_data: Optional[dict] = None): - """Initalize the PageData object based on router_data. - - 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, {}) - - -class SessionData(Base): - """An object containing session data.""" - - client_token: str = "" - client_ip: str = "" - session_id: str = "" - - def __init__(self, router_data: Optional[dict] = None): - """Initalize the SessionData object based on router_data. - - 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, "") - - -class RouterData(Base): - """An object containing RouterData.""" - - session: SessionData = SessionData() - headers: HeaderData = HeaderData() - page: PageData = PageData() - - def __init__(self, router_data: Optional[dict] = None): - """Initialize the RouterData object. - - Args: - router_data: the router_data dict. - """ - super().__init__() - self.session = SessionData(router_data) - self.headers = HeaderData(router_data) - self.page = PageData(router_data) +# Errors caught during pickling of state +HANDLED_PICKLE_ERRORS = ( + pickle.PicklingError, + AttributeError, + IndexError, + TypeError, + ValueError, +) def _no_chain_background_task( @@ -195,19 +153,9 @@ def _no_chain_background_task( raise TypeError(f"{fn} is marked as a background task, but is not async.") -RESERVED_BACKEND_VAR_NAMES = { - "_backend_vars", - "_computed_var_dependencies", - "_substate_var_dependencies", - "_always_dirty_computed_vars", - "_always_dirty_substates", - "_was_touched", -} - - def _substate_key( token: str, - state_cls_or_name: BaseState | Type[BaseState] | str | list[str], + state_cls_or_name: BaseState | Type[BaseState] | str | Sequence[str], ) -> str: """Get the substate key. @@ -240,10 +188,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. @@ -254,8 +203,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. @@ -280,6 +229,7 @@ class EventHandlerSetVar(EventHandler): Raises: AttributeError: If the given Var name does not exist on the state. EventHandlerValueError: If the given Var name is not a str + NotImplementedError: If the setter for the given Var is async """ from reflex.utils.exceptions import EventHandlerValueError @@ -288,14 +238,50 @@ class EventHandlerSetVar(EventHandler): raise EventHandlerValueError( f"Var name must be passed as a string, got {args[0]!r}" ) + + handler = getattr(self.state_cls, constants.SETTER_PREFIX + args[0], None) + # Check that the requested Var setter exists on the State at compile time. - if getattr(self.state_cls, constants.SETTER_PREFIX + args[0], None) is None: + if handler is None: raise AttributeError( f"Variable `{args[0]}` cannot be set on `{self.state_cls.get_full_name()}`" ) + + if asyncio.iscoroutinefunction(handler.fn): + raise NotImplementedError( + f"Setter for {args[0]} is async, which is not supported." + ) + 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. + """ + from reflex.vars import Field + + 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_ + if get_origin(f.outer_type_) is not Field + else get_args(f.outer_type_)[0], + ) + + class BaseState(Base, ABC, extra=pydantic.Extra.allow): """The state of the app.""" @@ -303,7 +289,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): vars: ClassVar[Dict[str, Var]] = {} # The base vars of the class. - base_vars: ClassVar[Dict[str, BaseVar]] = {} + base_vars: ClassVar[Dict[str, Var]] = {} # The computed vars of the class. computed_vars: ClassVar[Dict[str, ComputedVar]] = {} @@ -311,10 +297,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Vars inherited by the parent state. inherited_vars: ClassVar[Dict[str, Var]] = {} - # Backend vars that are never sent to the client. + # Backend base vars that are never sent to the client. backend_vars: ClassVar[Dict[str, Any]] = {} - # Backend vars inherited + # Backend base vars inherited inherited_backend_vars: ClassVar[Dict[str, Any]] = {} # The event handlers. @@ -350,7 +336,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # The routing path that triggered the state router_data: Dict[str, Any] = {} - # Per-instance copy of backend variable values + # Per-instance copy of backend base variable values _backend_vars: Dict[str, Any] = {} # The router data for the current page @@ -359,6 +345,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Whether the state has ever been touched since instantiation. _was_touched: bool = False + # Whether this state class is a mixin and should not be instantiated. + _mixin: ClassVar[bool] = False + # A special event handler for setting base vars. setvar: ClassVar[EventHandler] @@ -404,11 +393,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Create a fresh copy of the backend variables for this instance self._backend_vars = copy.deepcopy( - { - name: item - for name, item in self.backend_vars.items() - if name not in self.computed_vars - } + {name: item for name, item in self.backend_vars.items()} ) def __repr__(self) -> str: @@ -428,17 +413,32 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): """ return [ v - for mixin in cls.__mro__ - if mixin is cls or not issubclass(mixin, (BaseState, ABC)) - for v in mixin.__dict__.values() - if isinstance(v, ComputedVar) + for mixin in cls._mixins() + [cls] + for name, v in mixin.__dict__.items() + if is_computed_var(v) and name not in cls.inherited_vars ] @classmethod - def __init_subclass__(cls, **kwargs): + def _validate_module_name(cls) -> None: + """Check if the module name is valid. + + Reflex uses ___ as state name module separator. + + Raises: + NameError: If the module name is invalid. + """ + if "___" in cls.__module__: + raise NameError( + "The module name of a State class cannot contain '___'. " + "Please rename the module." + ) + + @classmethod + def __init_subclass__(cls, mixin: bool = False, **kwargs): """Do some magic for the subclass initialization. Args: + mixin: Whether the subclass is a mixin and should not be initialized. **kwargs: The kwargs to pass to the pydantic init_subclass method. Raises: @@ -447,10 +447,23 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): from reflex.utils.exceptions import StateValueError super().__init_subclass__(**kwargs) + + cls._mixin = mixin + if mixin: + return + + # Handle locally-defined states for pickling. + if "" in cls.__qualname__: + cls._handle_local_def() + + # Validate the module name. + cls._validate_module_name() + # Event handlers should not shadow builtin state methods. 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() @@ -465,61 +478,51 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls.inherited_backend_vars = parent_state.backend_vars # Check if another substate class with the same name has already been defined. - if cls.__name__ in set(c.__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.__name__ != cls.__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.__name__}' has been defined multiple times. " - "Shadowing substate classes is not allowed." - ) + if cls.get_name() in set( + c.get_name() for c in parent_state.class_subclasses + ): + # 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 for name, value in cls.__dict__.items() - if types.is_backend_variable(name, cls) - and name not in RESERVED_BACKEND_VAR_NAMES - and name not in cls.inherited_backend_vars - and not isinstance(value, FunctionType) - and not isinstance(value, ComputedVar) - } - - # Get backend computed vars - backend_computed_vars = { - v._var_name: v._var_set_state(cls) - for v in computed_vars - if types.is_backend_variable(v._var_name, cls) - and v._var_name not in cls.inherited_backend_vars + if types.is_backend_base_variable(name, cls) } + # Add annotated backend vars that may not have a default value. + new_backend_vars.update( + { + name: cls._get_var_default(name, annotation_value) + for name, annotation_value in cls._get_type_hints().items() + if name not in new_backend_vars + and types.is_backend_base_variable(name, cls) + } + ) cls.backend_vars = { **cls.inherited_backend_vars, **new_backend_vars, - **backend_computed_vars, } # Set the base and computed vars. cls.base_vars = { - f.name: BaseVar(_var_name=f.name, _var_type=f.outer_type_)._var_set_state( - cls - ) + 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._var_set_state(cls) for v in computed_vars} + cls.computed_vars = { + v._js_expr: v._replace(merge_var_data=VarData.from_state(cls)) + for v in computed_vars + } cls.vars = { **cls.inherited_vars, **cls.base_vars, @@ -540,13 +543,18 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for mixin in cls._mixins(): for name, value in mixin.__dict__.items(): - if isinstance(value, ComputedVar): + if name in cls.inherited_vars: + continue + if is_computed_var(value): fget = cls._copy_fn(value.fget) - newcv = ComputedVar(fget=fget, _var_name=value._var_name) - newcv._var_set_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) continue if events.get(name) is not None: continue @@ -566,6 +574,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 @@ -608,6 +619,48 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): and hasattr(value, "__code__") ) + @classmethod + def _evaluate( + cls, f: Callable[[Self], Any], of_type: Union[type, None] = None + ) -> Var: + """Evaluate a function to a ComputedVar. Experimental. + + Args: + f: The function to evaluate. + of_type: The type of the ComputedVar. Defaults to Component. + + Returns: + The ComputedVar. + """ + console.warn( + "The _evaluate method is experimental and may be removed in future versions." + ) + from reflex.components.component import Component + + of_type = of_type or Component + + unique_var_name = get_unique_variable_name() + + @computed_var(_js_expr=unique_var_name, return_type=of_type) + def computed_var_func(state: Self): + result = f(state) + + if not _isinstance(result, of_type): + console.warn( + f"Inline ComputedVar {f} expected type {of_type}, got {type(result)}. " + "You can specify expected type with `of_type` argument." + ) + + return result + + setattr(cls, unique_var_name, computed_var_func) + cls.computed_vars[unique_var_name] = computed_var_func + cls.vars[unique_var_name] = computed_var_func + cls._update_substate_inherited_vars({unique_var_name: computed_var_func}) + cls._always_dirty_computed_vars.add(unique_var_name) + + return getattr(cls, unique_var_name) + @classmethod def _mixins(cls) -> List[Type]: """Get the mixin classes of the state. @@ -618,10 +671,46 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return [ mixin for mixin in cls.__mro__ - if not issubclass(mixin, (BaseState, ABC)) - and mixin not in [pydantic.BaseModel, Base] + if ( + mixin not in [pydantic.BaseModel, Base, cls] + and issubclass(mixin, BaseState) + and mixin._mixin is True + ) ] + @classmethod + def _handle_local_def(cls): + """Handle locally-defined states for pickling.""" + known_names = dir(reflex.istate.dynamic) + proposed_name = cls.__name__ + for ix in range(len(known_names)): + if proposed_name not in known_names: + break + proposed_name = f"{cls.__name__}_{ix}" + setattr(reflex.istate.dynamic, proposed_name, cls) + cls.__original_name__ = cls.__name__ + cls.__original_module__ = cls.__module__ + cls.__name__ = cls.__qualname__ = proposed_name + cls.__module__ = reflex.istate.dynamic.__name__ + + @classmethod + def _get_type_hints(cls) -> dict[str, Any]: + """Get the type hints for this class. + + If the class is dynamic, evaluate the type hints with the original + module in the local namespace. + + Returns: + The type hints dict. + """ + original_module = getattr(cls, "__original_module__", None) + if original_module is not None: + localns = sys.modules[original_module].__dict__ + else: + localns = None + + return get_type_hints(cls, localns=localns) + @classmethod def _init_var_dependency_dicts(cls): """Initialize the var dependency tracking dicts. @@ -632,10 +721,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), ) @@ -676,12 +761,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): parent_state.get_parent_state(), ) + # Reset cached schema value + cls._to_schema.cache_clear() + @classmethod def _check_overridden_methods(cls): """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() @@ -695,21 +783,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 @@ -728,7 +832,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): "dirty_substates", "router_data", } - | RESERVED_BACKEND_VAR_NAMES + | types.RESERVED_BACKEND_VAR_NAMES ) @classmethod @@ -736,15 +840,19 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): def get_parent_state(cls) -> Type[BaseState] | None: """Get the parent state. + Raises: + ValueError: If more than one parent state is found. + Returns: The parent state. """ parent_states = [ base for base in cls.__bases__ - if types._issubclass(base, BaseState) and base is not BaseState + if issubclass(base, BaseState) and base is not BaseState and not base._mixin ] - assert len(parent_states) < 2, "Only one parent state is allowed." + if len(parent_states) >= 2: + raise ValueError(f"Only one parent state is allowed {parent_states}.") return parent_states[0] if len(parent_states) == 1 else None # type: ignore @classmethod @@ -764,7 +872,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: The name of the state. """ - return format.to_snake_case(cls.__name__) + module = cls.__module__.replace(".", "___") + return format.to_snake_case(f"{module}___{cls.__name__}") @classmethod @functools.lru_cache() @@ -828,7 +937,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return getattr(substate, name) @classmethod - def _init_var(cls, prop: BaseVar): + def _init_var(cls, prop: Var): """Initialize a variable. Args: @@ -844,7 +953,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) @@ -871,8 +980,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): ) # create the variable based on name and type - var = BaseVar(_var_name=name, _var_type=type_) - var._var_set_state(cls) + var = Var( + _js_expr=format.format_state_name(cls.get_full_name()) + "." + name, + _var_type=type_, + _var_data=VarData.from_state(cls, name), + ).guess_type() # add the pydantic field dynamically (must be done before _init_var) cls.add_field(var, default_value) @@ -891,13 +1003,13 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls._init_var_dependency_dicts() @classmethod - def _set_var(cls, prop: BaseVar): + def _set_var(cls, prop: Var): """Set the var as a class member. Args: prop: The var instance to set. """ - setattr(cls, prop._var_name, prop) + setattr(cls, prop._var_field_name, prop) @classmethod def _create_event_handler(cls, fn): @@ -917,7 +1029,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: BaseVar): + def _create_setter(cls, prop: Var): """Create a setter for the var. Args: @@ -930,14 +1042,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): setattr(cls, setter_name, event_handler) @classmethod - def _set_default_value(cls, prop: BaseVar): + 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. - 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: @@ -949,7 +1061,27 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): and not types.is_optional(prop._var_type) ): # Ensure frontend uses null coalescing when accessing. - prop._var_type = Optional[prop._var_type] + object.__setattr__(prop, "_var_type", Optional[prop._var_type]) + + @classmethod + def _get_var_default(cls, name: str, annotation_value: Any) -> Any: + """Get the default value of a (backend) var. + + Args: + name: The name of the var. + annotation_value: The annotation value of the var. + + Returns: + The default value of the var or None. + """ + try: + return getattr(cls, name) + except AttributeError: + try: + return Var("", _var_type=annotation_value).get_default_value() + except TypeError: + pass + return None @staticmethod def _get_base_functions() -> dict[str, FunctionType]: @@ -964,6 +1096,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. @@ -971,21 +1124,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) @@ -993,13 +1149,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. @@ -1068,6 +1250,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Args: name: The name of the attribute. value: The value of the attribute. + + Raises: + SetUndefinedStateVarError: If a value of a var is set without first defining it. """ if isinstance(value, MutableProxy): # unwrap proxy objects when assigning back to the state @@ -1079,15 +1264,38 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): setattr(self.parent_state, name, value) return - if ( - types.is_backend_variable(name, self.__class__) - and name not in RESERVED_BACKEND_VAR_NAMES - ): + if name in self.backend_vars: self._backend_vars.__setitem__(name, value) self.dirty_vars.add(name) self._mark_dirty() return + if ( + name not in self.vars + and name not in self.get_skip_vars() + and not name.startswith("__") + and not name.startswith( + f"_{getattr(type(self), '__original_name__', type(self).__name__)}__" + ) + ): + raise SetUndefinedStateVarError( + f"The state variable '{name}' has not been defined in '{type(self).__name__}'. " + f"All state variables must be declared before they can be set." + ) + + fields = self.get_fields() + + if name in fields and not _isinstance( + value, (field_type := fields[name].outer_type_) + ): + console.deprecate( + "mismatched-type-assignment", + f"Tried to assign value {value} of type {type(value)} to field {type(self).__name__}.{name} of type {field_type}." + " This might lead to unexpected behavior.", + "0.6.5", + "0.7.0", + ) + # Set the attribute. super().__setattr__(name, value) @@ -1115,6 +1323,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): default = copy.deepcopy(field.default) setattr(self, prop_name, default) + # Reset the backend vars. + for prop_name, value in self.backend_vars.items(): + setattr(self, prop_name, copy.deepcopy(value)) + # Recursively reset the substates. for substate in self.substates.values(): substate.reset() @@ -1217,6 +1429,17 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): parent_states_with_name.append((parent_state.get_full_name(), parent_state)) return parent_states_with_name + def _get_root_state(self) -> BaseState: + """Get the root state of the state tree. + + Returns: + The root state of the state tree. + """ + parent_state = self + while parent_state.parent_state is not None: + parent_state = parent_state.parent_state + return parent_state + async def _populate_parent_states(self, target_state_cls: Type[BaseState]): """Populate substates in the tree between the target_state_cls and common ancestor of this state. @@ -1276,10 +1499,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: The instance of state_cls associated with this state's client_token. """ - if self.parent_state is None: - root_state = self - else: - root_state = self._get_parent_states()[-1][1] + root_state = self._get_root_state() return root_state.get_substate(state_cls.get_full_name().split(".")) async def _get_state_from_redis(self, state_cls: Type[BaseState]) -> BaseState: @@ -1430,24 +1650,46 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): The valid StateUpdate containing the events and final flag. """ # get the delta from the root of the state tree - state = self - while state.parent_state is not None: - state = state.parent_state + state = self._get_root_state() token = self.router.session.client_token # Convert valid EventHandler and EventSpec into Event fixed_events = fix_events(self._check_valid(handler, events), token) - # Get the delta after processing the event. - delta = state.get_delta() - state._clean() + try: + # Get the delta after processing the event. + delta = state.get_delta() + state._clean() - return StateUpdate( - delta=delta, - events=fixed_events, - final=final if not handler.is_background else True, - ) + return StateUpdate( + delta=delta, + events=fixed_events, + final=final if not handler.is_background else True, + ) + except Exception as ex: + state._clean() + + app_instance = getattr(prerequisites.get_app(), constants.CompileVars.APP) + + event_specs = app_instance.backend_exception_handler(ex) + + if event_specs is None: + return StateUpdate() + + event_specs_correct_type = cast( + Union[List[Union[EventSpec, EventHandler]], None], + [event_specs] if isinstance(event_specs, EventSpec) else event_specs, + ) + fixed_events = fix_events( + event_specs_correct_type, + token, + router_data=state.router_data, + ) + return StateUpdate( + events=fixed_events, + final=True, + ) async def _process_event( self, handler: EventHandler, state: BaseState | StateProxy, payload: Dict @@ -1463,7 +1705,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): StateUpdate object """ from reflex.utils import telemetry - from reflex.utils.exceptions import ReflexError # Get the function to process the event. fn = functools.partial(handler.fn, state) @@ -1501,13 +1742,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # If an error occurs, throw a window alert. except Exception as ex: - error = traceback.format_exc() - print(error) - if isinstance(ex, ReflexError): - telemetry.send("error", context="backend", detail=str(ex)) + telemetry.send_error(ex, context="backend") + + app_instance = getattr(prerequisites.get_app(), constants.CompileVars.APP) + + event_specs = app_instance.backend_exception_handler(ex) + yield state._as_state_update( handler, - window_alert("An error occurred. See logs for details."), + event_specs, final=True, ) @@ -1523,11 +1766,26 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if actual_var is not None: actual_var.mark_dirty(instance=self) - def _dirty_computed_vars(self, from_vars: set[str] | None = None) -> set[str]: + def _expired_computed_vars(self) -> set[str]: + """Determine ComputedVars that need to be recalculated based on the expiration time. + + Returns: + Set of computed vars to include in the delta. + """ + return set( + cvar + for cvar in self.computed_vars + if self.computed_vars[cvar].needs_update(instance=self) + ) + + def _dirty_computed_vars( + self, from_vars: set[str] | None = None, include_backend: bool = True + ) -> set[str]: """Determine ComputedVars that need to be recalculated based on the given vars. Args: from_vars: find ComputedVar that depend on this set of vars. If unspecified, will use the dirty_vars. + include_backend: whether to include backend vars in the calculation. Returns: Set of computed vars to include in the delta. @@ -1536,6 +1794,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cvar for dirty_var in from_vars or self.dirty_vars for cvar in self._computed_var_dependencies[dirty_var] + if include_backend or not self.computed_vars[cvar]._backend ) @classmethod @@ -1571,19 +1830,25 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): self.dirty_vars.update(self._always_dirty_computed_vars) self._mark_dirty() + frontend_computed_vars: set[str] = { + name for name, cv in self.computed_vars.items() if not cv._backend + } + # Return the dirty vars for this instance, any cached/dependent computed vars, # and always dirty computed vars (cache=False) delta_vars = ( self.dirty_vars.intersection(self.base_vars) - .union(self._dirty_computed_vars()) + .union(self.dirty_vars.intersection(frontend_computed_vars)) + .union(self._dirty_computed_vars(include_backend=False)) .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_variable(prop, self.__class__) + if not types.is_backend_base_variable(prop, type(self)) } + if len(subdelta) > 0: delta[self.get_full_name()] = subdelta @@ -1592,9 +1857,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for substate in self.dirty_substates.union(self._always_dirty_substates): delta.update(substates[substate].get_delta()) - # Format the delta. - delta = format.format_state(delta) - # Return the delta. return delta @@ -1608,6 +1870,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): self.parent_state.dirty_substates.add(self.get_name()) self.parent_state._mark_dirty() + # Append expired computed vars to dirty_vars to trigger recalculation + self.dirty_vars.update(self._expired_computed_vars()) + # have to mark computed vars dirty to allow access to newly computed # values within the same ComputedVar function self._mark_dirty_computed_vars() @@ -1698,22 +1963,24 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): prop_name: 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) + if is_computed_var(cv) and not isinstance(cv._initial_value, types.Unset) else self.get_value(getattr(self, prop_name)) ) for prop_name, cv in self.computed_vars.items() + if not cv._backend } elif include_computed: computed_vars = { # Include the computed vars. prop_name: self.get_value(getattr(self, prop_name)) - for prop_name in self.computed_vars + for prop_name, cv in self.computed_vars.items() + if not cv._backend } else: computed_vars = {} @@ -1726,6 +1993,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for v in self.substates.values() ]: d.update(substate_d) + return d async def __aenter__(self) -> BaseState: @@ -1755,7 +2023,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): def __getstate__(self): """Get the state for redis serialization. - This method is called by cloudpickle to serialize the object. + This method is called by pickle to serialize the object. It explicitly removes parent_state and substates because those are serialized separately by the StateManagerRedis to allow for better horizontal scaling as state size increases. @@ -1764,15 +2032,106 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): The state dict for serialization. """ state = super().__getstate__() - # Never serialize parent_state or substates state["__dict__"] = state["__dict__"].copy() + if state["__dict__"].get("parent_state") is not None: + # Do not serialize router data in substates (only the root state). + state["__dict__"].pop("router", None) + state["__dict__"].pop("router_data", None) + # Never serialize parent_state or substates. state["__dict__"]["parent_state"] = None state["__dict__"]["substates"] = {} state["__dict__"].pop("_was_touched", None) + # Remove all inherited vars. + for inherited_var_name in self.inherited_vars: + state["__dict__"].pop(inherited_var_name, None) return state + @classmethod + @functools.lru_cache() + def _to_schema(cls) -> str: + """Convert a state to a schema. -EventHandlerSetVar.update_forward_refs() + Returns: + The hash of the schema. + """ + + def _field_tuple( + field_name: str, + ) -> Tuple[str, str, Any, Union[bool, None], Any]: + model_field = cls.__fields__[field_name] + return ( + field_name, + model_field.name, + _serialize_type(model_field.type_), + ( + model_field.required + if isinstance(model_field.required, bool) + else None + ), + (model_field.default if is_serializable(model_field.default) else None), + ) + + return md5( + pickle.dumps( + list(sorted(_field_tuple(field_name) for field_name in cls.base_vars)) + ) + ).hexdigest() + + def _serialize(self) -> bytes: + """Serialize the state for redis. + + Returns: + The serialized state. + """ + try: + return pickle.dumps((self._to_schema(), self)) + except HANDLED_PICKLE_ERRORS as og_pickle_error: + error = ( + f"Failed to serialize state {self.get_full_name()} due to unpicklable object. " + "This state will not be persisted. " + ) + try: + import dill + + return dill.dumps((self._to_schema(), self)) + except ImportError: + error += ( + f"Pickle error: {og_pickle_error}. " + "Consider `pip install 'dill>=0.3.8'` for more exotic serialization support." + ) + except HANDLED_PICKLE_ERRORS as ex: + error += f"Dill was also unable to pickle the state: {ex}" + console.warn(error) + return b"" + + @classmethod + def _deserialize( + cls, data: bytes | None = None, fp: BinaryIO | None = None + ) -> BaseState: + """Deserialize the state from redis/disk. + + data and fp are mutually exclusive, but one must be provided. + + Args: + data: The serialized state data. + fp: The file pointer to the serialized state data. + + Returns: + The deserialized state. + + Raises: + ValueError: If both data and fp are provided, or neither are provided. + StateSchemaMismatchError: If the state schema does not match the expected schema. + """ + if data is not None and fp is None: + (substate_schema, state) = pickle.loads(data) + elif fp is not None and data is None: + (substate_schema, state) = pickle.load(fp) + else: + raise ValueError("Only one of `data` or `fp` must be provided") + if substate_schema != state._to_schema(): + raise StateSchemaMismatchError() + return state class State(BaseState): @@ -1782,6 +2141,70 @@ class State(BaseState): is_hydrated: bool = False +T = TypeVar("T", bound=BaseState) + + +def dynamic(func: Callable[[T], Component]): + """Create a dynamically generated components from a state class. + + Args: + func: The function to generate the component. + + Returns: + The dynamically generated component. + + Raises: + DynamicComponentInvalidSignature: If the function does not have exactly one parameter. + DynamicComponentInvalidSignature: If the function does not have a type hint for the state class. + """ + number_of_parameters = len(inspect.signature(func).parameters) + + func_signature = get_type_hints(func) + + if "return" in func_signature: + func_signature.pop("return") + + values = list(func_signature.values()) + + if number_of_parameters != 1: + raise DynamicComponentInvalidSignature( + "The function must have exactly one parameter, which is the state class." + ) + + if len(values) != 1: + raise DynamicComponentInvalidSignature( + "You must provide a type hint for the state class in the function." + ) + + state_class: Type[T] = values[0] + + def wrapper() -> Component: + from reflex.components.base.fragment import fragment + + return fragment(state_class._evaluate(lambda state: func(state))) + + return wrapper + + +class FrontendEventExceptionState(State): + """Substate for handling frontend exceptions.""" + + @event + def handle_frontend_exception(self, stack: str, component_stack: str) -> None: + """Handle frontend exceptions. + + If a frontend exception handler is provided, it will be called. + Otherwise, the default frontend exception handler will be called. + + Args: + stack: The stack trace of the exception. + component_stack: The stack trace of the component where the exception occurred. + + """ + app_instance = getattr(prerequisites.get_app(), constants.CompileVars.APP) + app_instance.frontend_exception_handler(Exception(stack)) + + class UpdateVarsInternalState(State): """Substate for handling internal state var updates.""" @@ -1833,7 +2256,7 @@ class OnLoadInternalState(State): ] -class ComponentState(Base): +class ComponentState(State, mixin=True): """Base class to allow for the creation of a state instance per component. This allows for the bundling of UI and state logic into a single class, @@ -1875,6 +2298,16 @@ class ComponentState(Base): # The number of components created from this class. _per_component_state_instance_count: ClassVar[int] = 0 + @classmethod + def __init_subclass__(cls, mixin: bool = True, **kwargs): + """Overwrite mixin default to True. + + Args: + mixin: Whether the subclass is a mixin and should not be initialized. + **kwargs: The kwargs to pass to the pydantic init_subclass method. + """ + super().__init_subclass__(mixin=mixin, **kwargs) + @classmethod def get_component(cls, *children, **props) -> "Component": """Get the component instance. @@ -1903,7 +2336,14 @@ class ComponentState(Base): """ cls._per_component_state_instance_count += 1 state_cls_name = f"{cls.__name__}_n{cls._per_component_state_instance_count}" - component_state = type(state_cls_name, (cls, State), {}) + component_state = type( + state_cls_name, + (cls, State), + {"__module__": reflex.istate.dynamic.__name__}, + mixin=False, + ) + # Save a reference to the dynamic state for pickle/unpickle. + setattr(reflex.istate.dynamic, state_cls_name, component_state) component = component_state.get_component(*children, **props) component.State = component_state return component @@ -1928,25 +2368,45 @@ class StateProxy(wrapt.ObjectProxy): class State(rx.State): counter: int = 0 - @rx.background + @rx.event(background=True) async def bg_increment(self): await asyncio.sleep(1) async with self: self.counter += 1 """ - def __init__(self, state_instance): + def __init__( + self, state_instance, parent_state_proxy: Optional["StateProxy"] = None + ): """Create a proxy for a state instance. + If `get_state` is used on a StateProxy, the resulting state will be + linked to the given state via parent_state_proxy. The first state in the + chain is the state that initiated the background task. + Args: state_instance: The state instance to proxy. + parent_state_proxy: The parent state proxy, for linked mutability and context tracking. """ super().__init__(state_instance) # compile is not relevant to backend logic self._self_app = getattr(prerequisites.get_app(), constants.CompileVars.APP) - self._self_substate_path = state_instance.get_full_name().split(".") + self._self_substate_path = tuple(state_instance.get_full_name().split(".")) self._self_actx = None self._self_mutable = False + self._self_actx_lock = asyncio.Lock() + self._self_actx_lock_holder = None + self._self_parent_state_proxy = parent_state_proxy + + def _is_mutable(self) -> bool: + """Check if the state is mutable. + + Returns: + Whether the state is mutable. + """ + if self._self_parent_state_proxy is not None: + return self._self_parent_state_proxy._is_mutable() or self._self_mutable + return self._self_mutable async def __aenter__(self) -> StateProxy: """Enter the async context manager protocol. @@ -1959,7 +2419,31 @@ class StateProxy(wrapt.ObjectProxy): Returns: This StateProxy instance in mutable mode. + + Raises: + ImmutableStateError: If the state is already mutable. """ + if self._self_parent_state_proxy is not None: + parent_state = ( + await self._self_parent_state_proxy.__aenter__() + ).__wrapped__ + super().__setattr__( + "__wrapped__", + await parent_state.get_state( + State.get_class_substate(self._self_substate_path) + ), + ) + return self + current_task = asyncio.current_task() + if ( + self._self_actx_lock.locked() + and current_task == self._self_actx_lock_holder + ): + raise ImmutableStateError( + "The state is already mutable. Do not nest `async with self` blocks." + ) + await self._self_actx_lock.acquire() + self._self_actx_lock_holder = current_task self._self_actx = self._self_app.modify_state( token=_substate_key( self.__wrapped__.router.session.client_token, @@ -1981,10 +2465,17 @@ class StateProxy(wrapt.ObjectProxy): Args: exc_info: The exception info tuple. """ + if self._self_parent_state_proxy is not None: + await self._self_parent_state_proxy.__aexit__(*exc_info) + return if self._self_actx is None: return self._self_mutable = False - await self._self_actx.__aexit__(*exc_info) + try: + await self._self_actx.__aexit__(*exc_info) + finally: + self._self_actx_lock_holder = None + self._self_actx_lock.release() self._self_actx = None def __enter__(self): @@ -2018,7 +2509,7 @@ class StateProxy(wrapt.ObjectProxy): Raises: ImmutableStateError: If the state is not in mutable mode. """ - if name in ["substates", "parent_state"] and not self._self_mutable: + if name in ["substates", "parent_state"] and not self._is_mutable(): raise ImmutableStateError( "Background task StateProxy is immutable outside of a context " "manager. Use `async with self` to modify state." @@ -2058,7 +2549,7 @@ class StateProxy(wrapt.ObjectProxy): """ if ( name.startswith("_self_") # wrapper attribute - or self._self_mutable # lock held + or self._is_mutable() # lock held # non-persisted state attribute or name in self.__wrapped__.get_skip_vars() ): @@ -2082,7 +2573,7 @@ class StateProxy(wrapt.ObjectProxy): Raises: ImmutableStateError: If the state is not in mutable mode. """ - if not self._self_mutable: + if not self._is_mutable(): raise ImmutableStateError( "Background task StateProxy is immutable outside of a context " "manager. Use `async with self` to modify state." @@ -2101,12 +2592,14 @@ class StateProxy(wrapt.ObjectProxy): Raises: ImmutableStateError: If the state is not in mutable mode. """ - if not self._self_mutable: + if not self._is_mutable(): raise ImmutableStateError( "Background task StateProxy is immutable outside of a context " "manager. Use `async with self` to modify state." ) - return await self.__wrapped__.get_state(state_cls) + return type(self)( + await self.__wrapped__.get_state(state_cls), parent_state_proxy=self + ) def _as_state_update(self, *args, **kwargs) -> StateUpdate: """Temporarily allow mutability to access parent_state. @@ -2118,25 +2611,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(self) + class StateManager(Base, ABC): """A class to manage many client states.""" @@ -2151,13 +2656,32 @@ class StateManager(Base, ABC): Args: state: The state class to use. + Raises: + InvalidStateManagerMode: If the state manager mode is invalid. + Returns: - The state manager (either memory or redis). + The state manager (either disk, memory or redis). """ - redis = prerequisites.get_redis() - if redis is not None: - return StateManagerRedis(state=state, redis=redis) - return StateManagerMemory(state=state) + config = get_config() + if prerequisites.parse_redis_url() is not None: + config.state_manager_mode = constants.StateManagerMode.REDIS + if config.state_manager_mode == constants.StateManagerMode.MEMORY: + return StateManagerMemory(state=state) + if config.state_manager_mode == constants.StateManagerMode.DISK: + return StateManagerDisk(state=state) + if config.state_manager_mode == constants.StateManagerMode.REDIS: + redis = prerequisites.get_redis() + if redis is not None: + # make sure expiration values are obtained only from the config object on creation + return StateManagerRedis( + state=state, + redis=redis, + token_expiration=config.redis_token_expiration, + lock_expiration=config.redis_lock_expiration, + ) + raise InvalidStateManagerMode( + f"Expected one of: DISK, MEMORY, REDIS, got {config.state_manager_mode}" + ) @abstractmethod async def get_state(self, token: str) -> BaseState: @@ -2214,6 +2738,7 @@ class StateManagerMemory(StateManager): "_states_locks": {"exclude": True}, } + @override async def get_state(self, token: str) -> BaseState: """Get the state for a token. @@ -2229,6 +2754,7 @@ class StateManagerMemory(StateManager): self.states[token] = self.state(_reflex_internal_init=True) return self.states[token] + @override async def set_state(self, token: str, state: BaseState): """Set the state for a token. @@ -2238,6 +2764,7 @@ class StateManagerMemory(StateManager): """ pass + @override @contextlib.asynccontextmanager async def modify_state(self, token: str) -> AsyncIterator[BaseState]: """Modify the state for a token while holding exclusive lock. @@ -2261,23 +2788,263 @@ class StateManagerMemory(StateManager): 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__) +def _default_token_expiration() -> int: + """Get the default token expiration time. - @dill.register(cython_function_or_method) - def _dill_reduce_cython_function_or_method(pickler, obj): - # Ignore cython function when pickling. - pass + Returns: + The default token expiration time. + """ + return get_config().redis_token_expiration -@dill.register(type(State)) -def _dill_reduce_state(pickler, obj): - if obj is not State and issubclass(obj, State): - # Avoid serializing subclasses of State, instead get them by reference from the State class. - pickler.save_reduce(State.get_class_substate, (obj.get_full_name(),), obj=obj) - else: - dill.Pickler.dispatch[type](pickler, obj) +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 is_serializable(value: Any) -> bool: + """Check if a value is serializable. + + Args: + value: The value to check. + + Returns: + Whether the value is serializable. + """ + try: + return bool(pickle.dumps(value)) + except Exception: + return False + + +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"{md5(token.encode()).hexdigest()}.pkl" + ).absolute() + + async def load_state(self, token: str) -> BaseState | None: + """Load a state object based on the provided token. + + Args: + token: The token used to identify the state object. + + Returns: + The loaded state object or None. + """ + token_path = self.token_path(token) + + if token_path.exists(): + try: + with token_path.open(mode="rb") as file: + return BaseState._deserialize(fp=file) + except Exception: + pass + + 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) + + fresh_instance = await root_state.get_state(substate) + instance = await self.load_state(substate_token) + if instance is not None: + # Ensure all substates exist, even if they weren't serialized previously. + instance.substates = fresh_instance.substates + else: + instance = fresh_instance + state.substates[substate.get_name()] = instance + instance.parent_state = state + + await self.populate_substates(client_token, instance, root_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 = _split_substate_key(token)[0] + root_state = self.states.get(client_token) + if root_state is not None: + # Retrieved state from memory. + return root_state + + # Deserialize root state from disk. + root_state = await self.load_state(_substate_key(client_token, self.state)) + # Create a new root state tree with all substates instantiated. + fresh_root_state = self.state(_reflex_internal_init=True) + if root_state is None: + root_state = fresh_root_state + else: + # Ensure all substates exist, even if they were not serialized previously. + root_state.substates = fresh_root_state.substates + self.states[client_token] = root_state + await self.populate_substates(client_token, root_state, root_state) + return root_state + + 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) + + if substate._get_was_touched(): + substate._was_touched = False # Reset the touched flag after serializing. + pickle_state = substate._serialize() + if pickle_state: + if not self.states_directory.exists(): + self.states_directory.mkdir(parents=True, exist_ok=True) + self.token_path(substate_token).write_bytes(pickle_state) + + 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) + + +def _default_lock_expiration() -> int: + """Get the default lock expiration time. + + Returns: + The default lock expiration time. + """ + return get_config().redis_lock_expiration class StateManagerRedis(StateManager): @@ -2287,10 +3054,10 @@ class StateManagerRedis(StateManager): redis: Redis # The token expiration time (s). - token_expiration: int = constants.Expiration.TOKEN + token_expiration: int = pydantic.Field(default_factory=_default_token_expiration) # The maximum time to hold a lock (ms). - lock_expiration: int = constants.Expiration.LOCK + lock_expiration: int = pydantic.Field(default_factory=_default_lock_expiration) # The keyspace subscription string when redis is waiting for lock to be released _redis_notify_keyspace_events: str = ( @@ -2311,24 +3078,14 @@ class StateManagerRedis(StateManager): # Only warn about each state class size once. _warned_about_state_size: ClassVar[Set[str]] = set() - def _get_root_state(self, state: BaseState) -> BaseState: - """Chase parent_state pointers to find an instance of the top-level state. - - Args: - state: The state to start from. - - Returns: - An instance of the top-level state (self.state). - """ - while type(state) != self.state and state.parent_state is not None: - state = state.parent_state - return state - - async def _get_parent_state(self, token: str) -> BaseState | None: + async def _get_parent_state( + self, token: str, state: BaseState | None = None + ) -> BaseState | None: """Get the parent state for the state requested in the token. Args: token: The token to get the state for (_substate_key). + state: The state instance to get parent state for. Returns: The parent state for the state requested by the token or None if there is no such parent. @@ -2337,11 +3094,15 @@ class StateManagerRedis(StateManager): client_token, state_path = _split_substate_key(token) parent_state_name = state_path.rpartition(".")[0] if parent_state_name: + cached_substates = None + if state is not None: + cached_substates = [state] # Retrieve the parent state to populate event handlers onto this substate. parent_state = await self.get_state( token=_substate_key(client_token, parent_state_name), top_level=False, get_substates=False, + cached_substates=cached_substates, ) return parent_state @@ -2373,6 +3134,8 @@ class StateManagerRedis(StateManager): tasks = {} # Retrieve the necessary substates from redis. for substate_cls in fetch_substates: + if substate_cls.get_name() in state.substates: + continue substate_name = substate_cls.get_name() tasks[substate_name] = asyncio.create_task( self.get_state( @@ -2386,12 +3149,14 @@ class StateManagerRedis(StateManager): for substate_name, substate_task in tasks.items(): state.substates[substate_name] = await substate_task + @override async def get_state( self, token: str, top_level: bool = True, get_substates: bool = True, parent_state: BaseState | None = None, + cached_substates: list[BaseState] | None = None, ) -> BaseState: """Get the state for a token. @@ -2400,6 +3165,7 @@ class StateManagerRedis(StateManager): top_level: If true, return an instance of the top-level state (self.state). get_substates: If true, also retrieve substates. parent_state: If provided, use this parent_state instead of getting it from redis. + cached_substates: If provided, attach these substates to the state. Returns: The state for the token. @@ -2417,49 +3183,42 @@ class StateManagerRedis(StateManager): "StateManagerRedis requires token to be specified in the form of {token}_{state_full_name}" ) + # The deserialized or newly created (sub)state instance. + state = None + # Fetch the serialized substate from redis. redis_state = await self.redis.get(token) if redis_state is not None: # Deserialize the substate. - state = dill.loads(redis_state) - - # Populate parent state if missing and requested. - if parent_state is None: - parent_state = await self._get_parent_state(token) - # Set up Bidirectional linkage between this state and its parent. - if parent_state is not None: - parent_state.substates[state.get_name()] = state - state.parent_state = parent_state - # Populate substates if requested. - await self._populate_substates(token, state, all_substates=get_substates) - - # To retain compatibility with previous implementation, by default, we return - # the top-level state by chasing `parent_state` pointers up the tree. - if top_level: - return self._get_root_state(state) - return state - - # TODO: dedupe the following logic with the above block - # Key didn't exist so we have to create a new instance for this token. + with contextlib.suppress(StateSchemaMismatchError): + state = BaseState._deserialize(data=redis_state) + if state is None: + # Key didn't exist or schema mismatch so create a new instance for this token. + state = state_cls( + init_substates=False, + _reflex_internal_init=True, + ) + # Populate parent state if missing and requested. if parent_state is None: - parent_state = await self._get_parent_state(token) - # Instantiate the new state class (but don't persist it yet). - state = state_cls( - parent_state=parent_state, - init_substates=False, - _reflex_internal_init=True, - ) + parent_state = await self._get_parent_state(token, state) # Set up Bidirectional linkage between this state and its parent. if parent_state is not None: parent_state.substates[state.get_name()] = state state.parent_state = parent_state - # Populate substates for the newly created state. + # Avoid fetching substates multiple times. + if cached_substates: + for substate in cached_substates: + state.substates[substate.get_name()] = substate + if substate.parent_state is None: + substate.parent_state = state + # Populate substates if requested. await self._populate_substates(token, state, all_substates=get_substates) + # To retain compatibility with previous implementation, by default, we return # the top-level state by chasing `parent_state` pointers up the tree. if top_level: - return self._get_root_state(state) + return state._get_root_state() return state def _warn_if_too_large( @@ -2485,6 +3244,7 @@ class StateManagerRedis(StateManager): ) self._warned_about_state_size.add(state_full_name) + @override async def set_state( self, token: str, @@ -2510,7 +3270,7 @@ class StateManagerRedis(StateManager): raise LockExpiredError( f"Lock expired for token {token} while processing. Consider increasing " f"`app.state_manager.lock_expiration` (currently {self.lock_expiration}) " - "or use `@rx.background` decorator for long-running tasks." + "or use `@rx.event(background=True)` decorator for long-running tasks." ) client_token, substate_name = _split_substate_key(token) # If the substate name on the token doesn't match the instance name, it cannot have a parent. @@ -2533,18 +3293,20 @@ class StateManagerRedis(StateManager): ) # Persist only the given state (parents or substates are excluded by BaseState.__getstate__). if state._get_was_touched(): - pickle_state = dill.dumps(state, byref=True) + pickle_state = state._serialize() self._warn_if_too_large(state, len(pickle_state)) - await self.redis.set( - _substate_key(client_token, state), - pickle_state, - ex=self.token_expiration, - ) + if pickle_state: + await self.redis.set( + _substate_key(client_token, state), + pickle_state, + ex=self.token_expiration, + ) # Wait for substates to be persisted. for t in tasks: await t + @override @contextlib.asynccontextmanager async def modify_state(self, token: str) -> AsyncIterator[BaseState]: """Modify the state for a token while holding exclusive lock. @@ -2599,13 +3361,22 @@ class StateManagerRedis(StateManager): Args: lock_key: The redis key for the lock. lock_id: The ID of the lock. + + Raises: + ResponseError: when the keyspace config cannot be set. """ state_is_locked = False lock_key_channel = f"__keyspace@0__:{lock_key.decode()}" # Enable keyspace notifications for the lock key, so we know when it is available. - await self.redis.config_set( - "notify-keyspace-events", self._redis_notify_keyspace_events - ) + try: + await self.redis.config_set( + "notify-keyspace-events", + self._redis_notify_keyspace_events, + ) + except ResponseError: + # Some redis servers only allow out-of-band configuration, so ignore errors here. + if not environment.REFLEX_IGNORE_REDIS_CONFIG_ERROR: + raise async with self.redis.pubsub() as pubsub: await pubsub.psubscribe(lock_key_channel) while not state_is_locked: @@ -2676,111 +3447,6 @@ def get_state_manager() -> StateManager: return app.state_manager -class ClientStorageBase: - """Base class for client-side storage.""" - - def options(self) -> dict[str, Any]: - """Get the options for the storage. - - Returns: - All set options for the storage (not None). - """ - return { - format.to_camel_case(k): v for k, v in vars(self).items() if v is not None - } - - -class Cookie(ClientStorageBase, str): - """Represents a state Var that is stored as a cookie in the browser.""" - - name: str | None - path: str - max_age: int | None - domain: str | None - secure: bool | None - same_site: str - - def __new__( - cls, - object: Any = "", - encoding: str | None = None, - errors: str | None = None, - /, - name: str | None = None, - path: str = "/", - max_age: int | None = None, - domain: str | None = None, - secure: bool | None = None, - same_site: str = "lax", - ): - """Create a client-side Cookie (str). - - Args: - object: The initial object. - encoding: The encoding to use. - errors: The error handling scheme to use. - name: The name of the cookie on the client side. - path: Cookie path. Use / as the path if the cookie should be accessible on all pages. - max_age: Relative max age of the cookie in seconds from when the client receives it. - domain: Domain for the cookie (sub.domain.com or .allsubdomains.com). - secure: Is the cookie only accessible through HTTPS? - same_site: Whether the cookie is sent with third party requests. - One of (true|false|none|lax|strict) - - Returns: - The client-side Cookie object. - - Note: expires (absolute Date) is not supported at this time. - """ - if encoding or errors: - inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict") - else: - inst = super().__new__(cls, object) - inst.name = name - inst.path = path - inst.max_age = max_age - inst.domain = domain - inst.secure = secure - inst.same_site = same_site - return inst - - -class LocalStorage(ClientStorageBase, str): - """Represents a state Var that is stored in localStorage in the browser.""" - - name: str | None - sync: bool = False - - def __new__( - cls, - object: Any = "", - encoding: str | None = None, - errors: str | None = None, - /, - name: str | None = None, - sync: bool = False, - ) -> "LocalStorage": - """Create a client-side localStorage (str). - - Args: - object: The initial object. - encoding: The encoding to use. - errors: The error handling scheme to use. - name: The name of the storage key on the client side. - sync: Whether changes should be propagated to other tabs. - - Returns: - The client-side localStorage object. - """ - if encoding or errors: - inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict") - else: - inst = super().__new__(cls, object) - inst.name = name - inst.sync = sync - return inst - - class MutableProxy(wrapt.ObjectProxy): """A proxy for a mutable object that tracks changes.""" @@ -2813,7 +3479,12 @@ class MutableProxy(wrapt.ObjectProxy): ] ) - __mutable_types__ = (list, dict, set, Base) + # These internal attributes on rx.Base should NOT be wrapped in a MutableProxy. + __never_wrap_base_attrs__ = set(Base.__dict__) - {"set"} | set( + pydantic.BaseModel.__dict__ + ) + + __mutable_types__ = (list, dict, set, Base, DeclarativeBase) def __init__(self, wrapped: Any, state: BaseState, field_name: str): """Create a proxy for a mutable object that tracks changes. @@ -2862,7 +3533,10 @@ class MutableProxy(wrapt.ObjectProxy): Returns: The wrapped value. """ - if isinstance(value, self.__mutable_types__): + # Recursively wrap mutable types, but do not re-wrap MutableProxy instances. + if isinstance(value, self.__mutable_types__) and not isinstance( + value, MutableProxy + ): return type(self)( wrapped=value, state=self._self_state, @@ -2909,6 +3583,17 @@ class MutableProxy(wrapt.ObjectProxy): self._wrap_recursive_decorator, ) + if ( + isinstance(self.__wrapped__, Base) + and __name not in self.__never_wrap_base_attrs__ + and hasattr(value, "__func__") + ): + # Wrap methods called on Base subclasses, which might do _anything_ + return wrapt.FunctionWrapper( + functools.partial(value.__func__, self), + self._wrap_recursive_decorator, + ) + if isinstance(value, self.__mutable_types__) and __name not in ( "__wrapped__", "_self_state", @@ -3018,22 +3703,16 @@ class MutableProxy(wrapt.ObjectProxy): @serializer -def serialize_mutable_proxy(mp: MutableProxy) -> SerializedType: - """Serialize the wrapped value of a MutableProxy. +def serialize_mutable_proxy(mp: MutableProxy): + """Return the wrapped value of a MutableProxy. Args: mp: The MutableProxy to serialize. Returns: - The serialized wrapped object. - - Raises: - ValueError: when the wrapped object is not serializable. + The wrapped object. """ - value = serialize(mp.__wrapped__) - if value is None: - raise ValueError(f"Cannot serialize {type(mp.__wrapped__)}") - return value + return mp.__wrapped__ class ImmutableMutableProxy(MutableProxy): @@ -3066,7 +3745,7 @@ class ImmutableMutableProxy(MutableProxy): Raises: ImmutableStateError: if the StateProxy is not mutable. """ - if not self._self_state._self_mutable: + if not self._self_state._is_mutable(): raise ImmutableStateError( "Background task StateProxy is immutable outside of a context " "manager. Use `async with self` to modify state." @@ -3104,5 +3783,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 e48aa3dd8..f0ee8c6a7 100644 --- a/reflex/style.py +++ b/reflex/style.py @@ -2,43 +2,94 @@ from __future__ import annotations -from typing import Any, Tuple +from typing import Any, Literal, Tuple, Type from reflex import constants -from reflex.event import EventChain +from reflex.components.core.breakpoints import Breakpoints, breakpoints_values +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 BaseVar, Var, VarData - -VarData.update_forward_refs() # Ensure all type definitions are resolved +from reflex.utils.types import get_origin +from reflex.vars import VarData +from reflex.vars.base import CallableVar, LiteralVar, Var +from reflex.vars.function import FunctionVar +from reflex.vars.object import ObjectVar +SYSTEM_COLOR_MODE: str = "system" LIGHT_COLOR_MODE: str = "light" DARK_COLOR_MODE: str = "dark" +LiteralColorMode = Literal["system", "light", "dark"] # Reference the global ColorModeContext -color_mode_var_data = VarData( # type: ignore - imports={ - f"/{constants.Dirs.CONTEXTS_PATH}": {ImportVar(tag="ColorModeContext")}, - "react": {ImportVar(tag="useContext")}, - }, - hooks={ - f"const [ {constants.ColorMode.NAME}, {constants.ColorMode.TOGGLE} ] = useContext(ColorModeContext)": None, - }, -) -# Var resolves to the current color mode for the app ("light" or "dark") -color_mode = BaseVar( - _var_name=constants.ColorMode.NAME, - _var_type="str", - _var_data=color_mode_var_data, -) -# Var resolves to a function invocation that toggles the color mode -toggle_color_mode = BaseVar( - _var_name=constants.ColorMode.TOGGLE, - _var_type=EventChain, - _var_data=color_mode_var_data, -) +color_mode_imports = { + f"$/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="ColorModeContext")], + "react": [ImportVar(tag="useContext")], +} -breakpoints = ["0", "30em", "48em", "62em", "80em", "96em"] + +def _color_mode_var(_js_expr: str, _var_type: Type = str) -> Var: + """Create a Var that destructs the _js_expr from ColorModeContext. + + Args: + _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 Var( + _js_expr=_js_expr, + _var_type=_var_type, + _var_data=VarData( + imports=color_mode_imports, + hooks={f"const {{ {_js_expr} }} = useContext(ColorModeContext)": None}, + ), + ).guess_type() + + +@CallableVar +def set_color_mode( + new_color_mode: LiteralColorMode | Var[LiteralColorMode] | None = None, +) -> Var[EventChain]: + """Create an EventChain Var that sets the color mode to a specific value. + + Note: `set_color_mode` is not a real event and cannot be triggered from a + backend event handler. + + Args: + new_color_mode: The color mode to set. + + Returns: + The EventChain Var that can be passed to an event trigger. + """ + base_setter = _color_mode_var( + _js_expr=constants.ColorMode.SET, + _var_type=EventChain, + ) + if new_color_mode is None: + return base_setter + + if not isinstance(new_color_mode, Var): + new_color_mode = LiteralVar.create(new_color_mode) + + return Var( + f"() => {str(base_setter)}({str(new_color_mode)})", + _var_data=VarData.merge( + base_setter._get_all_var_data(), new_color_mode._get_all_var_data() + ), + ).to(FunctionVar, EventChain) # type: ignore + + +# Var resolves to the current color mode for the app ("light", "dark" or "system") +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(_js_expr=constants.ColorMode.RESOLVED_NAME) +# Var resolves to a function invocation that toggles the color mode +toggle_color_mode = _color_mode_var( + _js_expr=constants.ColorMode.TOGGLE, + _var_type=EventChain, +) STYLE_PROP_SHORTHAND_MAPPING = { "paddingX": ("paddingInlineStart", "paddingInlineEnd"), @@ -47,22 +98,26 @@ STYLE_PROP_SHORTHAND_MAPPING = { "marginY": ("marginTop", "marginBottom"), "bg": ("background",), "bgColor": ("backgroundColor",), + # Radix components derive their font from this CSS var, not inherited from body or class. + "fontFamily": ("fontFamily", "--default-font-family"), } -def media_query(breakpoint_index: int): +def media_query(breakpoint_expr: str): """Create a media query selector. Args: - breakpoint_index: The index of the breakpoint to use. + breakpoint_expr: The CSS expression representing the breakpoint. Returns: The media query selector used as a key in emotion css dict. """ - return f"@media screen and (min-width: {breakpoints[breakpoint_index]})" + return f"@media screen and (min-width: {breakpoint_expr})" -def convert_item(style_item: str | Var) -> tuple[str, VarData | None]: +def convert_item( + style_item: int | str | Var, +) -> tuple[str | Var, VarData | None]: """Format a single value in a style dictionary. Args: @@ -70,23 +125,31 @@ def convert_item(style_item: str | Var) -> tuple[str, VarData | None]: 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): - # If the value is a Var, extract the var_data and cast as str. - return str(style_item), style_item._var_data + return style_item, style_item._get_all_var_data() + + # if isinstance(style_item, str) and REFLEX_VAR_OPENING_TAG not in style_item: + # return style_item, None # Otherwise, convert to Var to collapse VarData encoded in f-string. - new_var = Var.create(style_item) - if new_var is not None and new_var._var_data: - # The wrapped backtick is used to identify the Var for interpolation. - return f"`{str(new_var)}`", new_var._var_data - - return style_item, None + new_var = LiteralVar.create(style_item) + var_data = new_var._get_all_var_data() if new_var is not None else None + return new_var, var_data def convert_list( responsive_list: list[str | dict | Var], -) -> tuple[list[str | dict], VarData | None]: +) -> tuple[list[str | dict[str, Var | list | dict]], VarData | None]: """Format a responsive value list. Args: @@ -108,7 +171,9 @@ def convert_list( return converted_value, VarData.merge(*item_var_datas) -def convert(style_dict): +def convert( + style_dict: dict[str, Var | dict | list | str], +) -> tuple[dict[str, str | list | dict], VarData | None]: """Format a style dictionary. Args: @@ -125,8 +190,25 @@ def convert(style_dict): out[k] = return_value for key, value in style_dict.items(): - keys = format_style_key(key) - if isinstance(value, dict): + keys = ( + format_style_key(key) + if not isinstance(value, (dict, ObjectVar)) + or ( + isinstance(value, Breakpoints) + and all(not isinstance(v, dict) for v in value.values()) + ) + or ( + isinstance(value, ObjectVar) + and not issubclass(get_origin(value._var_type) or value._var_type, dict) + ) + else (key,) + ) + + if isinstance(value, Var): + return_val = value + new_var_data = value._get_all_var_data() + update_out_dict(return_val, keys) + elif isinstance(value, dict): # Recursively format nested style dictionaries. return_val, new_var_data = convert(value) update_out_dict(return_val, keys) @@ -139,6 +221,10 @@ def convert(style_dict): update_out_dict(return_val, keys) # Combine all the collected VarData instances. var_data = VarData.merge(var_data, new_var_data) + + if isinstance(style_dict, Breakpoints): + out = Breakpoints(out).factorize() + return out, var_data @@ -201,10 +287,10 @@ class Style(dict): value: The value to set. """ # Create a Var to collapse VarData encoded in f-string. - _var = Var.create(value) + _var = LiteralVar.create(value) if _var is not None: # Carry the imports/hooks when setting a Var as a value. - self._var_data = VarData.merge(self._var_data, _var._var_data) + self._var_data = VarData.merge(self._var_data, _var._get_all_var_data()) super().__setitem__(key, value) @@ -212,14 +298,13 @@ def _format_emotion_style_pseudo_selector(key: str) -> str: """Format a pseudo selector for emotion CSS-in-JS. Args: - key: Underscore-prefixed or colon-prefixed pseudo selector key (_hover). + key: Underscore-prefixed or colon-prefixed pseudo selector key (_hover/:hover). Returns: A self-referential pseudo selector key (&:hover). """ prefix = None if key.startswith("_"): - # Handle pseudo selectors in chakra style format. prefix = "&:" key = key[1:] if key.startswith(":"): @@ -245,14 +330,22 @@ def format_as_emotion(style_dict: dict[str, Any]) -> Style | None: for orig_key, value in style_dict.items(): key = _format_emotion_style_pseudo_selector(orig_key) - if isinstance(value, list): - # Apply media queries from responsive value list. - mbps = { - media_query(bp): ( - bp_value if isinstance(bp_value, dict) else {key: bp_value} - ) - for bp, bp_value in enumerate(value) - } + if isinstance(value, (Breakpoints, list)): + if isinstance(value, Breakpoints): + mbps = { + media_query(bp): ( + bp_value if isinstance(bp_value, dict) else {key: bp_value} + ) + for bp, bp_value in value.items() + } + else: + # Apply media queries from responsive value list. + mbps = { + media_query([0, *breakpoints_values][bp]): ( + bp_value if isinstance(bp_value, dict) else {key: bp_value} + ) + for bp, bp_value in enumerate(value) + } if key.startswith("&:"): emotion_style[key] = mbps else: @@ -270,7 +363,7 @@ def format_as_emotion(style_dict: dict[str, Any]) -> Style | None: def convert_dict_to_style_and_format_emotion( - raw_dict: dict[str, Any] + raw_dict: dict[str, Any], ) -> dict[str, Any] | None: """Convert a dict to a style dict and then format as emotion. diff --git a/reflex/testing.py b/reflex/testing.py index 5613af333..b41e56884 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -26,6 +26,7 @@ from typing import ( AsyncIterator, Callable, Coroutine, + List, Optional, Type, TypeVar, @@ -39,10 +40,13 @@ import reflex import reflex.reflex import reflex.utils.build import reflex.utils.exec +import reflex.utils.format import reflex.utils.prerequisites import reflex.utils.processes from reflex.state import ( BaseState, + StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, reload_state_module, @@ -113,7 +117,7 @@ class AppHarness: app_name: str app_source: Optional[ - types.FunctionType | types.ModuleType | str | functools.partial + types.FunctionType | types.ModuleType | str | functools.partial[Any] ] app_path: pathlib.Path app_module_path: pathlib.Path @@ -124,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) @@ -132,7 +136,9 @@ class AppHarness: def create( cls, root: pathlib.Path, - app_source: Optional[types.FunctionType | types.ModuleType | str] = None, + app_source: Optional[ + types.FunctionType | types.ModuleType | str | functools.partial[Any] + ] = None, app_name: Optional[str] = None, ) -> "AppHarness": """Create an AppHarness instance at root. @@ -176,6 +182,33 @@ class AppHarness: app_module_path=root / app_name / f"{app_name}.py", ) + def get_state_name(self, state_cls_name: str) -> str: + """Get the state name for the given state class name. + + Args: + state_cls_name: The state class name + + Returns: + The state name + """ + return reflex.utils.format.to_snake_case( + f"{self.app_name}___{self.app_name}___" + state_cls_name + ) + + def get_full_state_name(self, path: List[str]) -> str: + """Get the full state name for the given state class name. + + Args: + path: A list of state class names + + Returns: + The full state name + """ + # NOTE: using State.get_name() somehow causes trouble here + # path = [State.get_name()] + [self.get_state_name(p) for p in path] + path = ["reflex___state____state"] + [self.get_state_name(p) for p in path] + return ".".join(path) + def _get_globals_from_signature(self, func: Any) -> dict[str, Any]: """Get the globals from a function or module object. @@ -216,7 +249,8 @@ class AppHarness: return textwrap.dedent(source) def _initialize_app(self): - os.environ["TELEMETRY_ENABLED"] = "" # disable telemetry reporting for tests + # disable telemetry reporting for tests + os.environ["TELEMETRY_ENABLED"] = "false" self.app_path.mkdir(parents=True, exist_ok=True) if self.app_source is not None: app_globals = self._get_globals_from_signature(self.app_source) @@ -245,7 +279,10 @@ class AppHarness: before_decorated_pages = reflex.app.DECORATED_PAGES[self.app_name].copy() # Ensure the AppHarness test does not skip State assignment due to running via pytest os.environ.pop(reflex.constants.PYTEST_CURRENT_TEST, None) - self.app_module = reflex.utils.prerequisites.get_compiled_app(reload=True) + self.app_module = reflex.utils.prerequisites.get_compiled_app( + # Do not reload the module for pre-existing apps (only apps generated from source) + reload=self.app_source is not None + ) # Save the pages that were added during testing self._decorated_pages = [ p @@ -293,9 +330,35 @@ 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): + """Reset the StateManagerRedis event loop affinity. + + This is necessary when the backend is restarted and the state manager is a + StateManagerRedis instance. + + Raises: + RuntimeError: when the state manager cannot be reset + """ + if ( + self.app_instance is not None + and isinstance( + self.app_instance.state_manager, + StateManagerRedis, + ) + and self.app_instance.state is not None + ): + with contextlib.suppress(RuntimeError): + await self.app_instance.state_manager.close() + self.app_instance._state_manager = StateManagerRedis.create( + state=self.app_instance.state, + ) + if not isinstance(self.app_instance.state_manager, StateManagerRedis): + raise RuntimeError("Failed to reset state manager.") + def _start_frontend(self): # Set up the frontend. with chdir(self.app_path): @@ -308,7 +371,7 @@ class AppHarness: # Start the frontend. self.frontend_process = reflex.utils.processes.new_process( [reflex.utils.prerequisites.get_package_manager(), "run", "dev"], - cwd=self.app_path / reflex.constants.Dirs.WEB, + cwd=self.app_path / reflex.utils.prerequisites.get_web_dir(), env={"PORT": "0"}, **FRONTEND_POPEN_ARGS, ) @@ -324,15 +387,22 @@ class AppHarness: m = re.search(reflex.constants.Next.FRONTEND_LISTENING_REGEX, line) if m is not None: self.frontend_url = m.group(1) + config = reflex.config.get_config() + config.deploy_url = self.frontend_url break if self.frontend_url is None: raise RuntimeError("Frontend did not start") def consume_frontend_output(): while True: - line = ( - self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess] - ) + try: + line = ( + self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess] + ) + # catch I/O operation on closed file. + except ValueError as e: + print(e) + break if not line: break print(line) @@ -513,12 +583,23 @@ class AppHarness: raise TimeoutError("Backend is not listening.") return backend.servers[0].sockets[0] - def frontend(self, driver_clz: Optional[Type["WebDriver"]] = None) -> "WebDriver": + def frontend( + self, + driver_clz: Optional[Type["WebDriver"]] = None, + driver_kwargs: dict[str, Any] | None = None, + driver_options: ArgOptions | None = None, + driver_option_args: List[str] | None = None, + driver_option_capabilities: dict[str, Any] | None = None, + ) -> "WebDriver": """Get a selenium webdriver instance pointed at the app. Args: driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari, webdriver.Edge, etc + driver_kwargs: additional keyword arguments to pass to the webdriver constructor + driver_options: selenium ArgOptions instance to pass to the webdriver constructor + driver_option_args: additional arguments for the webdriver options + driver_option_capabilities: additional capabilities for the webdriver options Returns: Instance of the given webdriver navigated to the frontend url of the app. @@ -534,26 +615,43 @@ class AppHarness: if self.frontend_url is None: raise RuntimeError("Frontend is not running.") want_headless = False - options: ArgOptions | None = None if os.environ.get("APP_HARNESS_HEADLESS"): want_headless = True if driver_clz is None: requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome") driver_clz = getattr(webdriver, requested_driver) - options = getattr(webdriver, f"{requested_driver}Options")() - if driver_clz is webdriver.Chrome and want_headless: - options = webdriver.ChromeOptions() - options.add_argument("--headless=new") - elif driver_clz is webdriver.Firefox and want_headless: - options = webdriver.FirefoxOptions() - options.add_argument("-headless") - elif driver_clz is webdriver.Edge and want_headless: - options = webdriver.EdgeOptions() - options.add_argument("headless") - if options and (args := os.environ.get("APP_HARNESS_DRIVER_ARGS")): + if driver_options is None: + driver_options = getattr(webdriver, f"{requested_driver}Options")() + if driver_clz is webdriver.Chrome: + if driver_options is None: + driver_options = webdriver.ChromeOptions() + driver_options.add_argument("--class=AppHarness") + if want_headless: + driver_options.add_argument("--headless=new") + elif driver_clz is webdriver.Firefox: + if driver_options is None: + driver_options = webdriver.FirefoxOptions() + if want_headless: + driver_options.add_argument("-headless") + elif driver_clz is webdriver.Edge: + if driver_options is None: + driver_options = webdriver.EdgeOptions() + if want_headless: + driver_options.add_argument("headless") + if driver_options is None: + raise RuntimeError(f"Could not determine options for {driver_clz}") + if args := os.environ.get("APP_HARNESS_DRIVER_ARGS"): for arg in args.split(","): - options.add_argument(arg) - driver = driver_clz(options=options) # type: ignore + driver_options.add_argument(arg) + if driver_option_args is not None: + for arg in driver_option_args: + driver_options.add_argument(arg) + if driver_option_capabilities is not None: + for key, value in driver_option_capabilities.items(): + driver_options.set_capability(key, value) + if driver_kwargs is None: + driver_kwargs = {} + driver = driver_clz(options=driver_options, **driver_kwargs) # type: ignore driver.get(self.frontend_url) self._frontends.append(driver) return driver @@ -697,13 +795,13 @@ class AppHarness: Raises: RuntimeError: when the app hasn't started running TimeoutError: when the timeout expires before any states are seen + ValueError: when the state_manager is not a memory state manager """ if self.app_instance is None: raise RuntimeError("App is not running.") state_manager = self.app_instance.state_manager - assert isinstance( - state_manager, StateManagerMemory - ), "Only works with memory state manager" + if not isinstance(state_manager, (StateManagerMemory, StateManagerDisk)): + raise ValueError("Only works with memory or disk state manager") if not self._poll_for( target=lambda: state_manager.states, timeout=timeout, @@ -802,7 +900,11 @@ class AppHarnessProd(AppHarness): frontend_server: Optional[Subdir404TCPServer] = None def _run_frontend(self): - web_root = self.app_path / reflex.constants.Dirs.WEB_STATIC + web_root = ( + self.app_path + / reflex.utils.prerequisites.get_web_dir() + / reflex.constants.Dirs.STATIC + ) error_page_map = { 404: web_root / "404.html", } diff --git a/reflex/utils/build.py b/reflex/utils/build.py index 65bb8b04c..14709d99c 100644 --- a/reflex/utils/build.py +++ b/reflex/utils/build.py @@ -18,23 +18,11 @@ from reflex.utils import console, path_ops, prerequisites, processes def set_env_json(): """Write the upload url to a REFLEX_JSON.""" path_ops.update_json_file( - constants.Dirs.ENV_JSON, + str(prerequisites.get_web_dir() / constants.Dirs.ENV_JSON), {endpoint.name: endpoint.get_url() for endpoint in constants.Endpoint}, ) -def set_os_env(**kwargs): - """Set os environment variables. - - Args: - kwargs: env key word args. - """ - for key, value in kwargs.items(): - if not value: - continue - os.environ[key.upper()] = value - - def generate_sitemap_config(deploy_url: str, export=False): """Generate the sitemap config file. @@ -55,14 +43,14 @@ def generate_sitemap_config(deploy_url: str, export=False): config = json.dumps(config) - with open(constants.Next.SITEMAP_CONFIG_FILE, "w") as f: - f.write(templates.SITEMAP_CONFIG(config=config)) + sitemap = prerequisites.get_web_dir() / constants.Next.SITEMAP_CONFIG_FILE + sitemap.write_text(templates.SITEMAP_CONFIG(config=config)) def _zip( component_name: constants.ComponentName, - target: str, - root_dir: str, + target: str | Path, + root_dir: str | Path, exclude_venv_dirs: bool, upload_db_file: bool = False, dirs_to_exclude: set[str] | None = None, @@ -82,22 +70,22 @@ def _zip( top_level_dirs_to_exclude: The top level directory names immediately under root_dir to exclude. Do not exclude folders by these names further in the sub-directories. """ + target = Path(target) + root_dir = Path(root_dir) dirs_to_exclude = dirs_to_exclude or set() files_to_exclude = files_to_exclude or set() files_to_zip: list[str] = [] # Traverse the root directory in a top-down manner. In this traversal order, # we can modify the dirs list in-place to remove directories we don't want to include. for root, dirs, files in os.walk(root_dir, topdown=True): + root = Path(root) # Modify the dirs in-place so excluded and hidden directories are skipped in next traversal. dirs[:] = [ d for d in dirs - if (basename := os.path.basename(os.path.normpath(d))) - not in dirs_to_exclude + if (basename := Path(d).resolve().name) not in dirs_to_exclude and not basename.startswith(".") - and ( - not exclude_venv_dirs or not _looks_like_venv_dir(os.path.join(root, d)) - ) + and (not exclude_venv_dirs or not _looks_like_venv_dir(root / d)) ] # If we are at the top level with root_dir, exclude the top level dirs. if top_level_dirs_to_exclude and root == root_dir: @@ -109,7 +97,7 @@ def _zip( if not f.startswith(".") and (upload_db_file or not f.endswith(".db")) ] files_to_zip += [ - os.path.join(root, file) for file in files if file not in files_to_exclude + str(root / file) for file in files if file not in files_to_exclude ] # Create a progress bar for zipping the component. @@ -126,88 +114,93 @@ def _zip( for file in files_to_zip: console.debug(f"{target}: {file}", progress=progress) progress.advance(task) - zipf.write(file, os.path.relpath(file, root_dir)) + zipf.write(file, Path(file).relative_to(root_dir)) -def export( - backend: bool = True, +def zip_app( frontend: bool = True, - zip: bool = False, - zip_dest_dir: str = os.getcwd(), - deploy_url: str | None = None, + backend: bool = True, + zip_dest_dir: str | Path = Path.cwd(), upload_db_file: bool = False, ): - """Export the app for deployment. + """Zip up the app. Args: - backend: Whether to zip up the backend app. frontend: Whether to zip up the frontend app. - zip: Whether to zip the app. - zip_dest_dir: The destination directory for created zip files (if any) - deploy_url: The URL of the deployed app. - upload_db_file: Whether to include local sqlite db files from the backend zip. + backend: Whether to zip up the backend app. + zip_dest_dir: The directory to export the zip file to. + upload_db_file: Whether to upload the database file. """ - # Remove the static folder. - path_ops.rm(constants.Dirs.WEB_STATIC) + zip_dest_dir = Path(zip_dest_dir) + files_to_exclude = { + constants.ComponentName.FRONTEND.zip(), + constants.ComponentName.BACKEND.zip(), + } + + if frontend: + _zip( + component_name=constants.ComponentName.FRONTEND, + target=zip_dest_dir / constants.ComponentName.FRONTEND.zip(), + root_dir=prerequisites.get_web_dir() / constants.Dirs.STATIC, + files_to_exclude=files_to_exclude, + exclude_venv_dirs=False, + ) + + if backend: + _zip( + component_name=constants.ComponentName.BACKEND, + target=zip_dest_dir / constants.ComponentName.BACKEND.zip(), + root_dir=Path("."), + dirs_to_exclude={"__pycache__"}, + files_to_exclude=files_to_exclude, + top_level_dirs_to_exclude={"assets"}, + exclude_venv_dirs=True, + upload_db_file=upload_db_file, + ) + + +def build( + deploy_url: str | None = None, + for_export: bool = False, +): + """Build the app for deployment. + + Args: + deploy_url: The deployment URL. + for_export: Whether the build is for export. + """ + wdir = prerequisites.get_web_dir() + + # Clean the static directory if it exists. + path_ops.rm(str(wdir / constants.Dirs.STATIC)) # The export command to run. command = "export" - if frontend: - checkpoints = [ - "Linting and checking ", - "Creating an optimized production build", - "Route (pages)", - "prerendered as static HTML", - "Collecting page data", - "Finalizing page optimization", - "Collecting build traces", - ] + checkpoints = [ + "Linting and checking ", + "Creating an optimized production build", + "Route (pages)", + "prerendered as static HTML", + "Collecting page data", + "Finalizing page optimization", + "Collecting build traces", + ] - # Generate a sitemap if a deploy URL is provided. - if deploy_url is not None: - generate_sitemap_config(deploy_url, export=zip) - command = "export-sitemap" + # Generate a sitemap if a deploy URL is provided. + if deploy_url is not None: + generate_sitemap_config(deploy_url, export=for_export) + command = "export-sitemap" - checkpoints.extend(["Loading next-sitemap", "Generation completed"]) + checkpoints.extend(["Loading next-sitemap", "Generation completed"]) - # Start the subprocess with the progress bar. - process = processes.new_process( - [prerequisites.get_package_manager(), "run", command], - cwd=constants.Dirs.WEB, - shell=constants.IS_WINDOWS, - ) - processes.show_progress("Creating Production Build", process, checkpoints) - - # Zip up the app. - if zip: - files_to_exclude = { - constants.ComponentName.FRONTEND.zip(), - constants.ComponentName.BACKEND.zip(), - } - if frontend: - _zip( - component_name=constants.ComponentName.FRONTEND, - target=os.path.join( - zip_dest_dir, constants.ComponentName.FRONTEND.zip() - ), - root_dir=constants.Dirs.WEB_STATIC, - files_to_exclude=files_to_exclude, - exclude_venv_dirs=False, - ) - if backend: - _zip( - component_name=constants.ComponentName.BACKEND, - target=os.path.join( - zip_dest_dir, constants.ComponentName.BACKEND.zip() - ), - root_dir=".", - dirs_to_exclude={"__pycache__"}, - files_to_exclude=files_to_exclude, - top_level_dirs_to_exclude={"assets"}, - exclude_venv_dirs=True, - upload_db_file=upload_db_file, - ) + # Start the subprocess with the progress bar. + process = processes.new_process( + [prerequisites.get_package_manager(), "run", command], + cwd=wdir, + shell=constants.IS_WINDOWS, + ) + processes.show_progress("Creating Production Build", process, checkpoints) def setup_frontend( @@ -226,12 +219,15 @@ def setup_frontend( # Copy asset files to public folder. path_ops.cp( src=str(root / constants.Dirs.APP_ASSETS), - dest=str(root / constants.Dirs.WEB_ASSETS), + dest=str(root / prerequisites.get_web_dir() / constants.Dirs.PUBLIC), ) # Set the environment variables in client (env.json). set_env_json() + # update the last reflex run time. + prerequisites.set_last_reflex_run_time() + # Disable the Next telemetry. if disable_telemetry: processes.new_process( @@ -242,7 +238,7 @@ def setup_frontend( "telemetry", "disable", ], - cwd=constants.Dirs.WEB, + cwd=prerequisites.get_web_dir(), stdout=subprocess.DEVNULL, shell=constants.IS_WINDOWS, ) @@ -259,8 +255,9 @@ def setup_frontend_prod( disable_telemetry: Whether to disable the Next telemetry. """ setup_frontend(root, disable_telemetry) - export(deploy_url=get_config().deploy_url) + build(deploy_url=get_config().deploy_url) -def _looks_like_venv_dir(dir_to_check: str) -> bool: - return os.path.exists(os.path.join(dir_to_check, "pyvenv.cfg")) +def _looks_like_venv_dir(dir_to_check: str | Path) -> bool: + dir_to_check = Path(dir_to_check) + return (dir_to_check / "pyvenv.cfg").exists() diff --git a/reflex/utils/codespaces.py b/reflex/utils/codespaces.py new file mode 100644 index 000000000..7ff686129 --- /dev/null +++ b/reflex/utils/codespaces.py @@ -0,0 +1,94 @@ +"""Utilities for working with Github Codespaces.""" + +from __future__ import annotations + +import os + +from fastapi.responses import HTMLResponse + +from reflex.components.base.script import Script +from reflex.components.component import Component +from reflex.components.core.banner import has_connection_errors +from reflex.components.core.cond import cond +from reflex.constants import Endpoint + +redirect_script = """ +const thisUrl = new URL(window.location.href); +const params = new URLSearchParams(thisUrl.search) + +function doRedirect(url) { + if (!window.sessionStorage.getItem("authenticated_github_codespaces")) { + const a = document.createElement("a"); + if (params.has("redirect_to")) { + a.href = params.get("redirect_to") + } else if (!window.location.href.startsWith(url)) { + a.href = url + `?redirect_to=${window.location.href}` + } else { + return + } + a.hidden = true; + a.click(); + a.remove(); + window.sessionStorage.setItem("authenticated_github_codespaces", "true") + } +} +doRedirect("%s") +""" % Endpoint.AUTH_CODESPACE.get_url() + + +def codespaces_port_forwarding_domain() -> str | None: + """Get the domain for port forwarding in Github Codespaces. + + Returns: + The domain for port forwarding in Github Codespaces, or None if not running in Codespaces. + """ + GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN = os.getenv( + "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" + ) + return GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN + + +def is_running_in_codespaces() -> bool: + """Check if the app is running in Github Codespaces. + + Returns: + True if running in Github Codespaces, False otherwise. + """ + return codespaces_port_forwarding_domain() is not None + + +def codespaces_auto_redirect() -> list[Component]: + """Get the components for automatically redirecting back to the app after authenticating a codespace port forward. + + Returns: + A list containing the conditional redirect component, or empty list. + """ + if is_running_in_codespaces(): + return [cond(has_connection_errors, Script.create(redirect_script))] + return [] + + +async def auth_codespace() -> HTMLResponse: + """Page automatically redirecting back to the app after authenticating a codespace port forward. + + Returns: + An HTML response with an embedded script to redirect back to the app. + """ + return HTMLResponse( + """ + + + Reflex Github Codespace Forward Successfully Authenticated + + +
+

Successfully Authenticated

+
+ + + + """ + % redirect_script + ) diff --git a/reflex/utils/compat.py b/reflex/utils/compat.py index 0b5ad3ad8..e63492a6b 100644 --- a/reflex/utils/compat.py +++ b/reflex/utils/compat.py @@ -4,6 +4,30 @@ import contextlib import sys +async def windows_hot_reload_lifespan_hack(): + """[REF-3164] A hack to fix hot reload on Windows. + + Uvicorn has an issue stopping itself on Windows after detecting changes in + the filesystem. + + This workaround repeatedly prints and flushes null characters to stderr, + which seems to allow the uvicorn server to exit when the CTRL-C signal is + sent from the reloader process. + + Don't ask me why this works, I discovered it by accident - masenf. + """ + import asyncio + import sys + + try: + while True: + sys.stderr.write("\0") + sys.stderr.flush() + await asyncio.sleep(0.5) + except asyncio.CancelledError: + pass + + @contextlib.contextmanager def pydantic_v1_patch(): """A context manager that patches the Pydantic module to mimic v1 behaviour. @@ -11,6 +35,13 @@ def pydantic_v1_patch(): Yields: None when the Pydantic module is patched. """ + import pydantic + + if pydantic.__version__.startswith("1."): + # pydantic v1 is already installed + yield + return + patched_modules = [ "pydantic", "pydantic.fields", @@ -41,3 +72,19 @@ def pydantic_v1_patch(): with pydantic_v1_patch(): import sqlmodel as sqlmodel + + +def sqlmodel_field_has_primary_key(field) -> bool: + """Determines if a field is a priamary. + + Args: + field: a rx.model field + + Returns: + If field is a primary key (Bool) + """ + if getattr(field.field_info, "primary_key", None) is True: + return True + if getattr(field.field_info, "sa_column", None) is None: + return False + return bool(getattr(field.field_info.sa_column, "primary_key", None)) diff --git a/reflex/utils/console.py b/reflex/utils/console.py index a54103064..20c699e20 100644 --- a/reflex/utils/console.py +++ b/reflex/utils/console.py @@ -17,6 +17,9 @@ _LOG_LEVEL = LogLevel.INFO # Deprecated features who's warning has been printed. _EMITTED_DEPRECATION_WARNINGS = set() +# Info messages which have been printed. +_EMITTED_INFO = set() + def set_log_level(log_level: LogLevel): """Set the log level. @@ -55,21 +58,27 @@ def debug(msg: str, **kwargs): kwargs: Keyword arguments to pass to the print function. """ if is_debug(): - msg_ = f"[blue]Debug: {msg}[/blue]" + msg_ = f"[purple]Debug: {msg}[/purple]" if progress := kwargs.pop("progress", None): progress.console.print(msg_, **kwargs) else: print(msg_, **kwargs) -def info(msg: str, **kwargs): +def info(msg: str, dedupe: bool = False, **kwargs): """Print an info message. Args: msg: The info message. + dedupe: If True, suppress multiple console logs of info message. kwargs: Keyword arguments to pass to the print function. """ if _LOG_LEVEL <= LogLevel.INFO: + if dedupe: + if msg in _EMITTED_INFO: + return + else: + _EMITTED_INFO.add(msg) print(f"[cyan]Info: {msg}[/cyan]", **kwargs) diff --git a/reflex/utils/exceptions.py b/reflex/utils/exceptions.py index aabaaef14..661f29095 100644 --- a/reflex/utils/exceptions.py +++ b/reflex/utils/exceptions.py @@ -5,6 +5,14 @@ class ReflexError(Exception): """Base exception for all Reflex exceptions.""" +class ConfigError(ReflexError): + """Custom exception for config related errors.""" + + +class InvalidStateManagerMode(ReflexError, ValueError): + """Raised when an invalid state manager mode is provided.""" + + class ReflexRuntimeError(ReflexError, RuntimeError): """Custom RuntimeError for Reflex.""" @@ -61,6 +69,10 @@ class VarOperationTypeError(ReflexError, TypeError): """Custom TypeError for when unsupported operations are performed on vars.""" +class VarDependencyError(ReflexError, ValueError): + """Custom ValueError for when a var depends on a non-existent var.""" + + class InvalidStylePropError(ReflexError, TypeError): """Custom Type Error when style props have invalid values.""" @@ -75,3 +87,67 @@ 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 differs from that provided by the event trigger.""" + + +class EventHandlerArgTypeMismatch(ReflexError, TypeError): + """Raised when the annotations of args accepted by an EventHandler differs from the spec of 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.""" + + +class InvalidLifespanTaskType(ReflexError, TypeError): + """Raised when an invalid task type is registered as a lifespan task.""" + + +class DynamicComponentMissingLibrary(ReflexError, ValueError): + """Raised when a dynamic component is missing a library.""" + + +class SetUndefinedStateVarError(ReflexError, AttributeError): + """Raised when setting the value of a var without first declaring it.""" + + +class StateSchemaMismatchError(ReflexError, TypeError): + """Raised when the serialized schema of a state class does not match the current schema.""" + + +class EnvironmentVarValueError(ReflexError, ValueError): + """Raised when an environment variable is set to an invalid value.""" + + +class DynamicComponentInvalidSignature(ReflexError, TypeError): + """Raised when a dynamic component has an invalid signature.""" + + +class InvalidPropValueError(ReflexError): + """Raised when a prop value is invalid.""" diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index e4aefb8f1..bdc9be4ae 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -15,24 +15,15 @@ from urllib.parse import urljoin import psutil from reflex import constants -from reflex.config import get_config +from reflex.config import environment, get_config +from reflex.constants.base import LogLevel from reflex.utils import console, path_ops -from reflex.utils.watch import AssetFolderWatch +from reflex.utils.prerequisites import get_web_dir # 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. @@ -70,6 +61,13 @@ def kill(proc_pid: int): process.kill() +def notify_backend(): + """Output a string notifying where the backend is running.""" + console.print( + f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]" + ) + + # run_process_and_launch_url is assumed to be used # only to launch the frontend # If this is not the case, might have to change the logic @@ -82,8 +80,8 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True): """ from reflex.utils import processes - json_file_path = os.path.join(constants.Dirs.WEB, "package.json") - last_hash = detect_package_change(json_file_path) + json_file_path = get_web_dir() / constants.PackageJson.PATH + last_hash = detect_package_change(str(json_file_path)) process = None first_run = True @@ -94,7 +92,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True): kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore process = processes.new_process( run_command, - cwd=constants.Dirs.WEB, + cwd=get_web_dir(), shell=constants.IS_WINDOWS, **kwargs, ) @@ -108,12 +106,25 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True): url = match.group(1) if get_config().frontend_path != "": url = urljoin(url, get_config().frontend_path) - console.print(f"App running at: [bold green]{url}") + + console.print( + f"App running at: [bold green]{url}[/bold green]{' (Frontend-only mode)' if not backend_present else ''}" + ) + if backend_present: + notify_backend() first_run = False else: console.print("New packages detected: Updating app...") else: - new_hash = detect_package_change(json_file_path) + if any( + [x in line for x in ("bin executable does not exist on disk",)] + ): + console.error( + "Try setting `REFLEX_USE_NPM=1` and re-running `reflex init` and `reflex run` to use npm instead of bun:\n" + "`REFLEX_USE_NPM=1 reflex init`\n" + "`REFLEX_USE_NPM=1 reflex run`" + ) + new_hash = detect_package_change(str(json_file_path)) if new_hash != last_hash: last_hash = new_hash kill(process.pid) @@ -133,8 +144,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) @@ -169,13 +178,69 @@ def run_frontend_prod(root: Path, port: str, backend_present=True): ) +def should_use_granian(): + """Whether to use Granian for backend. + + Returns: + True if Granian should be used. + """ + return environment.REFLEX_USE_GRANIAN + + +def get_app_module(): + """Get the app module for the backend. + + Returns: + The app module for the backend. + """ + return f"reflex.app_module_for_backend:{constants.CompileVars.APP}" + + +def get_granian_target(): + """Get the Granian target for the backend. + + Returns: + The Granian target for the backend. + """ + import reflex + + app_module_path = Path(reflex.__file__).parent / "app_module_for_backend.py" + + return f"{str(app_module_path)}:{constants.CompileVars.APP}.{constants.CompileVars.API}" + + def run_backend( host: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR, + frontend_present: bool = False, ): """Run the backend. + Args: + host: The app host + port: The app port + loglevel: The log level. + frontend_present: Whether the frontend is present. + """ + web_dir = get_web_dir() + # Create a .nocompile file to skip compile for backend. + if web_dir.exists(): + (web_dir / constants.NOCOMPILE_FILE).touch() + + if not frontend_present: + notify_backend() + + # Run the backend in development mode. + if should_use_granian(): + run_granian_backend(host, port, loglevel) + else: + run_uvicorn_backend(host, port, loglevel) + + +def run_uvicorn_backend(host, port, loglevel: LogLevel): + """Run the backend in development mode using Uvicorn. + Args: host: The app host port: The app port @@ -183,23 +248,55 @@ def run_backend( """ import uvicorn - config = get_config() - app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}" - - # Create a .nocompile file to skip compile for backend. - if os.path.exists(constants.Dirs.WEB): - with open(constants.NOCOMPILE_FILE, "w"): - pass - - # Run the backend in development mode. uvicorn.run( - app=f"{app_module}.{constants.CompileVars.API}", + app=f"{get_app_module()}.{constants.CompileVars.API}", host=host, port=port, log_level=loglevel.value, reload=True, - reload_dirs=[config.app_name], - reload_excludes=[constants.Dirs.WEB], + reload_dirs=[get_config().app_name], + ) + + +def run_granian_backend(host, port, loglevel: LogLevel): + """Run the backend in development mode using Granian. + + Args: + host: The app host + port: The app port + loglevel: The log level. + """ + console.debug("Using Granian for backend") + try: + from granian import Granian # type: ignore + from granian.constants import Interfaces # type: ignore + from granian.log import LogLevels # type: ignore + + Granian( + target=get_granian_target(), + address=host, + port=port, + interface=Interfaces.ASGI, + log_level=LogLevels(loglevel.value), + reload=True, + reload_paths=[Path(get_config().app_name)], + reload_ignore_dirs=[".web"], + ).serve() + except ImportError: + console.error( + 'InstallError: REFLEX_USE_GRANIAN is set but `granian` is not installed. (run `pip install "granian[reload]>=1.6.0"`)' + ) + os._exit(1) + + +def _get_backend_workers(): + from reflex.utils import processes + + config = get_config() + return ( + processes.get_num_workers() + if not config.gunicorn_workers + else config.gunicorn_workers ) @@ -207,9 +304,28 @@ def run_backend_prod( host: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR, + frontend_present: bool = False, ): """Run the backend. + Args: + host: The app host + port: The app port + loglevel: The log level. + frontend_present: Whether the frontend is present. + """ + if not frontend_present: + notify_backend() + + if should_use_granian(): + run_granian_backend_prod(host, port, loglevel) + else: + run_uvicorn_backend_prod(host, port, loglevel) + + +def run_uvicorn_backend_prod(host, port, loglevel): + """Run the backend in production mode using Uvicorn. + Args: host: The app host port: The app port @@ -217,11 +333,12 @@ def run_backend_prod( """ from reflex.utils import processes - num_workers = processes.get_num_workers() config = get_config() - RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --preload --timeout {config.timeout} --log-level critical".split() - RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {config.timeout}".split() - app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}" + + app_module = get_app_module() + + RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --max-requests {config.gunicorn_max_requests} --max-requests-jitter {config.gunicorn_max_requests_jitter} --preload --timeout {config.timeout} --log-level critical".split() + RUN_BACKEND_PROD_WINDOWS = f"uvicorn --limit-max-requests {config.gunicorn_max_requests} --timeout-keep-alive {config.timeout}".split() command = ( [ *RUN_BACKEND_PROD_WINDOWS, @@ -237,7 +354,7 @@ def run_backend_prod( "--bind", f"{host}:{port}", "--threads", - str(num_workers), + str(_get_backend_workers()), f"{app_module}()", ] ) @@ -246,7 +363,7 @@ def run_backend_prod( "--log-level", loglevel.value, "--workers", - str(num_workers), + str(_get_backend_workers()), ] processes.new_process( command, @@ -256,6 +373,47 @@ def run_backend_prod( ) +def run_granian_backend_prod(host, port, loglevel): + """Run the backend in production mode using Granian. + + Args: + host: The app host + port: The app port + loglevel: The log level. + """ + from reflex.utils import processes + + try: + from granian.constants import Interfaces # type: ignore + + command = [ + "granian", + "--workers", + str(_get_backend_workers()), + "--log-level", + "critical", + "--host", + host, + "--port", + str(port), + "--interface", + str(Interfaces.ASGI), + get_granian_target(), + ] + processes.new_process( + command, + run=True, + show_logs=True, + env={ + constants.SKIP_COMPILE_ENV_VAR: "yes" + }, # skip compile for prod backend + ) + except ImportError: + console.error( + 'InstallError: REFLEX_USE_GRANIAN is set but `granian` is not installed. (run `pip install "granian[reload]>=1.6.0"`)' + ) + + def output_system_info(): """Show system information if the loglevel is in DEBUG.""" if console._LOG_LEVEL > constants.LogLevel.DEBUG: @@ -338,6 +496,24 @@ def is_prod_mode() -> bool: return current_mode == constants.Env.PROD.value +def is_frontend_only() -> bool: + """Check if the app is running in frontend-only mode. + + Returns: + True if the app is running in frontend-only mode. + """ + return os.environ.get(constants.ENV_FRONTEND_ONLY_ENV_VAR, "").lower() == "true" + + +def is_backend_only() -> bool: + """Check if the app is running in backend-only mode. + + Returns: + True if the app is running in backend-only mode. + """ + return os.environ.get(constants.ENV_BACKEND_ONLY_ENV_VAR, "").lower() == "true" + + def should_skip_compile() -> bool: """Whether the app should skip compile. diff --git a/reflex/utils/export.py b/reflex/utils/export.py index 3116f4859..31ac0d0b5 100644 --- a/reflex/utils/export.py +++ b/reflex/utils/export.py @@ -1,4 +1,5 @@ """Export utilities.""" + import os from pathlib import Path from typing import Optional @@ -55,15 +56,18 @@ def export( # Set up .web directory and install frontend dependencies. build.setup_frontend(Path.cwd()) - # Export the app. - build.export( - backend=backend, - frontend=frontend, - zip=zipping, - zip_dest_dir=zip_dest_dir, - deploy_url=config.deploy_url, - upload_db_file=upload_db_file, - ) + # Build the static app. + if frontend: + build.build(deploy_url=config.deploy_url, for_export=True) + + # Zip up the app. + if zipping: + build.zip_app( + frontend=frontend, + backend=backend, + zip_dest_dir=zip_dest_dir, + upload_db_file=upload_db_file, + ) # Post a telemetry event. telemetry.send("export") diff --git a/reflex/utils/format.py b/reflex/utils/format.py index 70f6b5b25..a914a585c 100644 --- a/reflex/utils/format.py +++ b/reflex/utils/format.py @@ -6,16 +6,15 @@ import inspect import json import os import re -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union from reflex import constants -from reflex.utils import exceptions, serializers, types -from reflex.utils.serializers import serialize -from reflex.vars import BaseVar, Var +from reflex.utils import exceptions +from reflex.utils.console import deprecate if TYPE_CHECKING: from reflex.components.component import ComponentStyle - from reflex.event import EventChain, EventHandler, EventSpec + from reflex.event import ArgsSpec, EventChain, EventHandler, EventSpec WRAP_MAP = { "{": "}", @@ -198,8 +197,16 @@ def make_default_page_title(app_name: str, route: str) -> str: Returns: The default page title. """ - title = constants.DefaultPage.TITLE.format(app_name, route) - return to_title_case(title, " ") + route_parts = [ + part + for part in route.split("/") + if part and not (part.startswith("[") and part.endswith("]")) + ] + + title = constants.DefaultPage.TITLE.format( + app_name, route_parts[-1] if route_parts else constants.PageNames.INDEX_ROUTE + ) + return to_title_case(title) def _escape_js_string(string: str) -> str: @@ -211,10 +218,31 @@ def _escape_js_string(string: str) -> str: Returns: The escaped string. """ - # Escape backticks. - string = string.replace(r"\`", "`") - string = string.replace("`", r"\`") - return string + + # TODO: we may need to re-vist this logic after new Var API is implemented. + def escape_outside_segments(segment): + """Escape backticks in segments outside of `${}`. + + Args: + segment: The part of the string to escape. + + Returns: + The escaped or unescaped segment. + """ + if segment.startswith("${") and segment.endswith("}"): + # Return the `${}` segment unchanged + return segment + else: + # Escape backticks in the segment + segment = segment.replace(r"\`", "`") + segment = segment.replace("`", r"\`") + return segment + + # Split the string into parts, keeping the `${}` segments + parts = re.split(r"(\$\{.*?\})", string) + escaped_parts = [escape_outside_segments(part) for part in parts] + escaped_string = "".join(escaped_parts) + return escaped_string def _wrap_js_string(string: str) -> str: @@ -243,32 +271,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. - """ - s = prop._var_full_name - var_data = prop._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. @@ -278,13 +280,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: @@ -309,46 +305,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: @@ -367,17 +328,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 @@ -397,35 +353,21 @@ def format_prop( Raises: exceptions.InvalidStylePropError: If the style prop value is not a valid type. TypeError: If the prop is not valid. + ValueError: If the prop is not a string. """ # import here to avoid circular import. from reflex.event import EventChain + from reflex.utils import serializers + 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): - if prop._var_data and prop._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): - sig = inspect.signature(prop.args_spec) # type: ignore - if sig.parameters: - arg_def = ",".join(f"_{p}" for p in sig.parameters) - arg_def = f"({arg_def})" - else: - # add a default argument for addEvents if none were specified in prop.args_spec - # used to trigger the preventDefault() on the event. - arg_def = "(_e)" - - chain = ",".join([format_event(event) for event in prop.events]) - event = f"addEvents([{chain}], {arg_def}, {json_dumps(prop.event_actions)})" - prop = f"{arg_def} => {event}" + if isinstance(prop, EventChain): + return str(Var.create(prop)) # Handle other types. elif isinstance(prop, str): @@ -446,7 +388,8 @@ def format_prop( raise TypeError(f"Could not format prop: {prop} of type {type(prop)}") from e # Wrap the variable in braces. - assert isinstance(prop, str), "The prop must be a string." + if not isinstance(prop, str): + raise ValueError(f"Invalid prop: {prop}. Expected a string.") return wrap(prop, "{", check_first=False) @@ -461,11 +404,15 @@ def format_props(*single_props, **key_value_props) -> list[str]: The formatted props list. """ # Format all the props. + from reflex.vars.base import LiteralVar, Var + return [ - f"{name}={format_prop(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) 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]: @@ -480,13 +427,13 @@ def get_event_handler_parts(handler: EventHandler) -> tuple[str, str]: # Get the class that defines the event handler. parts = handler.fn.__qualname__.split(".") - # If there's no enclosing class, just return the function name. - if len(parts) == 1: - return ("", parts[-1]) - # Get the state full name state_full_name = handler.state_full_name + # If there's no enclosing class, just return the function name. + if not state_full_name: + return ("", parts[-1]) + # Get the function name name = parts[-1] @@ -526,14 +473,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) ), ) ) @@ -550,44 +497,116 @@ 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. + """ + 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: ( + EventSpec + | EventHandler + | Callable + | List[EventSpec | EventHandler | Callable] + | None + ) = None, + args_spec: Optional[ArgsSpec] = None, +) -> Var[EventChain]: + """Format a list of event handler / event spec as a javascript callback. + + The resulting code can be passed to interfaces that expect a callback + function and when triggered it will directly call queueEvents. + + It is intended to be executed in the rx.call_script context, where some + existing API needs a callback to trigger a backend event handler. + + Args: + events: The events to queue. + args_spec: The argument spec for the callback. + + Returns: + The compiled javascript callback to queue the given events on the frontend. Raises: - ValueError: When the given event chain is not a valid event chain. + ValueError: If a lambda function is given which returns a Var. """ - 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 "", - ")", - ] + from reflex.event import ( + EventChain, + EventHandler, + EventSpec, + call_event_fn, + call_event_handler, ) + from reflex.vars import FunctionVar, Var + + if not events: + return Var("(() => null)").to(FunctionVar, EventChain) # type: ignore + + # If no spec is provided, the function will take no arguments. + def _default_args_spec(): + return [] + + # Construct the arguments that the function accepts. + sig = inspect.signature(args_spec or _default_args_spec) # type: ignore + if sig.parameters: + arg_def = ",".join(f"_{p}" for p in sig.parameters) + arg_def = f"({arg_def})" + else: + arg_def = "()" + + payloads = [] + if not isinstance(events, list): + events = [events] + + # Process each event/spec/lambda (similar to Component._create_event_chain). + for spec in events: + specs: list[EventSpec] = [] + if isinstance(spec, (EventHandler, EventSpec)): + specs = [call_event_handler(spec, args_spec or _default_args_spec)] + elif isinstance(spec, type(lambda: None)): + specs = call_event_fn(spec, args_spec or _default_args_spec) # type: ignore + if isinstance(specs, Var): + raise ValueError( + f"Invalid event spec: {specs}. Expected a list of EventSpecs." + ) + payloads.extend(format_event(s) for s in specs) + + # 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 Var( + f"{arg_def} => {{queueEvents([{','.join(payloads)}], {constants.CompileVars.SOCKET}); " + f"processEvent({constants.CompileVars.SOCKET})}}", + ).to(FunctionVar, EventChain) # type: ignore def format_query_params(router_data: dict[str, Any]) -> dict[str, str]: @@ -603,46 +622,6 @@ def format_query_params(router_data: dict[str, Any]) -> dict[str, str]: return {k.replace("-", "_"): v for k, v in params.items()} -def format_state(value: Any, key: Optional[str] = None) -> Any: - """Recursively format values in the given state. - - Args: - value: The state to format. - key: The key associated with the value (optional). - - Returns: - The formatted state. - - Raises: - TypeError: If the given value is not a valid state. - """ - # Handle dicts. - if isinstance(value, dict): - return {k: format_state(v, k) for k, v in value.items()} - - # Handle lists, sets, typles. - if isinstance(value, types.StateIterBases): - return [format_state(v) for v in value] - - # Return state vars as is. - if isinstance(value, types.StateBases): - return value - - # Serialize the value. - serialized = serialize(value) - if serialized is not None: - return serialized - - if key is None: - raise TypeError( - f"No JSON serializer found for var {value} of type {type(value)}." - ) - else: - raise TypeError( - f"No JSON serializer found for State Var '{key}' of value {value} of type {type(value)}." - ) - - def format_state_name(state_name: str) -> str: """Format a state name, replacing dots with double underscore. @@ -672,41 +651,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}[{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. @@ -716,6 +660,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 @@ -732,43 +678,9 @@ def json_dumps(obj: Any) -> str: Returns: A string """ - return json.dumps(obj, ensure_ascii=False, default=serialize) + from reflex.utils import serializers - -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('`"', "`") - ) + return json.dumps(obj, ensure_ascii=False, default=serializers.serialize) def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]: @@ -793,6 +705,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. @@ -805,6 +734,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"} @@ -817,7 +748,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( @@ -834,4 +765,9 @@ def format_data_editor_cell(cell: Any): Returns: The formatted cell. """ - return {"kind": Var.create(value="GridCellKind.Text"), "data": cell} + from reflex.vars.base import Var + + return { + "kind": Var(_js_expr="GridCellKind.Text"), + "data": cell, + } diff --git a/reflex/utils/imports.py b/reflex/utils/imports.py index 263de1e3d..bd422ecc0 100644 --- a/reflex/utils/imports.py +++ b/reflex/utils/imports.py @@ -2,13 +2,14 @@ from __future__ import annotations +import dataclasses from collections import defaultdict -from typing import Dict, List, Optional - -from reflex.base import Base +from typing import DefaultDict, Dict, List, Optional, Tuple, Union -def merge_imports(*imports) -> ImportDict: +def merge_imports( + *imports: ImportDict | ParsedImportDict | ImmutableParsedImportDict, +) -> ParsedImportDict: """Merge multiple import dicts together. Args: @@ -17,14 +18,58 @@ def merge_imports(*imports) -> ImportDict: 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.items(): - all_imports[lib].extend(fields) + for lib, fields in ( + import_dict if isinstance(import_dict, tuple) else import_dict.items() + ): + # If the lib is an absolute path, we need to prefix it with a $ + lib = ( + "$" + lib + if lib.startswith(("/utils/", "/components/", "/styles/", "/public/")) + else lib + ) + 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 -def collapse_imports(imports: ImportDict) -> ImportDict: +def parse_imports(imports: ImportDict | ParsedImportDict) -> ParsedImportDict: + """Parse the import dict into a standard format. + + Args: + imports: The import dict to parse. + + Returns: + The parsed import dict. + """ + + def _make_list(value: ImportTypes) -> list[str | ImportVar] | list[ImportVar]: + if isinstance(value, (str, ImportVar)): + return [value] + return value + + return { + package: [ + ImportVar(tag=tag) if isinstance(tag, str) else tag + for tag in _make_list(maybe_tags) + ] + for package, maybe_tags in imports.items() + } + + +def collapse_imports( + imports: ParsedImportDict | ImmutableParsedImportDict, +) -> ParsedImportDict: """Remove all duplicate ImportVar within an ImportDict. Args: @@ -33,10 +78,20 @@ def collapse_imports(imports: ImportDict) -> ImportDict: Returns: The collapsed import dict. """ - return {lib: list(set(import_vars)) for lib, import_vars in imports.items()} + return { + lib: ( + list(set(import_vars)) + if isinstance(import_vars, list) + else list(import_vars) + ) + for lib, import_vars in ( + imports if isinstance(imports, tuple) else imports.items() + ) + } -class ImportVar(Base): +@dataclasses.dataclass(order=True, frozen=True) +class ImportVar: """An import var.""" # The name of the import tag. @@ -72,22 +127,8 @@ class ImportVar(Base): else: return self.tag or "" - def __hash__(self) -> int: - """Define a hash function for the import var. - Returns: - The hash of the var. - """ - return hash( - ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) - ) - - -ImportDict = Dict[str, List[ImportVar]] +ImportTypes = Union[str, ImportVar, List[Union[str, ImportVar]], List[ImportVar]] +ImportDict = Dict[str, ImportTypes] +ParsedImportDict = Dict[str, List[ImportVar]] +ImmutableParsedImportDict = Tuple[Tuple[str, Tuple[ImportVar, ...]], ...] diff --git a/reflex/utils/lazy_loader.py b/reflex/utils/lazy_loader.py new file mode 100644 index 000000000..61e3967e5 --- /dev/null +++ b/reflex/utils/lazy_loader.py @@ -0,0 +1,34 @@ +"""Module to implement lazy loading in reflex.""" + +import copy + +import lazy_loader as lazy + + +def attach(package_name, submodules=None, submod_attrs=None): + """Replaces a package's __getattr__, __dir__, and __all__ attributes using lazy.attach. + The lazy loader __getattr__ doesn't support tuples as list values. We needed to add + this functionality (tuples) in Reflex to support 'import as _' statements. This function + reformats the submod_attrs dictionary to flatten the module list before passing it to + lazy_loader. + + Args: + package_name: name of the package. + submodules : List of submodules to attach. + submod_attrs : Dictionary of submodule -> list of attributes / functions. + These attributes are imported as they are used. + + Returns: + __getattr__, __dir__, __all__ + """ + _submod_attrs = copy.deepcopy(submod_attrs) + if _submod_attrs: + for k, v in _submod_attrs.items(): + # when flattening the list, only keep the alias in the tuple(mod[1]) + _submod_attrs[k] = [ + mod if not isinstance(mod, tuple) else mod[1] for mod in v + ] + + return lazy.attach( + package_name=package_name, submodules=submodules, submod_attrs=_submod_attrs + ) diff --git a/reflex/utils/net.py b/reflex/utils/net.py new file mode 100644 index 000000000..2c6f22764 --- /dev/null +++ b/reflex/utils/net.py @@ -0,0 +1,41 @@ +"""Helpers for downloading files from the network.""" + +import httpx + +from ..config import environment +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 + """ + return not environment.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 3073dca0e..ee93b24cf 100644 --- a/reflex/utils/path_ops.py +++ b/reflex/utils/path_ops.py @@ -9,24 +9,26 @@ import shutil from pathlib import Path from reflex import constants +from reflex.config import environment # Shorthand for join. join = os.linesep.join -def rm(path: str): +def rm(path: str | Path): """Remove a file or directory. Args: path: The path to the file or directory. """ - if os.path.isdir(path): + path = Path(path) + if path.is_dir(): shutil.rmtree(path) - elif os.path.isfile(path): - os.remove(path) + elif path.is_file(): + path.unlink() -def cp(src: str, dest: str, overwrite: bool = True) -> bool: +def cp(src: str | Path, dest: str | Path, overwrite: bool = True) -> bool: """Copy a file or directory. Args: @@ -37,11 +39,12 @@ def cp(src: str, dest: str, overwrite: bool = True) -> bool: Returns: Whether the copy was successful. """ + src, dest = Path(src), Path(dest) if src == dest: return False - if not overwrite and os.path.exists(dest): + if not overwrite and dest.exists(): return False - if os.path.isdir(src): + if src.is_dir(): rm(dest) shutil.copytree(src, dest) else: @@ -49,7 +52,7 @@ def cp(src: str, dest: str, overwrite: bool = True) -> bool: return True -def mv(src: str, dest: str, overwrite: bool = True) -> bool: +def mv(src: str | Path, dest: str | Path, overwrite: bool = True) -> bool: """Move a file or directory. Args: @@ -60,25 +63,38 @@ def mv(src: str, dest: str, overwrite: bool = True) -> bool: Returns: Whether the move was successful. """ + src, dest = Path(src), Path(dest) if src == dest: return False - if not overwrite and os.path.exists(dest): + if not overwrite and dest.exists(): return False rm(dest) shutil.move(src, dest) return True -def mkdir(path: str): +def mkdir(path: str | Path): """Create a directory. Args: path: The path to the directory. """ - os.makedirs(path, exist_ok=True) + Path(path).mkdir(parents=True, exist_ok=True) -def ln(src: str, dest: str, overwrite: bool = False) -> bool: +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. Args: @@ -89,19 +105,20 @@ def ln(src: str, dest: str, overwrite: bool = False) -> bool: Returns: Whether the link was successful. """ + src, dest = Path(src), Path(dest) if src == dest: return False - if not overwrite and (os.path.exists(dest) or os.path.islink(dest)): + if not overwrite and (dest.exists() or dest.is_symlink()): return False - if os.path.isdir(src): + if src.is_dir(): rm(dest) - os.symlink(src, dest, target_is_directory=True) + src.symlink_to(dest, target_is_directory=True) else: - os.symlink(src, dest) + src.symlink_to(dest) return True -def which(program: str) -> str | None: +def which(program: str | Path) -> str | Path | None: """Find the path to an executable. Args: @@ -110,19 +127,38 @@ def which(program: str) -> str | None: Returns: The path to the executable. """ - return shutil.which(program) + return shutil.which(str(program)) -def get_node_bin_path() -> str | None: +def use_system_node() -> bool: + """Check if the system node should be used. + + Returns: + Whether the system node should be used. + """ + return environment.REFLEX_USE_SYSTEM_NODE + + +def use_system_bun() -> bool: + """Check if the system bun should be used. + + Returns: + Whether the system bun should be used. + """ + return environment.REFLEX_USE_SYSTEM_BUN + + +def get_node_bin_path() -> Path | None: """Get the node binary dir path. Returns: The path to the node bin folder. """ - if not os.path.exists(constants.Node.BIN_PATH): + bin_path = Path(constants.Node.BIN_PATH) + if not bin_path.exists(): str_path = which("node") - return str(Path(str_path).parent.resolve()) if str_path else str_path - return str(Path(constants.Node.BIN_PATH).resolve()) + return Path(str_path).parent.resolve() if str_path else None + return bin_path.resolve() def get_node_path() -> str | None: @@ -131,9 +167,11 @@ def get_node_path() -> str | None: Returns: The path to the node binary file. """ - if not os.path.exists(constants.Node.PATH): - return which("node") - return constants.Node.PATH + node_path = Path(constants.Node.PATH) + if use_system_node() or not node_path.exists(): + system_node_path = which("node") + return str(system_node_path) if system_node_path else None + return str(node_path) def get_npm_path() -> str | None: @@ -142,12 +180,14 @@ def get_npm_path() -> str | None: Returns: The path to the npm binary file. """ - if not os.path.exists(constants.Node.PATH): - return which("npm") - return constants.Node.NPM_PATH + npm_path = Path(constants.Node.NPM_PATH) + if use_system_node() or not npm_path.exists(): + system_npm_path = which("npm") + return str(system_npm_path) if system_npm_path else None + return str(npm_path) -def update_json_file(file_path: str, update_dict: dict[str, int | str]): +def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]): """Update the contents of a json file. Args: @@ -164,7 +204,7 @@ def update_json_file(file_path: str, update_dict: dict[str, int | str]): # Read the existing json object from the file. json_object = {} - if fp.stat().st_size == 0: + if fp.stat().st_size: with open(fp) as f: json_object = json.load(f) @@ -176,7 +216,7 @@ def update_json_file(file_path: str, update_dict: dict[str, int | str]): json.dump(json_object, f, ensure_ascii=False) -def find_replace(directory: str, find: str, replace: str): +def find_replace(directory: str | Path, find: str, replace: str): """Recursively find and replace text in files in a directory. Args: @@ -184,11 +224,10 @@ def find_replace(directory: str, find: str, replace: str): find: The text to find. replace: The text to replace. """ + directory = Path(directory) for root, _dirs, files in os.walk(directory): for file in files: - filepath = os.path.join(root, file) - with open(filepath, "r", encoding="utf-8") as f: - text = f.read() + filepath = Path(root, file) + text = filepath.read_text(encoding="utf-8") text = re.sub(find, replace, text) - with open(filepath, "w") as f: - f.write(text) + filepath.write_text(text, encoding="utf-8") diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index de4741c1e..d70e7706f 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -2,10 +2,11 @@ from __future__ import annotations +import contextlib +import dataclasses import functools -import glob import importlib -import inspect +import importlib.metadata import json import os import platform @@ -15,33 +16,34 @@ import shutil import stat import sys import tempfile +import time import zipfile from datetime import datetime -from fileinput import FileInput from pathlib import Path from types import ModuleType from typing import Callable, List, Optional import httpx -import pkg_resources 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 -import reflex 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.config import Config, environment, get_config +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_npm_registry CURRENTLY_INSTALLING_NODE = False -class Template(Base): +@dataclasses.dataclass(frozen=True) +class Template: """A template for a Reflex app.""" name: str @@ -50,7 +52,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] @@ -58,6 +61,29 @@ class CpuInfo(Base): address_width: Optional[int] +def get_web_dir() -> Path: + """Get the working directory for the next.js commands. + + Can be overridden with REFLEX_WEB_WORKDIR. + + Returns: + The working directory. + """ + return environment.REFLEX_WEB_WORKDIR + + +def _python_version_check(): + """Emit deprecation warning for deprecated python versions.""" + # Check for end-of-life python versions. + if sys.version_info < (3, 10): + console.deprecate( + feature_name="Support for Python 3.9 and older", + reason="please upgrade to Python 3.10 or newer", + deprecation_version="0.6.0", + removal_version="0.7.0", + ) + + def check_latest_package_version(package_name: str): """Check if the latest version of the package is installed. @@ -66,19 +92,20 @@ def check_latest_package_version(package_name: str): """ try: # Get the latest version from PyPI - current_version = pkg_resources.get_distribution(package_name).version + 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) - and not get_or_set_last_reflex_version_check_datetime() - ): - # only show a warning when the host version is outdated and - # the last_version_check_datetime is not set in reflex.json + if get_or_set_last_reflex_version_check_datetime(): + # Versions were already checked and saved in reflex.json, no need to warn again + return + if version.parse(current_version) < version.parse(latest_version): + # Show a warning when the host version is older than PyPI version console.warn( f"Your version ({current_version}) of {package_name} is out of date. Upgrade to {latest_version} with 'pip install {package_name} --upgrade'" ) + # Check for depreacted python versions + _python_version_check() except Exception: pass @@ -91,18 +118,26 @@ def get_or_set_last_reflex_version_check_datetime(): Returns: The last version check datetime. """ - if not os.path.exists(constants.Reflex.JSON): + reflex_json_file = get_web_dir() / constants.Reflex.JSON + if not reflex_json_file.exists(): return None # Open and read the file - with open(constants.Reflex.JSON, "r") as file: - data: dict = json.load(file) + data = json.loads(reflex_json_file.read_text()) last_version_check_datetime = data.get("last_version_check_datetime") if not last_version_check_datetime: data.update({"last_version_check_datetime": str(datetime.now())}) - path_ops.update_json_file(constants.Reflex.JSON, data) + path_ops.update_json_file(reflex_json_file, data) return last_version_check_datetime +def set_last_reflex_run_time(): + """Set the last Reflex run time.""" + path_ops.update_json_file( + get_web_dir() / constants.Reflex.JSON, + {"last_reflex_run_datetime": str(datetime.now())}, + ) + + def check_node_version() -> bool: """Check the version of Node.js. @@ -110,14 +145,9 @@ def check_node_version() -> bool: Whether the version of Node.js is valid. """ current_version = get_node_version() - if current_version: - # Compare the version numbers - return ( - current_version >= version.parse(constants.Node.MIN_VERSION) - if constants.IS_WINDOWS - else current_version == version.parse(constants.Node.VERSION) - ) - return False + return current_version is not None and current_version >= version.parse( + constants.Node.MIN_VERSION + ) def get_node_version() -> version.Version | None: @@ -163,7 +193,7 @@ def get_bun_version() -> version.Version | None: """ try: # Run the bun -v command and capture the output - result = processes.new_process([get_config().bun_path, "-v"], run=True) + result = processes.new_process([str(get_config().bun_path), "-v"], run=True) return version.parse(result.stdout) # type: ignore except FileNotFoundError: return None @@ -181,9 +211,14 @@ def get_install_package_manager() -> str | None: Returns: The path to the package manager. """ - if constants.IS_WINDOWS and not is_windows_bun_supported(): + if ( + constants.IS_WINDOWS + and not is_windows_bun_supported() + or windows_check_onedrive_in_path() + or windows_npm_escape_hatch() + ): return get_package_manager() - return get_config().bun_path + return str(get_config().bun_path) def get_package_manager() -> str | None: @@ -199,6 +234,24 @@ def get_package_manager() -> str | None: return npm_path +def windows_check_onedrive_in_path() -> bool: + """For windows, check if oneDrive is present in the project dir path. + + Returns: + If oneDrive is in the path of the project directory. + """ + return "onedrive" in str(Path.cwd()).lower() + + +def windows_npm_escape_hatch() -> bool: + """For windows, if the user sets REFLEX_USE_NPM, use npm instead of bun. + + Returns: + If the user has set REFLEX_USE_NPM. + """ + return environment.REFLEX_USE_NPM + + def get_app(reload: bool = False) -> ModuleType: """Get the app module based on the default config. @@ -210,9 +263,8 @@ def get_app(reload: bool = False) -> ModuleType: Raises: RuntimeError: If the app name is not set in the config. - exceptions.ReflexError: Reflex specific errors. """ - from reflex.utils import exceptions, telemetry + from reflex.utils import telemetry try: os.environ[constants.RELOAD_CONFIG] = str(reload) @@ -236,8 +288,8 @@ def get_app(reload: bool = False) -> ModuleType: importlib.reload(app) return app - except exceptions.ReflexError as ex: - telemetry.send("error", context="frontend", detail=str(ex)) + except Exception as ex: + telemetry.send_error(ex, context="frontend") raise @@ -253,7 +305,7 @@ def get_compiled_app(reload: bool = False, export: bool = False) -> ModuleType: """ app_module = get_app(reload=reload) app = getattr(app_module, constants.CompileVars.APP) - # For py3.8 and py3.9 compatibility when redis is used, we MUST add any decorator pages + # For py3.9 compatibility when redis is used, we MUST add any decorator pages # before compiling the app in a thread to avoid event loop error (REF-2172). app._apply_decorated_pages() app._compile(export=export) @@ -290,37 +342,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 -def get_production_backend_url() -> str: - """Get the production backend 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: - The production backend URL. + 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. """ - config = get_config() - return constants.PRODUCTION_BACKEND_URL.format( - username=config.username, - app_name=config.app_name, - ) + 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: @@ -337,9 +395,7 @@ def validate_app_name(app_name: str | None = None) -> str: Raises: Exit: if the app directory name is reflex or if the name is not standard for a python package name. """ - app_name = ( - app_name if app_name else os.getcwd().split(os.path.sep)[-1].replace("-", "_") - ) + app_name = app_name if app_name else Path.cwd().name.replace("-", "_") # Make sure the app is not named "reflex". if app_name.lower() == constants.Reflex.MODULE_NAME: console.error( @@ -373,7 +429,7 @@ def create_config(app_name: str): def initialize_gitignore( - gitignore_file: str = constants.GitIgnore.FILE, + gitignore_file: Path = constants.GitIgnore.FILE, files_to_ignore: set[str] = constants.GitIgnore.DEFAULTS, ): """Initialize the template .gitignore file. @@ -383,14 +439,23 @@ def initialize_gitignore( files_to_ignore: The files to add to the .gitignore file. """ # Combine with the current ignored files. - if os.path.exists(gitignore_file): - with open(gitignore_file, "r") as f: - files_to_ignore |= set([line.strip() for line in f.readlines()]) + current_ignore: set[str] = set() + if gitignore_file.exists(): + current_ignore |= set( + line.strip() for line in gitignore_file.read_text().splitlines() + ) + + if files_to_ignore == current_ignore: + console.debug(f"{gitignore_file} already up to date.") + return + files_to_ignore |= current_ignore # Write files to the .gitignore file. - with open(gitignore_file, "w", newline="\n") as f: - console.debug(f"Creating {gitignore_file}") - f.write(f"{(path_ops.join(sorted(files_to_ignore))).lstrip()}") + gitignore_file.touch(exist_ok=True) + console.debug(f"Creating {gitignore_file}") + gitignore_file.write_text( + "\n".join(sorted(files_to_ignore)) + "\n", + ) def initialize_requirements_txt(): @@ -483,8 +548,8 @@ def initialize_app_directory( # Rename the template app to the app name. path_ops.mv(template_code_dir_name, app_name) path_ops.mv( - os.path.join(app_name, template_name + constants.Ext.PY), - os.path.join(app_name, app_name + constants.Ext.PY), + Path(app_name) / (template_name + constants.Ext.PY), + Path(app_name) / (app_name + constants.Ext.PY), ) # Fix up the imports. @@ -504,12 +569,11 @@ def get_project_hash(raise_on_fail: bool = False) -> int | None: Returns: project_hash: The app hash. """ - if not os.path.exists(constants.Reflex.JSON) and not raise_on_fail: + json_file = get_web_dir() / constants.Reflex.JSON + if not json_file.exists() and not raise_on_fail: return None - # Open and read the file - with open(constants.Reflex.JSON, "r") as file: - data = json.load(file) - return data.get("project_hash") + data = json.loads(json_file.read_text()) + return data.get("project_hash") def initialize_web_directory(): @@ -519,11 +583,11 @@ def initialize_web_directory(): # Re-use the hash if one is already created, so we don't over-write it when running reflex init project_hash = get_project_hash() - path_ops.cp(constants.Templates.Dirs.WEB_TEMPLATE, constants.Dirs.WEB) + path_ops.cp(constants.Templates.Dirs.WEB_TEMPLATE, str(get_web_dir())) initialize_package_json() - path_ops.mkdir(constants.Dirs.WEB_ASSETS) + path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC) update_next_config() @@ -546,10 +610,18 @@ def _compile_package_json(): def initialize_package_json(): """Render and write in .web the package.json file.""" - output_path = constants.PackageJson.PATH + output_path = get_web_dir() / constants.PackageJson.PATH code = _compile_package_json() - with open(output_path, "w") as file: - file.write(code) + output_path.write_text(code) + + best_registry = _get_npm_registry() + bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH + bun_config_path.write_text( + f""" +[install] +registry = "{best_registry}" +""" + ) def init_reflex_json(project_hash: int | None): @@ -574,7 +646,7 @@ def init_reflex_json(project_hash: int | None): "version": constants.Reflex.VERSION, "project_hash": project_hash, } - path_ops.update_json_file(constants.Reflex.JSON, reflex_json) + path_ops.update_json_file(get_web_dir() / constants.Reflex.JSON, reflex_json) def update_next_config(export=False, transpile_packages: Optional[List[str]] = None): @@ -584,7 +656,7 @@ def update_next_config(export=False, transpile_packages: Optional[List[str]] = N export: if the method run during reflex export. transpile_packages: list of packages to transpile via next.config.js. """ - next_config_file = Path(constants.Dirs.WEB, constants.Next.CONFIG_FILE) + next_config_file = get_web_dir() / constants.Next.CONFIG_FILE next_config = _update_next_config( get_config(), export=export, transpile_packages=transpile_packages @@ -603,8 +675,9 @@ def _update_next_config( next_config = { "basePath": config.frontend_path or "", "compress": config.next_compression, - "reactStrictMode": True, + "reactStrictMode": config.react_strict_mode, "trailingSlash": True, + "staticPageGenerationTimeout": config.static_page_generation_timeout, } if transpile_packages: next_config["transpilePackages"] = list( @@ -621,7 +694,7 @@ def _update_next_config( def remove_existing_bun_installation(): """Remove existing bun installation.""" console.debug("Removing existing bun installation.") - if os.path.exists(get_config().bun_path): + if Path(get_config().bun_path).exists(): path_ops.rm(constants.Bun.ROOT_PATH) @@ -636,7 +709,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() @@ -661,16 +734,16 @@ def download_and_extract_fnm_zip(): # Download the zip file url = constants.Fnm.INSTALL_URL console.debug(f"Downloading {url}") - fnm_zip_file = os.path.join(constants.Fnm.DIR, f"{constants.Fnm.FILENAME}.zip") + fnm_zip_file = constants.Fnm.DIR / f"{constants.Fnm.FILENAME}.zip" # Function to download and extract the FNM zip release. 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: @@ -700,7 +773,7 @@ def install_node(): return path_ops.mkdir(constants.Fnm.DIR) - if not os.path.exists(constants.Fnm.EXE): + if not constants.Fnm.EXE.exists(): download_and_extract_fnm_zip() if constants.IS_WINDOWS: @@ -744,13 +817,20 @@ def install_bun(): Raises: FileNotFoundError: If required packages are not found. """ - if constants.IS_WINDOWS and not is_windows_bun_supported(): - console.warn( - "Bun for Windows is currently only available for x86 64-bit Windows. Installation will fall back on npm." - ) + win_supported = is_windows_bun_supported() + one_drive_in_path = windows_check_onedrive_in_path() + if constants.IS_WINDOWS and not win_supported or one_drive_in_path: + if not win_supported: + console.warn( + "Bun for Windows is currently only available for x86 64-bit Windows. Installation will fall back on npm." + ) + if one_drive_in_path: + console.warn( + "Creating project directories in OneDrive is not recommended for bun usage on windows. This will fallback to npm." + ) # Skip if bun is already installed. - if os.path.exists(get_config().bun_path) and get_bun_version() == version.parse( + if Path(get_config().bun_path).exists() and get_bun_version() == version.parse( constants.Bun.VERSION ): console.debug("Skipping bun installation as it is already installed.") @@ -765,7 +845,7 @@ def install_bun(): f"irm {constants.Bun.WINDOWS_INSTALL_URL}|iex", ], env={ - "BUN_INSTALL": constants.Bun.ROOT_PATH, + "BUN_INSTALL": str(constants.Bun.ROOT_PATH), "BUN_VERSION": constants.Bun.VERSION, }, shell=True, @@ -781,25 +861,26 @@ def install_bun(): download_and_run( constants.Bun.INSTALL_URL, f"bun-v{constants.Bun.VERSION}", - BUN_INSTALL=constants.Bun.ROOT_PATH, + BUN_INSTALL=str(constants.Bun.ROOT_PATH), ) -def _write_cached_procedure_file(payload: str, cache_file: str): - with open(cache_file, "w") as f: - f.write(payload) +def _write_cached_procedure_file(payload: str, cache_file: str | Path): + cache_file = Path(cache_file) + cache_file.write_text(payload) -def _read_cached_procedure_file(cache_file: str) -> str | None: - if os.path.exists(cache_file): - with open(cache_file, "r") as f: - return f.read() +def _read_cached_procedure_file(cache_file: str | Path) -> str | None: + cache_file = Path(cache_file) + if cache_file.exists(): + return cache_file.read_text() return None -def _clear_cached_procedure_file(cache_file: str): - if os.path.exists(cache_file): - os.remove(cache_file) +def _clear_cached_procedure_file(cache_file: str | Path): + cache_file = Path(cache_file) + if cache_file.exists(): + cache_file.unlink() def cached_procedure(cache_file: str, payload_fn: Callable[..., str]): @@ -829,9 +910,7 @@ def cached_procedure(cache_file: str, payload_fn: Callable[..., str]): @cached_procedure( - cache_file=os.path.join( - constants.Dirs.WEB, "reflex.install_frontend_packages.cached" - ), + cache_file=str(get_web_dir() / "reflex.install_frontend_packages.cached"), payload_fn=lambda p, c: f"{repr(sorted(list(p)))},{c.json()}", ) def install_frontend_packages(packages: set[str], config: Config): @@ -850,6 +929,7 @@ def install_frontend_packages(packages: set[str], config: Config): if not constants.IS_WINDOWS or constants.IS_WINDOWS and is_windows_bun_supported() + and not windows_check_onedrive_in_path() else None ) processes.run_process_with_fallback( @@ -857,7 +937,7 @@ def install_frontend_packages(packages: set[str], config: Config): fallback=fallback_command, analytics_enabled=True, show_status_message="Installing base frontend packages", - cwd=constants.Dirs.WEB, + cwd=get_web_dir(), shell=constants.IS_WINDOWS, ) @@ -873,7 +953,7 @@ def install_frontend_packages(packages: set[str], config: Config): fallback=fallback_command, analytics_enabled=True, show_status_message="Installing tailwind", - cwd=constants.Dirs.WEB, + cwd=get_web_dir(), shell=constants.IS_WINDOWS, ) @@ -884,7 +964,7 @@ def install_frontend_packages(packages: set[str], config: Config): fallback=fallback_command, analytics_enabled=True, show_status_message="Installing frontend packages from config and components", - cwd=constants.Dirs.WEB, + cwd=get_web_dir(), shell=constants.IS_WINDOWS, ) @@ -901,7 +981,7 @@ def needs_reinit(frontend: bool = True) -> bool: Raises: Exit: If the app is not initialized. """ - if not os.path.exists(constants.Config.FILE): + if not constants.Config.FILE.exists(): console.error( f"[cyan]{constants.Config.FILE}[/cyan] not found. Move to the root folder of your project, or run [bold]{constants.Reflex.MODULE_NAME} init[/bold] to start a new project." ) @@ -912,11 +992,11 @@ def needs_reinit(frontend: bool = True) -> bool: return False # Make sure the .reflex directory exists. - if not os.path.exists(constants.Reflex.DIR): + if not environment.REFLEX_DIR.exists(): return True # Make sure the .web directory exists in frontend mode. - if not os.path.exists(constants.Dirs.WEB): + if not get_web_dir().exists(): return True # If the template is out of date, then we need to re-init @@ -924,20 +1004,13 @@ def needs_reinit(frontend: bool = True) -> bool: return True if constants.IS_WINDOWS: - import uvicorn - - uvi_ver = uvicorn.__version__ console.warn( """Windows Subsystem for Linux (WSL) is recommended for improving initial install times.""" ) - if sys.version_info >= (3, 12) and uvi_ver != "0.24.0.post1": - console.warn( - f"""On Python 3.12, `uvicorn==0.24.0.post1` is recommended for improved hot reload times. Found {uvi_ver} instead.""" - ) - if sys.version_info < (3, 12) and uvi_ver != "0.20.0": + if windows_check_onedrive_in_path(): console.warn( - f"""On Python < 3.12, `uvicorn==0.20.0` is recommended for improved hot reload times. Found {uvi_ver} instead.""" + "Creating project directories in OneDrive may lead to performance issues. For optimal performance, It is recommended to avoid using OneDrive for your reflex app." ) # No need to reinitialize if the app is already initialized. return False @@ -949,10 +1022,10 @@ def is_latest_template() -> bool: Returns: Whether the app is using the latest template. """ - if not os.path.exists(constants.Reflex.JSON): + json_file = get_web_dir() / constants.Reflex.JSON + if not json_file.exists(): return False - with open(constants.Reflex.JSON) as f: # type: ignore - app_version = json.load(f)["version"] + app_version = json.loads(json_file.read_text()).get("version") return app_version == constants.Reflex.VERSION @@ -965,6 +1038,8 @@ def validate_bun(): # if a custom bun path is provided, make sure its valid # This is specific to non-FHS OS bun_path = get_config().bun_path + if path_ops.use_system_bun(): + bun_path = path_ops.which("bun") if bun_path != constants.Bun.DEFAULT_PATH: console.info(f"Using custom Bun path: {bun_path}") bun_version = get_bun_version() @@ -1022,25 +1097,21 @@ def ensure_reflex_installation_id() -> Optional[int]: """ try: initialize_reflex_user_directory() - installation_id_file = os.path.join(constants.Reflex.DIR, "installation_id") + installation_id_file = environment.REFLEX_DIR / "installation_id" installation_id = None - if os.path.exists(installation_id_file): - try: - with open(installation_id_file, "r") as f: - installation_id = int(f.read()) - except Exception: + if installation_id_file.exists(): + with contextlib.suppress(Exception): + installation_id = int(installation_id_file.read_text()) # If anything goes wrong at all... just regenerate. # Like what? Examples: # - file not exists # - file not readable # - content not parseable as an int - pass if installation_id is None: installation_id = random.getrandbits(128) - with open(installation_id_file, "w") as f: - f.write(str(installation_id)) + installation_id_file.write_text(str(installation_id)) # If we get here, installation_id is definitely set return installation_id except Exception as e: @@ -1051,7 +1122,7 @@ def ensure_reflex_installation_id() -> Optional[int]: def initialize_reflex_user_directory(): """Initialize the reflex user directory.""" # Create the reflex directory. - path_ops.mkdir(constants.Reflex.DIR) + path_ops.mkdir(environment.REFLEX_DIR) def initialize_frontend_dependencies(): @@ -1074,7 +1145,7 @@ def check_db_initialized() -> bool: Returns: True if alembic is initialized (or if database is not used). """ - if get_config().db_url is not None and not Path(constants.ALEMBIC_CONFIG).exists(): + if get_config().db_url is not None and not environment.ALEMBIC_CONFIG.exists(): console.error( "Database is not initialized. Run [bold]reflex db init[/bold] first." ) @@ -1084,7 +1155,7 @@ def check_db_initialized() -> bool: def check_schema_up_to_date(): """Check if the sqlmodel metadata matches the current database schema.""" - if get_config().db_url is None or not Path(constants.ALEMBIC_CONFIG).exists(): + if get_config().db_url is None or not environment.ALEMBIC_CONFIG.exists(): return with model.Model.get_db_engine().connect() as connection: try: @@ -1134,191 +1205,65 @@ def prompt_for_template(templates: list[Template]) -> str: return templates[int(template)].name -def should_show_rx_chakra_migration_instructions() -> bool: - """Should we show the migration instructions for rx.chakra.* => rx.*?. +def fetch_app_templates(version: str) -> dict[str, Template]: + """Fetch a dict of templates from the templates repo using github API. + + Args: + version: The version of the templates to fetch. Returns: - bool: True if we should show the migration instructions. + The dict of templates. """ - if os.getenv("REFLEX_PROMPT_MIGRATE_TO_RX_CHAKRA") == "yes": - return True - if not Path(constants.Config.FILE).exists(): - # They are running reflex init for the first time. - return False - - existing_init_reflex_version = None - reflex_json = Path(constants.Dirs.REFLEX_JSON) - if reflex_json.exists(): - with reflex_json.open("r") as f: - data = json.load(f) - existing_init_reflex_version = data.get("version", None) - - if existing_init_reflex_version is None: - # They clone a reflex app from git for the first time. - # That app may or may not be 0.4 compatible. - # So let's just show these instructions THIS TIME. - return True - - if constants.Reflex.VERSION < "0.4": - return False - else: - return existing_init_reflex_version < "0.4" - - -def show_rx_chakra_migration_instructions(): - """Show the migration instructions for rx.chakra.* => rx.*.""" - console.log( - "Prior to reflex 0.4.0, rx.* components are based on Chakra UI. They are now based on Radix UI. To stick to Chakra UI, use rx.chakra.*." - ) - console.log("") - console.log( - "[bold]Run `reflex script keep-chakra` to automatically update your app." - ) - console.log("") - console.log( - "For more details, please see https://reflex.dev/blog/2024-02-16-reflex-v0.4.0/" - ) - - -def migrate_to_rx_chakra(): - """Migrate rx.button => r.chakra.button, etc.""" - file_pattern = os.path.join(get_config().app_name, "**/*.py") - file_list = glob.glob(file_pattern, recursive=True) - - # Populate with all rx. components that have been moved to rx.chakra. - patterns = { - rf"\brx\.{name}\b": f"rx.chakra.{name}" - for name in _get_rx_chakra_component_to_migrate() - } - - for file_path in file_list: - with FileInput(file_path, inplace=True) as file: - for _line_num, line in enumerate(file): - for old, new in patterns.items(): - line = re.sub(old, new, line) - print(line, end="") - - -def _get_rx_chakra_component_to_migrate() -> set[str]: - from reflex.components.chakra import ChakraComponent - - rx_chakra_names = set(dir(reflex.chakra)) - - names_to_migrate = set() - - # whitelist names will always be rewritten as rx.chakra. - whitelist = { - "ColorModeIcon", - "MultiSelect", - "MultiSelectOption", - "color_mode_icon", - "multi_select", - "multi_select_option", - } - - for rx_chakra_name in sorted(rx_chakra_names): - if rx_chakra_name.startswith("_"): - continue - - rx_chakra_object = getattr(reflex.chakra, rx_chakra_name) - try: - if ( - ( - inspect.ismethod(rx_chakra_object) - and inspect.isclass(rx_chakra_object.__self__) - and issubclass(rx_chakra_object.__self__, ChakraComponent) - ) - or ( - inspect.isclass(rx_chakra_object) - and issubclass(rx_chakra_object, ChakraComponent) - ) - or rx_chakra_name in whitelist - ): - names_to_migrate.add(rx_chakra_name) - - except Exception: - raise - return names_to_migrate - - -def migrate_to_reflex(): - """Migration from Pynecone to Reflex.""" - # Check if the old config file exists. - if not os.path.exists(constants.Config.PREVIOUS_FILE): - return - - # Ask the user if they want to migrate. - action = console.ask( - "Pynecone project detected. Automatically upgrade to Reflex?", - choices=["y", "n"], - ) - if action == "n": - return - - # Rename pcconfig to rxconfig. - console.log( - f"[bold]Renaming {constants.Config.PREVIOUS_FILE} to {constants.Config.FILE}" - ) - os.rename(constants.Config.PREVIOUS_FILE, constants.Config.FILE) - - # Find all python files in the app directory. - file_pattern = os.path.join(get_config().app_name, "**/*.py") - file_list = glob.glob(file_pattern, recursive=True) - - # Add the config file to the list of files to be migrated. - file_list.append(constants.Config.FILE) - - # Migrate all files. - updates = { - "Pynecone": "Reflex", - "pynecone as pc": "reflex as rx", - "pynecone.io": "reflex.dev", - "pynecone": "reflex", - "pc.": "rx.", - "pcconfig": "rxconfig", - } - for file_path in file_list: - with FileInput(file_path, inplace=True) as file: - for line in file: - for old, new in updates.items(): - line = line.replace(old, new) - print(line, end="") - - -def fetch_app_templates() -> dict[str, Template]: - """Fetch the list of app templates from the Reflex backend server. - - Returns: - The name and download URL as a dictionary. - """ - config = get_config() - if not config.cp_backend_url: - console.info( - "Skip fetching App templates. No backend URL is specified in the config." - ) - return {} - try: - response = httpx.get( - f"{config.cp_backend_url}{constants.Templates.APP_TEMPLATES_ROUTE}" - ) + def get_release_by_tag(tag: str) -> dict | None: + response = net.get(constants.Reflex.RELEASES_URL) response.raise_for_status() - return { - template["name"]: Template.parse_obj(template) - for template in response.json() - } - except httpx.HTTPError as ex: - console.info(f"Failed to fetch app templates: {ex}") - return {} - except (TypeError, KeyError, json.JSONDecodeError) as tkje: - console.info(f"Unable to process server response for app templates: {tkje}") + releases = response.json() + for release in releases: + if release["tag_name"] == f"v{tag}": + return release + return None + + release = get_release_by_tag(version) + if release is None: + console.warn(f"No templates known for version {version}") return {} + assets = release.get("assets", []) + asset = next((a for a in assets if a["name"] == "templates.json"), None) + if asset is None: + console.warn(f"Templates metadata not found for version {version}") + return {} + else: + templates_url = asset["browser_download_url"] -def create_config_init_app_from_remote_template( - app_name: str, - template_url: str, -): + templates_data = net.get(templates_url, follow_redirects=True).json()["templates"] + + for template in templates_data: + if template["name"] == "blank": + template["code_url"] = "" + continue + template["code_url"] = next( + ( + a["browser_download_url"] + for a in assets + if a["name"] == f"{template['name']}.zip" + ), + 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): """Create new rxconfig and initialize app using a remote template. Args: @@ -1340,7 +1285,7 @@ def create_config_init_app_from_remote_template( 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: @@ -1388,7 +1333,11 @@ def create_config_init_app_from_remote_template( template_code_dir_name=template_name, template_dir=template_dir, ) - + req_file = Path("requirements.txt") + if req_file.exists() and len(req_file.read_text().splitlines()) > 1: + console.info( + "Run `pip install -r requirements.txt` to install the required python packages for this template." + ) # Clean up the temp directories. shutil.rmtree(temp_dir) shutil.rmtree(unzip_dir) @@ -1408,19 +1357,24 @@ def initialize_app(app_name: str, template: str | None = None): from reflex.utils import telemetry # Check if the app is already initialized. - if os.path.exists(constants.Config.FILE): + if constants.Config.FILE.exists(): telemetry.send("reinit") return - # Get the available templates - templates: dict[str, Template] = fetch_app_templates() + templates: dict[str, Template] = {} - # Prompt for a template if not provided. - if template is None and len(templates) > 0: - template = prompt_for_template(list(templates.values())) - elif template is None: - template = constants.Templates.DEFAULT - assert template is not None + # Don't fetch app templates if the user directly asked for DEFAULT. + if template is None or (template != constants.Templates.DEFAULT): + try: + # Get the available templates + templates = fetch_app_templates(constants.Reflex.VERSION) + if template is None and len(templates) > 0: + template = prompt_for_template(list(templates.values())) + except Exception as e: + console.warn("Failed to fetch templates. Falling back to default template.") + console.debug(f"Error while fetching templates: {e}") + finally: + template = template or constants.Templates.DEFAULT # If the blank template is selected, create a blank app. if template == constants.Templates.DEFAULT: @@ -1443,14 +1397,77 @@ def initialize_app(app_name: str, template: str | None = None): else: console.error(f"Template `{template}` not found.") raise typer.Exit(1) + + if template_url is None: + return + create_config_init_app_from_remote_template( - app_name=app_name, - template_url=template_url, + app_name=app_name, template_url=template_url ) telemetry.send("init", template=template) +def initialize_main_module_index_from_generation(app_name: str, generation_hash: str): + """Overwrite the `index` function in the main module with reflex.build generated code. + + 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. + 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}." + ) + render_func_name = defined_funcs[-1] + + def replace_content(_match): + return "\n".join( + [ + resp.text, + "", + "" "def index() -> rx.Component:", + f" return {render_func_name}()", + "", + "", + ], + ) + + main_module_path = Path(app_name, app_name + constants.Ext.PY) + main_module_code = main_module_path.read_text() + + main_module_code = re.sub( + r"def index\(\).*:\n([^\n]\s+.*\n+)+", + replace_content, + main_module_code, + ) + # Make the app use light mode until flexgen enforces the conversion of + # tailwind colors to radix colors. + main_module_code = re.sub( + r"app\s*=\s*rx\.App\(\s*\)", + 'app = rx.App(theme=rx.theme(color_mode="light"))', + main_module_code, + ) + main_module_path.write_text(main_module_code) + + def format_address_width(address_width) -> int | None: """Cast address width to an int. @@ -1538,3 +1555,15 @@ def is_windows_bun_supported() -> bool: and cpu_info.model_name is not None and "ARM" not in cpu_info.model_name ) + + +def is_generation_hash(template: str) -> bool: + """Check if the template looks like a generation hash. + + Args: + template: The template name. + + Returns: + True if the template is composed of 32 or more hex characters. + """ + return re.match(r"^[0-9a-f]{32,}$", template) is not None diff --git a/reflex/utils/processes.py b/reflex/utils/processes.py index cadd87547..a45676c01 100644 --- a/reflex/utils/processes.py +++ b/reflex/utils/processes.py @@ -4,6 +4,7 @@ from __future__ import annotations import collections import contextlib +import importlib.metadata import os import signal import subprocess @@ -58,8 +59,12 @@ def get_process_on_port(port) -> Optional[psutil.Process]: """ for proc in psutil.process_iter(["pid", "name", "cmdline"]): try: - for conns in proc.connections(kind="inet"): - if conns.laddr.port == int(port): + if importlib.metadata.version("psutil") >= "6.0.0": + conns = proc.net_connections(kind="inet") # type: ignore + else: + conns = proc.connections(kind="inet") + for conn in conns: + if conn.laddr.port == int(port): return proc except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass @@ -109,6 +114,33 @@ def change_port(port: str, _type: str) -> str: return new_port +def handle_port(service_name: str, port: str, default_port: str) -> str: + """Change port if the specified port is in use and is not explicitly specified as a CLI arg or config arg. + otherwise tell the user the port is in use and exit the app. + + We make an assumption that when port is the default port,then it hasnt been explicitly set since its not straightforward + to know whether a port was explicitly provided by the user unless its any other than the default. + + Args: + service_name: The frontend or backend. + port: The provided port. + default_port: The default port number associated with the specified service. + + Returns: + The port to run the service on. + + Raises: + Exit:when the port is in use. + """ + if is_process_on_port(port): + if int(port) == int(default_port): + return change_port(port, service_name) + else: + console.error(f"{service_name.capitalize()} port: {port} is already in use") + raise typer.Exit() + return port + + def new_process(args, run: bool = False, show_logs: bool = False, **kwargs): """Wrapper over subprocess.Popen to unify the launch of child processes. @@ -124,7 +156,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs): Raises: Exit: When attempting to run a command with a None value. """ - node_bin_path = path_ops.get_node_bin_path() + node_bin_path = str(path_ops.get_node_bin_path()) if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE: console.warn( "The path to the Node binary could not be found. Please ensure that Node is properly " @@ -135,7 +167,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs): console.error(f"Invalid command: {args}") raise typer.Exit(1) # Add the node bin path to the PATH environment variable. - env = { + env: dict[str, str] = { **os.environ, "PATH": os.pathsep.join( [node_bin_path if node_bin_path else "", os.environ["PATH"]] @@ -158,7 +190,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs): @contextlib.contextmanager def run_concurrently_context( - *fns: Union[Callable, Tuple] + *fns: Union[Callable, Tuple], ) -> Generator[list[futures.Future], None, None]: """Run functions concurrently in a thread pool. diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py index d14a8af4b..342277cad 100644 --- a/reflex/utils/pyi_generator.py +++ b/reflex/utils/pyi_generator.py @@ -9,32 +9,25 @@ import inspect import logging import re import subprocess -import textwrap import typing +from fileinput import FileInput from inspect import getfullargspec +from itertools import chain from multiprocessing import Pool, cpu_count from pathlib import Path from types import ModuleType, SimpleNamespace -from typing import Any, Callable, Iterable, Type, get_args - -try: - import black - import black.mode -except ImportError: - black = None +from typing import Any, Callable, Iterable, Type, get_args, get_origin 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") -INIT_FILE = Path("reflex/__init__.pyi").resolve() PWD = Path(".").resolve() EXCLUDED_FILES = [ - "__init__.py", - # "app.py", + "app.py", "component.py", "bare.py", "foreach.py", @@ -65,6 +58,7 @@ EXCLUDED_PROPS = [ DEFAULT_TYPING_IMPORTS = { "overload", "Any", + "Callable", "Dict", # "List", "Literal", @@ -72,6 +66,15 @@ DEFAULT_TYPING_IMPORTS = { "Union", } +# TODO: fix import ordering and unused imports with ruff later +DEFAULT_IMPORTS = { + "typing": sorted(DEFAULT_TYPING_IMPORTS), + "reflex.components.core.breakpoints": ["Breakpoints"], + "reflex.event": ["EventChain", "EventHandler", "EventSpec", "EventType"], + "reflex.style": ["Style"], + "reflex.vars.base": ["Var"], +} + def _walk_files(path): """Walk all files in a path. @@ -114,6 +117,9 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: Returns: The resolved type hint as a str. + + Raises: + TypeError: If the value name is not visible in the type hint globals. """ res = "" args = get_args(value) @@ -128,6 +134,7 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: for arg in value.__args__ if arg is not type(None) ] + res_args.sort() if len(res_args) == 1: return f"Optional[{res_args[0]}]" else: @@ -138,11 +145,12 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: _get_type_hint(arg, type_hint_globals, rx_types.is_optional(arg)) for arg in value.__args__ ] + res_args.sort() return f"Union[{', '.join(res_args)}]" 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) @@ -150,9 +158,25 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: if arg is not type(None) ] ) + + if ( + value.__module__ not in ["builtins", "__builtins__"] + and value.__name__ not in type_hint_globals + ): + raise TypeError( + f"{value.__module__ + '.' + value.__name__} is not a default import, " + "add it to DEFAULT_IMPORTS in pyi_generator.py" + ) + res = f"{value.__name__}[{', '.join(inner_container_type_args)}]" if value.__name__ == "Var": + args = list( + chain.from_iterable( + [get_args(arg) if rx_types.is_union(arg) else [arg] for arg in args] + ) + ) + # For Var types, Union with the inner args so they can be passed directly. types = [res] + [ _get_type_hint(arg, type_hint_globals, is_optional=False) @@ -160,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) @@ -190,7 +214,9 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: return res -def _generate_imports(typing_imports: Iterable[str]) -> list[ast.ImportFrom]: +def _generate_imports( + typing_imports: Iterable[str], +) -> list[ast.ImportFrom | ast.Import]: """Generate the import statements for the stub file. Args: @@ -200,22 +226,11 @@ def _generate_imports(typing_imports: Iterable[str]) -> list[ast.ImportFrom]: The list of import statements. """ return [ - ast.ImportFrom( - module="typing", - names=[ast.alias(name=imp) for imp in sorted(typing_imports)], - ), - *ast.parse( # type: ignore - textwrap.dedent( - """ - from reflex.vars import Var, BaseVar, ComputedVar - from reflex.event import EventChain, EventHandler, EventSpec - from reflex.style import Style""" - ) - ).body, - # *[ - # ast.ImportFrom(module=name, names=[ast.alias(name=val) for val in values]) - # for name, values in EXTRA_IMPORTS.items() - # ], + *[ + ast.ImportFrom(module=name, names=[ast.alias(name=val) for val in values]) + for name, values in DEFAULT_IMPORTS.items() + ], + ast.Import([ast.alias("reflex")]), ] @@ -322,6 +337,7 @@ def _extract_class_props_as_ast_nodes( all_props = [] kwargs = [] for target_class in clzs: + event_triggers = target_class().get_event_triggers() # Import from the target class to ensure type hints are resolvable. exec(f"from {target_class.__module__} import *", type_hint_globals) for name, value in target_class.__annotations__.items(): @@ -329,6 +345,7 @@ def _extract_class_props_as_ast_nodes( name in spec.kwonlyargs or name in EXCLUDED_PROPS or name in all_props + or name in event_triggers or (isinstance(value, str) and "ClassVar" in value) ): continue @@ -358,6 +375,64 @@ def _extract_class_props_as_ast_nodes( return kwargs +def type_to_ast(typ, cls: type) -> ast.AST: + """Converts any type annotation into its AST representation. + Handles nested generic types, unions, etc. + + Args: + typ: The type annotation to convert. + cls: The class where the type annotation is used. + + Returns: + The AST representation of the type annotation. + """ + if typ is type(None): + return ast.Name(id="None") + + origin = get_origin(typ) + + # Handle plain types (int, str, custom classes, etc.) + if origin is None: + if hasattr(typ, "__name__"): + if typ.__module__.startswith("reflex."): + typ_parts = typ.__module__.split(".") + cls_parts = cls.__module__.split(".") + + zipped = list(zip(typ_parts, cls_parts, strict=False)) + + if all(a == b for a, b in zipped) and len(typ_parts) == len(cls_parts): + return ast.Name(id=typ.__name__) + + return ast.Name(id=typ.__module__ + "." + typ.__name__) + return ast.Name(id=typ.__name__) + elif hasattr(typ, "_name"): + return ast.Name(id=typ._name) + return ast.Name(id=str(typ)) + + # Get the base type name (List, Dict, Optional, etc.) + base_name = origin._name if hasattr(origin, "_name") else origin.__name__ + + # Get type arguments + args = get_args(typ) + + # Handle empty type arguments + if not args: + return ast.Name(id=base_name) + + # Convert all type arguments recursively + arg_nodes = [type_to_ast(arg, cls) for arg in args] + + # Special case for single-argument types (like List[T] or Optional[T]) + if len(arg_nodes) == 1: + slice_value = arg_nodes[0] + else: + slice_value = ast.Tuple(elts=arg_nodes, ctx=ast.Load()) + + return ast.Subscript( + value=ast.Name(id=base_name), slice=ast.Index(value=slice_value), ctx=ast.Load() + ) + + def _get_parent_imports(func): _imports = {"reflex.vars": ["Var"]} for type_hint in inspect.get_annotations(func).values(): @@ -413,19 +488,103 @@ def _generate_component_create_functiondef( all_props = [arg[0].arg for arg in prop_kwargs] kwargs.extend(prop_kwargs) + def figure_out_return_type(annotation: Any): + if inspect.isclass(annotation) and issubclass(annotation, inspect._empty): + return ast.Name(id="EventType") + + if not isinstance(annotation, str) and get_origin(annotation) is tuple: + arguments = get_args(annotation) + + arguments_without_var = [ + get_args(argument)[0] if get_origin(argument) == Var else argument + for argument in arguments + ] + + # Convert each argument type to its AST representation + type_args = [type_to_ast(arg, cls=clz) for arg in arguments_without_var] + + # Join the type arguments with commas for EventType + args_str = ", ".join(ast.unparse(arg) for arg in type_args) + + # Create EventType using the joined string + event_type = ast.Name(id=f"EventType[{args_str}]") + + return event_type + + if isinstance(annotation, str) and annotation.startswith("Tuple["): + inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]") + + if inside_of_tuple == "()": + return ast.Name(id="EventType[[]]") + + arguments = [""] + + bracket_count = 0 + + for char in inside_of_tuple: + if char == "[": + bracket_count += 1 + elif char == "]": + bracket_count -= 1 + + if char == "," and bracket_count == 0: + arguments.append("") + else: + arguments[-1] += char + + arguments = [argument.strip() for argument in arguments] + + arguments_without_var = [ + argument.removeprefix("Var[").removesuffix("]") + if argument.startswith("Var[") + else argument + for argument in arguments + ] + + return ast.Name(id=f"EventType[{', '.join(arguments_without_var)}]") + return ast.Name(id="EventType") + + event_triggers = clz().get_event_triggers() + # event handler kwargs kwargs.extend( ( ast.arg( arg=trigger, - annotation=ast.Name( - id="Optional[Union[EventHandler, EventSpec, list, function, BaseVar]]" + annotation=ast.Subscript( + ast.Name("Optional"), + ast.Index( # type: ignore + value=ast.Name( + id=ast.unparse( + figure_out_return_type( + inspect.signature(event_specs).return_annotation + ) + if not isinstance( + event_specs := event_triggers[trigger], tuple + ) + else ast.Subscript( + ast.Name("Union"), + ast.Tuple( + [ + figure_out_return_type( + inspect.signature( + event_spec + ).return_annotation + ) + for event_spec in event_specs + ] + ), + ) + ) + ) + ), ), ), ast.Constant(value=None), ) - for trigger in sorted(clz().get_event_triggers().keys()) + for trigger in sorted(event_triggers) ) + logger.debug(f"Generated {clz.__name__}.create method with {len(kwargs)} kwargs") create_args = ast.arguments( args=[ast.arg(arg="cls")], @@ -436,12 +595,17 @@ def _generate_component_create_functiondef( kwarg=ast.arg(arg="props"), defaults=[], ) + definition = ast.FunctionDef( name="create", args=create_args, body=[ ast.Expr( - value=ast.Constant(value=_generate_docstrings(all_classes, all_props)) + value=ast.Constant( + value=_generate_docstrings( + all_classes, [*all_props, *event_triggers] + ) + ), ), ast.Expr( value=ast.Ellipsis(), @@ -488,7 +652,11 @@ def _generate_staticmethod_call_functiondef( kwonlyargs=[], kw_defaults=[], kwarg=ast.arg(arg="props"), - defaults=[], + defaults=( + [ast.Constant(value=default) for default in fullspec.defaults] + if fullspec.defaults + else [] + ), ) definition = ast.FunctionDef( name="__call__", @@ -576,7 +744,7 @@ class StubGenerator(ast.NodeTransformer): # Track the last class node that was visited. self.current_class = None # These imports will be included in the AST of stub files. - self.typing_imports = DEFAULT_TYPING_IMPORTS + self.typing_imports = DEFAULT_TYPING_IMPORTS.copy() # Whether those typing imports have been inserted yet. self.inserted_imports = False # Collected import statements from the module. @@ -644,7 +812,9 @@ class StubGenerator(ast.NodeTransformer): self.import_statements.append(ast.unparse(node)) if not self.inserted_imports: self.inserted_imports = True - return _generate_imports(self.typing_imports) + [node] + default_imports = _generate_imports(self.typing_imports) + self.import_statements.extend(ast.unparse(i) for i in default_imports) + return default_imports + [node] return node def visit_ImportFrom( @@ -775,6 +945,13 @@ class StubGenerator(ast.NodeTransformer): # Remove annotated assignments in Component classes (props) return None + # remove dunder method assignments for lazy_loader.attach + for target in node.targets: + if isinstance(target, ast.Tuple): + for name in target.elts: + if isinstance(name, ast.Name) and name.id.startswith("_"): + return + return node def visit_AnnAssign(self, node: ast.AnnAssign) -> ast.AnnAssign | None: @@ -805,6 +982,23 @@ class StubGenerator(ast.NodeTransformer): return node +class InitStubGenerator(StubGenerator): + """A node transformer that will generate the stubs for a given init file.""" + + def visit_Import( + self, node: ast.Import | ast.ImportFrom + ) -> ast.Import | ast.ImportFrom | list[ast.Import | ast.ImportFrom]: + """Collect import statements from the init module. + + Args: + node: The import node to visit. + + Returns: + The modified import node(s). + """ + return [node] + + class PyiGenerator: """A .pyi file generator that will scan all defined Component in Reflex and generate the approriate stub. @@ -813,36 +1007,67 @@ class PyiGenerator: modules: list = [] root: str = "" current_module: Any = {} + written_files: list[str] = [] def _write_pyi_file(self, module_path: Path, source: str): relpath = str(_relative_to_pwd(module_path)).replace("\\", "/") - pyi_content = [ - f'"""Stub file for {relpath}"""', - "# ------------------- DO NOT EDIT ----------------------", - "# This file was generated by `reflex/utils/pyi_generator.py`!", - "# ------------------------------------------------------", - "", - ] - if black is not None: - for formatted_line in black.format_file_contents( - src_contents=source, - fast=True, - mode=black.mode.Mode(is_pyi=True), - ).splitlines(): - # Bit of a hack here, since the AST cannot represent comments. - if "def create(" in formatted_line or "Figure" in formatted_line: - pyi_content.append(formatted_line + " # type: ignore") - else: - pyi_content.append(formatted_line) - pyi_content.append("") # add empty line at the end for formatting - else: - pyi_content = source.splitlines() + pyi_content = ( + "\n".join( + [ + f'"""Stub file for {relpath}"""', + "# ------------------- DO NOT EDIT ----------------------", + "# This file was generated by `reflex/utils/pyi_generator.py`!", + "# ------------------------------------------------------", + "", + ] + ) + + source + ) pyi_path = module_path.with_suffix(".pyi") - pyi_path.write_text("\n".join(pyi_content)) + pyi_path.write_text(pyi_content) logger.info(f"Wrote {relpath}") - def _scan_file(self, module_path: Path): + def _get_init_lazy_imports(self, mod, new_tree): + # retrieve the _SUBMODULES and _SUBMOD_ATTRS from an init file if present. + sub_mods = getattr(mod, "_SUBMODULES", None) + sub_mod_attrs = getattr(mod, "_SUBMOD_ATTRS", None) + pyright_ignore_imports = getattr(mod, "_PYRIGHT_IGNORE_IMPORTS", []) + + if not sub_mods and not sub_mod_attrs: + return + sub_mods_imports = [] + sub_mod_attrs_imports = [] + + if sub_mods: + sub_mods_imports = [ + f"from . import {mod} as {mod}" for mod in sorted(sub_mods) + ] + sub_mods_imports.append("") + + if sub_mod_attrs: + sub_mod_attrs = { + attr: mod for mod, attrs in sub_mod_attrs.items() for attr in attrs + } + # 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 " # 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("") + + text = "\n" + "\n".join([*sub_mods_imports, *sub_mod_attrs_imports]) + text += ast.unparse(new_tree) + "\n" + return text + + def _scan_file(self, module_path: Path) -> str | None: module_import = ( _relative_to_pwd(module_path) .with_suffix("") @@ -860,21 +1085,34 @@ class PyiGenerator: and obj != Component and inspect.getmodule(obj) == module } - if not class_names: + is_init_file = _relative_to_pwd(module_path).name == "__init__.py" + if not class_names and not is_init_file: return - new_tree = StubGenerator(module, class_names).visit( - ast.parse(inspect.getsource(module)) - ) - self._write_pyi_file(module_path, ast.unparse(new_tree)) + if is_init_file: + new_tree = InitStubGenerator(module, class_names).visit( + ast.parse(inspect.getsource(module)) + ) + init_imports = self._get_init_lazy_imports(module, new_tree) + if not init_imports: + return + self._write_pyi_file(module_path, init_imports) + else: + new_tree = StubGenerator(module, class_names).visit( + ast.parse(inspect.getsource(module)) + ) + self._write_pyi_file(module_path, ast.unparse(new_tree)) + return str(module_path.with_suffix(".pyi").resolve()) def _scan_files_multiprocess(self, files: list[Path]): with Pool(processes=cpu_count()) as pool: - pool.map(self._scan_file, files) + self.written_files.extend(f for f in pool.map(self._scan_file, files) if f) def _scan_files(self, files: list[Path]): for file in files: - self._scan_file(file) + pyi_path = self._scan_file(file) + if pyi_path: + self.written_files.append(pyi_path) def scan_all(self, targets, changed_files: list[Path] | None = None): """Scan all targets for class inheriting Component and generate the .pyi files. @@ -923,15 +1161,23 @@ class PyiGenerator: else: self._scan_files_multiprocess(file_targets) + # Fix generated pyi files with ruff. + subprocess.run(["ruff", "format", *self.written_files]) + subprocess.run(["ruff", "check", "--fix", *self.written_files]) -def generate_init(): - """Generate a pyi file for the main __init__.py.""" - from reflex import _MAPPING # type: ignore + # For some reason, we need to format the __init__.pyi files again after fixing... + init_files = [f for f in self.written_files if "/__init__.pyi" in f] + subprocess.run(["ruff", "format", *init_files]) - imports = [ - f"from {path if mod != path.rsplit('.')[-1] or mod == 'page' else '.'.join(path.rsplit('.')[:-1])} import {mod} as {mod}" - for mod, path in _MAPPING.items() - ] - imports.append("") - with contextlib.suppress(Exception): - INIT_FILE.write_text("\n".join(imports)) + # Post-process the generated pyi files to add hacky type: ignore comments + for file_path in self.written_files: + with FileInput(file_path, inplace=True) as f: + for line in f: + # Hack due to ast not supporting comments in the tree. + if ( + "def create(" in line + or "Var[Figure]" in line + or "Var[Template]" in line + ): + line = line.rstrip() + " # type: ignore\n" + print(line, end="") diff --git a/reflex/utils/redir.py b/reflex/utils/redir.py new file mode 100644 index 000000000..1dbd989e9 --- /dev/null +++ b/reflex/utils/redir.py @@ -0,0 +1,52 @@ +"""Utilities to handle redirection to browser UI.""" + +import time +import uuid +import webbrowser + +import httpx + +from .. import constants +from . import console + + +def open_browser_and_wait( + target_url: str, poll_url: str, interval: int = 2 +) -> httpx.Response: + """Open a browser window to target_url and request poll_url until it returns successfully. + + Args: + target_url: The URL to open in the browser. + poll_url: The URL to poll for success. + interval: The interval in seconds to wait between polling. + + Returns: + The response from the poll_url. + """ + if not webbrowser.open(target_url): + console.warn( + f"Unable to automatically open the browser. Please navigate to {target_url} in your browser." + ) + console.info("[b]Complete the workflow in the browser to continue.[/b]") + while True: + try: + response = httpx.get(poll_url, follow_redirects=True) + if response.is_success: + break + except httpx.RequestError as err: + console.info(f"Will retry after error occurred while polling: {err}.") + time.sleep(interval) + return response + + +def reflex_build_redirect() -> str: + """Open the browser window to reflex.build and wait for the user to select a generation. + + Returns: + The selected generation hash. + """ + token = str(uuid.uuid4()) + target_url = constants.Templates.REFLEX_BUILD_URL.format(reflex_init_token=token) + poll_url = constants.Templates.REFLEX_BUILD_POLL_URL.format(reflex_init_token=token) + response = open_browser_and_wait(target_url, poll_url) + return response.json()["generation_hash"] diff --git a/reflex/utils/registry.py b/reflex/utils/registry.py new file mode 100644 index 000000000..77c3d31cd --- /dev/null +++ b/reflex/utils/registry.py @@ -0,0 +1,58 @@ +"""Utilities for working with registries.""" + +import httpx + +from reflex.config import environment +from reflex.utils import console, net + + +def latency(registry: str) -> int: + """Get the latency of a registry. + + Args: + registry (str): The URL of the registry. + + Returns: + int: The latency of the registry in microseconds. + """ + try: + return net.get(registry).elapsed.microseconds + except httpx.HTTPError: + console.info(f"Failed to connect to {registry}.") + return 10_000_000 + + +def average_latency(registry, attempts: int = 3) -> int: + """Get the average latency of a registry. + + Args: + registry (str): The URL of the registry. + attempts (int): The number of attempts to make. Defaults to 10. + + Returns: + int: The average latency of the registry in microseconds. + """ + return sum(latency(registry) for _ in range(attempts)) // attempts + + +def get_best_registry() -> str: + """Get the best registry based on latency. + + Returns: + str: The best registry. + """ + registries = [ + "https://registry.npmjs.org", + "https://r.cnpmjs.org", + ] + + return min(registries, key=average_latency) + + +def _get_npm_registry() -> str: + """Get npm registry. If environment variable is set, use it first. + + Returns: + str: + """ + return environment.NPM_CONFIG_REGISTRY or get_best_registry() diff --git a/reflex/utils/serializers.py b/reflex/utils/serializers.py index 1e1de7507..614257181 100644 --- a/reflex/utils/serializers.py +++ b/reflex/utils/serializers.py @@ -2,30 +2,52 @@ 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 from pathlib import Path -from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union, get_type_hints +from typing import ( + Any, + Callable, + List, + Literal, + Optional, + Set, + Tuple, + Type, + Union, + get_type_hints, + overload, +) from reflex.base import Base from reflex.constants.colors import Color, format_color -from reflex.utils import exceptions, format, 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] + + SERIALIZERS: dict[Type, Serializer] = {} +SERIALIZER_TYPES: dict[Type, Type] = {} -def serializer(fn: Serializer) -> Serializer: +def serializer( + fn: Serializer | None = None, + to: Type | None = None, +) -> Serializer: """Decorator to add a serializer for a given type. Args: fn: The function to decorate. + to: The type returned by the serializer. If this is `str`, then any Var created from this type will be treated as a string. Returns: The decorated function. @@ -33,8 +55,9 @@ def serializer(fn: Serializer) -> Serializer: Raises: ValueError: If the function does not take a single argument. """ - # Get the global serializers. - global SERIALIZERS + if fn is None: + # If the function is not provided, return a partial that acts as a decorator. + return functools.partial(serializer, to=to) # type: ignore # Check the type hints to get the type of the argument. type_hints = get_type_hints(fn) @@ -54,18 +77,44 @@ def serializer(fn: Serializer) -> Serializer: f"Serializer for type {type_} is already registered as {registered_fn.__qualname__}." ) + # Apply type transformation if requested + if to is not None: + SERIALIZER_TYPES[type_] = to + get_serializer_type.cache_clear() + # Register the serializer. SERIALIZERS[type_] = fn + get_serializer.cache_clear() # Return the function. return fn -def serialize(value: Any) -> SerializedType | None: +@overload +def serialize( + value: Any, get_type: Literal[True] +) -> Tuple[Optional[SerializedType], Optional[types.GenericType]]: ... + + +@overload +def serialize(value: Any, get_type: Literal[False]) -> Optional[SerializedType]: ... + + +@overload +def serialize(value: Any) -> Optional[SerializedType]: ... + + +def serialize( + value: Any, get_type: bool = False +) -> Union[ + Optional[SerializedType], + Tuple[Optional[SerializedType], Optional[types.GenericType]], +]: """Serialize the value to a JSON string. Args: value: The value to serialize. + get_type: Whether to return the type of the serialized value. Returns: The serialized value, or None if a serializer is not found. @@ -75,13 +124,25 @@ def serialize(value: Any) -> SerializedType | None: # If there is no serializer, return None. if serializer is None: + if dataclasses.is_dataclass(value) and not isinstance(value, type): + return {k.name: getattr(value, k.name) for k in dataclasses.fields(value)} + + if get_type: + return None, None return None # Serialize the value. - return serializer(value) + serialized = serializer(value) + + # Return the serialized value and the type. + if get_type: + return serialized, get_serializer_type(type(value)) + else: + return serialized -def get_serializer(type_: Type) -> Serializer | None: +@functools.lru_cache +def get_serializer(type_: Type) -> Optional[Serializer]: """Get the serializer for the type. Args: @@ -90,8 +151,6 @@ def get_serializer(type_: Type) -> Serializer | None: Returns: The serializer for the type, or None if there is no serializer. """ - global SERIALIZERS - # First, check if the type is registered. serializer = SERIALIZERS.get(type_) if serializer is not None: @@ -106,6 +165,30 @@ def get_serializer(type_: Type) -> Serializer | None: return None +@functools.lru_cache +def get_serializer_type(type_: Type) -> Optional[Type]: + """Get the converted type for the type after serializing. + + Args: + type_: The type to get the serializer type for. + + Returns: + The serialized type for the type, or None if there is no type conversion registered. + """ + # First, check if the type is registered. + serializer = SERIALIZER_TYPES.get(type_) + if serializer is not None: + return serializer + + # If the type is not registered, check if it is a subclass of a registered type. + for registered_type, serializer in reversed(SERIALIZER_TYPES.items()): + if types._issubclass(type_, registered_type): + return serializer + + # If there is no serializer, return None. + return None + + def has_serializer(type_: Type) -> bool: """Check if there is a serializer for the type. @@ -118,7 +201,7 @@ def has_serializer(type_: Type) -> bool: return get_serializer(type_) is not None -@serializer +@serializer(to=str) def serialize_type(value: type) -> str: """Serialize a python type. @@ -132,33 +215,7 @@ def serialize_type(value: type) -> str: @serializer -def serialize_str(value: str) -> str: - """Serialize a string. - - Args: - value: The string to serialize. - - Returns: - The serialized string. - """ - return value - - -@serializer -def serialize_primitive(value: Union[bool, int, float, None]) -> str: - """Serialize a primitive type. - - Args: - value: The number/bool/None to serialize. - - Returns: - The serialized number/bool/None. - """ - return format.json_dumps(value) - - -@serializer -def serialize_base(value: Base) -> str: +def serialize_base(value: Base) -> dict: """Serialize a Base instance. Args: @@ -167,61 +224,23 @@ def serialize_base(value: Base) -> str: Returns: The serialized Base. """ - return value.json() + return {k: v for k, v in value.dict().items() if not callable(v)} @serializer -def serialize_list(value: Union[List, Tuple, Set]) -> str: - """Serialize a list to a JSON string. +def serialize_set(value: Set) -> list: + """Serialize a set to a JSON serializable list. Args: - value: The list to serialize. + value: The set to serialize. Returns: The serialized list. """ - # Dump the list to a string. - fprop = format.json_dumps(list(value)) - - # Unwrap var values. - return format.unwrap_vars(fprop) + return list(value) -@serializer -def serialize_dict(prop: Dict[str, Any]) -> str: - """Serialize a dictionary to a JSON string. - - Args: - prop: The dictionary to serialize. - - Returns: - The serialized dictionary. - - Raises: - InvalidStylePropError: If the style prop is invalid. - """ - # Import here to avoid circular imports. - from reflex.event import EventHandler - - 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) - - -@serializer +@serializer(to=str) def serialize_datetime(dt: Union[date, datetime, time, timedelta]) -> str: """Serialize a datetime to a JSON string. @@ -234,8 +253,8 @@ def serialize_datetime(dt: Union[date, datetime, time, timedelta]) -> str: return str(dt) -@serializer -def serialize_path(path: Path): +@serializer(to=str) +def serialize_path(path: Path) -> str: """Serialize a pathlib.Path to a JSON string. Args: @@ -255,12 +274,12 @@ def serialize_enum(en: Enum) -> str: en: The enum to serialize. Returns: - The serialized enum. + The serialized enum. """ return en.value -@serializer +@serializer(to=str) def serialize_color(color: Color) -> str: """Serialize a color. @@ -309,11 +328,11 @@ except ImportError: pass try: - from plotly.graph_objects import Figure + from plotly.graph_objects import Figure, layout from plotly.io import to_json @serializer - def serialize_figure(figure: Figure) -> list: + def serialize_figure(figure: Figure) -> dict: """Serialize a plotly figure. Args: @@ -322,7 +341,22 @@ try: Returns: The serialized figure. """ - return json.loads(str(to_json(figure)))["data"] + return json.loads(str(to_json(figure))) + + @serializer + def serialize_template(template: layout.Template) -> dict: + """Serialize a plotly template. + + Args: + template: The template to serialize. + + Returns: + The serialized template. + """ + return { + "data": json.loads(str(to_json(template.data))), + "layout": json.loads(str(to_json(template.layout))), + } except ImportError: pass diff --git a/reflex/utils/telemetry.py b/reflex/utils/telemetry.py index f7398f01a..9ae165ea2 100644 --- a/reflex/utils/telemetry.py +++ b/reflex/utils/telemetry.py @@ -2,8 +2,11 @@ from __future__ import annotations +import asyncio +import dataclasses import multiprocessing import platform +import warnings try: from datetime import UTC, datetime @@ -91,9 +94,7 @@ def _raise_on_missing_project_hash() -> bool: False when compilation should be skipped (i.e. no .web directory is required). Otherwise return True. """ - if should_skip_compile(): - return False - return True + return not should_skip_compile() def _prepare_event(event: str, **kwargs) -> dict: @@ -118,7 +119,7 @@ def _prepare_event(event: str, **kwargs) -> dict: return {} if UTC is None: - # for python 3.8, 3.9 & 3.10 + # for python 3.9 & 3.10 stamp = datetime.utcnow().isoformat() else: # for python 3.11 & 3.12 @@ -142,7 +143,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, @@ -157,17 +158,7 @@ def _send_event(event_data: dict) -> bool: return False -def send(event: str, telemetry_enabled: bool | None = None, **kwargs) -> bool: - """Send anonymous telemetry for Reflex. - - Args: - event: The event name. - telemetry_enabled: Whether to send the telemetry (If None, get from config). - kwargs: Additional data to send with the event. - - Returns: - Whether the telemetry was sent successfully. - """ +def _send(event, telemetry_enabled, **kwargs): from reflex.config import get_config # Get the telemetry_enabled from the config if it is not specified. @@ -182,3 +173,37 @@ def send(event: str, telemetry_enabled: bool | None = None, **kwargs) -> bool: if not event_data: return False return _send_event(event_data) + + +def send(event: str, telemetry_enabled: bool | None = None, **kwargs): + """Send anonymous telemetry for Reflex. + + Args: + event: The event name. + telemetry_enabled: Whether to send the telemetry (If None, get from config). + kwargs: Additional data to send with the event. + """ + + async def async_send(event, telemetry_enabled, **kwargs): + return _send(event, telemetry_enabled, **kwargs) + + try: + # Within an event loop context, send the event asynchronously. + asyncio.create_task(async_send(event, telemetry_enabled, **kwargs)) + except RuntimeError: + # If there is no event loop, send the event synchronously. + warnings.filterwarnings("ignore", category=RuntimeWarning) + _send(event, telemetry_enabled, **kwargs) + + +def send_error(error: Exception, context: str): + """Send an error event. + + Args: + error: The error to send. + context: The context of the error (e.g. "frontend" or "backend") + + Returns: + Whether the telemetry was sent successfully. + """ + return send("error", detail=type(error).__name__, context=context) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index f75e20dcc..d58825ed5 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -3,29 +3,38 @@ from __future__ import annotations import contextlib +import dataclasses import inspect import sys import types -from functools import wraps +from functools import cached_property, lru_cache, wraps from typing import ( + TYPE_CHECKING, Any, Callable, + ClassVar, Dict, Iterable, List, Literal, Optional, + Sequence, Tuple, Type, Union, _GenericAlias, # type: ignore get_args, - get_origin, get_type_hints, ) +from typing import ( + get_origin as get_origin_og, +) import sqlalchemy +import reflex +from reflex.components.core.breakpoints import Breakpoints + try: from pydantic.v1.fields import ModelField except ModuleNotFoundError: @@ -42,7 +51,23 @@ from sqlalchemy.orm import ( from reflex import constants from reflex.base import Base -from reflex.utils import console, serializers +from reflex.utils import console + +if sys.version_info >= (3, 12): + from typing import override as override +else: + + def override(func: Callable) -> Callable: + """Fallback for @override decorator. + + Args: + func: The function to decorate. + + Returns: + The unmodified function. + """ + return func + # Potential GenericAlias types for isinstance checks. GenericAliasTypes = [_GenericAlias] @@ -73,8 +98,22 @@ PrimitiveType = Union[int, float, bool, str, list, dict, set, tuple] StateVar = Union[PrimitiveType, Base, None] StateIterVar = Union[list, set, tuple] -# ArgsSpec = Callable[[Var], list[Var]] -ArgsSpec = Callable +if TYPE_CHECKING: + from reflex.vars.base import Var + + # ArgsSpec = Callable[[Var], list[Var]] + ArgsSpec = ( + Callable[[], Sequence[Var]] + | Callable[[Var], Sequence[Var]] + | Callable[[Var, Var], Sequence[Var]] + | Callable[[Var, Var, Var], Sequence[Var]] + | Callable[[Var, Var, Var, Var], Sequence[Var]] + | Callable[[Var, Var, Var, Var, Var], Sequence[Var]] + | Callable[[Var, Var, Var, Var, Var, Var], Sequence[Var]] + | Callable[[Var, Var, Var, Var, Var, Var, Var], Sequence[Var]] + ) +else: + ArgsSpec = Callable[..., List[Any]] PrimitiveToAnnotation = { @@ -83,6 +122,17 @@ PrimitiveToAnnotation = { dict: Dict, } +RESERVED_BACKEND_VAR_NAMES = { + "_abc_impl", + "_backend_vars", + "_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. @@ -107,6 +157,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. @@ -119,6 +183,26 @@ def is_generic_alias(cls: GenericType) -> bool: return isinstance(cls, GenericAliasTypes) +def unionize(*args: GenericType) -> 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 is_none(cls: GenericType) -> bool: """Check if a class is None. @@ -131,6 +215,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. @@ -143,6 +228,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. @@ -155,6 +241,27 @@ def is_literal(cls: GenericType) -> bool: return get_origin(cls) is Literal +def has_args(cls) -> bool: + """Check if the class has generic parameters. + + Args: + cls: The class to check. + + Returns: + Whether the class has generic + """ + if get_args(cls): + return True + + # Check if the class inherits from a generic class (using __orig_bases__) + if hasattr(cls, "__orig_bases__"): + for base in cls.__orig_bases__: + if get_args(base): + return True + + return False + + def is_optional(cls: GenericType) -> bool: """Check if a class is an Optional. @@ -167,6 +274,20 @@ def is_optional(cls: GenericType) -> bool: return is_union(cls) and type(None) in get_args(cls) +def value_inside_optional(cls: GenericType) -> GenericType: + """Get the value inside an Optional type or the original type. + + Args: + cls: The class to check. + + Returns: + The value inside the Optional type or the original type. + """ + if is_union(cls) and len(args := get_args(cls)) >= 2 and type(None) in args: + return unionize(*[arg for arg in args if arg is not type(None)]) + return cls + + def get_property_hint(attr: Any | None) -> GenericType | None: """Check if an attribute is a property and return its type hint. @@ -196,10 +317,19 @@ 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__: + + if ( + hasattr(cls, "__fields__") + and name in cls.__fields__ + and hasattr(cls.__fields__[name], "outer_type_") + ): # pydantic models field = cls.__fields__[name] type_ = field.outer_type_ @@ -215,36 +345,41 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None # check for list types column = insp.columns[name] column_type = column.type - type_ = insp.columns[name].type.python_type - if hasattr(column_type, "item_type") and ( - item_type := column_type.item_type.python_type # type: ignore - ): - if type_ in PrimitiveToAnnotation: - type_ = PrimitiveToAnnotation[type_] # type: ignore - type_ = type_[item_type] # type: ignore - if column.nullable: - type_ = Optional[type_] - return type_ - if name not in insp.all_orm_descriptors: - return None - descriptor = insp.all_orm_descriptors[name] - if hint := get_property_hint(descriptor): - return hint - if isinstance(descriptor, QueryableAttribute): - prop = descriptor.property - if not isinstance(prop, Relationship): - return None - type_ = prop.mapper.class_ - # TODO: check for nullable? - type_ = List[type_] if prop.uselist else Optional[type_] - return type_ - if isinstance(attr, AssociationProxyInstance): - return List[ - get_attribute_access_type( - attr.target_class, - attr.remote_attr.key, # type: ignore[attr-defined] - ) - ] + try: + type_ = insp.columns[name].type.python_type + except NotImplementedError: + type_ = None + if type_ is not None: + if hasattr(column_type, "item_type"): + try: + item_type = column_type.item_type.python_type # type: ignore + except NotImplementedError: + item_type = None + if item_type is not None: + if type_ in PrimitiveToAnnotation: + type_ = PrimitiveToAnnotation[type_] # type: ignore + type_ = type_[item_type] # type: ignore + if column.nullable: + type_ = Optional[type_] + return type_ + if name in insp.all_orm_descriptors: + descriptor = insp.all_orm_descriptors[name] + if hint := get_property_hint(descriptor): + return hint + if isinstance(descriptor, QueryableAttribute): + prop = descriptor.property + if isinstance(prop, Relationship): + type_ = prop.mapper.class_ + # TODO: check for nullable? + type_ = List[type_] if prop.uselist else Optional[type_] + return type_ + if isinstance(attr, AssociationProxyInstance): + return List[ + get_attribute_access_type( + attr.target_class, + attr.remote_attr.key, # type: ignore[attr-defined] + ) + ] elif isinstance(cls, type) and not is_generic_alias(cls) and issubclass(cls, Model): # Check in the annotations directly (for sqlmodel.Relationship) hints = get_type_hints(cls) @@ -258,11 +393,9 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None return type_ elif is_union(cls): # Check in each arg of the annotation. - for arg in get_args(cls): - type_ = get_attribute_access_type(arg, name) - if type_ is not None: - # Return the first attribute type that is accessible. - return type_ + return unionize( + *(get_attribute_access_type(arg, name) for arg in get_args(cls)) + ) elif isinstance(cls, type): # Bare class if sys.version_info >= (3, 10): @@ -279,6 +412,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. @@ -294,7 +428,7 @@ def get_base_class(cls: GenericType) -> Type: if is_literal(cls): # only literals of the same type are supported. arg_type = type(get_args(cls)[0]) - if not all(type(arg) == arg_type for arg in get_args(cls)): + if not all(type(arg) is arg_type for arg in get_args(cls)): raise TypeError("only literals of the same type are supported") return type(get_args(cls)[0]) @@ -304,12 +438,44 @@ def get_base_class(cls: GenericType) -> Type: return get_base_class(cls.__origin__) if is_generic_alias(cls) else cls -def _issubclass(cls: GenericType, cls_check: GenericType) -> bool: +def _breakpoints_satisfies_typing(cls_check: GenericType, instance: Any) -> bool: + """Check if the breakpoints instance satisfies the typing. + + Args: + cls_check: The class to check against. + instance: The instance to check. + + Returns: + Whether the breakpoints instance satisfies the typing. + """ + cls_check_base = get_base_class(cls_check) + + if cls_check_base == Breakpoints: + _, expected_type = get_args(cls_check) + if is_literal(expected_type): + for value in instance.values(): + if not isinstance(value, str) or value not in get_args(expected_type): + return False + return True + elif isinstance(cls_check_base, tuple): + # union type, so check all types + return any( + _breakpoints_satisfies_typing(type_to_check, instance) + for type_to_check in get_args(cls_check) + ) + elif cls_check_base == reflex.vars.Var and "__args__" in cls_check.__dict__: + return _breakpoints_satisfies_typing(get_args(cls_check)[0], instance) + + return False + + +def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None) -> bool: """Check if a class is a subclass of another class. Args: cls: The class to check. cls_check: The class to check against. + instance: An instance of cls to aid in checking generics. Returns: Whether the class is a subclass of the other class. @@ -331,6 +497,10 @@ def _issubclass(cls: GenericType, cls_check: GenericType) -> bool: if isinstance(cls_base, tuple): return False + # Check that fields of breakpoints match the expected values. + if isinstance(instance, Breakpoints): + return _breakpoints_satisfies_typing(cls_check, instance) + # Check if the types match. try: return cls_check_base == Any or issubclass(cls_base, cls_check_base) @@ -340,16 +510,66 @@ def _issubclass(cls: GenericType, cls_check: GenericType) -> bool: raise TypeError(f"Invalid type for issubclass: {cls_base}") from te -def _isinstance(obj: Any, cls: GenericType) -> bool: +def _isinstance(obj: Any, cls: GenericType, nested: bool = False) -> bool: """Check if an object is an instance of a class. Args: obj: The object to check. cls: The class to check against. + nested: Whether the check is nested. Returns: Whether the object is an instance of the class. """ + if cls is Any: + return True + + if cls is None or cls is type(None): + return obj is None + + if is_literal(cls): + return obj in get_args(cls) + + if is_union(cls): + return any(_isinstance(obj, arg) for arg in get_args(cls)) + + origin = get_origin(cls) + + if origin is None: + # cls is a simple class + return isinstance(obj, cls) + + args = get_args(cls) + + if not args: + # cls is a simple generic class + return isinstance(obj, origin) + + if nested and args: + if origin is list: + return isinstance(obj, list) and all( + _isinstance(item, args[0]) for item in obj + ) + if origin is tuple: + if args[-1] is Ellipsis: + return isinstance(obj, tuple) and all( + _isinstance(item, args[0]) for item in obj + ) + return ( + isinstance(obj, tuple) + and len(obj) == len(args) + and all(_isinstance(item, arg) for item, arg in zip(obj, args)) + ) + if origin is dict: + return isinstance(obj, dict) and all( + _isinstance(key, args[0]) and _isinstance(value, args[1]) + for key, value in obj.items() + ) + if origin is set: + return isinstance(obj, set) and all( + _isinstance(item, args[0]) for item in obj + ) + return isinstance(obj, get_base_class(cls)) @@ -376,12 +596,18 @@ def is_valid_var_type(type_: Type) -> bool: Returns: Whether the type is a valid prop type. """ + from reflex.utils import serializers + 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_variable(name: str, cls: Type | None = None) -> bool: +def is_backend_base_variable(name: str, cls: Type) -> bool: """Check if this variable name correspond to a backend variable. Args: @@ -391,9 +617,51 @@ def is_backend_variable(name: str, cls: Type | None = None) -> bool: Returns: bool: The result of the check """ - if cls is not None and name.startswith(f"_{cls.__name__}__"): + if name in RESERVED_BACKEND_VAR_NAMES: return False - return name.startswith("_") and not name.startswith("__") + + if not name.startswith("_"): + return False + + if name.startswith("__"): + return False + + if name.startswith(f"_{cls.__name__}__"): + return False + + # Extract the namespace of the original module if defined (dynamic substates). + if callable(getattr(cls, "_get_type_hints", None)): + hints = cls._get_type_hints() + else: + hints = get_type_hints(cls) + if name in hints: + hint = get_origin(hints[name]) + if hint == ClassVar: + return False + + 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) is classmethod: + return False + if callable(value): + return False + + if isinstance( + value, + ( + types.FunctionType, + property, + cached_property, + ), + ) or is_computed_var(value): + return False + + return True def check_type_in_allowed_types(value_type: Type, allowed_types: Iterable) -> bool: @@ -487,7 +755,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.keys(), args): + for param, arg in zip(annotations, args): if annotations[param] is inspect.Parameter.empty: continue validate_literal(param, arg, annotations[param], func.__name__) @@ -506,3 +774,69 @@ def validate_parameter_literals(func): # Store this here for performance. StateBases = get_base_class(StateVar) StateIterBases = get_base_class(StateIterVar) + + +def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> bool: + """Check if a type hint is a subclass of another type hint. + + Args: + possible_subclass: The type hint to check. + possible_superclass: The type hint to check against. + + Returns: + Whether the type hint is a subclass of the other type hint. + """ + if possible_superclass is Any: + return True + if possible_subclass is Any: + return False + + provided_type_origin = get_origin(possible_subclass) + accepted_type_origin = get_origin(possible_superclass) + + if provided_type_origin is None and accepted_type_origin is None: + # In this case, we are dealing with a non-generic type, so we can use issubclass + return issubclass(possible_subclass, possible_superclass) + + # Remove this check when Python 3.10 is the minimum supported version + if hasattr(types, "UnionType"): + provided_type_origin = ( + Union if provided_type_origin is types.UnionType else provided_type_origin + ) + accepted_type_origin = ( + Union if accepted_type_origin is types.UnionType else accepted_type_origin + ) + + # Get type arguments (e.g., [float, int] for Dict[float, int]) + provided_args = get_args(possible_subclass) + accepted_args = get_args(possible_superclass) + + if accepted_type_origin is Union: + if provided_type_origin is not Union: + return any( + typehint_issubclass(possible_subclass, accepted_arg) + for accepted_arg in accepted_args + ) + return all( + any( + typehint_issubclass(provided_arg, accepted_arg) + for accepted_arg in accepted_args + ) + for provided_arg in provided_args + ) + + # Check if the origin of both types is the same (e.g., list for List[int]) + # This probably should be issubclass instead of == + if (provided_type_origin or possible_subclass) != ( + accepted_type_origin or possible_superclass + ): + return False + + # Ensure all specific types are compatible with accepted types + # Note this is not necessarily correct, as it doesn't check against contravariance and covariance + # It also ignores when the length of the arguments is different + return all( + typehint_issubclass(provided_arg, accepted_arg) + for provided_arg, accepted_arg in zip(provided_args, accepted_args) + if accepted_arg is not Any + ) diff --git a/reflex/utils/watch.py b/reflex/utils/watch.py deleted file mode 100644 index a56635d6e..000000000 --- a/reflex/utils/watch.py +++ /dev/null @@ -1,94 +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 - - -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 / Dirs.WEB_ASSETS) - ) diff --git a/reflex/vars.py b/reflex/vars.py deleted file mode 100644 index 6ac78706a..000000000 --- a/reflex/vars.py +++ /dev/null @@ -1,2103 +0,0 @@ -"""Define a state var.""" - -from __future__ import annotations - -import contextlib -import dataclasses -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, format, imports, serializers, types -from reflex.utils.exceptions import VarAttributeError, VarTypeError, VarValueError - -# This module used to export ImportVar itself, so we still import it for export here -from reflex.utils.imports import ImportDict, ImportVar - -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: ImportDict = {} - - # 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]] = [] - - @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 = "" - _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) - interpolations += var_data.interpolations - - 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, - } - - -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) - - -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:] - - # Read the JSON, pull out the string length, parse the rest as VarData. - data = json_loads(m.group(1)) - 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 = False - ) -> 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. - - Returns: - The var. - - Raises: - VarTypeError: If the value is JSON-unserializable. - """ - # 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. - _var_data = None - if not isinstance(value, str): - _var_data = VarData.merge(*_extract_var_data(value)) - - # Try to serialize the value. - type_ = type(value) - name = value if type_ in types.JSONType else serializers.serialize(value) - 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 BaseVar( - _var_name=name, - _var_type=type_, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - _var_data=_var_data, - ) - - @classmethod - def create_safe( - cls, value: Any, _var_is_local: bool = True, _var_is_string: bool = False - ) -> 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. - - Returns: - The var. - """ - var = cls.create( - value, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - ) - 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) -> 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 BaseVar with the updated fields overwriting the corresponding fields in this Var. - """ - 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.get("_var_data", self._var_data), merge_var_data - ), - ) - 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: - 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. - """ - 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) - 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 __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}. - """ - out = ( - self._var_full_name - if self._var_is_local - else 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. - """ - # 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("_"): - # 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_, - _var_is_string=False, - ) - - 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 - """ - if isinstance(other, str): - other = Var.create(json.dumps(other)) - else: - other = Var.create(other) - - 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) -> Var: - """Check if a var contains the object `other`. - - Args: - other: The object to check. - - 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) - 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}" - ) - return self._replace( - _var_name=f"{self._var_name}.includes({other._var_full_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)) 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)) 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('""') - if isinstance(other, str): - other = Var.create_safe(json.dumps(other)) - else: - other = Var.create_safe(other) - - 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") - 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. - """ - 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. - """ - 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 "" - - @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 - - type_ = ( - get_origin(self._var_type) - if types.is_generic_alias(self._var_type) - else self._var_type - ) - wrapped_var = str(self) - - return ( - wrapped_var - if not self._var_state - 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) - - _initial_value: Any | types.Unset = dataclasses.field(default_factory=types.Unset) - - def __init__( - self, - fget: Callable[[BaseState], Any], - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - **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. - **kwargs: additional attributes to set on the instance - """ - self._initial_value = initial_value - self._cache = cache - 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 - - @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}" - - def __get__(self, instance, 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): - setattr(instance, self._cache_attr, super().__get__(instance, owner)) - # Ensure the computed var gets serialized to redis. - instance._was_touched = True - 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). - """ - d = set() - 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, - ) - ) - else: - # normal attribute 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 | None = None, - cache: 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. - **kwargs: additional attributes to set on the instance - - Returns: - A ComputedVar instance. - """ - if fget is not None: - return ComputedVar(fget=fget, cache=cache) - - def wrapper(fget): - return ComputedVar( - fget=fget, - initial_value=initial_value, - cache=cache, - **kwargs, - ) - - return wrapper - - -# Partial function of computed_var with cache=True -cached_var = functools.partial(computed_var, cache=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 UUIDs via .web/utils/state.js. - - Returns: - the var to generate UUIDs at runtime. - """ - from reflex.utils.imports import ImportVar - - unique_uuid_var_data = VarData( - imports={f"/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}} # type: ignore - ) - - return BaseVar( - _var_name="generateUUID()", _var_type=str, _var_data=unique_uuid_var_data - ) diff --git a/reflex/vars.pyi b/reflex/vars.pyi deleted file mode 100644 index fb2ed4657..000000000 --- a/reflex/vars.pyi +++ /dev/null @@ -1,167 +0,0 @@ -""" Generated with stubgen from mypy, then manually edited, do not regen.""" - -from __future__ import annotations - -from dataclasses import dataclass -from _typeshed import Incomplete -from reflex import constants as constants -from reflex.base import Base as Base -from reflex.state import State as State -from reflex.state import BaseState as BaseState -from reflex.utils import console as console, format as format, types as types -from reflex.utils.imports import ImportVar -from types import FunctionType -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Optional, - Set, - Tuple, - Type, - Union, - overload, - _GenericAlias, # type: ignore -) - -USED_VARIABLES: Incomplete - -def get_unique_variable_name() -> str: ... -def _encode_var(value: Var) -> str: ... -def _decode_var(value: str) -> tuple[VarData, str]: ... -def _extract_var_data(value: Iterable) -> list[VarData | None]: ... - -class VarData(Base): - state: str - imports: dict[str, set[ImportVar]] - hooks: Dict[str, None] - interpolations: List[Tuple[int, int]] - @classmethod - def merge(cls, *others: VarData | None) -> VarData | None: ... - -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 = False, _var_is_string: bool = False - ) -> Optional[Var]: ... - @classmethod - def create_safe( - cls, value: Any, _var_is_local: bool = False, _var_is_string: bool = False - ) -> Var: ... - @classmethod - def __class_getitem__(cls, type_: Type) -> _GenericAlias: ... - def _replace(self, merge_var_data=None, **kwargs: Any) -> Var: ... - 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) -> 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: ... - -@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 mark_dirty(self, instance) -> None: ... - 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 | None = None, - **kwargs, -) -> Callable[[Callable[[Any], Any]], ComputedVar]: ... -@overload -def computed_var(fget: Callable[[Any], Any]) -> ComputedVar: ... -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/vars/__init__.py b/reflex/vars/__init__.py new file mode 100644 index 000000000..1a4cebe19 --- /dev/null +++ b/reflex/vars/__init__.py @@ -0,0 +1,25 @@ +"""Immutable-Based Var System.""" + +from .base import Field as Field +from .base import LiteralVar as LiteralVar +from .base import Var as Var +from .base import VarData as VarData +from .base import field as field +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 +from .number import BooleanVar as BooleanVar +from .number import LiteralBooleanVar as LiteralBooleanVar +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 ArrayVar as ArrayVar +from .sequence import ConcatVarOperation as ConcatVarOperation +from .sequence import LiteralArrayVar as LiteralArrayVar +from .sequence import LiteralStringVar as LiteralStringVar +from .sequence import StringVar as StringVar diff --git a/reflex/vars/base.py b/reflex/vars/base.py new file mode 100644 index 000000000..b06e7b7c9 --- /dev/null +++ b/reflex/vars/base.py @@ -0,0 +1,2951 @@ +"""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, + ClassVar, + 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, + _isinstance, + get_origin, + has_args, + unionize, +) + +if TYPE_CHECKING: + from reflex.state import BaseState + + from .function import FunctionVar + from .number import ( + BooleanVar, + NumberVar, + ) + from .object import ObjectVar + from .sequence import ArrayVar, StringVar + + +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 VarSubclassEntry: + """Entry for a Var subclass.""" + + var_subclass: Type[Var] + to_var_subclass: Type[ToOperation] + python_types: Tuple[GenericType, ...] + + +_var_subclasses: List[VarSubclassEntry] = [] +_var_literal_subclasses: List[Tuple[Type[LiteralVar], VarSubclassEntry]] = [] + + +@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) + + def merge(*all: VarData | None) -> VarData | None: + """Merge multiple var data objects. + + Args: + *all: The var data objects to merge. + + Returns: + The merged var data object. + + # noqa: DAR102 *all + """ + all_var_datas = list(filter(None, all)) + + if not all_var_datas: + return None + + if len(all_var_datas) == 1: + return all_var_datas[0] + + # Get the first non-empty field name or default to empty string. + field_name = next( + (var_data.field_name for var_data in all_var_datas if var_data.field_name), + "", + ) + + # Get the first non-empty state or default to empty string. + state = next( + (var_data.state for var_data in all_var_datas if var_data.state), "" + ) + + hooks = {hook: None for var_data in all_var_datas for hook in var_data.hooks} + + _imports = imports.merge_imports( + *(var_data.imports for var_data in all_var_datas) + ) + + 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 + + +@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 __init_subclass__( + cls, python_types: Tuple[GenericType, ...] | GenericType = types.Unset, **kwargs + ): + """Initialize the subclass. + + Args: + python_types: The python types that the var represents. + **kwargs: Additional keyword arguments. + """ + super().__init_subclass__(**kwargs) + + if python_types is not types.Unset: + python_types = ( + python_types if isinstance(python_types, tuple) else (python_types,) + ) + + @dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, + ) + class ToVarOperation(ToOperation, cls): + """Base class of converting a var to another var type.""" + + _original: Var = dataclasses.field( + default=Var(_js_expr="null", _var_type=None), + ) + + _default_var_type: ClassVar[GenericType] = python_types[0] + + ToVarOperation.__name__ = f'To{cls.__name__.removesuffix("Var")}Operation' + + _var_subclasses.append(VarSubclassEntry(cls, ToVarOperation, python_types)) + + 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")) 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]) -> StringVar: ... + + @overload + def to(self, output: Type[str]) -> StringVar: ... + + @overload + def to(self, output: Type[BooleanVar]) -> BooleanVar: ... + + @overload + def to( + self, output: Type[NumberVar], var_type: type[int] | type[float] = float + ) -> NumberVar: ... + + @overload + def to( + self, + output: Type[ArrayVar], + var_type: type[list] | type[tuple] | type[set] = list, + ) -> ArrayVar: ... + + @overload + def to( + self, output: Type[ObjectVar], var_type: types.GenericType = dict + ) -> ObjectVar: ... + + @overload + def to( + self, output: Type[FunctionVar], var_type: Type[Callable] = Callable + ) -> FunctionVar: ... + + @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. + + Returns: + The converted var. + """ + from .object import ObjectVar + + fixed_output_type = get_origin(output) or output + + # If the first argument is a python type, we map it to the corresponding Var type. + for var_subclass in _var_subclasses[::-1]: + if fixed_output_type in var_subclass.python_types: + return self.to(var_subclass.var_subclass, output) + + if fixed_output_type is None: + return get_to_operation(NoneVar).create(self) # type: ignore + + # Handle fixed_output_type being Base or a dataclass. + try: + if issubclass(fixed_output_type, Base): + return self.to(ObjectVar, output) + except TypeError: + pass + if dataclasses.is_dataclass(fixed_output_type) and not issubclass( + fixed_output_type, Var + ): + return self.to(ObjectVar, output) + + if inspect.isclass(output): + for var_subclass in _var_subclasses[::-1]: + if issubclass(output, var_subclass.var_subclass): + to_operation_return = var_subclass.to_var_subclass.create( + value=self, _var_type=var_type + ) + return to_operation_return # type: ignore + + # 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 + + @overload + def guess_type(self: Var[str]) -> StringVar: ... + + @overload + def guess_type(self: Var[bool]) -> BooleanVar: ... + + @overload + def guess_type(self: Var[int] | Var[float] | Var[int | float]) -> NumberVar: ... + + @overload + def guess_type(self) -> 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 NumberVar + from .object import ObjectVar + + 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 in types.UnionTypes: + 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 fixed_type is Literal: + args = get_args(var_type) + fixed_type = unionize(*(type(arg) for arg in args)) + + if not inspect.isclass(fixed_type): + raise TypeError(f"Unsupported type {var_type} for guess_type.") + + if fixed_type is None: + return self.to(None) + + for var_subclass in _var_subclasses[::-1]: + if issubclass(fixed_type, var_subclass.python_types): + return self.to(var_subclass.var_subclass, self._var_type) + + try: + if issubclass(fixed_type, Base): + return self.to(ObjectVar, self._var_type) + except TypeError: + pass + 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, use_json: bool = True) -> StringVar: + """Convert the var to a string. + + Args: + use_json: Whether to use JSON stringify. If False, uses Object.prototype.toString. + + Returns: + The string var. + """ + from .function import JSON_STRINGIFY, PROTOTYPE_TO_STRING + from .sequence import StringVar + + return ( + JSON_STRINGIFY.call(self).to(StringVar) + if use_json + else PROTOTYPE_TO_STRING.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 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. + """ + from .object import ObjectVar + + if isinstance(self, ObjectVar) and name != "_js_expr": + return ObjectVar.__getattr__(self, name) + return getattr(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(self._original) + + def _get_all_var_data(self) -> VarData | None: + """Get all the var data. + + Returns: + The var data. + """ + return VarData.merge( + 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 + ) + + +class LiteralVar(Var): + """Base class for immutable literal vars.""" + + def __init_subclass__(cls, **kwargs): + """Initialize the subclass. + + Args: + **kwargs: Additional keyword arguments. + + Raises: + TypeError: If the LiteralVar subclass does not have a corresponding Var subclass. + """ + super().__init_subclass__(**kwargs) + + bases = cls.__bases__ + + bases_normalized = [ + base if inspect.isclass(base) else get_origin(base) for base in bases + ] + + possible_bases = [ + base + for base in bases_normalized + if issubclass(base, Var) and base != LiteralVar + ] + + if not possible_bases: + raise TypeError( + f"LiteralVar subclass {cls} must have a base class that is a subclass of Var and not LiteralVar." + ) + + var_subclasses = [ + var_subclass + for var_subclass in _var_subclasses + if var_subclass.var_subclass in possible_bases + ] + + if not var_subclasses: + raise TypeError( + f"LiteralVar {cls} must have a base class annotated with `python_types`." + ) + + if len(var_subclasses) != 1: + raise TypeError( + f"LiteralVar {cls} must have exactly one base class annotated with `python_types`." + ) + + var_subclass = var_subclasses[0] + + # Remove the old subclass, happens because __init_subclass__ is called twice + # for each subclass. This is because of __slots__ in dataclasses. + for var_literal_subclass in list(_var_literal_subclasses): + if var_literal_subclass[1] is var_subclass: + _var_literal_subclasses.remove(var_literal_subclass) + + _var_literal_subclasses.append((cls, var_subclass)) + + @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 .object import LiteralObjectVar + from .sequence import LiteralStringVar + + if isinstance(value, Var): + if _var_data is None: + return value + return value._replace(merge_var_data=_var_data) + + for literal_subclass, var_subclass in _var_literal_subclasses[::-1]: + if isinstance(value, var_subclass.python_types): + return literal_subclass.create(value, _var_data=_var_data) + + from reflex.event import EventHandler + from reflex.utils.format import get_event_handler_parts + + 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 value._var_value + + +def get_python_literal(value: Union[LiteralVar, Any]) -> Any | None: + """Get the Python literal value. + + Args: + value: The value to get the Python literal value of. + + Returns: + The Python literal value. + """ + if isinstance(value, LiteralVar): + return value._var_value + if isinstance(value, Var): + return None + return 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]]: ... + + +@overload +def var_operation( + func: Callable[P, CustomVarOperationReturn[T]], +) -> Callable[P, Var[T]]: ... + + +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( + name=func.__name__, + 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 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, Var): + return value._var_type + type_ = type(value) + if has_args(type_): + return type_ + 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())), + ] + 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. + """ + hint = kwargs.pop("return_type", None) or get_type_hints(fget).get( + "return", Any + ) + + if hint is Any: + console.deprecate( + "untyped-computed-var", + "ComputedVar should have a return type annotation.", + "0.6.5", + "0.7.0", + ) + + kwargs.setdefault("_js_expr", fget.__name__) + kwargs.setdefault("_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 kwargs: + raise TypeError(f"Unexpected keyword arguments: {tuple(kwargs)}") + + 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: + value = self.fget(instance) + else: + # 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()) + value = getattr(instance, self._cache_attr) + + if not _isinstance(value, self._var_type): + console.deprecate( + "mismatched-computed-var-return", + f"Computed var {type(instance).__name__}.{self._js_expr} returned value of type {type(value)}, " + f"expected {self._var_type}. This might cause unexpected behavior.", + "0.6.5", + "0.7.0", + ) + + return value + + 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.""" + + _name: str = dataclasses.field(default="") + + _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, + name: str, + args: Tuple[Tuple[str, Var], ...], + return_var: CustomVarOperationReturn[T], + _var_data: VarData | None = None, + ) -> CustomVarOperation[T]: + """Create a CustomVarOperation. + + Args: + name: The name of the operation. + 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, + _name=name, + _args=args, + _return=return_var, + ) + + +class NoneVar(Var[None], python_types=type(None)): + """A var representing None.""" + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralNoneVar(LiteralVar, NoneVar): + """A var representing None.""" + + _var_value: None = None + + def json(self) -> str: + """Serialize the var to a JSON string. + + Returns: + The JSON string. + """ + return "null" + + @classmethod + def create( + cls, + value: None = None, + _var_data: VarData | None = None, + ) -> LiteralNoneVar: + """Create a var from a value. + + Args: + value: The value of the var. Must be None. Existed for compatibility with LiteralVar. + _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, + ) + + +def get_to_operation(var_subclass: Type[Var]) -> Type[ToOperation]: + """Get the ToOperation class for a given Var subclass. + + Args: + var_subclass: The Var subclass. + + Returns: + The ToOperation class. + + Raises: + ValueError: If the ToOperation class cannot be found. + """ + possible_classes = [ + saved_var_subclass.to_var_subclass + for saved_var_subclass in _var_subclasses + if saved_var_subclass.var_subclass is var_subclass + ] + if not possible_classes: + raise ValueError(f"Could not find ToOperation for {var_subclass}.") + return possible_classes[0] + + +@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, + ) + + +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() + + +# 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) + 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() + + +V = TypeVar("V") + + +class Field(Generic[T]): + """Shadow class for Var to allow for type hinting in the IDE.""" + + def __set__(self, instance, value: T): + """Set the Var. + + Args: + instance: The instance of the class setting the Var. + value: The value to set the Var to. + """ + + @overload + def __get__(self: Field[bool], instance: None, owner) -> BooleanVar: ... + + @overload + def __get__(self: Field[int], instance: None, owner) -> NumberVar: ... + + @overload + def __get__(self: Field[str], instance: None, owner) -> StringVar: ... + + @overload + def __get__(self: Field[None], instance: None, owner) -> NoneVar: ... + + @overload + def __get__( + self: Field[List[V]] | Field[Set[V]] | Field[Tuple[V, ...]], + instance: None, + owner, + ) -> ArrayVar[List[V]]: ... + + @overload + def __get__( + self: Field[Dict[str, V]], instance: None, owner + ) -> ObjectVar[Dict[str, V]]: ... + + @overload + def __get__(self, instance: None, owner) -> Var[T]: ... + + @overload + def __get__(self, instance, owner) -> T: ... + + def __get__(self, instance, owner): # type: ignore + """Get the Var. + + Args: + instance: The instance of the class accessing the Var. + owner: The class that the Var is attached to. + """ + + +def field(value: T) -> Field[T]: + """Create a Field with a value. + + Args: + value: The value of the Field. + + Returns: + The Field. + """ + return value # type: ignore diff --git a/reflex/vars/function.py b/reflex/vars/function.py new file mode 100644 index 000000000..9d734a458 --- /dev/null +++ b/reflex/vars/function.py @@ -0,0 +1,186 @@ +"""Immutable function vars.""" + +from __future__ import annotations + +import dataclasses +import sys +from typing import Any, Callable, Optional, Tuple, Type, Union + +from reflex.utils.types import GenericType + +from .base import ( + CachedVarOperation, + LiteralVar, + Var, + VarData, + cached_property_no_lock, +) + + +class FunctionVar(Var[Callable], python_types=Callable): + """Base class for immutable function vars.""" + + def __call__(self, *args: Var | Any) -> ArgsFunctionOperation: + """Call the function with the given arguments. + + Args: + *args: The arguments to call the function with. + + Returns: + The function call operation. + """ + return ArgsFunctionOperation.create( + ("...args",), + VarOperationCall.create(self, *args, Var(_js_expr="...args")), + ) + + def call(self, *args: Var | Any) -> VarOperationCall: + """Call the function with the given arguments. + + Args: + *args: The arguments to call the function with. + + Returns: + The function call operation. + """ + return VarOperationCall.create(self, *args) + + +class FunctionStringVar(FunctionVar): + """Base class for immutable function vars from a string.""" + + @classmethod + def create( + cls, + func: str, + _var_type: Type[Callable] = Callable, + _var_data: VarData | None = None, + ) -> FunctionStringVar: + """Create a new function var from a string. + + Args: + func: The function to call. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The function var. + """ + return cls( + _js_expr=func, + _var_type=_var_type, + _var_data=_var_data, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class VarOperationCall(CachedVarOperation, Var): + """Base class for immutable vars that are the result of a function call.""" + + _func: Optional[FunctionVar] = dataclasses.field(default=None) + _args: Tuple[Union[Var, Any], ...] = 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. + """ + 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) -> VarData | None: + """Get all the var data associated with the var. + + Returns: + All the var data associated with the var. + """ + 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, + ) + + @classmethod + def create( + cls, + func: FunctionVar, + *args: Var | Any, + _var_type: GenericType = Any, + _var_data: VarData | None = None, + ) -> VarOperationCall: + """Create a new function call var. + + Args: + func: The function to call. + *args: The arguments to call the function with. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The function call var. + """ + return cls( + _js_expr="", + _var_type=_var_type, + _var_data=_var_data, + _func=func, + _args=args, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ArgsFunctionOperation(CachedVarOperation, FunctionVar): + """Base class for immutable function defined via arguments and return expression.""" + + _args_names: Tuple[str, ...] = dataclasses.field(default_factory=tuple) + _return_expr: Union[Var, Any] = dataclasses.field(default=None) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return f"(({', '.join(self._args_names)}) => ({str(LiteralVar.create(self._return_expr))}))" + + @classmethod + def create( + cls, + args_names: Tuple[str, ...], + return_expr: Var | Any, + _var_type: GenericType = Callable, + _var_data: VarData | None = None, + ) -> ArgsFunctionOperation: + """Create a new function var. + + Args: + args_names: The names of the arguments. + return_expr: The return expression of the function. + _var_data: Additional hooks and imports associated with the Var. + + Returns: + The function var. + """ + return cls( + _js_expr="", + _var_type=_var_type, + _var_data=_var_data, + _args_names=args_names, + _return_expr=return_expr, + ) + + +JSON_STRINGIFY = FunctionStringVar.create("JSON.stringify") +ARRAY_ISARRAY = FunctionStringVar.create("Array.isArray") +PROTOTYPE_TO_STRING = FunctionStringVar.create( + "((__to_string) => __to_string.toString())" +) diff --git a/reflex/vars/number.py b/reflex/vars/number.py new file mode 100644 index 000000000..e403e63e4 --- /dev/null +++ b/reflex/vars/number.py @@ -0,0 +1,1140 @@ +"""Immutable number vars.""" + +from __future__ import annotations + +import dataclasses +import json +import math +import sys +from typing import ( + TYPE_CHECKING, + Any, + Callable, + 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 reflex.utils.types import is_optional + +from .base import ( + CustomVarOperationReturn, + LiteralVar, + 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], python_types=(int, float)): + """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. + """ + if is_optional(self._var_type): + return boolify((self != None) & (self != 0)) # noqa: E711 + 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], python_types=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 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, + ) + + +@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, + ) + + +number_types = Union[NumberVar, int, float] +boolean_types = Union[BooleanVar, 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), + ) + + +T = TypeVar("T") +U = TypeVar("U") + + +@var_operation +def ternary_operation(condition: BooleanVar, if_true: Var[T], if_false: Var[U]): + """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. + """ + type_value: Union[Type[T], Type[U]] = unionize( + if_true._var_type, if_false._var_type + ) + value: CustomVarOperationReturn[Union[T, U]] = var_operation_return( + js_expression=f"({condition} ? {if_true} : {if_false})", + var_type=type_value, + ) + return value + + +NUMBER_TYPES = (int, float, NumberVar) diff --git a/reflex/vars/object.py b/reflex/vars/object.py new file mode 100644 index 000000000..56f3535d8 --- /dev/null +++ b/reflex/vars/object.py @@ -0,0 +1,536 @@ +"""Classes for immutable object vars.""" + +from __future__ import annotations + +import dataclasses +import sys +import typing +from inspect import isclass +from typing import ( + Any, + Dict, + List, + NoReturn, + Tuple, + Type, + TypeVar, + Union, + get_args, + overload, +) + +from reflex.utils import types +from reflex.utils.exceptions import VarAttributeError +from reflex.utils.types import GenericType, get_attribute_access_type, get_origin + +from .base import ( + CachedVarOperation, + LiteralVar, + Var, + VarData, + cached_property_no_lock, + figure_out_type, + var_operation, + var_operation_return, +) +from .number import BooleanVar, NumberVar, raise_unsupported_operand_types +from .sequence import ArrayVar, StringVar + +OBJECT_TYPE = TypeVar("OBJECT_TYPE", bound=Dict) + +KEY_TYPE = TypeVar("KEY_TYPE") +VALUE_TYPE = TypeVar("VALUE_TYPE") + +ARRAY_INNER_TYPE = TypeVar("ARRAY_INNER_TYPE") + +OTHER_KEY_TYPE = TypeVar("OTHER_KEY_TYPE") + + +class ObjectVar(Var[OBJECT_TYPE], python_types=dict): + """Base class for immutable object vars.""" + + def _key_type(self) -> Type: + """Get the type of the keys of the object. + + Returns: + The type of the keys of the object. + """ + return str + + @overload + def _value_type( + self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], + ) -> Type[VALUE_TYPE]: ... + + @overload + def _value_type(self) -> Type: ... + + def _value_type(self) -> Type: + """Get the type of the values of the object. + + Returns: + The type of the values of the object. + """ + fixed_type = get_origin(self._var_type) or self._var_type + if not isclass(fixed_type): + return Any + args = get_args(self._var_type) if issubclass(fixed_type, dict) else () + return args[1] if args else Any + + def keys(self) -> ArrayVar[List[str]]: + """Get the keys of the object. + + Returns: + The keys of the object. + """ + return object_keys_operation(self) + + @overload + def values( + self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], + ) -> ArrayVar[List[VALUE_TYPE]]: ... + + @overload + def values(self) -> ArrayVar: ... + + def values(self) -> ArrayVar: + """Get the values of the object. + + Returns: + The values of the object. + """ + return object_values_operation(self) + + @overload + def entries( + self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], + ) -> ArrayVar[List[Tuple[str, VALUE_TYPE]]]: ... + + @overload + def entries(self) -> ArrayVar: ... + + def entries(self) -> ArrayVar: + """Get the entries of the object. + + Returns: + The entries of the object. + """ + return object_entries_operation(self) + + items = entries + + def merge(self, other: ObjectVar): + """Merge two objects. + + Args: + other: The other object to merge. + + Returns: + The merged object. + """ + 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, + ) -> Var: ... + + @overload + def __getitem__( + self: ( + ObjectVar[Dict[KEY_TYPE, int]] + | ObjectVar[Dict[KEY_TYPE, float]] + | ObjectVar[Dict[KEY_TYPE, int | float]] + ), + key: Var | Any, + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[KEY_TYPE, str]], + key: Var | Any, + ) -> StringVar: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[KEY_TYPE, list[ARRAY_INNER_TYPE]]], + key: Var | Any, + ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[KEY_TYPE, set[ARRAY_INNER_TYPE]]], + key: Var | Any, + ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[KEY_TYPE, tuple[ARRAY_INNER_TYPE, ...]]], + key: Var | Any, + ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[KEY_TYPE, dict[OTHER_KEY_TYPE, VALUE_TYPE]]], + key: Var | Any, + ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ... + + def __getitem__(self, key: Var | Any) -> Var: + """Get an item from the object. + + Args: + key: The key to get from the object. + + 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 + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, NoReturn]], + name: str, + ) -> Var: ... + + @overload + def __getattr__( + self: ( + ObjectVar[Dict[KEY_TYPE, int]] + | ObjectVar[Dict[KEY_TYPE, float]] + | ObjectVar[Dict[KEY_TYPE, int | float]] + ), + name: str, + ) -> NumberVar: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, str]], + name: str, + ) -> StringVar: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, list[ARRAY_INNER_TYPE]]], + name: str, + ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, set[ARRAY_INNER_TYPE]]], + name: str, + ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, tuple[ARRAY_INNER_TYPE, ...]]], + name: str, + ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[KEY_TYPE, dict[OTHER_KEY_TYPE, VALUE_TYPE]]], + name: str, + ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ... + + def __getattr__(self, name) -> Var: + """Get an attribute of the var. + + Args: + name: The name of the attribute. + + Raises: + VarAttributeError: The State var has no such attribute or may have been annotated wrongly. + + Returns: + The attribute of the var. + """ + if name.startswith("__") and name.endswith("__"): + return getattr(super(type(self), self), name) + + var_type = self._var_type + + if types.is_optional(var_type): + var_type = get_args(var_type)[0] + + fixed_type = var_type if isclass(var_type) else get_origin(var_type) + if (isclass(fixed_type) and not issubclass(fixed_type, dict)) or ( + fixed_type in types.UnionTypes + ): + attribute_type = get_attribute_access_type(var_type, name) + if attribute_type is None: + raise VarAttributeError( + f"The State var `{str(self)}` has no attribute '{name}' or may have been annotated " + f"wrongly." + ) + return ObjectItemOperation.create(self, name, attribute_type).guess_type() + else: + return ObjectItemOperation.create(self, name).guess_type() + + def contains(self, key: Var | Any) -> BooleanVar: + """Check if the object contains a key. + + Args: + key: The key to check. + + Returns: + The result of the check. + """ + return object_has_own_property_operation(self, key) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar): + """Base class for immutable literal object vars.""" + + _var_value: Dict[Union[Var, Any], Union[Var, Any]] = dataclasses.field( + default_factory=dict + ) + + def _key_type(self) -> Type: + """Get the type of the keys of the object. + + Returns: + The type of the keys of the object. + """ + args_list = typing.get_args(self._var_type) + return args_list[0] if args_list else Any + + def _value_type(self) -> Type: + """Get the type of the values of the object. + + Returns: + The type of the values of the object. + """ + args_list = typing.get_args(self._var_type) + return args_list[1] if args_list else Any + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return ( + "({ " + + ", ".join( + [ + f"[{str(LiteralVar.create(key))}] : {str(LiteralVar.create(value))}" + for key, value in self._var_value.items() + ] + ) + + " })" + ) + + def json(self) -> str: + """Get the JSON representation of the object. + + Returns: + The JSON representation of the object. + """ + return ( + "{" + + ", ".join( + [ + f"{LiteralVar.create(key).json()}:{LiteralVar.create(value).json()}" + for key, value in self._var_value.items() + ] + ) + + "}" + ) + + def __hash__(self) -> int: + """Get the hash of the var. + + Returns: + The hash of the var. + """ + return hash((self.__class__.__name__, self._js_expr)) + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get all the var data. + + Returns: + The var data. + """ + return VarData.merge( + *[LiteralVar.create(var)._get_all_var_data() for var in self._var_value], + *[ + LiteralVar.create(var)._get_all_var_data() + for var in self._var_value.values() + ], + self._var_data, + ) + + @classmethod + def create( + cls, + _var_value: OBJECT_TYPE, + _var_type: GenericType | None = None, + _var_data: VarData | None = None, + ) -> LiteralObjectVar[OBJECT_TYPE]: + """Create the literal object var. + + Args: + _var_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 literal object var. + """ + return LiteralObjectVar( + _js_expr="", + _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type), + _var_data=_var_data, + _var_value=_var_value, + ) + + +@var_operation +def object_keys_operation(value: ObjectVar): + """Get the keys of an object. + + 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], + ) + + +@var_operation +def object_values_operation(value: ObjectVar): + """Get the values of an object. + + Args: + value: The object to get the values from. + + Returns: + The values of the object. + """ + return var_operation_return( + js_expression=f"Object.values({value})", + var_type=List[value._value_type()], + ) + + +@var_operation +def object_entries_operation(value: ObjectVar): + """Get the entries of an object. + + Args: + value: The object to get the entries from. + + Returns: + The entries of the object. + """ + return var_operation_return( + js_expression=f"Object.entries({value})", + var_type=List[Tuple[str, value._value_type()]], + ) + + +@var_operation +def object_merge_operation(lhs: ObjectVar, rhs: ObjectVar): + """Merge two objects. + + Args: + lhs: The first object to merge. + rhs: The second object to merge. + + 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( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ObjectItemOperation(CachedVarOperation, Var): + """Operation to get an item from an object.""" + + _object: ObjectVar = dataclasses.field( + default_factory=lambda: LiteralObjectVar.create({}) + ) + _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. + """ + if types.is_optional(self._object._var_type): + return f"{str(self._object)}?.[{str(self._key)}]" + return f"{str(self._object)}[{str(self._key)}]" + + @classmethod + def create( + cls, + object: ObjectVar, + key: Var | Any, + _var_type: GenericType | None = None, + _var_data: VarData | None = None, + ) -> ObjectItemOperation: + """Create the object item operation. + + Args: + object: The object to get the item from. + key: The key to get from the object. + _var_type: The type of the item. + _var_data: Additional hooks and imports associated with the operation. + + Returns: + The object item operation. + """ + return cls( + _js_expr="", + _var_type=object._value_type() if _var_type is None else _var_type, + _var_data=_var_data, + _object=object, + _key=key if isinstance(key, Var) else LiteralVar.create(key), + ) + + +@var_operation +def object_has_own_property_operation(object: ObjectVar, key: Var): + """Check if an object has a key. + + 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, + ) diff --git a/reflex/vars/sequence.py b/reflex/vars/sequence.py new file mode 100644 index 000000000..39139ce3f --- /dev/null +++ b/reflex/vars/sequence.py @@ -0,0 +1,1789 @@ +"""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, + NoReturn, + Set, + Tuple, + Type, + Union, + overload, +) + +from typing_extensions import TypeVar + +from reflex import constants +from reflex.constants.base import REFLEX_VAR_OPENING_TAG +from reflex.constants.colors import Color +from reflex.utils.exceptions import VarTypeError +from reflex.utils.types import GenericType, get_origin + +from .base import ( + CachedVarOperation, + CustomVarOperationReturn, + LiteralVar, + Var, + VarData, + _global_vars, + cached_property_no_lock, + figure_out_type, + get_python_literal, + get_unique_variable_name, + unionize, + var_operation, + var_operation_return, +) +from .number import ( + BooleanVar, + LiteralNumberVar, + NumberVar, + raise_unsupported_operand_types, + ternary_operation, +) + +if TYPE_CHECKING: + from .object import ObjectVar + +STRING_TYPE = TypeVar("STRING_TYPE", default=str) + + +class StringVar(Var[STRING_TYPE], python_types=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 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[Any] | str, rhs: StringVar[Any] | 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[Any] | str, rhs: StringVar[Any] | 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[Any] | str, rhs: StringVar[Any] | 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[Any] | str, rhs: StringVar[Any] | 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[Any]): + """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[Any]): + """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[Any]): + """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[Any], needle: StringVar[Any] | str, field: StringVar[Any] | 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[Any], needle: StringVar[Any] | 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[Any], prefix: StringVar[Any] | 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[Any], 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[Any] | 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) + + +@var_operation +def string_replace_operation( + string: StringVar, search_value: StringVar | str, new_value: StringVar | str +): + """Replace a string with a value. + + Args: + string: The string. + search_value: The string to search. + new_value: The value to be replaced with. + + Returns: + The string replace operation. + """ + return var_operation_return( + js_expression=f"{string}.replace({search_value}, {new_value})", + 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[str]): + """Base class for immutable literal string vars.""" + + _var_value: str = dataclasses.field(default="") + + @classmethod + def create( + cls, + value: str, + _var_type: GenericType | None = None, + _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. + """ + # Determine var type in case the value is inherited from str. + _var_type = _var_type or type(value) or str + + 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) + + if len( + literal_strings := [ + s + for s in filtered_strings_and_vals + if isinstance(s, (str, LiteralStringVar)) + ] + ) == len(filtered_strings_and_vals): + return LiteralStringVar.create( + "".join( + s._var_value if isinstance(s, LiteralStringVar) else s + for s in literal_strings + ), + _var_type=_var_type, + _var_data=VarData.merge( + _var_data, + *( + s._get_all_var_data() + for s in filtered_strings_and_vals + if isinstance(s, Var) + ), + ), + ) + + 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[str]): + """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], python_types=(list, tuple, set)): + """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))) + if ( + isinstance(self, LiteralArrayVar) + and ( + len( + args := [ + x + for x in self._var_value + if isinstance(x, (LiteralStringVar, str)) + ] + ) + == len(self._var_value) + ) + and isinstance(sep, (LiteralStringVar, str)) + ): + sep_str = sep._var_value if isinstance(sep, LiteralStringVar) else sep + return LiteralStringVar.create( + sep_str.join( + i._var_value if isinstance(i, LiteralStringVar) else i for i in args + ) + ) + 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[KEY_TYPE, VALUE_TYPE]], + i: int | NumberVar, + ) -> ArrayVar[Tuple[KEY_TYPE, VALUE_TYPE]]: ... + + @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, int) + + 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,), + Var.create(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[Any], 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, + ) + + +@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], + ) + + +class ColorVar(StringVar[Color], python_types=Color): + """Base class for immutable color vars.""" + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar): + """Base class for immutable literal color vars.""" + + _var_value: Color = dataclasses.field(default_factory=lambda: Color(color="black")) + + @classmethod + def create( + cls, + value: Color, + _var_type: Type[Color] | None = None, + _var_data: VarData | None = None, + ) -> ColorVar: + """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. + """ + return cls( + _js_expr="", + _var_type=_var_type or Color, + _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.color, + self._var_value.alpha, + self._var_value.shade, + ) + ) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + alpha = self._var_value.alpha + alpha = ( + ternary_operation( + alpha, + LiteralStringVar.create("a"), + LiteralStringVar.create(""), + ) + if isinstance(alpha, Var) + else LiteralStringVar.create("a" if alpha else "") + ) + + shade = self._var_value.shade + shade = ( + shade.to_string(use_json=False) + if isinstance(shade, Var) + else LiteralStringVar.create(str(shade)) + ) + return str( + ConcatVarOperation.create( + LiteralStringVar.create("var(--"), + self._var_value.color, + LiteralStringVar.create("-"), + alpha, + shade, + LiteralStringVar.create(")"), + ) + ) + + @cached_property_no_lock + def _cached_get_all_var_data(self) -> VarData | None: + """Get all the var data. + + Returns: + The var data. + """ + return VarData.merge( + *[ + LiteralVar.create(var)._get_all_var_data() + for var in ( + self._var_value.color, + self._var_value.alpha, + self._var_value.shade, + ) + ], + self._var_data, + ) + + def json(self) -> str: + """Get the JSON representation of the var. + + Returns: + The JSON representation of the var. + + Raises: + TypeError: If the color is not a valid color. + """ + color, alpha, shade = map( + get_python_literal, + (self._var_value.color, self._var_value.alpha, self._var_value.shade), + ) + if color is None or alpha is None or shade is None: + raise TypeError("Cannot serialize color that contains non-literal vars.") + if ( + not isinstance(color, str) + or not isinstance(alpha, bool) + or not isinstance(shade, int) + ): + raise TypeError("Color is not a valid color.") + return f"var(--{color}-{'a' if alpha else ''}{shade})" diff --git a/scripts/benchmarks/benchmark_reflex_size.py b/scripts/benchmarks/benchmark_reflex_size.py deleted file mode 100644 index 1bb5e535d..000000000 --- a/scripts/benchmarks/benchmark_reflex_size.py +++ /dev/null @@ -1,206 +0,0 @@ -"""Checks the size of a specific directory and uploads result.""" -import argparse -import os -import subprocess -from datetime import datetime - -import psycopg2 - - -def get_directory_size(directory): - """Get the size of a directory in bytes. - - Args: - directory: The directory to check. - - Returns: - The size of the dir in bytes. - """ - total_size = 0 - for dirpath, _, filenames in os.walk(directory): - for f in filenames: - fp = os.path.join(dirpath, f) - total_size += os.path.getsize(fp) - return total_size - - -def get_python_version(venv_path, os_name): - """Get the python version of python in a virtual env. - - Args: - venv_path: Path to virtual environment. - os_name: Name of os. - - Returns: - The python version. - """ - python_executable = ( - os.path.join(venv_path, "bin", "python") - if "windows" not in os_name - else os.path.join(venv_path, "Scripts", "python.exe") - ) - try: - output = subprocess.check_output( - [python_executable, "--version"], stderr=subprocess.STDOUT - ) - python_version = output.decode("utf-8").strip().split()[1] - return ".".join(python_version.split(".")[:-1]) - except subprocess.CalledProcessError: - return None - - -def get_package_size(venv_path, os_name): - """Get the size of a specified package. - - Args: - venv_path: The path to the venv. - os_name: Name of os. - - Returns: - The total size of the package in bytes. - - Raises: - ValueError: when venv does not exist or python version is None. - """ - python_version = get_python_version(venv_path, os_name) - if python_version is None: - raise ValueError("Error: Failed to determine Python version.") - - is_windows = "windows" in os_name - - full_path = ( - ["lib", f"python{python_version}", "site-packages"] - if not is_windows - else ["Lib", "site-packages"] - ) - - package_dir = os.path.join(venv_path, *full_path) - if not os.path.exists(package_dir): - raise ValueError( - "Error: Virtual environment does not exist or is not activated." - ) - - total_size = get_directory_size(package_dir) - return total_size - - -def insert_benchmarking_data( - db_connection_url: str, - os_type_version: str, - python_version: str, - measurement_type: str, - commit_sha: str, - pr_title: str, - branch_name: str, - pr_id: str, - path: str, -): - """Insert the benchmarking data into the database. - - Args: - db_connection_url: The URL to connect to the database. - os_type_version: The OS type and version to insert. - python_version: The Python version to insert. - measurement_type: The type of metric to measure. - commit_sha: The commit SHA to insert. - pr_title: The PR title to insert. - branch_name: The name of the branch. - pr_id: The id of the PR. - path: The path to the dir or file to check size. - """ - if measurement_type == "reflex-package": - size = get_package_size(path, os_type_version) - else: - size = get_directory_size(path) - - # Get the current timestamp - current_timestamp = datetime.now() - - # Connect to the database and insert the data - with psycopg2.connect(db_connection_url) as conn, conn.cursor() as cursor: - insert_query = """ - INSERT INTO size_benchmarks (os, python_version, commit_sha, created_at, pr_title, branch_name, pr_id, measurement_type, size) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s); - """ - cursor.execute( - insert_query, - ( - os_type_version, - python_version, - commit_sha, - current_timestamp, - pr_title, - branch_name, - pr_id, - measurement_type, - round( - size / (1024 * 1024), 3 - ), # save size in mb and round to 3 places. - ), - ) - # Commit the transaction - conn.commit() - - -def main(): - """Runs the benchmarks and inserts the results.""" - parser = argparse.ArgumentParser(description="Run benchmarks and process results.") - parser.add_argument( - "--os", help="The OS type and version to insert into the database." - ) - parser.add_argument( - "--python-version", help="The Python version to insert into the database." - ) - parser.add_argument( - "--commit-sha", help="The commit SHA to insert into the database." - ) - parser.add_argument( - "--db-url", - help="The URL to connect to the database.", - required=True, - ) - parser.add_argument( - "--pr-title", - help="The PR title to insert into the database.", - ) - parser.add_argument( - "--branch-name", - help="The current branch", - required=True, - ) - parser.add_argument( - "--pr-id", - help="The pr id", - required=True, - ) - parser.add_argument( - "--measurement-type", - help="The type of metric to be checked.", - required=True, - ) - parser.add_argument( - "--path", - help="the current path to check size.", - required=True, - ) - args = parser.parse_args() - - # Get the PR title from env or the args. For the PR merge or push event, there is no PR title, leaving it empty. - pr_title = args.pr_title or os.getenv("PR_TITLE", "") - - # Insert the data into the database - insert_benchmarking_data( - db_connection_url=args.db_url, - os_type_version=args.os, - python_version=args.python_version, - measurement_type=args.measurement_type, - commit_sha=args.commit_sha, - pr_title=pr_title, - branch_name=args.branch_name, - pr_id=args.pr_id, - path=args.path, - ) - - -if __name__ == "__main__": - main() diff --git a/scripts/benchmarks/lighthouse_score_upload.py b/scripts/benchmarks/lighthouse_score_upload.py deleted file mode 100644 index 35f32f5d9..000000000 --- a/scripts/benchmarks/lighthouse_score_upload.py +++ /dev/null @@ -1,109 +0,0 @@ -"""Runs the benchmarks and inserts the results into the database.""" - -from __future__ import annotations - -import json -import os -import sys -from datetime import datetime - -import psycopg2 - - -def insert_benchmarking_data( - db_connection_url: str, - lighthouse_data: dict, - commit_sha: str, - pr_title: str, -): - """Insert the benchmarking data into the database. - - Args: - db_connection_url: The URL to connect to the database. - lighthouse_data: The Lighthouse data to insert. - commit_sha: The commit SHA to insert. - pr_title: The PR title to insert. - """ - # Serialize the JSON data - lighthouse_json = json.dumps(lighthouse_data) - - # Get the current timestamp - current_timestamp = datetime.now() - - # Connect to the database and insert the data - with psycopg2.connect(db_connection_url) as conn, conn.cursor() as cursor: - insert_query = """ - INSERT INTO benchmarks (lighthouse, commit_sha, pr_title, time) - VALUES (%s, %s, %s, %s); - """ - cursor.execute( - insert_query, - ( - lighthouse_json, - commit_sha, - pr_title, - current_timestamp, - ), - ) - # Commit the transaction - conn.commit() - - -def get_lighthouse_scores(directory_path: str) -> dict: - """Extracts the Lighthouse scores from the JSON files in the specified directory. - - Args: - directory_path (str): The path to the directory containing the JSON files. - - Returns: - dict: The Lighthouse scores. - """ - scores = {} - - try: - for filename in os.listdir(directory_path): - if filename.endswith(".json") and filename != "manifest.json": - file_path = os.path.join(directory_path, filename) - with open(file_path, "r") as file: - data = json.load(file) - # Extract scores and add them to the dictionary with the filename as key - scores[data["finalUrl"].replace("http://localhost:3000/", "")] = { - "performance_score": data["categories"]["performance"]["score"], - "accessibility_score": data["categories"]["accessibility"][ - "score" - ], - "best_practices_score": data["categories"]["best-practices"][ - "score" - ], - "seo_score": data["categories"]["seo"]["score"], - "pwa_score": data["categories"]["pwa"]["score"], - } - except Exception as e: - print(e) - return {"error": "Error parsing JSON files"} - - return scores - - -def main(): - """Runs the benchmarks and inserts the results into the database.""" - # Get the commit SHA and JSON directory from the command line arguments - commit_sha = sys.argv[1] - json_dir = sys.argv[2] - - # Get the PR title and database URL from the environment variables - pr_title = os.environ.get("PR_TITLE") - db_url = os.environ.get("DATABASE_URL") - - if db_url is None or pr_title is None: - sys.exit("Missing environment variables") - - # Get the Lighthouse scores - lighthouse_scores = get_lighthouse_scores(json_dir) - - # Insert the data into the database - insert_benchmarking_data(db_url, lighthouse_scores, commit_sha, pr_title) - - -if __name__ == "__main__": - main() diff --git a/scripts/bun_install.sh b/scripts/bun_install.sh new file mode 100644 index 000000000..08a0817f6 --- /dev/null +++ b/scripts/bun_install.sh @@ -0,0 +1,311 @@ +#!/usr/bin/env bash +set -euo pipefail + +platform=$(uname -ms) + +if [[ ${OS:-} = Windows_NT ]]; then + if [[ $platform != MINGW64* ]]; then + powershell -c "irm bun.sh/install.ps1|iex" + exit $? + fi +fi + +# Reset +Color_Off='' + +# Regular Colors +Red='' +Green='' +Dim='' # White + +# Bold +Bold_White='' +Bold_Green='' + +if [[ -t 1 ]]; then + # Reset + Color_Off='\033[0m' # Text Reset + + # Regular Colors + Red='\033[0;31m' # Red + Green='\033[0;32m' # Green + Dim='\033[0;2m' # White + + # Bold + Bold_Green='\033[1;32m' # Bold Green + Bold_White='\033[1m' # Bold White +fi + +error() { + echo -e "${Red}error${Color_Off}:" "$@" >&2 + exit 1 +} + +info() { + echo -e "${Dim}$@ ${Color_Off}" +} + +info_bold() { + echo -e "${Bold_White}$@ ${Color_Off}" +} + +success() { + echo -e "${Green}$@ ${Color_Off}" +} + +command -v unzip >/dev/null || + error 'unzip is required to install bun' + +if [[ $# -gt 2 ]]; then + error 'Too many arguments, only 2 are allowed. The first can be a specific tag of bun to install. (e.g. "bun-v0.1.4") The second can be a build variant of bun to install. (e.g. "debug-info")' +fi + +case $platform in +'Darwin x86_64') + target=darwin-x64 + ;; +'Darwin arm64') + target=darwin-aarch64 + ;; +'Linux aarch64' | 'Linux arm64') + target=linux-aarch64 + ;; +'MINGW64'*) + target=windows-x64 + ;; +'Linux x86_64' | *) + target=linux-x64 + ;; +esac + +if [[ $target = darwin-x64 ]]; then + # Is this process running in Rosetta? + # redirect stderr to devnull to avoid error message when not running in Rosetta + if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then + target=darwin-aarch64 + info "Your shell is running in Rosetta 2. Downloading bun for $target instead" + fi +fi + +GITHUB=${GITHUB-"https://github.com"} + +github_repo="$GITHUB/oven-sh/bun" + +if [[ $target = darwin-x64 ]]; then + # If AVX2 isn't supported, use the -baseline build + if [[ $(sysctl -a | grep machdep.cpu | grep AVX2) == '' ]]; then + target=darwin-x64-baseline + fi +fi + +if [[ $target = linux-x64 ]]; then + # If AVX2 isn't supported, use the -baseline build + if [[ $(cat /proc/cpuinfo | grep avx2) = '' ]]; then + target=linux-x64-baseline + fi +fi + +exe_name=bun + +if [[ $# = 2 && $2 = debug-info ]]; then + target=$target-profile + exe_name=bun-profile + info "You requested a debug build of bun. More information will be shown if a crash occurs." +fi + +if [[ $# = 0 ]]; then + bun_uri=$github_repo/releases/latest/download/bun-$target.zip +else + bun_uri=$github_repo/releases/download/$1/bun-$target.zip +fi + +install_env=BUN_INSTALL +bin_env=\$$install_env/bin + +install_dir=${!install_env:-$HOME/.bun} +bin_dir=$install_dir/bin +exe=$bin_dir/bun + +if [[ ! -d $bin_dir ]]; then + mkdir -p "$bin_dir" || + error "Failed to create install directory \"$bin_dir\"" +fi + +curl --fail --location --progress-bar --output "$exe.zip" "$bun_uri" || + error "Failed to download bun from \"$bun_uri\"" + +unzip -oqd "$bin_dir" "$exe.zip" || + error 'Failed to extract bun' + +mv "$bin_dir/bun-$target/$exe_name" "$exe" || + error 'Failed to move extracted bun to destination' + +chmod +x "$exe" || + error 'Failed to set permissions on bun executable' + +rm -r "$bin_dir/bun-$target" "$exe.zip" + +tildify() { + if [[ $1 = $HOME/* ]]; then + local replacement=\~/ + + echo "${1/$HOME\//$replacement}" + else + echo "$1" + fi +} + +success "bun was installed successfully to $Bold_Green$(tildify "$exe")" + +if command -v bun >/dev/null; then + # Install completions, but we don't care if it fails + IS_BUN_AUTO_UPDATE=true $exe completions &>/dev/null || : + + echo "Run 'bun --help' to get started" + exit +fi + +refresh_command='' + +tilde_bin_dir=$(tildify "$bin_dir") +quoted_install_dir=\"${install_dir//\"/\\\"}\" + +if [[ $quoted_install_dir = \"$HOME/* ]]; then + quoted_install_dir=${quoted_install_dir/$HOME\//\$HOME/} +fi + +echo + +case $(basename "$SHELL") in +fish) + # Install completions, but we don't care if it fails + IS_BUN_AUTO_UPDATE=true SHELL=fish $exe completions &>/dev/null || : + + commands=( + "set --export $install_env $quoted_install_dir" + "set --export PATH $bin_env \$PATH" + ) + + fish_config=$HOME/.config/fish/config.fish + tilde_fish_config=$(tildify "$fish_config") + + if [[ -w $fish_config ]]; then + { + echo -e '\n# bun' + + for command in "${commands[@]}"; do + echo "$command" + done + } >>"$fish_config" + + info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_fish_config\"" + + refresh_command="source $tilde_fish_config" + else + echo "Manually add the directory to $tilde_fish_config (or similar):" + + for command in "${commands[@]}"; do + info_bold " $command" + done + fi + ;; +zsh) + # Install completions, but we don't care if it fails + IS_BUN_AUTO_UPDATE=true SHELL=zsh $exe completions &>/dev/null || : + + commands=( + "export $install_env=$quoted_install_dir" + "export PATH=\"$bin_env:\$PATH\"" + ) + + zsh_config=$HOME/.zshrc + tilde_zsh_config=$(tildify "$zsh_config") + + if [[ -w $zsh_config ]]; then + { + echo -e '\n# bun' + + for command in "${commands[@]}"; do + echo "$command" + done + } >>"$zsh_config" + + info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_zsh_config\"" + + refresh_command="exec $SHELL" + else + echo "Manually add the directory to $tilde_zsh_config (or similar):" + + for command in "${commands[@]}"; do + info_bold " $command" + done + fi + ;; +bash) + # Install completions, but we don't care if it fails + IS_BUN_AUTO_UPDATE=true SHELL=bash $exe completions &>/dev/null || : + + commands=( + "export $install_env=$quoted_install_dir" + "export PATH=\"$bin_env:\$PATH\"" + ) + + bash_configs=( + "$HOME/.bashrc" + "$HOME/.bash_profile" + ) + + if [[ ${XDG_CONFIG_HOME:-} ]]; then + bash_configs+=( + "$XDG_CONFIG_HOME/.bash_profile" + "$XDG_CONFIG_HOME/.bashrc" + "$XDG_CONFIG_HOME/bash_profile" + "$XDG_CONFIG_HOME/bashrc" + ) + fi + + set_manually=true + for bash_config in "${bash_configs[@]}"; do + tilde_bash_config=$(tildify "$bash_config") + + if [[ -w $bash_config ]]; then + { + echo -e '\n# bun' + + for command in "${commands[@]}"; do + echo "$command" + done + } >>"$bash_config" + + info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\"" + + refresh_command="source $bash_config" + set_manually=false + break + fi + done + + if [[ $set_manually = true ]]; then + echo "Manually add the directory to $tilde_bash_config (or similar):" + + for command in "${commands[@]}"; do + info_bold " $command" + done + fi + ;; +*) + echo 'Manually add the directory to ~/.bashrc (or similar):' + info_bold " export $install_env=$quoted_install_dir" + info_bold " export PATH=\"$bin_env:\$PATH\"" + ;; +esac + +echo +info "To get started, run:" +echo + +if [[ $refresh_command ]]; then + info_bold " $refresh_command" +fi + +info_bold " bun --help" diff --git a/scripts/make_pyi.py b/scripts/make_pyi.py index 10a2e1acd..c17200b8a 100644 --- a/scripts/make_pyi.py +++ b/scripts/make_pyi.py @@ -5,13 +5,14 @@ import subprocess import sys from pathlib import Path -from reflex.utils.pyi_generator import PyiGenerator, _relative_to_pwd, generate_init +from reflex.utils.pyi_generator import PyiGenerator, _relative_to_pwd logger = logging.getLogger("pyi_generator") LAST_RUN_COMMIT_SHA_FILE = Path(".pyi_generator_last_run").resolve() GENERATOR_FILE = Path(__file__).resolve() GENERATOR_DIFF_FILE = Path(".pyi_generator_diff").resolve() +DEFAULT_TARGETS = ["reflex/components", "reflex/experimental", "reflex/__init__.py"] def _git_diff(args: list[str]) -> str: @@ -92,8 +93,16 @@ if __name__ == "__main__": targets = ( [arg for arg in sys.argv[1:] if not arg.startswith("tests")] if len(sys.argv) > 1 - else ["reflex/components"] + else DEFAULT_TARGETS ) + + # Only include targets that have a prefix in the default target list + targets = [ + target + for target in targets + if any(str(target).startswith(prefix) for prefix in DEFAULT_TARGETS) + ] + logger.info(f"Running .pyi generator for {targets}") changed_files = _get_changed_files() @@ -104,7 +113,6 @@ if __name__ == "__main__": gen = PyiGenerator() gen.scan_all(targets, changed_files) - generate_init() current_commit_sha = subprocess.run( ["git", "rev-parse", "HEAD"], capture_output=True, encoding="utf-8" diff --git a/scripts/migrate_project_to_rx_chakra.py b/scripts/migrate_project_to_rx_chakra.py deleted file mode 100644 index b13cccafd..000000000 --- a/scripts/migrate_project_to_rx_chakra.py +++ /dev/null @@ -1,13 +0,0 @@ -"""Migrate project to rx.chakra. I.e. switch usage of rx. to rx.chakra..""" - -import argparse - -if __name__ == "__main__": - # parse args just for the help message (-h, etc) - parser = argparse.ArgumentParser( - description="Migrate project to rx.chakra. I.e. switch usage of rx. to rx.chakra.." - ) - args = parser.parse_args() - from reflex.utils.prerequisites import migrate_to_rx_chakra - - migrate_to_rx_chakra() diff --git a/scripts/wait_for_listening_port.py b/scripts/wait_for_listening_port.py index 093b8e7e2..247ff4fba 100644 --- a/scripts/wait_for_listening_port.py +++ b/scripts/wait_for_listening_port.py @@ -3,6 +3,7 @@ Replaces logic previously implemented in a shell script that needed tools that are not available on Windows. """ + import argparse import socket import time diff --git a/tests/__init__.py b/tests/__init__.py index b4d8570e5..d0196603c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,5 @@ """Root directory for tests.""" + import os from reflex import constants diff --git a/tests/components/core/test_colors.py b/tests/components/core/test_colors.py deleted file mode 100644 index 53aa4d86c..000000000 --- a/tests/components/core/test_colors.py +++ /dev/null @@ -1,116 +0,0 @@ -import pytest - -import reflex as rx -from reflex.components.datadisplay.code import CodeBlock -from reflex.vars import Var - - -class ColorState(rx.State): - """Test color state.""" - - color: str = "mint" - color_part: str = "tom" - shade: int = 4 - - -def create_color_var(color): - return Var.create(color) - - -@pytest.mark.parametrize( - "color, expected", - [ - (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(ColorState.color, ColorState.shade)), # type: ignore - "var(--${state__color_state.color}-${state__color_state.shade})", - ), - ( - create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore - "var(--${state__color_state.color}-${state__color_state.shade})", - ), - ( - create_color_var( - rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore - ), - "var(--${state__color_state.color_part}ato-${state__color_state.shade})", - ), - ( - create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore - "var(--${state__color_state.color}-${state__color_state.shade})", - ), - ( - create_color_var( - f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore - ), - "var(--${state__color_state.color}-${state__color_state.shade})", - ), - ], -) -def test_color(color, expected): - assert str(color) == expected - - -@pytest.mark.parametrize( - "cond_var, expected", - [ - ( - rx.cond(True, rx.color("mint"), rx.color("tomato", 5)), - "{isTrue(true) ? `var(--mint-7)` : `var(--tomato-5)`}", - ), - ( - rx.cond(True, rx.color(ColorState.color), rx.color(ColorState.color, 5)), # type: ignore - "{isTrue(true) ? `var(--${state__color_state.color}-7)` : `var(--${state__color_state.color}-5)`}", - ), - ( - rx.match( - "condition", - ("first", rx.color("mint")), - ("second", rx.color("tomato", 5)), - rx.color(ColorState.color, 2), # type: ignore - ), - "{(() => { switch (JSON.stringify(`condition`)) {case JSON.stringify(`first`): return (`var(--mint-7)`);" - " break;case JSON.stringify(`second`): return (`var(--tomato-5)`); break;default: " - "return (`var(--${state__color_state.color}-2)`); break;};})()}", - ), - ( - rx.match( - "condition", - ("first", rx.color(ColorState.color)), # type: ignore - ("second", rx.color(ColorState.color, 5)), # type: ignore - rx.color(ColorState.color, 2), # type: ignore - ), - "{(() => { switch (JSON.stringify(`condition`)) {case JSON.stringify(`first`): " - "return (`var(--${state__color_state.color}-7)`); break;case JSON.stringify(`second`): " - "return (`var(--${state__color_state.color}-5)`); break;default: " - "return (`var(--${state__color_state.color}-2)`); break;};})()}", - ), - ], -) -def test_color_with_conditionals(cond_var, expected): - assert str(cond_var) == expected - - -@pytest.mark.parametrize( - "color, expected", - [ - (create_color_var(rx.color("red")), "var(--red-7)"), - (create_color_var(rx.color("green", shade=1)), "var(--green-1)"), - (create_color_var(rx.color("blue", alpha=True)), "var(--blue-a7)"), - ("red", "red"), - ("green", "green"), - ("blue", "blue"), - ], -) -def test_radix_color(color, expected): - """Test that custom_style can accept both string - literals and rx.color inputs. - - Args: - color (Color): A Color made with rx.color - expected (str): The expected custom_style string, radix or literal - """ - code_block = CodeBlock.create("Hello World", background_color=color) - assert code_block.custom_style["backgroundColor"].__format__("") == expected # type: ignore diff --git a/tests/components/core/test_html.py b/tests/components/core/test_html.py deleted file mode 100644 index 325bdcaf9..000000000 --- a/tests/components/core/test_html.py +++ /dev/null @@ -1,22 +0,0 @@ -import pytest - -from reflex.components.core.html import Html - - -def test_html_no_children(): - with pytest.raises(ValueError): - _ = Html.create() - - -def test_html_many_children(): - with pytest.raises(ValueError): - _ = Html.create("foo", "bar") - - -def test_html_create(): - html = Html.create("

Hello !

") - assert str(html.dangerouslySetInnerHTML) == '{"__html": "

Hello !

"}' # type: ignore - assert ( - str(html) - == '
Hello !

"}}/>' - ) diff --git a/tests/components/datadisplay/test_table.py b/tests/components/datadisplay/test_table.py deleted file mode 100644 index 1cec624e9..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.components.chakra.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_uploads.py b/tests/components/forms/test_uploads.py deleted file mode 100644 index 930d669ef..000000000 --- a/tests/components/forms/test_uploads.py +++ /dev/null @@ -1,161 +0,0 @@ -import pytest - -import reflex as rx - - -@pytest.fixture -def upload_root_component(): - """A test upload component function. - - Returns: - A test upload component function. - """ - - def upload_root_component(): - return rx.upload.root( - rx.button("select file"), - rx.text("Drag and drop files here or click to select files"), - border="1px dotted black", - ) - - return upload_root_component() - - -@pytest.fixture -def upload_component(): - """A test upload component function. - - Returns: - A test upload component function. - """ - - def upload_component(): - return rx.upload( - rx.button("select file"), - rx.text("Drag and drop files here or click to select files"), - border="1px dotted black", - ) - - return upload_component() - - -@pytest.fixture -def upload_component_with_props(): - """A test upload component with props function. - - Returns: - A test upload component with props function. - """ - - def upload_component_with_props(): - return rx.upload( - rx.button("select file"), - rx.text("Drag and drop files here or click to select files"), - border="1px dotted black", - no_drag=True, - max_files=2, - ) - - return upload_component_with_props() - - -def test_upload_root_component_render(upload_root_component): - """Test that the render function is set correctly. - - Args: - upload_root_component: component fixture - """ - upload = upload_root_component.render() - - # upload - assert upload["name"] == "ReactDropzone" - assert upload["props"] == [ - "id={`default`}", - "multiple={true}", - "onDrop={e => setFilesById(filesById => ({...filesById, default: e}))}", - "ref={ref_default}", - ] - assert upload["args"] == ("getRootProps", "getInputProps") - - # box inside of upload - [box] = upload["children"] - assert box["name"] == "Box" - assert box["props"] == [ - "className={`rx-Upload`}", - 'sx={{"border": "1px dotted black"}}', - "{...getRootProps()}", - ] - - # input, button and text inside of box - [input, button, text] = box["children"] - assert input["name"] == "Input" - assert input["props"] == ["type={`file`}", "{...getInputProps()}"] - - assert button["name"] == "RadixThemesButton" - assert button["children"][0]["contents"] == "{`select file`}" - - assert text["name"] == "RadixThemesText" - assert ( - text["children"][0]["contents"] - == "{`Drag and drop files here or click to select files`}" - ) - - -def test_upload_component_render(upload_component): - """Test that the render function is set correctly. - - Args: - upload_component: component fixture - """ - upload = upload_component.render() - - # upload - assert upload["name"] == "ReactDropzone" - assert upload["props"] == [ - "id={`default`}", - "multiple={true}", - "onDrop={e => setFilesById(filesById => ({...filesById, default: e}))}", - "ref={ref_default}", - ] - assert upload["args"] == ("getRootProps", "getInputProps") - - # box inside of upload - [box] = upload["children"] - assert box["name"] == "Box" - assert box["props"] == [ - "className={`rx-Upload`}", - 'sx={{"border": "1px dotted black", "padding": "5em", "textAlign": "center"}}', - "{...getRootProps()}", - ] - - # input, button and text inside of box - [input, button, text] = box["children"] - assert input["name"] == "Input" - assert input["props"] == ["type={`file`}", "{...getInputProps()}"] - - assert button["name"] == "RadixThemesButton" - assert button["children"][0]["contents"] == "{`select file`}" - - assert text["name"] == "RadixThemesText" - assert ( - text["children"][0]["contents"] - == "{`Drag and drop files here or click to select files`}" - ) - - -def test_upload_component_with_props_render(upload_component_with_props): - """Test that the render function is set correctly. - - Args: - upload_component_with_props: component fixture - """ - upload = upload_component_with_props.render() - - assert upload["props"] == [ - "id={`default`}", - "maxFiles={2}", - "multiple={true}", - "noDrag={true}", - "onDrop={e => setFilesById(filesById => ({...filesById, default: e}))}", - "ref={ref_default}", - ] diff --git a/tests/components/media/test_icon.py b/tests/components/media/test_icon.py deleted file mode 100644 index 95dc8de28..000000000 --- a/tests/components/media/test_icon.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest - -from reflex.components.chakra.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/integration/__init__.py b/tests/integration/__init__.py similarity index 100% rename from integration/__init__.py rename to tests/integration/__init__.py diff --git a/integration/conftest.py b/tests/integration/conftest.py similarity index 100% rename from integration/conftest.py rename to tests/integration/conftest.py diff --git a/integration/init-test/Dockerfile b/tests/integration/init-test/Dockerfile similarity index 91% rename from integration/init-test/Dockerfile rename to tests/integration/init-test/Dockerfile index aa11344b1..f30466e7f 100644 --- a/integration/init-test/Dockerfile +++ b/tests/integration/init-test/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8 +FROM python:3.9 ARG USERNAME=kerrigan RUN useradd -m $USERNAME diff --git a/integration/init-test/in_docker_test_script.sh b/tests/integration/init-test/in_docker_test_script.sh similarity index 96% rename from integration/init-test/in_docker_test_script.sh rename to tests/integration/init-test/in_docker_test_script.sh index 4e898ac99..31d245588 100755 --- a/integration/init-test/in_docker_test_script.sh +++ b/tests/integration/init-test/in_docker_test_script.sh @@ -13,7 +13,7 @@ function do_export () { reflex init --template "$template" reflex export ( - cd "$SCRIPTPATH/../.." + cd "$SCRIPTPATH/../../.." scripts/integration.sh ~/"$template" dev pkill -9 -f 'next-server|python3' || true sleep 10 diff --git a/integration/shared/state.py b/tests/integration/shared/state.py similarity index 99% rename from integration/shared/state.py rename to tests/integration/shared/state.py index e3aaf62d3..be6aa1f2a 100644 --- a/integration/shared/state.py +++ b/tests/integration/shared/state.py @@ -1,4 +1,5 @@ """Simple module which contains one reusable reflex state class.""" + import reflex as rx diff --git a/integration/test_background_task.py b/tests/integration/test_background_task.py similarity index 51% rename from integration/test_background_task.py rename to tests/integration/test_background_task.py index 5edf810f4..87aa1459b 100644 --- a/integration/test_background_task.py +++ b/tests/integration/test_background_task.py @@ -1,4 +1,4 @@ -"""Test @rx.background task functionality.""" +"""Test @rx.event(background=True) task functionality.""" from typing import Generator @@ -12,14 +12,17 @@ def BackgroundTask(): """Test that background tasks work as expected.""" import asyncio + import pytest + import reflex as rx + from reflex.state import ImmutableStateError class State(rx.State): counter: int = 0 _task_id: int = 0 iterations: int = 10 - @rx.background + @rx.event(background=True) async def handle_event(self): async with self: self._task_id += 1 @@ -28,7 +31,7 @@ def BackgroundTask(): self.counter += 1 await asyncio.sleep(0.005) - @rx.background + @rx.event(background=True) async def handle_event_yield_only(self): async with self: self._task_id += 1 @@ -39,31 +42,87 @@ def BackgroundTask(): yield State.increment() # type: ignore await asyncio.sleep(0.005) + @rx.event def increment(self): self.counter += 1 - @rx.background + @rx.event(background=True) async def increment_arbitrary(self, amount: int): async with self: self.counter += int(amount) + @rx.event def reset_counter(self): self.counter = 0 + @rx.event async def blocking_pause(self): await asyncio.sleep(0.02) - @rx.background + @rx.event(background=True) async def non_blocking_pause(self): await asyncio.sleep(0.02) + async def racy_task(self): + async with self: + self._task_id += 1 + for _ix in range(int(self.iterations)): + async with self: + self.counter += 1 + await asyncio.sleep(0.005) + + @rx.event(background=True) + async def handle_racy_event(self): + await asyncio.gather( + self.racy_task(), self.racy_task(), self.racy_task(), self.racy_task() + ) + + @rx.event(background=True) + async def nested_async_with_self(self): + async with self: + self.counter += 1 + with pytest.raises(ImmutableStateError): + async with self: + self.counter += 1 + + async def triple_count(self): + third_state = await self.get_state(ThirdState) + await third_state._triple_count() + + @rx.event(background=True) + async def yield_in_async_with_self(self): + async with self: + self.counter += 1 + yield + self.counter += 1 + + class OtherState(rx.State): + @rx.event(background=True) + async def get_other_state(self): + async with self: + state = await self.get_state(State) + state.counter += 1 + await state.triple_count() + with pytest.raises(ImmutableStateError): + await state.triple_count() + with pytest.raises(ImmutableStateError): + state.counter += 1 + async with state: + state.counter += 1 + await state.triple_count() + + class ThirdState(rx.State): + async def _triple_count(self): + state = await self.get_state(State) + state.counter *= 3 + def index() -> rx.Component: return rx.vstack( - rx.chakra.input( + rx.input( id="token", value=State.router.session.client_token, is_read_only=True ), rx.heading(State.counter, id="counter"), - rx.chakra.input( + rx.input( id="iterations", placeholder="Iterations", value=State.iterations.to_string(), # type: ignore @@ -90,6 +149,26 @@ def BackgroundTask(): on_click=State.non_blocking_pause, id="non-blocking-pause", ), + rx.button( + "Racy Increment (x4)", + on_click=State.handle_racy_event, + id="racy-increment", + ), + rx.button( + "Nested Async with Self", + on_click=State.nested_async_with_self, + id="nested-async-with-self", + ), + rx.button( + "Increment from OtherState", + 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"), ) @@ -176,6 +255,7 @@ def test_background_task( increment_button = driver.find_element(By.ID, "increment") blocking_pause_button = driver.find_element(By.ID, "blocking-pause") non_blocking_pause_button = driver.find_element(By.ID, "non-blocking-pause") + racy_increment_button = driver.find_element(By.ID, "racy-increment") driver.find_element(By.ID, "reset") # get a reference to the counter @@ -196,6 +276,7 @@ def test_background_task( delayed_increment_button.click() delayed_increment_button.click() yield_increment_button.click() + racy_increment_button.click() non_blocking_pause_button.click() yield_increment_button.click() blocking_pause_button.click() @@ -204,8 +285,93 @@ def test_background_task( increment_button.click() yield_increment_button.click() blocking_pause_button.click() - assert background_task._poll_for(lambda: counter.text == "420", timeout=40) + assert background_task._poll_for(lambda: counter.text == "620", timeout=40) # all tasks should have exited and cleaned up assert background_task._poll_for( lambda: not background_task.app_instance.background_tasks # type: ignore ) + + +def test_nested_async_with_self( + background_task: AppHarness, + driver: WebDriver, + token: str, +): + """Test that nested async with self in the same coroutine raises Exception. + + 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 + nested_async_with_self_button = driver.find_element(By.ID, "nested-async-with-self") + increment_button = driver.find_element(By.ID, "increment") + + # get a reference to the counter + counter = driver.find_element(By.ID, "counter") + assert background_task._poll_for(lambda: counter.text == "0", timeout=5) + + nested_async_with_self_button.click() + assert background_task._poll_for(lambda: counter.text == "1", timeout=5) + + increment_button.click() + assert background_task._poll_for(lambda: counter.text == "2", timeout=5) + + +def test_get_state( + background_task: AppHarness, + driver: WebDriver, + token: str, +): + """Test that get_state returns a state bound to the correct StateProxy. + + 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 + other_state_button = driver.find_element(By.ID, "increment-from-other-state") + increment_button = driver.find_element(By.ID, "increment") + + # get a reference to the counter + counter = driver.find_element(By.ID, "counter") + assert background_task._poll_for(lambda: counter.text == "0", timeout=5) + + other_state_button.click() + assert background_task._poll_for(lambda: counter.text == "12", timeout=5) + + 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_call_script.py b/tests/integration/test_call_script.py similarity index 60% rename from integration/test_call_script.py rename to tests/integration/test_call_script.py index 18e66cff5..a949dc451 100644 --- a/integration/test_call_script.py +++ b/tests/integration/test_call_script.py @@ -1,4 +1,5 @@ """Integration tests for client side storage.""" + from __future__ import annotations from typing import Generator @@ -9,6 +10,8 @@ from selenium.webdriver.remote.webdriver import WebDriver from reflex.testing import AppHarness +from .utils import SessionStorage + def CallScript(): """A test app for browser javascript integration.""" @@ -42,6 +45,8 @@ def CallScript(): results: List[Optional[Union[str, Dict, List]]] = [] inline_counter: int = 0 external_counter: int = 0 + value: str = "Initial" + last_result: str = "" def call_script_callback(self, result): self.results.append(result) @@ -49,15 +54,18 @@ def CallScript(): def call_script_callback_other_arg(self, result, other_arg): self.results.append([other_arg, result]) + @rx.event def call_scripts_inline_yield(self): yield rx.call_script("inline1()") yield rx.call_script("inline2()") yield rx.call_script("inline3()") yield rx.call_script("inline4()") + @rx.event def call_script_inline_return(self): return rx.call_script("inline2()") + @rx.event def call_scripts_inline_yield_callback(self): yield rx.call_script( "inline1()", callback=CallScriptState.call_script_callback @@ -72,11 +80,13 @@ def CallScript(): "inline4()", callback=CallScriptState.call_script_callback ) + @rx.event def call_script_inline_return_callback(self): return rx.call_script( "inline3()", callback=CallScriptState.call_script_callback ) + @rx.event def call_script_inline_return_lambda(self): return rx.call_script( "inline2()", @@ -85,21 +95,25 @@ def CallScript(): ), ) + @rx.event def get_inline_counter(self): return rx.call_script( "inline_counter", callback=CallScriptState.set_inline_counter, # type: ignore ) + @rx.event def call_scripts_external_yield(self): yield rx.call_script("external1()") yield rx.call_script("external2()") yield rx.call_script("external3()") yield rx.call_script("external4()") + @rx.event def call_script_external_return(self): return rx.call_script("external2()") + @rx.event def call_scripts_external_yield_callback(self): yield rx.call_script( "external1()", callback=CallScriptState.call_script_callback @@ -114,11 +128,13 @@ def CallScript(): "external4()", callback=CallScriptState.call_script_callback ) + @rx.event def call_script_external_return_callback(self): return rx.call_script( "external3()", callback=CallScriptState.call_script_callback ) + @rx.event def call_script_external_return_lambda(self): return rx.call_script( "external2()", @@ -127,12 +143,44 @@ def CallScript(): ), ) + @rx.event def get_external_counter(self): return rx.call_script( "external_counter", callback=CallScriptState.set_external_counter, # type: ignore ) + @rx.event + def call_with_var_f_string(self): + return rx.call_script( + f"{rx.Var('inline_counter')} + {rx.Var('external_counter')}", + callback=CallScriptState.set_last_result, # type: ignore + ) + + @rx.event + def call_with_var_str_cast(self): + return rx.call_script( + f"{str(rx.Var('inline_counter'))} + {str(rx.Var('external_counter'))}", + callback=CallScriptState.set_last_result, # type: ignore + ) + + @rx.event + def call_with_var_f_string_wrapped(self): + return rx.call_script( + rx.Var(f"{rx.Var('inline_counter')} + {rx.Var('external_counter')}"), + callback=CallScriptState.set_last_result, # type: ignore + ) + + @rx.event + def call_with_var_str_cast_wrapped(self): + return rx.call_script( + rx.Var( + f"{str(rx.Var('inline_counter'))} + {str(rx.Var('external_counter'))}" + ), + callback=CallScriptState.set_last_result, # type: ignore + ) + + @rx.event def reset_(self): yield rx.call_script("inline_counter = 0; external_counter = 0") self.reset() @@ -144,25 +192,20 @@ def CallScript(): @app.add_page def index(): return rx.vstack( - rx.chakra.input( - value=CallScriptState.router.session.client_token, - is_read_only=True, - id="token", - ), - rx.chakra.input( + rx.input( value=CallScriptState.inline_counter.to(str), # type: ignore id="inline_counter", - is_read_only=True, + read_only=True, ), - rx.chakra.input( + rx.input( value=CallScriptState.external_counter.to(str), # type: ignore id="external_counter", - is_read_only=True, + read_only=True, ), rx.text_area( value=CallScriptState.results.to_string(), # type: ignore id="results", - is_read_only=True, + read_only=True, ), rx.script(inline_scripts), rx.script(src="/external.js"), @@ -226,7 +269,77 @@ def CallScript(): on_click=CallScriptState.get_external_counter, id="update_external_counter", ), + rx.button( + CallScriptState.value, + on_click=rx.call_script( + "'updated'", + callback=CallScriptState.set_value, # type: ignore + ), + id="update_value", + ), rx.button("Reset", id="reset", on_click=CallScriptState.reset_), + rx.input( + value=CallScriptState.last_result, + id="last_result", + read_only=True, + on_click=CallScriptState.set_last_result(""), # type: ignore + ), + rx.button( + "call_with_var_f_string", + on_click=CallScriptState.call_with_var_f_string, + id="call_with_var_f_string", + ), + rx.button( + "call_with_var_str_cast", + on_click=CallScriptState.call_with_var_str_cast, + id="call_with_var_str_cast", + ), + rx.button( + "call_with_var_f_string_wrapped", + on_click=CallScriptState.call_with_var_f_string_wrapped, + id="call_with_var_f_string_wrapped", + ), + rx.button( + "call_with_var_str_cast_wrapped", + on_click=CallScriptState.call_with_var_str_cast_wrapped, + id="call_with_var_str_cast_wrapped", + ), + rx.button( + "call_with_var_f_string_inline", + on_click=rx.call_script( + f"{rx.Var('inline_counter')} + {CallScriptState.last_result}", + callback=CallScriptState.set_last_result, # type: ignore + ), + id="call_with_var_f_string_inline", + ), + rx.button( + "call_with_var_str_cast_inline", + on_click=rx.call_script( + f"{str(rx.Var('inline_counter'))} + {str(rx.Var('external_counter'))}", + callback=CallScriptState.set_last_result, # type: ignore + ), + id="call_with_var_str_cast_inline", + ), + rx.button( + "call_with_var_f_string_wrapped_inline", + on_click=rx.call_script( + rx.Var( + f"{rx.Var('inline_counter')} + {CallScriptState.last_result}" + ), + callback=CallScriptState.set_last_result, # type: ignore + ), + id="call_with_var_f_string_wrapped_inline", + ), + rx.button( + "call_with_var_str_cast_wrapped_inline", + on_click=rx.call_script( + rx.Var( + f"{str(rx.Var('inline_counter'))} + {str(rx.Var('external_counter'))}" + ), + callback=CallScriptState.set_last_result, # type: ignore + ), + id="call_with_var_str_cast_wrapped_inline", + ), ) @@ -265,25 +378,18 @@ def driver(call_script: AppHarness) -> Generator[WebDriver, None, None]: driver.quit() -def assert_token(call_script: AppHarness, driver: WebDriver) -> str: +def assert_token(driver: WebDriver) -> str: """Get the token associated with backend state. Args: - call_script: harness for CallScript app. driver: WebDriver instance. Returns: The token visible in the driver browser. """ - assert call_script.app_instance is not None - token_input = driver.find_element(By.ID, "token") - assert token_input - - # wait for the backend connection to send the token - token = call_script.poll_for_value(token_input) - assert token is not None - - return token + ss = SessionStorage(driver) + assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found" + return ss.get("token") @pytest.mark.parametrize("script", ["inline", "external"]) @@ -299,7 +405,7 @@ def test_call_script( driver: WebDriver instance. script: The type of script to test. """ - assert_token(call_script, driver) + assert_token(driver) reset_button = driver.find_element(By.ID, "reset") update_counter_button = driver.find_element(By.ID, f"update_{script}_counter") counter = driver.find_element(By.ID, f"{script}_counter") @@ -354,3 +460,82 @@ def test_call_script( ) reset_button.click() assert call_script.poll_for_value(counter, exp_not_equal="1") == "0" + + # Check that triggering script from event trigger calls callback + update_value_button = driver.find_element(By.ID, "update_value") + update_value_button.click() + + assert ( + call_script.poll_for_content(update_value_button, exp_not_equal="Initial") + == "updated" + ) + + +def test_call_script_w_var( + call_script: AppHarness, + driver: WebDriver, +): + """Test evaluating javascript expressions containing Vars. + + Args: + call_script: harness for CallScript app. + driver: WebDriver instance. + """ + assert_token(driver) + last_result = driver.find_element(By.ID, "last_result") + assert last_result.get_attribute("value") == "" + + inline_return_button = driver.find_element(By.ID, "inline_return") + + call_with_var_f_string_button = driver.find_element(By.ID, "call_with_var_f_string") + call_with_var_str_cast_button = driver.find_element(By.ID, "call_with_var_str_cast") + call_with_var_f_string_wrapped_button = driver.find_element( + By.ID, "call_with_var_f_string_wrapped" + ) + call_with_var_str_cast_wrapped_button = driver.find_element( + By.ID, "call_with_var_str_cast_wrapped" + ) + call_with_var_f_string_inline_button = driver.find_element( + By.ID, "call_with_var_f_string_inline" + ) + call_with_var_str_cast_inline_button = driver.find_element( + By.ID, "call_with_var_str_cast_inline" + ) + call_with_var_f_string_wrapped_inline_button = driver.find_element( + By.ID, "call_with_var_f_string_wrapped_inline" + ) + call_with_var_str_cast_wrapped_inline_button = driver.find_element( + By.ID, "call_with_var_str_cast_wrapped_inline" + ) + + inline_return_button.click() + call_with_var_f_string_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="") == "1" + + inline_return_button.click() + call_with_var_str_cast_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="1") == "2" + + inline_return_button.click() + call_with_var_f_string_wrapped_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="2") == "3" + + inline_return_button.click() + call_with_var_str_cast_wrapped_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="3") == "4" + + inline_return_button.click() + call_with_var_f_string_inline_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="4") == "9" + + inline_return_button.click() + call_with_var_str_cast_inline_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="9") == "6" + + inline_return_button.click() + call_with_var_f_string_wrapped_inline_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="6") == "13" + + inline_return_button.click() + call_with_var_str_cast_wrapped_inline_button.click() + assert call_script.poll_for_value(last_result, exp_not_equal="13") == "8" diff --git a/integration/test_client_storage.py b/tests/integration/test_client_storage.py similarity index 77% rename from integration/test_client_storage.py rename to tests/integration/test_client_storage.py index 24c3c7be0..ae66087e2 100644 --- a/integration/test_client_storage.py +++ b/tests/integration/test_client_storage.py @@ -1,4 +1,5 @@ """Integration tests for client side storage.""" + from __future__ import annotations import time @@ -46,9 +47,15 @@ def ClientSide(): l5: str = rx.LocalStorage(sync=True) l6: str = rx.LocalStorage(sync=True, name="l6") + # Session storage + s1: str = rx.SessionStorage() + s2: rx.SessionStorage = "s2 default" # type: ignore + s3: str = rx.SessionStorage(name="s3") + def set_l6(self, my_param: str): self.l6 = my_param + @rx.event def set_var(self): setattr(self, self.state_var, self.input_value) self.state_var = self.input_value = "" @@ -56,25 +63,27 @@ def ClientSide(): class ClientSideSubSubState(ClientSideSubState): c1s: str = rx.Cookie() l1s: str = rx.LocalStorage() + s1s: str = rx.SessionStorage() + @rx.event def set_var(self): setattr(self, self.state_var, self.input_value) self.state_var = self.input_value = "" def index(): return rx.fragment( - rx.chakra.input( + rx.input( value=ClientSideState.router.session.client_token, is_read_only=True, id="token", ), - rx.chakra.input( + rx.input( placeholder="state var", value=ClientSideState.state_var, on_change=ClientSideState.set_state_var, # type: ignore id="state_var", ), - rx.chakra.input( + rx.input( placeholder="input value", value=ClientSideState.input_value, on_change=ClientSideState.set_input_value, # type: ignore @@ -103,8 +112,12 @@ def ClientSide(): rx.box(ClientSideSubState.l4, id="l4"), rx.box(ClientSideSubState.l5, id="l5"), rx.box(ClientSideSubState.l6, id="l6"), + rx.box(ClientSideSubState.s1, id="s1"), + rx.box(ClientSideSubState.s2, id="s2"), + rx.box(ClientSideSubState.s3, id="s3"), rx.box(ClientSideSubSubState.c1s, id="c1s"), rx.box(ClientSideSubSubState.l1s, id="l1s"), + rx.box(ClientSideSubSubState.s1s, id="s1s"), ) app = rx.App(state=rx.State) @@ -162,6 +175,21 @@ def local_storage(driver: WebDriver) -> Generator[utils.LocalStorage, None, None ls.clear() +@pytest.fixture() +def session_storage(driver: WebDriver) -> Generator[utils.SessionStorage, None, None]: + """Get an instance of the session storage helper. + + Args: + driver: WebDriver instance. + + Yields: + Session storage helper. + """ + ss = utils.SessionStorage(driver) + yield ss + ss.clear() + + @pytest.fixture(autouse=True) def delete_all_cookies(driver: WebDriver) -> Generator[None, None, None]: """Delete all cookies after each test. @@ -190,7 +218,10 @@ def cookie_info_map(driver: WebDriver) -> dict[str, dict[str, str]]: @pytest.mark.asyncio async def test_client_side_state( - client_side: AppHarness, driver: WebDriver, local_storage: utils.LocalStorage + client_side: AppHarness, + driver: WebDriver, + local_storage: utils.LocalStorage, + session_storage: utils.SessionStorage, ): """Test client side state. @@ -198,8 +229,10 @@ async def test_client_side_state( client_side: harness for ClientSide app. driver: WebDriver instance. local_storage: Local storage helper. + session_storage: Session storage helper. """ - assert client_side.app_instance is not None + app = client_side.app_instance + assert app is not None assert client_side.frontend_url is not None def poll_for_token(): @@ -251,8 +284,12 @@ async def test_client_side_state( l2 = driver.find_element(By.ID, "l2") l3 = driver.find_element(By.ID, "l3") l4 = driver.find_element(By.ID, "l4") + s1 = driver.find_element(By.ID, "s1") + s2 = driver.find_element(By.ID, "s2") + s3 = driver.find_element(By.ID, "s3") c1s = driver.find_element(By.ID, "c1s") l1s = driver.find_element(By.ID, "l1s") + s1s = driver.find_element(By.ID, "s1s") # assert on defaults where present assert c1.text == "" @@ -266,13 +303,17 @@ async def test_client_side_state( assert l2.text == "l2 default" assert l3.text == "" assert l4.text == "l4 default" + assert s1.text == "" + assert s2.text == "s2 default" + assert s3.text == "" assert c1s.text == "" assert l1s.text == "" + assert s1s.text == "" # 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 # set some cookies and local storage values @@ -287,32 +328,44 @@ async def test_client_side_state( set_sub("l2", "l2 value") set_sub("l3", "l3 value") set_sub("l4", "l4 value") + set_sub("s1", "s1 value") + set_sub("s2", "s2 value") + set_sub("s3", "s3 value") set_sub_sub("c1s", "c1s value") set_sub_sub("l1s", "l1s value") + set_sub_sub("s1s", "s1s value") + + state_name = client_side.get_full_state_name(["_client_side_state"]) + sub_state_name = client_side.get_full_state_name( + ["_client_side_state", "_client_side_sub_state"] + ) + sub_sub_state_name = client_side.get_full_state_name( + ["_client_side_state", "_client_side_sub_state", "_client_side_sub_sub_state"] + ) exp_cookies = { - "state.client_side_state.client_side_sub_state.c1": { + f"{sub_state_name}.c1": { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c1", + "name": f"{sub_state_name}.c1", "path": "/", "sameSite": "Lax", "secure": False, "value": "c1%20value", }, - "state.client_side_state.client_side_sub_state.c2": { + f"{sub_state_name}.c2": { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c2", + "name": f"{sub_state_name}.c2", "path": "/", "sameSite": "Lax", "secure": False, "value": "c2%20value", }, - "state.client_side_state.client_side_sub_state.c4": { + f"{sub_state_name}.c4": { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c4", + "name": f"{sub_state_name}.c4", "path": "/", "sameSite": "Strict", "secure": False, @@ -327,19 +380,19 @@ async def test_client_side_state( "secure": False, "value": "c6%20value", }, - "state.client_side_state.client_side_sub_state.c7": { + f"{sub_state_name}.c7": { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c7", + "name": f"{sub_state_name}.c7", "path": "/", "sameSite": "Lax", "secure": False, "value": "c7%20value", }, - "state.client_side_state.client_side_sub_state.client_side_sub_sub_state.c1s": { + f"{sub_sub_state_name}.c1s": { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.client_side_sub_sub_state.c1s", + "name": f"{sub_sub_state_name}.c1s", "path": "/", "sameSite": "Lax", "secure": False, @@ -357,18 +410,13 @@ async def test_client_side_state( # Test cookie with expiry by itself to avoid timing flakiness set_sub("c3", "c3 value") - AppHarness._poll_for( - lambda: "state.client_side_state.client_side_sub_state.c3" - in cookie_info_map(driver) - ) - c3_cookie = cookie_info_map(driver)[ - "state.client_side_state.client_side_sub_state.c3" - ] + AppHarness._poll_for(lambda: f"{sub_state_name}.c3" in cookie_info_map(driver)) + c3_cookie = cookie_info_map(driver)[f"{sub_state_name}.c3"] assert c3_cookie.pop("expiry") is not None assert c3_cookie == { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c3", + "name": f"{sub_state_name}.c3", "path": "/", "sameSite": "Lax", "secure": False, @@ -377,34 +425,25 @@ async def test_client_side_state( time.sleep(2) # wait for c3 to expire if not isinstance(driver, Firefox): # Note: Firefox does not remove expired cookies Bug 576347 - assert ( - "state.client_side_state.client_side_sub_state.c3" - not in cookie_info_map(driver) - ) + 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) - assert ( - local_storage_items.pop("state.client_side_state.client_side_sub_state.l1") - == "l1 value" - ) - assert ( - local_storage_items.pop("state.client_side_state.client_side_sub_state.l2") - == "l2 value" - ) + 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" assert local_storage_items.pop("l3") == "l3 value" - assert ( - local_storage_items.pop("state.client_side_state.client_side_sub_state.l4") - == "l4 value" - ) - assert ( - local_storage_items.pop( - "state.client_side_state.client_side_sub_state.client_side_sub_sub_state.l1s" - ) - == "l1s value" - ) + assert local_storage_items.pop(f"{sub_state_name}.l4") == "l4 value" + assert local_storage_items.pop(f"{sub_sub_state_name}.l1s") == "l1s value" assert not local_storage_items + session_storage_items = session_storage.items() + session_storage_items.pop("token", None) + assert session_storage_items.pop(f"{sub_state_name}.s1") == "s1 value" + assert session_storage_items.pop(f"{sub_state_name}.s2") == "s2 value" + assert session_storage_items.pop("s3") == "s3 value" + assert session_storage_items.pop(f"{sub_sub_state_name}.s1s") == "s1s value" + assert not session_storage_items + assert c1.text == "c1 value" assert c2.text == "c2 value" assert c3.text == "c3 value" @@ -416,8 +455,12 @@ async def test_client_side_state( assert l2.text == "l2 value" assert l3.text == "l3 value" assert l4.text == "l4 value" + assert s1.text == "s1 value" + assert s2.text == "s2 value" + assert s3.text == "s3 value" assert c1s.text == "c1s value" assert l1s.text == "l1s value" + assert s1s.text == "s1s value" # navigate to the /foo route with utils.poll_for_navigation(driver): @@ -435,8 +478,12 @@ async def test_client_side_state( l2 = driver.find_element(By.ID, "l2") l3 = driver.find_element(By.ID, "l3") l4 = driver.find_element(By.ID, "l4") + s1 = driver.find_element(By.ID, "s1") + s2 = driver.find_element(By.ID, "s2") + s3 = driver.find_element(By.ID, "s3") c1s = driver.find_element(By.ID, "c1s") l1s = driver.find_element(By.ID, "l1s") + s1s = driver.find_element(By.ID, "s1s") assert c1.text == "c1 value" assert c2.text == "c2 value" @@ -449,11 +496,15 @@ async def test_client_side_state( assert l2.text == "l2 value" assert l3.text == "l3 value" assert l4.text == "l4 value" + assert s1.text == "s1 value" + assert s2.text == "s2 value" + assert s3.text == "s3 value" assert c1s.text == "c1s value" assert l1s.text == "l1s value" + assert s1s.text == "s1s value" # reset the backend state to force refresh from client storage - async with client_side.modify_state(f"{token}_state.client_side_state") as state: + async with client_side.modify_state(f"{token}_{state_name}") as state: state.reset() driver.refresh() @@ -475,8 +526,12 @@ async def test_client_side_state( l2 = driver.find_element(By.ID, "l2") l3 = driver.find_element(By.ID, "l3") l4 = driver.find_element(By.ID, "l4") + s1 = driver.find_element(By.ID, "s1") + s2 = driver.find_element(By.ID, "s2") + s3 = driver.find_element(By.ID, "s3") c1s = driver.find_element(By.ID, "c1s") l1s = driver.find_element(By.ID, "l1s") + s1s = driver.find_element(By.ID, "s1s") assert c1.text == "c1 value" assert c2.text == "c2 value" @@ -489,20 +544,19 @@ async def test_client_side_state( assert l2.text == "l2 value" assert l3.text == "l3 value" assert l4.text == "l4 value" + assert s1.text == "s1 value" + assert s2.text == "s2 value" + assert s3.text == "s3 value" assert c1s.text == "c1s value" assert l1s.text == "l1s value" + assert s1s.text == "s1s value" # make sure c5 cookie shows up on the `/foo` route - AppHarness._poll_for( - lambda: "state.client_side_state.client_side_sub_state.c5" - in cookie_info_map(driver) - ) - assert cookie_info_map(driver)[ - "state.client_side_state.client_side_sub_state.c5" - ] == { + AppHarness._poll_for(lambda: f"{sub_state_name}.c5" in cookie_info_map(driver)) + assert cookie_info_map(driver)[f"{sub_state_name}.c5"] == { "domain": "localhost", "httpOnly": False, - "name": "state.client_side_state.client_side_sub_state.c5", + "name": f"{sub_state_name}.c5", "path": "/foo/", "sameSite": "Lax", "secure": False, @@ -525,6 +579,15 @@ async def test_client_side_state( assert AppHarness._poll_for(lambda: l6.text == "l6 value") assert l5.text == "l5 value" + # Set session storage values in the new tab + set_sub("s1", "other tab s1") + s1 = driver.find_element(By.ID, "s1") + s2 = driver.find_element(By.ID, "s2") + s3 = driver.find_element(By.ID, "s3") + assert AppHarness._poll_for(lambda: s1.text == "other tab s1") + assert s2.text == "s2 default" + assert s3.text == "" + # Switch back to main window. driver.switch_to.window(main_tab) @@ -534,6 +597,13 @@ async def test_client_side_state( assert AppHarness._poll_for(lambda: l6.text == "l6 value") assert l5.text == "l5 value" + s1 = driver.find_element(By.ID, "s1") + s2 = driver.find_element(By.ID, "s2") + s3 = driver.find_element(By.ID, "s3") + assert AppHarness._poll_for(lambda: s1.text == "s1 value") + assert s2.text == "s2 value" + assert s3.text == "s3 value" + # clear the cookie jar and local storage, ensure state reset to default driver.delete_all_cookies() local_storage.clear() diff --git a/tests/integration/test_component_state.py b/tests/integration/test_component_state.py new file mode 100644 index 000000000..f4a295d07 --- /dev/null +++ b/tests/integration/test_component_state.py @@ -0,0 +1,204 @@ +"""Test that per-component state scaffold works and operates independently.""" + +from typing import Generator + +import pytest +from selenium.webdriver.common.by import By + +from reflex.state import State, _substate_key +from reflex.testing import AppHarness + +from . import utils + + +def ComponentStateApp(): + """App using per component state.""" + from typing import Generic, TypeVar + + import reflex as rx + + E = TypeVar("E") + + class MultiCounter(rx.ComponentState, Generic[E]): + """ComponentState style.""" + + count: int = 0 + _be: E + _be_int: int + _be_str: str = "42" + + @rx.event + def increment(self): + self.count += 1 + self._be = self.count # type: ignore + + @classmethod + def get_component(cls, *children, **props): + return rx.vstack( + *children, + rx.heading(cls.count, id=f"count-{props.get('id', 'default')}"), + rx.button( + "Increment", + on_click=cls.increment, + id=f"button-{props.get('id', 'default')}", + ), + **props, + ) + + def multi_counter_func(id: str = "default") -> rx.Component: + """Local-substate style. + + Args: + id: identifier for this instance + + Returns: + A new instance of the component with its own state. + """ + + class _Counter(rx.State): + count: int = 0 + + @rx.event + def increment(self): + self.count += 1 + + return rx.vstack( + rx.heading(_Counter.count, id=f"count-{id}"), + rx.button( + "Increment", + on_click=_Counter.increment, + id=f"button-{id}", + ), + State=_Counter, + ) + + app = rx.App(state=rx.State) # noqa + + @rx.page() + def index(): + mc_a = MultiCounter.create(id="a") + mc_b = MultiCounter.create(id="b") + mc_c = multi_counter_func(id="c") + mc_d = multi_counter_func(id="d") + assert mc_a.State != mc_b.State + assert mc_c.State != mc_d.State + return rx.vstack( + mc_a, + mc_b, + mc_c, + mc_d, + rx.button( + "Inc A", + on_click=mc_a.State.increment, # type: ignore + id="inc-a", + ), + rx.text( + mc_a.State.get_name() if mc_a.State is not None else "", + id="a_state_name", + ), + rx.text( + mc_b.State.get_name() if mc_b.State is not None else "", + id="b_state_name", + ), + ) + + +@pytest.fixture() +def component_state_app(tmp_path) -> Generator[AppHarness, None, None]: + """Start ComponentStateApp app at tmp_path via AppHarness. + + Args: + tmp_path: pytest tmp_path fixture + + Yields: + running AppHarness instance + """ + with AppHarness.create( + root=tmp_path, + app_source=ComponentStateApp, # type: ignore + ) as harness: + yield harness + + +@pytest.mark.asyncio +async def test_component_state_app(component_state_app: AppHarness): + """Increment counters independently. + + Args: + component_state_app: harness for ComponentStateApp app + """ + assert component_state_app.app_instance is not None, "app is not running" + driver = component_state_app.frontend() + + ss = utils.SessionStorage(driver) + assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found" + root_state_token = _substate_key(ss.get("token"), State) + + count_a = driver.find_element(By.ID, "count-a") + count_b = driver.find_element(By.ID, "count-b") + button_a = driver.find_element(By.ID, "button-a") + button_b = driver.find_element(By.ID, "button-b") + button_inc_a = driver.find_element(By.ID, "inc-a") + + # Check that backend vars in mixins are okay + a_state_name = driver.find_element(By.ID, "a_state_name").text + b_state_name = driver.find_element(By.ID, "b_state_name").text + root_state = await component_state_app.get_state(root_state_token) + a_state = root_state.substates[a_state_name] + b_state = root_state.substates[b_state_name] + assert a_state._backend_vars == a_state.backend_vars + assert a_state._backend_vars == b_state._backend_vars + assert a_state._backend_vars["_be"] is None + assert a_state._backend_vars["_be_int"] == 0 + assert a_state._backend_vars["_be_str"] == "42" + + assert count_a.text == "0" + + button_a.click() + assert component_state_app.poll_for_content(count_a, exp_not_equal="0") == "1" + + button_a.click() + assert component_state_app.poll_for_content(count_a, exp_not_equal="1") == "2" + + button_inc_a.click() + assert component_state_app.poll_for_content(count_a, exp_not_equal="2") == "3" + + root_state = await component_state_app.get_state(root_state_token) + a_state = root_state.substates[a_state_name] + b_state = root_state.substates[b_state_name] + assert a_state._backend_vars != a_state.backend_vars + assert a_state._be == a_state._backend_vars["_be"] == 3 + assert b_state._be is None + assert b_state._backend_vars["_be"] is None + + assert count_b.text == "0" + + button_b.click() + assert component_state_app.poll_for_content(count_b, exp_not_equal="0") == "1" + + button_b.click() + assert component_state_app.poll_for_content(count_b, exp_not_equal="1") == "2" + + root_state = await component_state_app.get_state(root_state_token) + a_state = root_state.substates[a_state_name] + b_state = root_state.substates[b_state_name] + assert b_state._backend_vars != b_state.backend_vars + assert b_state._be == b_state._backend_vars["_be"] == 2 + + # Check locally-defined substate style + count_c = driver.find_element(By.ID, "count-c") + count_d = driver.find_element(By.ID, "count-d") + button_c = driver.find_element(By.ID, "button-c") + button_d = driver.find_element(By.ID, "button-d") + + assert component_state_app.poll_for_content(count_c, exp_not_equal="") == "0" + assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0" + button_c.click() + assert component_state_app.poll_for_content(count_c, exp_not_equal="0") == "1" + assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0" + button_c.click() + assert component_state_app.poll_for_content(count_c, exp_not_equal="1") == "2" + assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0" + button_d.click() + assert component_state_app.poll_for_content(count_c, exp_not_equal="1") == "2" + assert component_state_app.poll_for_content(count_d, exp_not_equal="0") == "1" diff --git a/tests/integration/test_computed_vars.py b/tests/integration/test_computed_vars.py new file mode 100644 index 000000000..1f585cd8b --- /dev/null +++ b/tests/integration/test_computed_vars.py @@ -0,0 +1,259 @@ +"""Test computed vars.""" + +from __future__ import annotations + +import time +from typing import Generator + +import pytest +from selenium.webdriver.common.by import By + +from reflex.testing import DEFAULT_TIMEOUT, AppHarness, WebDriver + + +def ComputedVars(): + """Test app for computed vars.""" + import reflex as rx + + class StateMixin(rx.State, mixin=True): + pass + + class State(StateMixin, rx.State): + count: int = 0 + + # cached var with dep on count + @rx.var(cache=True, interval=15) + def count1(self) -> int: + return self.count + + # cached backend var with dep on count + @rx.var(cache=True, interval=15, backend=True) + def count1_backend(self) -> int: + return self.count + + # same as above but implicit backend with `_` prefix + @rx.var(cache=True, interval=15) + def _count1_backend(self) -> int: + return self.count + + # explicit disabled auto_deps + @rx.var(interval=15, cache=True, auto_deps=False) + def count3(self) -> int: + # this will not add deps, because auto_deps is False + print(self.count1) + + return self.count + + # explicit dependency on count var + @rx.var(cache=True, deps=["count"], auto_deps=False) + def depends_on_count(self) -> int: + return self.count + + # explicit dependency on count1 var + @rx.var(cache=True, deps=[count1], auto_deps=False) + def depends_on_count1(self) -> int: + return self.count + + @rx.var(deps=[count3], auto_deps=False, cache=True) + def depends_on_count3(self) -> int: + return self.count + + @rx.event + def increment(self): + self.count += 1 + + @rx.event + def mark_dirty(self): + self._mark_dirty() + + assert State.backend_vars == {} + + def index() -> rx.Component: + return rx.center( + rx.vstack( + rx.input( + id="token", + value=State.router.session.client_token, + is_read_only=True, + ), + rx.button("Increment", on_click=State.increment, id="increment"), + rx.button("Do nothing", on_click=State.mark_dirty, id="mark_dirty"), + rx.text("count:"), + rx.text(State.count, id="count"), + rx.text("count1:"), + rx.text(State.count1, id="count1"), + rx.text("count1_backend:"), + rx.text(State.count1_backend, id="count1_backend"), + rx.text("_count1_backend:"), + rx.text(State._count1_backend, id="_count1_backend"), + rx.text("count3:"), + rx.text(State.count3, id="count3"), + rx.text("depends_on_count:"), + rx.text( + State.depends_on_count, + id="depends_on_count", + ), + rx.text("depends_on_count1:"), + rx.text( + State.depends_on_count1, + id="depends_on_count1", + ), + rx.text("depends_on_count3:"), + rx.text( + State.depends_on_count3, + id="depends_on_count3", + ), + ), + ) + + # raise Exception(State.count3._deps(objclass=State)) + app = rx.App() + app.add_page(index) + + +@pytest.fixture(scope="module") +def computed_vars( + tmp_path_factory: pytest.TempPathFactory, +) -> Generator[AppHarness, None, None]: + """Start ComputedVars app at tmp_path via AppHarness. + + Args: + tmp_path_factory: pytest tmp_path_factory fixture + + Yields: + running AppHarness instance + """ + with AppHarness.create( + root=tmp_path_factory.mktemp(f"computed_vars"), + app_source=ComputedVars, # type: ignore + ) as harness: + yield harness + + +@pytest.fixture +def driver(computed_vars: AppHarness) -> Generator[WebDriver, None, None]: + """Get an instance of the browser open to the computed_vars app. + + Args: + computed_vars: harness for ComputedVars app + + Yields: + WebDriver instance. + """ + assert computed_vars.app_instance is not None, "app is not running" + driver = computed_vars.frontend() + try: + yield driver + finally: + driver.quit() + + +@pytest.fixture() +def token(computed_vars: AppHarness, driver: WebDriver) -> str: + """Get a function that returns the active token. + + Args: + computed_vars: harness for ComputedVars app. + driver: WebDriver instance. + + Returns: + The token for the connected client + """ + assert computed_vars.app_instance is not None + token_input = driver.find_element(By.ID, "token") + assert token_input + + # wait for the backend connection to send the token + token = computed_vars.poll_for_value(token_input, timeout=DEFAULT_TIMEOUT * 2) + assert token is not None + + return token + + +@pytest.mark.asyncio +async def test_computed_vars( + computed_vars: AppHarness, + driver: WebDriver, + token: str, +): + """Test that computed vars are working as expected. + + Args: + computed_vars: harness for ComputedVars app. + driver: WebDriver instance. + token: The token for the connected client. + """ + assert computed_vars.app_instance is not None + + state_name = computed_vars.get_state_name("_state") + full_state_name = computed_vars.get_full_state_name(["_state"]) + token = f"{token}_{full_state_name}" + state = (await computed_vars.get_state(token)).substates[state_name] + assert state is not None + assert state.count1_backend == 0 + assert state._count1_backend == 0 + + # test that backend var is not rendered + count1_backend = driver.find_element(By.ID, "count1_backend") + assert count1_backend + assert count1_backend.text == "" + _count1_backend = driver.find_element(By.ID, "_count1_backend") + assert _count1_backend + assert _count1_backend.text == "" + + count = driver.find_element(By.ID, "count") + assert count + assert count.text == "0" + + count1 = driver.find_element(By.ID, "count1") + assert count1 + assert count1.text == "0" + + count3 = driver.find_element(By.ID, "count3") + assert count3 + assert count3.text == "0" + + depends_on_count = driver.find_element(By.ID, "depends_on_count") + assert depends_on_count + assert depends_on_count.text == "0" + + depends_on_count1 = driver.find_element(By.ID, "depends_on_count1") + assert depends_on_count1 + assert depends_on_count1.text == "0" + + depends_on_count3 = driver.find_element(By.ID, "depends_on_count3") + assert depends_on_count3 + assert depends_on_count3.text == "0" + + increment = driver.find_element(By.ID, "increment") + assert increment.is_enabled() + + mark_dirty = driver.find_element(By.ID, "mark_dirty") + assert mark_dirty.is_enabled() + + mark_dirty.click() + + increment.click() + assert computed_vars.poll_for_content(count, timeout=2, exp_not_equal="0") == "1" + assert computed_vars.poll_for_content(count1, timeout=2, exp_not_equal="0") == "1" + assert ( + computed_vars.poll_for_content(depends_on_count, timeout=2, exp_not_equal="0") + == "1" + ) + state = (await computed_vars.get_state(token)).substates[state_name] + assert state is not None + assert state.count1_backend == 1 + assert count1_backend.text == "" + assert state._count1_backend == 1 + assert _count1_backend.text == "" + + mark_dirty.click() + with pytest.raises(TimeoutError): + _ = computed_vars.poll_for_content(count3, timeout=5, exp_not_equal="0") + + time.sleep(10) + assert count3.text == "0" + assert depends_on_count3.text == "0" + mark_dirty.click() + assert computed_vars.poll_for_content(count3, timeout=2, exp_not_equal="0") == "1" + assert depends_on_count3.text == "1" diff --git a/integration/test_connection_banner.py b/tests/integration/test_connection_banner.py similarity index 51% rename from integration/test_connection_banner.py rename to tests/integration/test_connection_banner.py index 293d2e412..6921444b0 100644 --- a/integration/test_connection_banner.py +++ b/tests/integration/test_connection_banner.py @@ -8,16 +8,33 @@ from selenium.webdriver.common.by import By from reflex.testing import AppHarness, WebDriver +from .utils import SessionStorage + def ConnectionBanner(): """App with a connection banner.""" + import asyncio + import reflex as rx class State(rx.State): foo: int = 0 + @rx.event + async def delay(self): + await asyncio.sleep(5) + def index(): - return rx.text("Hello World") + return rx.vstack( + rx.text("Hello World"), + rx.input(value=State.foo, read_only=True, id="counter"), + rx.button( + "Increment", + id="increment", + on_click=State.set_foo(State.foo + 1), # type: ignore + ), + rx.button("Delay", id="delay", on_click=State.delay), + ) app = rx.App(state=rx.State) app.add_page(index) @@ -40,7 +57,7 @@ def connection_banner(tmp_path) -> Generator[AppHarness, None, None]: yield harness -CONNECTION_ERROR_XPATH = "//*[ text() = 'Connection Error' ]" +CONNECTION_ERROR_XPATH = "//*[ contains(text(), 'Cannot connect to server') ]" def has_error_modal(driver: WebDriver) -> bool: @@ -59,7 +76,8 @@ def has_error_modal(driver: WebDriver) -> bool: return False -def test_connection_banner(connection_banner: AppHarness): +@pytest.mark.asyncio +async def test_connection_banner(connection_banner: AppHarness): """Test that the connection banner is displayed when the websocket drops. Args: @@ -69,7 +87,23 @@ def test_connection_banner(connection_banner: AppHarness): assert connection_banner.backend is not None driver = connection_banner.frontend() - connection_banner._poll_for(lambda: not has_error_modal(driver)) + ss = SessionStorage(driver) + assert connection_banner._poll_for( + lambda: ss.get("token") is not None + ), "token not found" + + assert connection_banner._poll_for(lambda: not has_error_modal(driver)) + + delay_button = driver.find_element(By.ID, "delay") + increment_button = driver.find_element(By.ID, "increment") + counter_element = driver.find_element(By.ID, "counter") + + # Increment the counter + increment_button.click() + assert connection_banner.poll_for_value(counter_element, exp_not_equal="0") == "1" + + # Start an long event before killing the backend, to mark event_processing=true + delay_button.click() # Get the backend port backend_port = connection_banner._poll_for_servers().getsockname()[1] @@ -80,10 +114,20 @@ def test_connection_banner(connection_banner: AppHarness): connection_banner.backend_thread.join() # Error modal should now be displayed - connection_banner._poll_for(lambda: has_error_modal(driver)) + assert connection_banner._poll_for(lambda: has_error_modal(driver)) + + # Increment the counter with backend down + increment_button.click() + assert connection_banner.poll_for_value(counter_element, exp_not_equal="0") == "1" # Bring the backend back up connection_banner._start_backend(port=backend_port) + # Create a new StateManager to avoid async loop affinity issues w/ redis + await connection_banner._reset_backend_state_manager() + # Banner should be gone now - connection_banner._poll_for(lambda: not has_error_modal(driver)) + assert connection_banner._poll_for(lambda: not has_error_modal(driver)) + + # Count should have incremented after coming back up + assert connection_banner.poll_for_value(counter_element, exp_not_equal="1") == "2" diff --git a/tests/integration/test_deploy_url.py b/tests/integration/test_deploy_url.py new file mode 100644 index 000000000..f93e9db27 --- /dev/null +++ b/tests/integration/test_deploy_url.py @@ -0,0 +1,99 @@ +"""Integration tests for deploy_url.""" + +from __future__ import annotations + +from typing import Generator + +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.remote.webdriver import WebDriver +from selenium.webdriver.support.ui import WebDriverWait + +from reflex.testing import AppHarness + + +def DeployUrlSample() -> None: + """Sample app for testing config deploy_url is correct (in tests).""" + import reflex as rx + + class State(rx.State): + @rx.event + def goto_self(self): + return rx.redirect(rx.config.get_config().deploy_url) # type: ignore + + def index(): + return rx.fragment( + rx.button("GOTO SELF", on_click=State.goto_self, id="goto_self") + ) + + app = rx.App(state=rx.State) + app.add_page(index) + + +@pytest.fixture(scope="module") +def deploy_url_sample( + tmp_path_factory: pytest.TempPathFactory, +) -> Generator[AppHarness, None, None]: + """AppHarness fixture for testing deploy_url. + + Args: + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + AppHarness: An AppHarness instance. + """ + with AppHarness.create( + root=tmp_path_factory.mktemp("deploy_url_sample"), + app_source=DeployUrlSample, # type: ignore + ) as harness: + yield harness + + +@pytest.fixture() +def driver(deploy_url_sample: AppHarness) -> Generator[WebDriver, None, None]: + """WebDriver fixture for testing deploy_url. + + Args: + deploy_url_sample: AppHarness fixture for testing deploy_url. + + Yields: + WebDriver: A WebDriver instance. + """ + assert deploy_url_sample.app_instance is not None, "app is not running" + driver = deploy_url_sample.frontend() + try: + yield driver + finally: + driver.quit() + + +def test_deploy_url(deploy_url_sample: AppHarness, driver: WebDriver) -> None: + """Test deploy_url is correct. + + Args: + deploy_url_sample: AppHarness fixture for testing deploy_url. + driver: WebDriver fixture for testing deploy_url. + """ + import reflex as rx + + deploy_url = rx.config.get_config().deploy_url + assert deploy_url is not None + assert deploy_url != "http://localhost:3000" + assert deploy_url == deploy_url_sample.frontend_url + driver.get(deploy_url) + assert driver.current_url == deploy_url + "/" + + +def test_deploy_url_in_app(deploy_url_sample: AppHarness, driver: WebDriver) -> None: + """Test deploy_url is correct in app. + + Args: + deploy_url_sample: AppHarness fixture for testing deploy_url. + driver: WebDriver fixture for testing deploy_url. + """ + driver.implicitly_wait(10) + driver.find_element(By.ID, "goto_self").click() + + WebDriverWait(driver, 10).until( + lambda driver: driver.current_url == f"{deploy_url_sample.frontend_url}/" + ) diff --git a/tests/integration/test_dynamic_components.py b/tests/integration/test_dynamic_components.py new file mode 100644 index 000000000..aeebd10e9 --- /dev/null +++ b/tests/integration/test_dynamic_components.py @@ -0,0 +1,169 @@ +"""Integration tests for var operations.""" + +import time +from typing import Callable, Generator, TypeVar + +import pytest +from selenium.webdriver.common.by import By + +from reflex.testing import AppHarness + +# pyright: reportOptionalMemberAccess=false, reportGeneralTypeIssues=false, reportUnknownMemberType=false + + +def DynamicComponents(): + """App with var operations.""" + import reflex as rx + + class DynamicComponentsState(rx.State): + value: int = 10 + + button: rx.Component = rx.button( + "Click me", + custom_attrs={ + "id": "button", + }, + ) + + def got_clicked(self): + self.button = rx.button( + "Clicked", + custom_attrs={ + "id": "button", + }, + ) + + @rx.var + def client_token_component(self) -> rx.Component: + return rx.vstack( + rx.el.input( + custom_attrs={ + "id": "token", + }, + value=self.router.session.client_token, + is_read_only=True, + ), + rx.button( + "Update", + custom_attrs={ + "id": "update", + }, + on_click=DynamicComponentsState.got_clicked, + ), + ) + + app = rx.App() + + def factorial(n: int) -> int: + if n == 0: + return 1 + return n * factorial(n - 1) + + @app.add_page + def index(): + return rx.vstack( + DynamicComponentsState.client_token_component, + DynamicComponentsState.button, + rx.text( + DynamicComponentsState._evaluate( + lambda state: factorial(state.value), of_type=int + ), + id="factorial", + ), + ) + + +@pytest.fixture(scope="module") +def dynamic_components(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start VarOperations app at tmp_path via AppHarness. + + Args: + tmp_path_factory: pytest tmp_path_factory fixture + + Yields: + running AppHarness instance + """ + with AppHarness.create( + root=tmp_path_factory.mktemp("dynamic_components"), + app_source=DynamicComponents, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +T = TypeVar("T") + + +def poll_for_result( + f: Callable[[], T], exception=Exception, max_attempts=5, seconds_between_attempts=1 +) -> T: + """Poll for a result from a function. + + Args: + f: function to call + exception: exception to catch + max_attempts: maximum number of attempts + seconds_between_attempts: seconds to wait between + + Returns: + Result of the function + + Raises: + AssertionError: if the function does not return a value + """ + attempts = 0 + while attempts < max_attempts: + try: + return f() + except exception: + attempts += 1 + time.sleep(seconds_between_attempts) + raise AssertionError("Function did not return a value") + + +@pytest.fixture +def driver(dynamic_components: AppHarness): + """Get an instance of the browser open to the dynamic components app. + + Args: + dynamic_components: AppHarness for the dynamic components + + Yields: + WebDriver instance. + """ + driver = dynamic_components.frontend() + try: + token_input = poll_for_result(lambda: driver.find_element(By.ID, "token")) + assert token_input + # wait for the backend connection to send the token + token = dynamic_components.poll_for_value(token_input) + assert token is not None + + yield driver + finally: + driver.quit() + + +def test_dynamic_components(driver, dynamic_components: AppHarness): + """Test that the var operations produce the right results. + + Args: + driver: selenium WebDriver open to the app + dynamic_components: AppHarness for the dynamic components + """ + button = poll_for_result(lambda: driver.find_element(By.ID, "button")) + assert button + assert button.text == "Click me" + + update_button = driver.find_element(By.ID, "update") + assert update_button + update_button.click() + + assert ( + dynamic_components.poll_for_content(button, exp_not_equal="Click me") + == "Clicked" + ) + + factorial = poll_for_result(lambda: driver.find_element(By.ID, "factorial")) + assert factorial + assert factorial.text == "3628800" diff --git a/integration/test_dynamic_routes.py b/tests/integration/test_dynamic_routes.py similarity index 64% rename from integration/test_dynamic_routes.py rename to tests/integration/test_dynamic_routes.py index dd1818eda..31b7fa419 100644 --- a/integration/test_dynamic_routes.py +++ b/tests/integration/test_dynamic_routes.py @@ -1,4 +1,5 @@ """Integration tests for dynamic route page behavior.""" + from __future__ import annotations from typing import Callable, Coroutine, Generator, Type @@ -20,14 +21,17 @@ def DynamicRoute(): 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'}") + page_data = f"{self.router.page.path}-{self.page_id or 'no page id'}" + print(f"on_load: {page_data}") + self.order.append(page_data) def on_load_redir(self): query_params = self.router.page.params - self.order.append(f"on_load_redir-{query_params}") + page_data = f"on_load_redir-{query_params}" + print(f"on_load_redir: {page_data}") + self.order.append(page_data) return rx.redirect(f"/page/{query_params['page_id']}") @rx.var @@ -39,17 +43,15 @@ def DynamicRoute(): def index(): return rx.fragment( - rx.chakra.input( + rx.input( value=DynamicState.router.session.client_token, - is_read_only=True, + read_only=True, id="token", ), - rx.chakra.input( - value=DynamicState.page_id, is_read_only=True, id="page_id" - ), - rx.chakra.input( + rx.input(value=rx.State.page_id, read_only=True, id="page_id"), # type: ignore + rx.input( value=DynamicState.router.page.raw_path, - is_read_only=True, + read_only=True, id="raw_path", ), rx.link("index", href="/", id="link_index"), @@ -60,22 +62,80 @@ def DynamicRoute(): id="link_page_next", # type: ignore ), rx.link("missing", href="/missing", id="link_missing"), - rx.chakra.list( + rx.list( # type: ignore rx.foreach( DynamicState.order, # type: ignore - lambda i: rx.chakra.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 @@ -153,18 +213,23 @@ def poll_for_order( Returns: An async function that polls for the order list to match the expected order. """ + dynamic_state_name = dynamic_route.get_state_name("_dynamic_state") + dynamic_state_full_name = dynamic_route.get_full_state_name(["_dynamic_state"]) async def _poll_for_order(exp_order: list[str]): async def _backend_state(): - return await dynamic_route.get_state(f"{token}_state.dynamic_state") + return await dynamic_route.get_state(f"{token}_{dynamic_state_full_name}") async def _check(): return (await _backend_state()).substates[ - "dynamic_state" + dynamic_state_name ].order == exp_order - await AppHarness._poll_for_async(_check) - assert (await _backend_state()).substates["dynamic_state"].order == exp_order + await AppHarness._poll_for_async(_check, timeout=60) + assert ( + list((await _backend_state()).substates[dynamic_state_name].order) + == exp_order + ) return _poll_for_order @@ -184,6 +249,7 @@ async def test_on_load_navigate( token: The token visible in the driver browser. poll_for_order: function that polls for the order list to match the expected order. """ + dynamic_state_full_name = dynamic_route.get_full_state_name(["_dynamic_state"]) assert dynamic_route.app_instance is not None is_prod = isinstance(dynamic_route, AppHarnessProd) link = driver.find_element(By.ID, "link_page_next") @@ -233,7 +299,7 @@ async def test_on_load_navigate( driver.get(f"{driver.current_url}?foo=bar") await poll_for_order(exp_order) assert ( - await dynamic_route.get_state(f"{token}_state.dynamic_state") + await dynamic_route.get_state(f"{token}_{dynamic_state_full_name}") ).router.page.params["foo"] == "bar" # hit a 404 and ensure we still hydrate @@ -301,3 +367,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/tests/integration/test_event_actions.py similarity index 95% rename from integration/test_event_actions.py rename to tests/integration/test_event_actions.py index 3991704b8..5d278835e 100644 --- a/integration/test_event_actions.py +++ b/tests/integration/test_event_actions.py @@ -1,4 +1,5 @@ """Ensure stopPropagation and preventDefault work as expected.""" + from __future__ import annotations import asyncio @@ -23,6 +24,7 @@ def TestEventAction(): def on_click(self, ev): self.order.append(f"on_click:{ev}") + @rx.event def on_click2(self): self.order.append("on_click2") @@ -52,7 +54,7 @@ def TestEventAction(): def index(): return rx.vstack( - rx.chakra.input( + rx.input( value=EventActionState.router.session.client_token, is_read_only=True, id="token", @@ -145,10 +147,10 @@ def TestEventAction(): 200 ).stop_propagation, ), - rx.chakra.list( + rx.list( # type: ignore rx.foreach( EventActionState.order, # type: ignore - rx.chakra.list_item, + rx.list_item, ), ), on_click=EventActionState.on_click("outer"), # type: ignore @@ -228,20 +230,18 @@ def poll_for_order( Returns: An async function that polls for the order list to match the expected order. """ + state_name = event_action.get_state_name("_event_action_state") + state_full_name = event_action.get_full_state_name(["_event_action_state"]) async def _poll_for_order(exp_order: list[str]): async def _backend_state(): - return await event_action.get_state(f"{token}_state.event_action_state") + return await event_action.get_state(f"{token}_{state_full_name}") async def _check(): - return (await _backend_state()).substates[ - "event_action_state" - ].order == exp_order + return (await _backend_state()).substates[state_name].order == exp_order await AppHarness._poll_for_async(_check) - assert (await _backend_state()).substates[ - "event_action_state" - ].order == exp_order + assert (await _backend_state()).substates[state_name].order == exp_order return _poll_for_order diff --git a/integration/test_event_chain.py b/tests/integration/test_event_chain.py similarity index 94% rename from integration/test_event_chain.py rename to tests/integration/test_event_chain.py index fe3eaf2a8..ea2d2191c 100644 --- a/integration/test_event_chain.py +++ b/tests/integration/test_event_chain.py @@ -1,4 +1,5 @@ """Ensure that Event Chains are properly queued and handled between frontend and backend.""" + from __future__ import annotations from typing import Generator @@ -26,45 +27,55 @@ def EventChain(): event_order: List[str] = [] interim_value: str = "" + @rx.event def event_no_args(self): self.event_order.append("event_no_args") + @rx.event def event_arg(self, arg): self.event_order.append(f"event_arg:{arg}") + @rx.event def event_arg_repr_type(self, arg): self.event_order.append(f"event_arg_repr:{arg!r}_{type(arg).__name__}") + @rx.event def event_nested_1(self): self.event_order.append("event_nested_1") yield State.event_nested_2 yield State.event_arg("nested_1") # type: ignore + @rx.event def event_nested_2(self): self.event_order.append("event_nested_2") yield State.event_nested_3 yield rx.console_log("event_nested_2") yield State.event_arg("nested_2") # type: ignore + @rx.event def event_nested_3(self): self.event_order.append("event_nested_3") yield State.event_no_args yield State.event_arg("nested_3") # type: ignore + @rx.event def on_load_return_chain(self): self.event_order.append("on_load_return_chain") return [State.event_arg(1), State.event_arg(2), State.event_arg(3)] # type: ignore + @rx.event def on_load_yield_chain(self): self.event_order.append("on_load_yield_chain") yield State.event_arg(4) # type: ignore yield State.event_arg(5) # type: ignore yield State.event_arg(6) # type: ignore + @rx.event def click_return_event(self): self.event_order.append("click_return_event") return State.event_no_args + @rx.event def click_return_events(self): self.event_order.append("click_return_events") return [ @@ -74,6 +85,7 @@ def EventChain(): State.event_arg(9), # type: ignore ] + @rx.event def click_yield_chain(self): self.event_order.append("click_yield_chain:0") yield State.event_arg(10) # type: ignore @@ -84,6 +96,7 @@ def EventChain(): yield State.event_arg(12) # type: ignore self.event_order.append("click_yield_chain:3") + @rx.event def click_yield_many_events(self): self.event_order.append("click_yield_many_events") for ix in range(MANY_EVENTS): @@ -91,33 +104,40 @@ def EventChain(): yield rx.console_log(f"many_events_{ix}") self.event_order.append("click_yield_many_events_done") + @rx.event def click_yield_nested(self): self.event_order.append("click_yield_nested") yield State.event_nested_1 yield State.event_arg("yield_nested") # type: ignore + @rx.event def redirect_return_chain(self): self.event_order.append("redirect_return_chain") yield rx.redirect("/on-load-return-chain") + @rx.event def redirect_yield_chain(self): self.event_order.append("redirect_yield_chain") yield rx.redirect("/on-load-yield-chain") + @rx.event def click_return_int_type(self): self.event_order.append("click_return_int_type") return State.event_arg_repr_type(1) # type: ignore + @rx.event def click_return_dict_type(self): self.event_order.append("click_return_dict_type") return State.event_arg_repr_type({"a": 1}) # type: ignore + @rx.event async def click_yield_interim_value_async(self): self.interim_value = "interim" yield await asyncio.sleep(0.5) self.interim_value = "final" + @rx.event def click_yield_interim_value(self): self.interim_value = "interim" yield @@ -126,7 +146,7 @@ def EventChain(): app = rx.App(state=rx.State) - token_input = rx.chakra.input( + token_input = rx.input( value=State.router.session.client_token, is_read_only=True, id="token" ) @@ -134,9 +154,7 @@ def EventChain(): def index(): return rx.fragment( token_input, - rx.chakra.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", @@ -300,7 +318,8 @@ def assert_token(event_chain: AppHarness, driver: WebDriver) -> str: token = event_chain.poll_for_value(token_input) assert token is not None - return f"{token}_state.state" + state_name = event_chain.get_full_state_name(["_state"]) + return f"{token}_{state_name}" @pytest.mark.parametrize( @@ -399,16 +418,17 @@ async def test_event_chain_click( exp_event_order: the expected events recorded in the State """ token = assert_token(event_chain, driver) + state_name = event_chain.get_state_name("_state") btn = driver.find_element(By.ID, button_id) btn.click() async def _has_all_events(): return len( - (await event_chain.get_state(token)).substates["state"].event_order + (await event_chain.get_state(token)).substates[state_name].event_order ) == len(exp_event_order) await AppHarness._poll_for_async(_has_all_events) - event_order = (await event_chain.get_state(token)).substates["state"].event_order + event_order = (await event_chain.get_state(token)).substates[state_name].event_order assert event_order == exp_event_order @@ -453,14 +473,15 @@ async def test_event_chain_on_load( assert event_chain.frontend_url is not None driver.get(event_chain.frontend_url + uri) token = assert_token(event_chain, driver) + state_name = event_chain.get_state_name("_state") async def _has_all_events(): return len( - (await event_chain.get_state(token)).substates["state"].event_order + (await event_chain.get_state(token)).substates[state_name].event_order ) == len(exp_event_order) await AppHarness._poll_for_async(_has_all_events) - backend_state = (await event_chain.get_state(token)).substates["state"] + backend_state = (await event_chain.get_state(token)).substates[state_name] assert backend_state.event_order == exp_event_order assert backend_state.is_hydrated is True @@ -525,6 +546,7 @@ async def test_event_chain_on_mount( assert event_chain.frontend_url is not None driver.get(event_chain.frontend_url + uri) token = assert_token(event_chain, driver) + state_name = event_chain.get_state_name("_state") unmount_button = driver.find_element(By.ID, "unmount") assert unmount_button @@ -532,11 +554,11 @@ async def test_event_chain_on_mount( async def _has_all_events(): return len( - (await event_chain.get_state(token)).substates["state"].event_order + (await event_chain.get_state(token)).substates[state_name].event_order ) == len(exp_event_order) await AppHarness._poll_for_async(_has_all_events) - event_order = (await event_chain.get_state(token)).substates["state"].event_order + event_order = (await event_chain.get_state(token)).substates[state_name].event_order assert event_order == exp_event_order diff --git a/tests/integration/test_exception_handlers.py b/tests/integration/test_exception_handlers.py new file mode 100644 index 000000000..00683c48b --- /dev/null +++ b/tests/integration/test_exception_handlers.py @@ -0,0 +1,154 @@ +"""Integration tests for event exception handlers.""" + +from __future__ import annotations + +import time +from typing import Generator, Type + +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.remote.webdriver import WebDriver +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait + +from reflex.testing import AppHarness + + +def TestApp(): + """A test app for event exception handler integration.""" + import reflex as rx + + class TestAppConfig(rx.Config): + """Config for the TestApp app.""" + + pass + + class TestAppState(rx.State): + """State for the TestApp app.""" + + def divide_by_number(self, number: int): + """Divide by number and print the result. + + Args: + number: number to divide by + + """ + print(1 / number) + + app = rx.App(state=rx.State) + + @app.add_page + def index(): + return rx.vstack( + rx.button( + "induce_frontend_error", + on_click=rx.call_script("induce_frontend_error()"), + id="induce-frontend-error-btn", + ), + rx.button( + "induce_backend_error", + on_click=lambda: TestAppState.divide_by_number(0), # type: ignore + id="induce-backend-error-btn", + ), + ) + + +@pytest.fixture(scope="module") +def test_app( + app_harness_env: Type[AppHarness], tmp_path_factory +) -> Generator[AppHarness, None, None]: + """Start TestApp app at tmp_path via AppHarness. + + Args: + app_harness_env: either AppHarness (dev) or AppHarnessProd (prod) + tmp_path_factory: pytest tmp_path_factory fixture + + Yields: + running AppHarness instance + + """ + with app_harness_env.create( + root=tmp_path_factory.mktemp("test_app"), + app_name=f"testapp_{app_harness_env.__name__.lower()}", + app_source=TestApp, # type: ignore + ) as harness: + yield harness + + +@pytest.fixture +def driver(test_app: AppHarness) -> Generator[WebDriver, None, None]: + """Get an instance of the browser open to the test_app app. + + Args: + test_app: harness for TestApp app + + Yields: + WebDriver instance. + + """ + assert test_app.app_instance is not None, "app is not running" + driver = test_app.frontend() + try: + yield driver + finally: + driver.quit() + + +def test_frontend_exception_handler_during_runtime( + driver: WebDriver, + capsys, +): + """Test calling frontend exception handler during runtime. + + We send an event containing a call to a non-existent function in the frontend. + This should trigger the default frontend exception handler. + + Args: + driver: WebDriver instance. + capsys: pytest fixture for capturing stdout and stderr. + + """ + reset_button = WebDriverWait(driver, 20).until( + EC.element_to_be_clickable((By.ID, "induce-frontend-error-btn")) + ) + + reset_button.click() + + # Wait for the error to be logged + time.sleep(2) + + captured_default_handler_output = capsys.readouterr() + assert ( + "induce_frontend_error" in captured_default_handler_output.out + and "ReferenceError" in captured_default_handler_output.out + ) + + +def test_backend_exception_handler_during_runtime( + driver: WebDriver, + capsys, +): + """Test calling backend exception handler during runtime. + + We invoke TestAppState.divide_by_zero to induce backend error. + This should trigger the default backend exception handler. + + Args: + driver: WebDriver instance. + capsys: pytest fixture for capturing stdout and stderr. + + """ + reset_button = WebDriverWait(driver, 20).until( + EC.element_to_be_clickable((By.ID, "induce-backend-error-btn")) + ) + + reset_button.click() + + # Wait for the error to be logged + time.sleep(2) + + captured_default_handler_output = capsys.readouterr() + assert ( + "divide_by_number" in captured_default_handler_output.out + and "ZeroDivisionError" in captured_default_handler_output.out + ) diff --git a/integration/test_form_submit.py b/tests/integration/test_form_submit.py similarity index 75% rename from integration/test_form_submit.py rename to tests/integration/test_form_submit.py index f7e2ba47d..3bfcf6e8c 100644 --- a/integration/test_form_submit.py +++ b/tests/integration/test_form_submit.py @@ -1,4 +1,5 @@ """Integration tests for forms.""" + import functools import time from typing import Generator @@ -34,28 +35,29 @@ def FormSubmit(form_component): @app.add_page def index(): return rx.vstack( - rx.chakra.input( + rx.input( value=FormState.router.session.client_token, is_read_only=True, id="token", ), eval(form_component)( rx.vstack( - rx.chakra.input(id="name_input"), - rx.hstack(rx.chakra.pin_input(length=4, id="pin_input")), - rx.chakra.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%"), - rx.chakra.range_slider(id="range_input"), rx.radio(["option1", "option2"], id="radio_input"), rx.radio(FormState.var_options, id="radio_input_var"), - rx.chakra.select(["option1", "option2"], id="select_input"), - rx.chakra.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"), - rx.chakra.input( + rx.input( id="debounce_input", debounce_timeout=0, on_change=rx.console_log, @@ -93,22 +95,19 @@ def FormSubmitName(form_component): @app.add_page def index(): return rx.vstack( - rx.chakra.input( + rx.input( value=FormState.router.session.client_token, is_read_only=True, id="token", ), eval(form_component)( rx.vstack( - rx.chakra.input(name="name_input"), - rx.hstack(rx.chakra.pin_input(length=4, name="pin_input")), - rx.chakra.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%"), - rx.chakra.range_slider(name="range_input"), rx.radio(FormState.options, name="radio_input"), rx.select( FormState.options, @@ -116,21 +115,13 @@ def FormSubmitName(form_component): default_value=FormState.options[0], ), rx.text_area(name="text_area_input"), - rx.chakra.input_group( - rx.chakra.input_left_element(rx.icon(tag="chevron_right")), - rx.chakra.input( - name="debounce_input", - debounce_timeout=0, - on_change=rx.console_log, - ), - rx.chakra.input_right_element(rx.icon(tag="chevron_left")), - ), - rx.chakra.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(rx.icon(tag="plus")), ), on_submit=FormState.form_submit, custom_attrs={"action": "/invalid"}, @@ -147,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="rx.chakra.form"), - functools.partial(FormSubmitName, form_component="rx.chakra.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]: @@ -219,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() @@ -251,10 +228,13 @@ async def test_submit(driver, form_submit: AppHarness): submit_input = driver.find_element(By.CLASS_NAME, "rt-Button") submit_input.click() + state_name = form_submit.get_state_name("_form_state") + full_state_name = form_submit.get_full_state_name(["_form_state"]) + async def get_form_data(): return ( - (await form_submit.get_state(f"{token}_state.form_state")) - .substates["form_state"] + (await form_submit.get_state(f"{token}_{full_state_name}")) + .substates[state_name] .form_data ) @@ -264,16 +244,15 @@ async def test_submit(driver, form_submit: AppHarness): form_data = format.collect_form_dict_names(form_data) + 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_input.py b/tests/integration/test_input.py similarity index 94% rename from integration/test_input.py rename to tests/integration/test_input.py index a57219b97..4679104a4 100644 --- a/integration/test_input.py +++ b/tests/integration/test_input.py @@ -1,4 +1,5 @@ """Integration tests for text input and related components.""" + from typing import Generator import pytest @@ -85,9 +86,12 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness): token = fully_controlled_input.poll_for_value(token_input) assert token + state_name = fully_controlled_input.get_state_name("_state") + full_state_name = fully_controlled_input.get_full_state_name(["_state"]) + async def get_state_text(): - state = await fully_controlled_input.get_state(f"{token}_state.state") - return state.substates["state"].text + state = await fully_controlled_input.get_state(f"{token}_{full_state_name}") + return state.substates[state_name].text # ensure defaults are set correctly assert ( @@ -137,8 +141,10 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness): assert fully_controlled_input.poll_for_value(plain_value_input) == "ifoonitial" # clear the input on the backend - async with fully_controlled_input.modify_state(f"{token}_state.state") as state: - state.substates["state"].text = "" + async with fully_controlled_input.modify_state( + f"{token}_{full_state_name}" + ) as state: + state.substates[state_name].text = "" assert await get_state_text() == "" assert ( fully_controlled_input.poll_for_value( diff --git a/integration/test_large_state.py b/tests/integration/test_large_state.py similarity index 99% rename from integration/test_large_state.py rename to tests/integration/test_large_state.py index 250b751a8..23a534a2b 100644 --- a/integration/test_large_state.py +++ b/tests/integration/test_large_state.py @@ -1,4 +1,5 @@ """Test large state.""" + import time import jinja2 diff --git a/tests/integration/test_lifespan.py b/tests/integration/test_lifespan.py new file mode 100644 index 000000000..22c399c07 --- /dev/null +++ b/tests/integration/test_lifespan.py @@ -0,0 +1,122 @@ +"""Test cases for the FastAPI lifespan integration.""" + +from typing import Generator + +import pytest +from selenium.webdriver.common.by import By + +from reflex.testing import AppHarness + +from .utils import SessionStorage + + +def LifespanApp(): + """App with lifespan tasks and context.""" + import asyncio + from contextlib import asynccontextmanager + + import reflex as rx + + lifespan_task_global = 0 + lifespan_context_global = 0 + + @asynccontextmanager + async def lifespan_context(app, inc: int = 1): + global lifespan_context_global + print(f"Lifespan context entered: {app}.") + lifespan_context_global += inc # pyright: ignore[reportUnboundVariable] + try: + yield + finally: + print("Lifespan context exited.") + lifespan_context_global += inc + + async def lifespan_task(inc: int = 1): + global lifespan_task_global + print("Lifespan global started.") + try: + while True: + lifespan_task_global += inc # pyright: ignore[reportUnboundVariable] + await asyncio.sleep(0.1) + except asyncio.CancelledError as ce: + print(f"Lifespan global cancelled: {ce}.") + lifespan_task_global = 0 + + class LifespanState(rx.State): + @rx.var + def task_global(self) -> int: + return lifespan_task_global + + @rx.var + def context_global(self) -> int: + return lifespan_context_global + + @rx.event + def tick(self, date): + pass + + def index(): + return rx.vstack( + rx.text(LifespanState.task_global, id="task_global"), + rx.text(LifespanState.context_global, id="context_global"), + rx.moment(interval=100, on_change=LifespanState.tick), + ) + + app = rx.App() + app.register_lifespan_task(lifespan_task) + app.register_lifespan_task(lifespan_context, inc=2) + app.add_page(index) + + +@pytest.fixture() +def lifespan_app(tmp_path) -> Generator[AppHarness, None, None]: + """Start LifespanApp app at tmp_path via AppHarness. + + Args: + tmp_path: pytest tmp_path fixture + + Yields: + running AppHarness instance + """ + with AppHarness.create( + root=tmp_path, + app_source=LifespanApp, # type: ignore + ) as harness: + yield harness + + +@pytest.mark.asyncio +async def test_lifespan(lifespan_app: AppHarness): + """Test the lifespan integration. + + Args: + lifespan_app: harness for LifespanApp app + """ + assert lifespan_app.app_module is not None, "app module is not found" + assert lifespan_app.app_instance is not None, "app is not running" + driver = lifespan_app.frontend() + + ss = SessionStorage(driver) + assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found" + + context_global = driver.find_element(By.ID, "context_global") + task_global = driver.find_element(By.ID, "task_global") + + assert context_global.text == "2" + assert lifespan_app.app_module.lifespan_context_global == 2 # type: ignore + + original_task_global_text = task_global.text + original_task_global_value = int(original_task_global_text) + lifespan_app.poll_for_content(task_global, exp_not_equal=original_task_global_text) + assert lifespan_app.app_module.lifespan_task_global > original_task_global_value # type: ignore + assert int(task_global.text) > original_task_global_value + + # Kill the backend + assert lifespan_app.backend is not None + lifespan_app.backend.should_exit = True + if lifespan_app.backend_thread is not None: + lifespan_app.backend_thread.join() + + # Check that the lifespan tasks have been cancelled + assert lifespan_app.app_module.lifespan_task_global == 0 + assert lifespan_app.app_module.lifespan_context_global == 4 diff --git a/integration/test_login_flow.py b/tests/integration/test_login_flow.py similarity index 94% rename from integration/test_login_flow.py rename to tests/integration/test_login_flow.py index bfa57ed02..ecaade9cf 100644 --- a/integration/test_login_flow.py +++ b/tests/integration/test_login_flow.py @@ -1,4 +1,5 @@ """Integration tests for client side storage.""" + from __future__ import annotations from typing import Generator @@ -20,9 +21,11 @@ def LoginSample(): class State(rx.State): auth_token: str = rx.LocalStorage("") + @rx.event def logout(self): self.set_auth_token("") + @rx.event def login(self): self.set_auth_token("12345") yield rx.redirect("/") @@ -136,6 +139,9 @@ def test_login_flow( logout_button = driver.find_element(By.ID, "logout") logout_button.click() - assert login_sample._poll_for(lambda: local_storage["state.state.auth_token"] == "") + state_name = login_sample.get_full_state_name(["_state"]) + assert login_sample._poll_for( + lambda: local_storage[f"{state_name}.auth_token"] == "" + ) with pytest.raises(NoSuchElementException): driver.find_element(By.ID, "auth-token") diff --git a/integration/test_media.py b/tests/integration/test_media.py similarity index 96% rename from integration/test_media.py rename to tests/integration/test_media.py index 3eb1f2007..c10f7102b 100644 --- a/integration/test_media.py +++ b/tests/integration/test_media.py @@ -1,4 +1,5 @@ """Integration tests for media components.""" + from typing import Generator import pytest @@ -21,31 +22,31 @@ def MediaApp(): img.format = format # type: ignore return img - @rx.cached_var + @rx.var(cache=True) def img_default(self) -> Image.Image: return self._blue() - @rx.cached_var + @rx.var(cache=True) def img_bmp(self) -> Image.Image: return self._blue(format="BMP") - @rx.cached_var + @rx.var(cache=True) def img_jpg(self) -> Image.Image: return self._blue(format="JPEG") - @rx.cached_var + @rx.var(cache=True) def img_png(self) -> Image.Image: return self._blue(format="PNG") - @rx.cached_var + @rx.var(cache=True) def img_gif(self) -> Image.Image: return self._blue(format="GIF") - @rx.cached_var + @rx.var(cache=True) def img_webp(self) -> Image.Image: return self._blue(format="WEBP") - @rx.cached_var + @rx.var(cache=True) def img_from_url(self) -> Image.Image: img_url = "https://picsum.photos/id/1/200/300" img_resp = httpx.get(img_url, follow_redirects=True) diff --git a/integration/test_navigation.py b/tests/integration/test_navigation.py similarity index 96% rename from integration/test_navigation.py rename to tests/integration/test_navigation.py index 2c288552f..492ae4510 100644 --- a/integration/test_navigation.py +++ b/tests/integration/test_navigation.py @@ -1,4 +1,5 @@ """Integration tests for links and related components.""" + from typing import Generator from urllib.parse import urlsplit @@ -67,8 +68,7 @@ async def test_navigation_app(navigation_app: AppHarness): driver = navigation_app.frontend() ss = SessionStorage(driver) - token = AppHarness._poll_for(lambda: ss.get("token") is not None) - assert token is not None + assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found" internal_link = driver.find_element(By.ID, "internal") diff --git a/integration/test_server_side_event.py b/tests/integration/test_server_side_event.py similarity index 95% rename from integration/test_server_side_event.py rename to tests/integration/test_server_side_event.py index 067cecfcc..cacf6e1c5 100644 --- a/integration/test_server_side_event.py +++ b/tests/integration/test_server_side_event.py @@ -1,4 +1,5 @@ """Integration tests for special server side events.""" + import time from typing import Generator @@ -13,16 +14,19 @@ def ServerSideEvent(): import reflex as rx class SSState(rx.State): + @rx.event def set_value_yield(self): yield rx.set_value("a", "") yield rx.set_value("b", "") yield rx.set_value("c", "") + @rx.event def set_value_yield_return(self): yield rx.set_value("a", "") yield rx.set_value("b", "") return rx.set_value("c", "") + @rx.event def set_value_return(self): return [ rx.set_value("a", ""), @@ -30,6 +34,7 @@ def ServerSideEvent(): rx.set_value("c", ""), ] + @rx.event def set_value_return_c(self): return rx.set_value("c", "") @@ -38,12 +43,12 @@ def ServerSideEvent(): @app.add_page def index(): return rx.fragment( - rx.chakra.input( + rx.input( id="token", value=SSState.router.session.client_token, is_read_only=True ), - rx.chakra.input(default_value="a", id="a"), - rx.chakra.input(default_value="b", id="b"), - rx.chakra.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_shared_state.py b/tests/integration/test_shared_state.py similarity index 96% rename from integration/test_shared_state.py rename to tests/integration/test_shared_state.py index 363f4536c..6f59c5142 100644 --- a/integration/test_shared_state.py +++ b/tests/integration/test_shared_state.py @@ -1,4 +1,5 @@ """Test shared state.""" + from __future__ import annotations from typing import Generator @@ -11,7 +12,7 @@ from reflex.testing import AppHarness, WebDriver def SharedStateApp(): """Test that shared state works as expected.""" import reflex as rx - from integration.shared.state import SharedState + from tests.integration.shared.state import SharedState class State(SharedState): pass diff --git a/integration/test_state_inheritance.py b/tests/integration/test_state_inheritance.py similarity index 88% rename from integration/test_state_inheritance.py rename to tests/integration/test_state_inheritance.py index 08a7fc951..86ab625e1 100644 --- a/integration/test_state_inheritance.py +++ b/tests/integration/test_state_inheritance.py @@ -45,17 +45,15 @@ def StateInheritance(): """Test that state inheritance works as expected.""" import reflex as rx - class ChildMixin: - # mixin basevars only work with pydantic/rx.Base models - # child_mixin: str = "child_mixin" + class ChildMixin(rx.State, mixin=True): + child_mixin: str = "child_mixin" @rx.var def computed_child_mixin(self) -> str: return "computed_child_mixin" - class Mixin(ChildMixin): - # mixin basevars only work with pydantic/rx.Base models - # mixin: str = "mixin" + class Mixin(ChildMixin, mixin=True): + mixin: str = "mixin" @rx.var def computed_mixin(self) -> str: @@ -64,7 +62,7 @@ def StateInheritance(): def on_click_mixin(self): return rx.call_script("alert('clicked')") - class OtherMixin(rx.Base): + class OtherMixin(rx.State, mixin=True): other_mixin: str = "other_mixin" other_mixin_clicks: int = 0 @@ -78,7 +76,7 @@ def StateInheritance(): f"{self.__class__.__name__}.clicked.{self.other_mixin_clicks}" ) - class Base1(rx.State, Mixin): + class Base1(Mixin, rx.State): _base1: str = "_base1" base1: str = "base1" @@ -122,14 +120,15 @@ def StateInheritance(): def index() -> rx.Component: return rx.vstack( - rx.chakra.input( + rx.input( id="token", value=Base1.router.session.client_token, is_read_only=True ), - # Base 1 + # Base 1 (Mixin, ChildMixin) rx.heading(Base1.computed_mixin, id="base1-computed_mixin"), rx.heading(Base1.computed_basevar, id="base1-computed_basevar"), - rx.heading(Base1.computed_child_mixin, id="base1-child-mixin"), + rx.heading(Base1.computed_child_mixin, id="base1-computed-child-mixin"), rx.heading(Base1.base1, id="base1-base1"), + rx.heading(Base1.child_mixin, id="base1-child-mixin"), rx.button( "Base1.on_click_mixin", on_click=Base1.on_click_mixin, # type: ignore @@ -138,31 +137,33 @@ def StateInheritance(): rx.heading( Base1.computed_backend_vars_base1, id="base1-computed_backend_vars" ), - # Base 2 + # Base 2 (no mixins) rx.heading(Base2.computed_basevar, id="base2-computed_basevar"), rx.heading(Base2.base2, id="base2-base2"), rx.heading( Base2.computed_backend_vars_base2, id="base2-computed_backend_vars" ), - # Child 1 + # Child 1 (Mixin, ChildMixin, OtherMixin) rx.heading(Child1.computed_basevar, id="child1-computed_basevar"), rx.heading(Child1.computed_mixin, id="child1-computed_mixin"), rx.heading(Child1.computed_other_mixin, id="child1-other-mixin"), - rx.heading(Child1.computed_child_mixin, id="child1-child-mixin"), + rx.heading(Child1.computed_child_mixin, id="child1-computed-child-mixin"), rx.heading(Child1.base1, id="child1-base1"), rx.heading(Child1.other_mixin, id="child1-other_mixin"), + rx.heading(Child1.child_mixin, id="child1-child-mixin"), rx.button( "Child1.on_click_other_mixin", on_click=Child1.on_click_other_mixin, # type: ignore id="child1-other-mixin-btn", ), - # Child 2 + # Child 2 (Mixin, ChildMixin, OtherMixin) rx.heading(Child2.computed_basevar, id="child2-computed_basevar"), rx.heading(Child2.computed_mixin, id="child2-computed_mixin"), rx.heading(Child2.computed_other_mixin, id="child2-other-mixin"), - rx.heading(Child2.computed_child_mixin, id="child2-child-mixin"), + rx.heading(Child2.computed_child_mixin, id="child2-computed-child-mixin"), rx.heading(Child2.base2, id="child2-base2"), rx.heading(Child2.other_mixin, id="child2-other_mixin"), + rx.heading(Child2.child_mixin, id="child2-child-mixin"), rx.button( "Child2.on_click_mixin", on_click=Child2.on_click_mixin, # type: ignore @@ -173,15 +174,16 @@ def StateInheritance(): on_click=Child2.on_click_other_mixin, # type: ignore id="child2-other-mixin-btn", ), - # Child 3 + # Child 3 (Mixin, ChildMixin, OtherMixin) rx.heading(Child3.computed_basevar, id="child3-computed_basevar"), rx.heading(Child3.computed_mixin, id="child3-computed_mixin"), rx.heading(Child3.computed_other_mixin, id="child3-other-mixin"), rx.heading(Child3.computed_childvar, id="child3-computed_childvar"), - rx.heading(Child3.computed_child_mixin, id="child3-child-mixin"), + rx.heading(Child3.computed_child_mixin, id="child3-computed-child-mixin"), rx.heading(Child3.child3, id="child3-child3"), rx.heading(Child3.base2, id="child3-base2"), rx.heading(Child3.other_mixin, id="child3-other_mixin"), + rx.heading(Child3.child_mixin, id="child3-child-mixin"), rx.button( "Child3.on_click_mixin", on_click=Child3.on_click_mixin, # type: ignore @@ -282,7 +284,9 @@ def test_state_inheritance( base1_computed_basevar = driver.find_element(By.ID, "base1-computed_basevar") assert base1_computed_basevar.text == "computed_basevar1" - base1_computed_child_mixin = driver.find_element(By.ID, "base1-child-mixin") + base1_computed_child_mixin = driver.find_element( + By.ID, "base1-computed-child-mixin" + ) assert base1_computed_child_mixin.text == "computed_child_mixin" base1_base1 = driver.find_element(By.ID, "base1-base1") @@ -293,6 +297,9 @@ def test_state_inheritance( ) assert base1_computed_backend_vars.text == "_base1" + base1_child_mixin = driver.find_element(By.ID, "base1-child-mixin") + assert base1_child_mixin.text == "child_mixin" + # Base 2 base2_computed_basevar = driver.find_element(By.ID, "base2-computed_basevar") assert base2_computed_basevar.text == "computed_basevar2" @@ -315,7 +322,9 @@ def test_state_inheritance( child1_computed_other_mixin = driver.find_element(By.ID, "child1-other-mixin") assert child1_computed_other_mixin.text == "other_mixin" - child1_computed_child_mixin = driver.find_element(By.ID, "child1-child-mixin") + child1_computed_child_mixin = driver.find_element( + By.ID, "child1-computed-child-mixin" + ) assert child1_computed_child_mixin.text == "computed_child_mixin" child1_base1 = driver.find_element(By.ID, "child1-base1") @@ -324,6 +333,9 @@ def test_state_inheritance( child1_other_mixin = driver.find_element(By.ID, "child1-other_mixin") assert child1_other_mixin.text == "other_mixin" + child1_child_mixin = driver.find_element(By.ID, "child1-child-mixin") + assert child1_child_mixin.text == "child_mixin" + # Child 2 child2_computed_basevar = driver.find_element(By.ID, "child2-computed_basevar") assert child2_computed_basevar.text == "computed_basevar2" @@ -334,7 +346,9 @@ def test_state_inheritance( child2_computed_other_mixin = driver.find_element(By.ID, "child2-other-mixin") assert child2_computed_other_mixin.text == "other_mixin" - child2_computed_child_mixin = driver.find_element(By.ID, "child2-child-mixin") + child2_computed_child_mixin = driver.find_element( + By.ID, "child2-computed-child-mixin" + ) assert child2_computed_child_mixin.text == "computed_child_mixin" child2_base2 = driver.find_element(By.ID, "child2-base2") @@ -343,6 +357,9 @@ def test_state_inheritance( child2_other_mixin = driver.find_element(By.ID, "child2-other_mixin") assert child2_other_mixin.text == "other_mixin" + child2_child_mixin = driver.find_element(By.ID, "child2-child-mixin") + assert child2_child_mixin.text == "child_mixin" + # Child 3 child3_computed_basevar = driver.find_element(By.ID, "child3-computed_basevar") assert child3_computed_basevar.text == "computed_basevar2" @@ -356,7 +373,9 @@ def test_state_inheritance( child3_computed_childvar = driver.find_element(By.ID, "child3-computed_childvar") assert child3_computed_childvar.text == "computed_childvar" - child3_computed_child_mixin = driver.find_element(By.ID, "child3-child-mixin") + child3_computed_child_mixin = driver.find_element( + By.ID, "child3-computed-child-mixin" + ) assert child3_computed_child_mixin.text == "computed_child_mixin" child3_child3 = driver.find_element(By.ID, "child3-child3") @@ -368,6 +387,9 @@ def test_state_inheritance( child3_other_mixin = driver.find_element(By.ID, "child3-other_mixin") assert child3_other_mixin.text == "other_mixin" + child3_child_mixin = driver.find_element(By.ID, "child3-child-mixin") + assert child3_child_mixin.text == "child_mixin" + child3_computed_backend_vars = driver.find_element( By.ID, "child3-computed_backend_vars" ) diff --git a/integration/test_tailwind.py b/tests/integration/test_tailwind.py similarity index 80% rename from integration/test_tailwind.py rename to tests/integration/test_tailwind.py index ce6bab225..bda664a1c 100644 --- a/integration/test_tailwind.py +++ b/tests/integration/test_tailwind.py @@ -25,21 +25,27 @@ def TailwindApp( paragraph_text: Text for the paragraph. paragraph_class_name: Tailwind class_name for the paragraph. """ + from pathlib import Path + import reflex as rx - import reflex.components.radix.themes as rdxt class UnusedState(rx.State): pass def index(): return rx.el.div( - rx.chakra.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), - rdxt.text(paragraph_text, as_="p", 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"), id="p-content", ) - app = rx.App(style={"font_family": "monospace"}) + assets = Path(__file__).resolve().parent.parent / "assets" + assets.mkdir(exist_ok=True) + stylesheet = assets / "test_styles.css" + stylesheet.write_text(".external { color: rgba(0, 0, 255, 0.5) }") + app = rx.App(style={"font_family": "monospace"}, stylesheets=[stylesheet.name]) app.add_page(index) if tailwind_disabled: config = rx.config.get_config() @@ -108,3 +114,9 @@ def test_tailwind_app(tailwind_app: AppHarness, tailwind_disabled: bool): else: # expect "text-red-500" from tailwind utility class assert p.value_of_css_property("color") in TEXT_RED_500_COLOR + + # Assert external stylesheet is applying rules + external = driver.find_elements(By.CLASS_NAME, "external") + assert len(external) == 1 + for ext_div in external: + assert ext_div.value_of_css_property("color") == "rgba(0, 0, 255, 0.5)" diff --git a/integration/test_upload.py b/tests/integration/test_upload.py similarity index 92% rename from integration/test_upload.py rename to tests/integration/test_upload.py index 44fec6b46..813313462 100644 --- a/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -1,4 +1,5 @@ """Integration tests for file upload.""" + from __future__ import annotations import asyncio @@ -43,7 +44,7 @@ def UploadFile(): def index(): return rx.vstack( - rx.chakra.input( + rx.input( value=UploadState.router.session.client_token, is_read_only=True, id="token", @@ -173,7 +174,9 @@ async def test_upload_file( # wait for the backend connection to send the token token = upload_file.poll_for_value(token_input) assert token is not None - substate_token = f"{token}_state.upload_state" + full_state_name = upload_file.get_full_state_name(["_upload_state"]) + state_name = upload_file.get_state_name("_upload_state") + substate_token = f"{token}_{full_state_name}" suffix = "_secondary" if secondary else "" @@ -196,7 +199,7 @@ async def test_upload_file( async def get_file_data(): return ( (await upload_file.get_state(substate_token)) - .substates["upload_state"] + .substates[state_name] ._file_data ) @@ -211,8 +214,8 @@ async def test_upload_file( state = await upload_file.get_state(substate_token) if secondary: # only the secondary form tracks progress and chain events - assert state.substates["upload_state"].event_order.count("upload_progress") == 1 - assert state.substates["upload_state"].event_order.count("chain_event") == 1 + assert state.substates[state_name].event_order.count("upload_progress") == 1 + assert state.substates[state_name].event_order.count("chain_event") == 1 @pytest.mark.asyncio @@ -230,7 +233,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver): # wait for the backend connection to send the token token = upload_file.poll_for_value(token_input) assert token is not None - substate_token = f"{token}_state.upload_state" + full_state_name = upload_file.get_full_state_name(["_upload_state"]) + state_name = upload_file.get_state_name("_upload_state") + substate_token = f"{token}_{full_state_name}" upload_box = driver.find_element(By.XPATH, "//input[@type='file']") assert upload_box @@ -260,7 +265,7 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver): async def get_file_data(): return ( (await upload_file.get_state(substate_token)) - .substates["upload_state"] + .substates[state_name] ._file_data ) @@ -342,7 +347,9 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive # wait for the backend connection to send the token token = upload_file.poll_for_value(token_input) assert token is not None - substate_token = f"{token}_state.upload_state" + state_name = upload_file.get_state_name("_upload_state") + state_full_name = upload_file.get_full_state_name(["_upload_state"]) + substate_token = f"{token}_{state_full_name}" upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1] upload_button = driver.find_element(By.ID, f"upload_button_secondary") @@ -361,7 +368,7 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive # look up the backend state and assert on progress state = await upload_file.get_state(substate_token) - assert state.substates["upload_state"].progress_dicts - assert exp_name not in state.substates["upload_state"]._file_data + assert state.substates[state_name].progress_dicts + assert exp_name not in state.substates[state_name]._file_data target_file.unlink() diff --git a/tests/integration/test_urls.py b/tests/integration/test_urls.py new file mode 100755 index 000000000..81689aa18 --- /dev/null +++ b/tests/integration/test_urls.py @@ -0,0 +1,68 @@ +"""Integration tests for all urls in Reflex.""" + +import os +import re +from pathlib import Path + +import pytest +import requests + + +def check_urls(repo_dir: Path): + """Check that all URLs in the repo are valid and secure. + + Args: + repo_dir: The directory of the repo. + + Returns: + A list of errors. + """ + url_pattern = re.compile(r'http[s]?://reflex\.dev[^\s")]*') + errors = [] + + for root, _dirs, files in os.walk(repo_dir): + root = Path(root) + if root.stem == "__pycache__": + continue + + for file_name in files: + if not file_name.endswith(".py") and not file_name.endswith(".md"): + continue + + file_path = root / file_name + try: + for line in file_path.read_text().splitlines(): + urls = url_pattern.findall(line) + for url in set(urls): + if url.startswith("http://"): + errors.append( + f"Found insecure HTTP URL: {url} in {file_path}" + ) + url = url.strip('"\n') + try: + response = requests.head( + url, allow_redirects=True, timeout=5 + ) + response.raise_for_status() + except requests.RequestException as e: + errors.append( + f"Error accessing URL: {url} in {file_path} | Error: {e}, , Check your path ends with a /" + ) + except Exception as e: + errors.append(f"Error reading file: {file_path} | Error: {e}") + + return errors + + +@pytest.mark.parametrize( + "repo_dir", + [Path(__file__).resolve().parent.parent / "reflex"], +) +def test_find_and_check_urls(repo_dir: Path): + """Test that all URLs in the repo are valid and secure. + + Args: + repo_dir: The directory of the repo. + """ + errors = check_urls(repo_dir) + assert not errors, "\n".join(errors) diff --git a/integration/test_var_operations.py b/tests/integration/test_var_operations.py similarity index 95% rename from integration/test_var_operations.py rename to tests/integration/test_var_operations.py index 9f8803dbe..cae56e1a8 100644 --- a/integration/test_var_operations.py +++ b/tests/integration/test_var_operations.py @@ -1,4 +1,5 @@ """Integration tests for var operations.""" + from typing import Generator import pytest @@ -14,6 +15,11 @@ def VarOperations(): from typing import Dict, List import reflex as rx + 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 @@ -24,12 +30,13 @@ 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" str_var4: str = "a long string" - dict1: Dict = {1: 2} - dict2: Dict = {3: 4} + dict1: Dict[int, int] = {1: 2} + dict2: Dict[int, int] = {3: 4} html_str: str = "
hello
" app = rx.App(state=rx.State) @@ -469,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( @@ -542,33 +550,30 @@ def VarOperations(): VarOperationState.html_str, id="html_str", ), - rx.chakra.highlight( - "second", - query=[VarOperationState.str_var2], - ), - rx.text(rx.Var.range(2, 5).join(","), id="list_join_range1"), - rx.text(rx.Var.range(2, 10, 2).join(","), id="list_join_range2"), - rx.text(rx.Var.range(5, 0, -1).join(","), id="list_join_range3"), - rx.text(rx.Var.range(0, 3).join(","), id="list_join_range4"), + 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"), + rx.text(ArrayVar.range(0, 3).join(","), id="list_join_range4"), rx.box( rx.foreach( - rx.Var.range(0, 2), + ArrayVar.range(0, 2), lambda x: rx.text(VarOperationState.list1[x], as_="p"), ), id="foreach_list_arg", ), rx.box( rx.foreach( - rx.Var.range(0, 2), + ArrayVar.range(0, 2), lambda x, ix: rx.text(VarOperationState.list1[ix], as_="p"), ), id="foreach_list_ix", ), rx.box( rx.foreach( - rx.Var.create_safe(list(range(0, 3))).to(List[int]), + LiteralVar.create(list(range(0, 3))).to(ArrayVar, List[int]), lambda x: rx.foreach( - rx.Var.range(x), + ArrayVar.range(x), lambda y: rx.text(VarOperationState.list1[y], as_="p"), ), ), @@ -583,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", + ), ) @@ -744,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"), @@ -779,9 +795,12 @@ 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: + print(tag) assert driver.find_element(By.ID, tag).text == expected # Highlight component with var query (does not plumb ID) diff --git a/tests/integration/tests_playwright/test_stateless_app.py b/tests/integration/tests_playwright/test_stateless_app.py new file mode 100644 index 000000000..129b69dc7 --- /dev/null +++ b/tests/integration/tests_playwright/test_stateless_app.py @@ -0,0 +1,59 @@ +"""Integration tests for a stateless app.""" + +from typing import Generator + +import httpx +import pytest +from playwright.sync_api import Page, expect + +import reflex as rx +from reflex.testing import AppHarness + + +def StatelessApp(): + """A stateless app that renders a heading.""" + import reflex as rx + + def index(): + return rx.heading("This is a stateless app") + + app = rx.App() + app.add_page(index) + + +@pytest.fixture(scope="module") +def stateless_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Create a stateless app AppHarness. + + Args: + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + AppHarness: A harness for testing the stateless app. + """ + with AppHarness.create( + root=tmp_path_factory.mktemp("stateless_app"), + app_source=StatelessApp, # type: ignore + ) as harness: + yield harness + + +def test_statelessness(stateless_app: AppHarness, page: Page): + """Test that the stateless app renders a heading but backend/_event is not mounted. + + Args: + stateless_app: A harness for testing the stateless app. + page: A Playwright page. + """ + assert stateless_app.frontend_url is not None + assert stateless_app.backend is not None + assert stateless_app.backend.started + + res = httpx.get(rx.config.get_config().api_url + "/_event") + assert res.status_code == 404 + + res2 = httpx.get(rx.config.get_config().api_url + "/ping") + assert res2.status_code == 200 + + page.goto(stateless_app.frontend_url) + expect(page.get_by_role("heading")).to_have_text("This is a stateless app") diff --git a/tests/integration/tests_playwright/test_table.py b/tests/integration/tests_playwright/test_table.py new file mode 100644 index 000000000..917247b89 --- /dev/null +++ b/tests/integration/tests_playwright/test_table.py @@ -0,0 +1,100 @@ +"""Integration tests for table and related components.""" + +from typing import Generator + +import pytest +from playwright.sync_api import Page + +from reflex.testing import AppHarness + +expected_col_headers = ["Name", "Age", "Location"] +expected_row_headers = ["John", "Jane", "Joe"] +expected_cells_data = [ + ["30", "New York"], + ["31", "San Fransisco"], + ["32", "Los Angeles"], +] + + +def Table(): + """App using table component.""" + import reflex as rx + + app = rx.App(state=rx.State) + + @app.add_page + def index(): + return rx.center( + 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%", + ), + ) + + +@pytest.fixture() +def table_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start Table app at tmp_path via AppHarness. + + Args: + tmp_path_factory: pytest tmp_path_factory fixture + + Yields: + running AppHarness instance + + """ + with AppHarness.create( + root=tmp_path_factory.mktemp("table"), + app_source=Table, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +def test_table(page: Page, table_app: AppHarness): + """Test that a table component is rendered properly. + + Args: + table_app: Harness for Table app + page: Playwright page instance + """ + assert table_app.frontend_url is not None, "frontend url is not available" + + page.goto(table_app.frontend_url) + table = page.get_by_role("table") + + # Check column headers + headers = table.get_by_role("columnheader").all_inner_texts() + assert headers == expected_col_headers + + # Check rows headers + rows = table.get_by_role("rowheader").all_inner_texts() + assert rows == expected_row_headers + + # Check cells + rows = table.get_by_role("cell").all_inner_texts() + for i, expected_row in enumerate(expected_cells_data): + assert [rows[idx := i * 2], rows[idx + 1]] == expected_row diff --git a/integration/utils.py b/tests/integration/utils.py similarity index 86% rename from integration/utils.py rename to tests/integration/utils.py index bcbd6c497..d993ea720 100644 --- a/integration/utils.py +++ b/tests/integration/utils.py @@ -1,4 +1,5 @@ """Helper utilities for integration tests.""" + from __future__ import annotations from contextlib import contextmanager @@ -54,7 +55,9 @@ class LocalStorage: Returns: The number of items in local storage. """ - return int(self.driver.execute_script("return window.localStorage.length;")) + return int( + self.driver.execute_script(f"return window.{self.storage_key}.length;") + ) def items(self) -> dict[str, str]: """Get all items in local storage. @@ -63,7 +66,7 @@ class LocalStorage: A dict mapping keys to values. """ return self.driver.execute_script( - "var ls = window.localStorage, items = {}; " + f"var ls = window.{self.storage_key}, items = {{}}; " "for (var i = 0, k; i < ls.length; ++i) " " items[k = ls.key(i)] = ls.getItem(k); " "return items; " @@ -76,7 +79,7 @@ class LocalStorage: A list of keys. """ return self.driver.execute_script( - "var ls = window.localStorage, keys = []; " + f"var ls = window.{self.storage_key}, keys = []; " "for (var i = 0; i < ls.length; ++i) " " keys[i] = ls.key(i); " "return keys; " @@ -92,7 +95,7 @@ class LocalStorage: The value of the key. """ return self.driver.execute_script( - "return window.localStorage.getItem(arguments[0]);", key + f"return window.{self.storage_key}.getItem(arguments[0]);", key ) def set(self, key, value) -> None: @@ -103,7 +106,9 @@ class LocalStorage: value: The value to set the key to. """ self.driver.execute_script( - "window.localStorage.setItem(arguments[0], arguments[1]);", key, value + f"window.{self.storage_key}.setItem(arguments[0], arguments[1]);", + key, + value, ) def has(self, key) -> bool: @@ -123,11 +128,13 @@ class LocalStorage: Args: key: The key to remove. """ - self.driver.execute_script("window.localStorage.removeItem(arguments[0]);", key) + self.driver.execute_script( + f"window.{self.storage_key}.removeItem(arguments[0]);", key + ) def clear(self) -> None: """Clear all local storage.""" - self.driver.execute_script("window.localStorage.clear();") + self.driver.execute_script(f"window.{self.storage_key}.clear();") def __getitem__(self, key) -> str: """Get a key from local storage. diff --git a/tests/test_init.py b/tests/test_init.py deleted file mode 100644 index 4f511983b..000000000 --- a/tests/test_init.py +++ /dev/null @@ -1,9 +0,0 @@ -from reflex import _reverse_mapping # type: ignore - - -def test__reverse_mapping(): - assert _reverse_mapping({"a": ["b"], "c": ["d"]}) == {"b": "a", "d": "c"} - - -def test__reverse_mapping_duplicate(): - assert _reverse_mapping({"a": ["b", "c"], "d": ["b"]}) == {"b": "a", "c": "a"} diff --git a/tests/test_node_version.py b/tests/test_node_version.py new file mode 100644 index 000000000..9555eb524 --- /dev/null +++ b/tests/test_node_version.py @@ -0,0 +1,73 @@ +"""Test for latest node version being able to run reflex.""" + +from __future__ import annotations + +from typing import Any, Generator + +import httpx +import pytest +from playwright.sync_api import Page, expect + +from reflex.testing import AppHarness + + +def TestNodeVersionApp(): + """A test app for node latest version.""" + import reflex as rx + from reflex.utils.prerequisites import get_node_version + + class TestNodeVersionConfig(rx.Config): + pass + + class TestNodeVersionState(rx.State): + @rx.var + def node_version(self) -> str: + return str(get_node_version()) + + app = rx.App() + + @app.add_page + def index(): + return rx.heading("Node Version check v", TestNodeVersionState.node_version) + + +@pytest.fixture() +def node_version_app(tmp_path) -> Generator[AppHarness, Any, None]: + """Fixture to start TestNodeVersionApp app at tmp_path via AppHarness. + + Args: + tmp_path: pytest tmp_path fixture + + Yields: + running AppHarness instance + """ + with AppHarness.create( + root=tmp_path, + app_source=TestNodeVersionApp, # type: ignore + ) as harness: + yield harness + + +def test_node_version(node_version_app: AppHarness, page: Page): + """Test for latest node version being able to run reflex. + + Args: + node_version_app: running AppHarness instance + page: playwright page instance + """ + + def get_latest_node_version(): + response = httpx.get("https://nodejs.org/dist/index.json") + versions = response.json() + + # Assuming the first entry in the API response is the most recent version + if versions: + latest_version = versions[0]["version"] + return latest_version + return None + + assert node_version_app.frontend_url is not None + page.goto(node_version_app.frontend_url) + expect(page.get_by_role("heading")).to_have_text( + f"Node Version check {get_latest_node_version()}" + ) diff --git a/tests/test_var.py b/tests/test_var.py deleted file mode 100644 index a58c49392..000000000 --- a/tests/test_var.py +++ /dev/null @@ -1,1387 +0,0 @@ -import json -import typing -from typing import Dict, List, Set, Tuple - -import pytest -from pandas import DataFrame - -from reflex.base import Base -from reflex.state import BaseState -from reflex.vars import ( - BaseVar, - Var, - 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), -] - - -class ATestState(BaseState): - """Test state.""" - - value: str - dict_val: Dict[str, List] = {} - - -@pytest.fixture -def TestObj(): - class TestObj(Base): - foo: int - bar: str - - return TestObj - - -@pytest.fixture -def ParentState(TestObj): - class ParentState(BaseState): - foo: int - bar: int - - @computed_var - def var_without_annotation(self): - return TestObj - - return ParentState - - -@pytest.fixture -def ChildState(ParentState, TestObj): - class ChildState(ParentState): - @computed_var - def var_without_annotation(self): - return TestObj - - return ChildState - - -@pytest.fixture -def GrandChildState(ChildState, TestObj): - class GrandChildState(ChildState): - @computed_var - def var_without_annotation(self): - return TestObj - - return GrandChildState - - -@pytest.fixture -def StateWithAnyVar(TestObj): - class StateWithAnyVar(BaseState): - @computed_var - def var_without_annotation(self) -> typing.Any: - return TestObj - - return StateWithAnyVar - - -@pytest.fixture -def StateWithCorrectVarAnnotation(): - class StateWithCorrectVarAnnotation(BaseState): - @computed_var - def var_with_annotation(self) -> str: - return "Correct annotation" - - return StateWithCorrectVarAnnotation - - -@pytest.fixture -def StateWithWrongVarAnnotation(TestObj): - class StateWithWrongVarAnnotation(BaseState): - @computed_var - def var_with_annotation(self) -> str: - return TestObj - - return StateWithWrongVarAnnotation - - -@pytest.fixture -def StateWithInitialComputedVar(): - class StateWithInitialComputedVar(BaseState): - @computed_var(initial_value="Initial value") - def var_with_initial_value(self) -> str: - return "Runtime value" - - return StateWithInitialComputedVar - - -@pytest.fixture -def ChildWithInitialComputedVar(StateWithInitialComputedVar): - class ChildWithInitialComputedVar(StateWithInitialComputedVar): - @computed_var(initial_value="Initial value") - def var_with_initial_value_child(self) -> str: - return "Runtime value" - - return ChildWithInitialComputedVar - - -@pytest.fixture -def StateWithRuntimeOnlyVar(): - class StateWithRuntimeOnlyVar(BaseState): - @computed_var(initial_value=None) - def var_raises_at_runtime(self) -> str: - raise ValueError("So nicht, mein Freund") - - return StateWithRuntimeOnlyVar - - -@pytest.fixture -def ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar): - class ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar): - @computed_var(initial_value="Initial value") - def var_raises_at_runtime_child(self) -> str: - raise ValueError("So nicht, mein Freund") - - return ChildWithRuntimeOnlyVar - - -@pytest.mark.parametrize( - "prop,expected", - zip( - test_vars, - [ - "prop1", - "key", - "state.value", - "state.local", - "local2", - ], - ), -) -def test_full_name(prop, expected): - """Test that the full name of a var is correct. - - Args: - prop: The var to test. - expected: The expected full name. - """ - assert prop._var_full_name == expected - - -@pytest.mark.parametrize( - "prop,expected", - zip( - test_vars, - ["{prop1}", "{key}", "{state.value}", "state.local", "local2"], - ), -) -def test_str(prop, expected): - """Test that the string representation of a var is correct. - - Args: - prop: The var to test. - expected: The expected string representation. - """ - assert 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()), - ], -) -def test_default_value(prop, expected): - """Test that the default value of a var is correct. - - Args: - prop: The var to test. - expected: The expected default value. - """ - assert prop.get_default_value() == expected - - -@pytest.mark.parametrize( - "prop,expected", - zip( - test_vars, - [ - "set_prop1", - "set_key", - "state.set_value", - "state.set_local", - "set_local2", - ], - ), -) -def test_get_setter(prop, expected): - """Test that the name of the setter function of a var is correct. - - Args: - prop: The var to test. - expected: The expected name of the setter function. - """ - assert prop.get_setter_name() == 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)), - ( - {"a": 1, "b": 2}, - BaseVar(_var_name='{"a": 1, "b": 2}', _var_type=dict, _var_is_local=True), - ), - ], -) -def test_create(value, expected): - """Test the var create function. - - Args: - 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 - - -def test_create_type_error(): - """Test the var create function when inputs type error.""" - - class ErrorType: - pass - - value = ErrorType() - - with pytest.raises(TypeError): - Var.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 - - -def test_basic_operations(TestObj): - """Test the var operations. - - 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( - Var.create("foo", _var_is_local=False) - == Var.create("bar", _var_is_local=False) - ) - == "{((foo) === (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`))" - ) - 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`))}" - ) - 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()}" - ) - 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`))}" - ) - 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`))}" - ) - - -@pytest.mark.parametrize( - "var, expected", - [ - (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"), - (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"), - "state.foo", - ), - (BaseVar(_var_name="foo", _var_type=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)}}" - - -@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"), - ], -) -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)}}" - - -@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"), - ], -) -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(other_state_var)) - == f"{{{expected}.hasOwnProperty(state.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), - ], -) -def test_var_indexing_lists(var): - """Test that we can index into str, list or tuple vars. - - Args: - 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)}}" - - # Test negative indexing. - assert str(var[-1]) == f"{{{var._var_name}.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]), - ], -) -def test_var_indexing_types(var, type_): - """Test that indexing returns valid types. - - Args: - var : The list, typle base var. - type_ : The type on indexed object. - - """ - assert var[2]._var_type == type_[0] - assert var[3]._var_type == type_[1] - - -def test_var_indexing_str(): - """Test that we can index into str vars.""" - str_var = BaseVar(_var_name="str", _var_type=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)}" - - # Test negative indexing. - assert str(str_var[-1]) == "{str.at(-1)}" - - -@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"}), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - ( - 1, - 2, - ), - ), - (BaseVar(_var_name="lst", _var_type=List[int]), 1.5), - (BaseVar(_var_name="lst", _var_type=List[int]), "str"), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="string_var", _var_type=str), - ), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="float_var", _var_type=float), - ), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="list_var", _var_type=List[int]), - ), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="set_var", _var_type=Set[str]), - ), - ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), - ), - (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"}), - ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="string_var", _var_type=str), - ), - ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="float_var", _var_type=float), - ), - (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"}), - ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="string_var", _var_type=str), - ), - ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="float_var", _var_type=float), - ), - ], -) -def test_var_unsupported_indexing_lists(var, index): - """Test unsupported indexing throws a type error. - - Args: - var: The base var. - index: The base var index. - """ - with pytest.raises(TypeError): - 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), - ], -) -def test_var_list_slicing(var): - """Test that we can slice into str, list or tuple vars. - - 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)}}" - - -def test_dict_indexing(): - """Test that we can index into dict vars.""" - dct = BaseVar(_var_name="dct", _var_type=Dict[str, int]) - - # Check correct indexing. - 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]), - [1, 2], - ), - ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), - {"name": "dict"}, - ), - ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), - {"set"}, - ), - ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), - ( - 1, - 2, - ), - ), - ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="list_var", _var_type=List[int]), - ), - ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="set_var", _var_type=Set[str]), - ), - ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - [1, 2], - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - {"name": "dict"}, - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - {"set"}, - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - ( - 1, - 2, - ), - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="list_var", _var_type=List[int]), - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="set_var", _var_type=Set[str]), - ), - ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), - ), - ], -) -def test_var_unsupported_indexing_dicts(var, index): - """Test unsupported indexing throws a type error. - - Args: - var: The base var. - index: The base var index. - """ - with pytest.raises(TypeError): - var[index] - - -@pytest.mark.parametrize( - "fixture,full_name", - [ - ("ParentState", "parent_state.var_without_annotation"), - ("ChildState", "parent_state__child_state.var_without_annotation"), - ( - "GrandChildState", - "parent_state__child_state__grand_child_state.var_without_annotation", - ), - ("StateWithAnyVar", "state_with_any_var.var_without_annotation"), - ], -) -def test_computed_var_without_annotation_error(request, fixture, full_name): - """Test that a type error is thrown when an attribute of a computed var is - accessed without annotating the computed var. - - Args: - request: Fixture Request. - fixture: The state fixture. - full_name: The full name of the state var. - """ - with pytest.raises(TypeError) as err: - state = request.getfixturevalue(fixture) - state.var_without_annotation.foo - assert ( - err.value.args[0] - == f"You must provide an annotation for the state var `{full_name}`. Annotation cannot be `typing.Any`" - ) - - -@pytest.mark.parametrize( - "fixture,full_name", - [ - ( - "StateWithCorrectVarAnnotation", - "state_with_correct_var_annotation.var_with_annotation", - ), - ( - "StateWithWrongVarAnnotation", - "state_with_wrong_var_annotation.var_with_annotation", - ), - ], -) -def test_computed_var_with_annotation_error(request, fixture, full_name): - """Test that an Attribute error is thrown when a non-existent attribute of an annotated computed var is - accessed or when the wrong annotation is provided to a computed var. - - Args: - request: Fixture Request. - fixture: The state fixture. - full_name: The full name of the state var. - """ - with pytest.raises(AttributeError) as err: - state = request.getfixturevalue(fixture) - state.var_with_annotation.foo - assert ( - err.value.args[0] - == f"The State var `{full_name}` has no attribute 'foo' or may have been annotated wrongly." - ) - - -@pytest.mark.parametrize( - "fixture,var_name,expected_initial,expected_runtime,raises_at_runtime", - [ - ( - "StateWithInitialComputedVar", - "var_with_initial_value", - "Initial value", - "Runtime value", - False, - ), - ( - "ChildWithInitialComputedVar", - "var_with_initial_value_child", - "Initial value", - "Runtime value", - False, - ), - ( - "StateWithRuntimeOnlyVar", - "var_raises_at_runtime", - None, - None, - True, - ), - ( - "ChildWithRuntimeOnlyVar", - "var_raises_at_runtime_child", - "Initial value", - None, - True, - ), - ], -) -def test_state_with_initial_computed_var( - request, fixture, var_name, expected_initial, expected_runtime, raises_at_runtime -): - """Test that the initial and runtime values of a computed var are correct. - - Args: - request: Fixture Request. - fixture: The state fixture. - var_name: The name of the computed var. - expected_initial: The expected initial value of the computed var. - expected_runtime: The expected runtime value of the computed var. - raises_at_runtime: Whether the computed var is runtime only. - """ - state = request.getfixturevalue(fixture)() - state_name = state.get_full_name() - initial_dict = state.dict(initial=True)[state_name] - assert initial_dict[var_name] == expected_initial - - if raises_at_runtime: - with pytest.raises(ValueError): - state.dict()[state_name][var_name] - else: - runtime_dict = state.dict()[state_name] - assert runtime_dict[var_name] == expected_runtime - - -@pytest.mark.parametrize( - "out, expected", - [ - (f"{BaseVar(_var_name='var', _var_type=str)}", "${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 local f-string {BaseVar(_var_name='x', _var_is_local=True, _var_type=str)}", - "testing local f-string x", - ), - ], -) -def test_fstrings(out, expected): - assert out == expected - - -@pytest.mark.parametrize( - ("value", "expect_state"), - [ - ([1], ""), - ({"a": 1}, ""), - ([Var.create_safe(1)._var_set_state("foo")], "foo"), - ({"a": Var.create_safe(1)._var_set_state("foo")}, "foo"), - ], -) -def test_extract_state_from_container(value, expect_state): - """Test that _var_state is extracted from containers containing BaseVar. - - Args: - value: The value to create a var from. - expect_state: The expected state. - """ - assert Var.create_safe(value)._var_state == expect_state - - -@pytest.mark.parametrize( - "value", - [ - "var", - "\nvar", - ], -) -def test_fstring_roundtrip(value): - """Test that f-string roundtrip carries state. - - 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}") - 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 - - -@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), - ], -) -def test_unsupported_types_for_reverse(var): - """Test that unsupported types for reverse throw a type error. - - Args: - var: The base var. - """ - with pytest.raises(TypeError) as err: - var.reverse() - assert err.value.args[0] == f"Cannot reverse non-list var 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), - ], -) -def test_unsupported_types_for_contains(var): - """Test that unsupported types for contains throw a type error. - - Args: - var: The base var. - """ - with pytest.raises(TypeError) as err: - assert var.contains(1) - assert ( - err.value.args[0] - == f"Var 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), - ], -) -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 ( - err.value.args[0] - == f"'in ' requires string as left operand, not {other._var_type}" - ) - - -def test_unsupported_default_contains(): - with pytest.raises(TypeError) as err: - assert 1 in BaseVar(_var_name="var", _var_type=str) - assert ( - err.value.args[0] - == "'in' operator not supported for Var types, use Var.contains() instead." - ) - - -@pytest.mark.parametrize( - "operand1_var,operand2_var,operators", - [ - ( - Var.create(10), - Var.create(5), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "&", - ], - ), - ( - Var.create(10.5), - Var.create(5), - ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], - ), - ( - Var.create(5), - Var.create(True), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "&", - ], - ), - ( - Var.create(10.5), - Var.create(5.5), - ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], - ), - ( - Var.create(10.5), - Var.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), ["*"]), - ( - Var.create(True), - Var.create(True), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "&", - ], - ), - ], -) -def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): - """Test that operations do not raise a TypeError. - - Args: - operand1_var: left operand. - operand2_var: right operand. - 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) - - -@pytest.mark.parametrize( - "operand1_var,operand2_var,operators", - [ - ( - Var.create(10), - Var.create(5), - [ - "^", - "<<", - ">>", - ], - ), - ( - Var.create(10.5), - Var.create(5), - [ - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create(10.5), - Var.create(True), - [ - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create(10.5), - Var.create(5.5), - [ - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - 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), - [ - "+", - "-", - "/", - "//", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create([10, 20]), - Var.create("5"), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create([10, 20]), - Var.create({"key": "value"}), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create([10, 20]), - Var.create(5.5), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create({"key": "value"}), - Var.create({"another_key": "another_value"}), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create({"key": "value"}), - Var.create(5), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create({"key": "value"}), - Var.create(True), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create({"key": "value"}), - Var.create(5.5), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ( - Var.create({"key": "value"}), - Var.create("5"), - [ - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "^", - "<<", - ">>", - "&", - ], - ), - ], -) -def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): - for operator in operators: - with pytest.raises(TypeError): - operand1_var.operation(op=operator, other=operand2_var) - - with pytest.raises(TypeError): - 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"}'), - (Var.create(ATestState.value, _var_is_string=True), "a_test_state.value"), - ( - Var.create(f"{ATestState.value} string", _var_is_string=True), - "`${a_test_state.value} string`", - ), - (Var.create(ATestState.dict_val), "a_test_state.dict_val"), - ], -) -def test_var_name_unwrapped(var, expected): - assert var._var_name_unwrapped == expected diff --git a/tests/units/__init__.py b/tests/units/__init__.py new file mode 100644 index 000000000..d0196603c --- /dev/null +++ b/tests/units/__init__.py @@ -0,0 +1,5 @@ +"""Root directory for tests.""" + +import os + +from reflex import constants diff --git a/tests/compiler/__init__.py b/tests/units/compiler/__init__.py similarity index 100% rename from tests/compiler/__init__.py rename to tests/units/compiler/__init__.py diff --git a/tests/compiler/test_compiler.py b/tests/units/compiler/test_compiler.py similarity index 94% rename from tests/compiler/test_compiler.py rename to tests/units/compiler/test_compiler.py index b6191974a..afacf43c5 100644 --- a/tests/compiler/test_compiler.py +++ b/tests/units/compiler/test_compiler.py @@ -1,11 +1,10 @@ -import os +from pathlib import Path from typing import List import pytest from reflex.compiler import compiler, utils -from reflex.utils import imports -from reflex.utils.imports import ImportVar +from reflex.utils.imports import ImportVar, ParsedImportDict @pytest.mark.parametrize( @@ -93,7 +92,7 @@ def test_compile_import_statement( ), ], ) -def test_compile_imports(import_dict: imports.ImportDict, test_dicts: List[dict]): +def test_compile_imports(import_dict: ParsedImportDict, test_dicts: List[dict]): """Test the compile_imports function. Args: @@ -131,11 +130,11 @@ def test_compile_stylesheets(tmp_path, mocker): ] assert compiler.compile_root_stylesheet(stylesheets) == ( - os.path.join(".web", "styles", "styles.css"), + str(Path(".web") / "styles" / "styles.css"), f"@import url('./tailwind.css'); \n" f"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n" f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n" - f"@import url('@/styles.css'); \n" + f"@import url('../public/styles.css'); \n" f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n", ) @@ -165,8 +164,8 @@ def test_compile_stylesheets_exclude_tailwind(tmp_path, mocker): ] assert compiler.compile_root_stylesheet(stylesheets) == ( - os.path.join(".web", "styles", "styles.css"), - "@import url('@/styles.css'); \n", + str(Path(".web") / "styles" / "styles.css"), + "@import url('../public/styles.css'); \n", ) diff --git a/tests/compiler/test_compiler_utils.py b/tests/units/compiler/test_compiler_utils.py similarity index 100% rename from tests/compiler/test_compiler_utils.py rename to tests/units/compiler/test_compiler_utils.py diff --git a/tests/components/__init__.py b/tests/units/components/__init__.py similarity index 100% rename from tests/components/__init__.py rename to tests/units/components/__init__.py diff --git a/tests/components/base/test_bare.py b/tests/units/components/base/test_bare.py similarity index 53% rename from tests/components/base/test_bare.py rename to tests/units/components/base/test_bare.py index 264d136cb..c30ffaf15 100644 --- a/tests/components/base/test_bare.py +++ b/tests/units/components/base/test_bare.py @@ -1,16 +1,21 @@ import pytest from reflex.components.base.bare import Bare +from reflex.vars.base import Var + +STATE_VAR = Var(_js_expr="default_state.name") @pytest.mark.parametrize( "contents,expected", [ - ("hello", "hello"), - ("{}", "{}"), - (None, ""), - ("${default_state.name}", "${default_state.name}"), - ("{state.name}", "{state.name}"), + ("hello", '{"hello"}'), + ("{}", '{"{}"}'), + (None, '{""}'), + (STATE_VAR, "{default_state.name}"), + # This behavior is now unsupported. + # ("${default_state.name}", "${default_state.name}"), + # ("{state.name}", "{state.name}"), ], ) def test_fstrings(contents, expected): diff --git a/tests/units/components/base/test_link.py b/tests/units/components/base/test_link.py new file mode 100644 index 000000000..7713330c4 --- /dev/null +++ b/tests/units/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/base/test_script.py b/tests/units/components/base/test_script.py similarity index 73% rename from tests/components/base/test_script.py rename to tests/units/components/base/test_script.py index 7ccdc0634..b909b6c61 100644 --- a/tests/components/base/test_script.py +++ b/tests/units/components/base/test_script.py @@ -1,6 +1,8 @@ """Test that Script from next/script renders correctly.""" + import pytest +import reflex as rx from reflex.components.base.script import Script from reflex.state import BaseState @@ -12,7 +14,7 @@ def test_script_inline(): assert render_dict["name"] == "Script" assert not render_dict["contents"] assert len(render_dict["children"]) == 1 - assert render_dict["children"][0]["contents"] == "{`let x = 42`}" + assert render_dict["children"][0]["contents"] == '{"let x = 42"}' def test_script_src(): @@ -22,7 +24,7 @@ def test_script_src(): assert render_dict["name"] == "Script" assert not render_dict["contents"] assert not render_dict["children"] - assert "src={`foo.js`}" in render_dict["props"] + assert 'src={"foo.js"}' in render_dict["props"] def test_script_neither(): @@ -34,14 +36,17 @@ def test_script_neither(): class EvState(BaseState): """State for testing event handlers.""" + @rx.event def on_ready(self): """Empty event handler.""" pass + @rx.event def on_load(self): """Empty event handler.""" pass + @rx.event def on_error(self): """Empty event handler.""" pass @@ -57,14 +62,14 @@ def test_script_event_handler(): ) render_dict = component.render() assert ( - 'onReady={(_e) => addEvents([Event("ev_state.on_ready", {})], (_e), {})}' + f'onReady={{((...args) => ((addEvents([(Event("{EvState.get_full_name()}.on_ready", ({{ }}), ({{ }})))], args, ({{ }})))))}}' in render_dict["props"] ) assert ( - 'onLoad={(_e) => addEvents([Event("ev_state.on_load", {})], (_e), {})}' + f'onLoad={{((...args) => ((addEvents([(Event("{EvState.get_full_name()}.on_load", ({{ }}), ({{ }})))], args, ({{ }})))))}}' in render_dict["props"] ) assert ( - 'onError={(_e) => addEvents([Event("ev_state.on_error", {})], (_e), {})}' + f'onError={{((...args) => ((addEvents([(Event("{EvState.get_full_name()}.on_error", ({{ }}), ({{ }})))], args, ({{ }})))))}}' in render_dict["props"] ) diff --git a/reflex/.templates/apps/demo/code/webui/__init__.py b/tests/units/components/core/__init__.py similarity index 100% rename from reflex/.templates/apps/demo/code/webui/__init__.py rename to tests/units/components/core/__init__.py diff --git a/tests/components/core/test_banner.py b/tests/units/components/core/test_banner.py similarity index 60% rename from tests/components/core/test_banner.py rename to tests/units/components/core/test_banner.py index f929eef37..7add913ea 100644 --- a/tests/components/core/test_banner.py +++ b/tests/units/components/core/test_banner.py @@ -9,20 +9,25 @@ from reflex.components.radix.themes.typography.text import Text def test_websocket_target_url(): url = WebsocketTargetURL.create() - _imports = url._get_all_imports(collapse=True) - assert list(_imports.keys()) == ["/utils/state", "/env.json"] + var_data = url._get_all_var_data() + assert var_data is not None + assert sorted(tuple((key for key, _ in var_data.imports))) == sorted( + ("$/utils/state", "$/env.json") + ) def test_connection_banner(): banner = ConnectionBanner.create() _imports = banner._get_all_imports(collapse=True) - assert list(_imports.keys()) == [ - "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" custom_banner = ConnectionBanner.create(Text.create(msg)) @@ -32,13 +37,15 @@ def test_connection_banner(): def test_connection_modal(): modal = ConnectionModal.create() _imports = modal._get_all_imports(collapse=True) - assert list(_imports.keys()) == [ - "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" custom_modal = ConnectionModal.create(Text.create(msg)) diff --git a/tests/units/components/core/test_colors.py b/tests/units/components/core/test_colors.py new file mode 100644 index 000000000..74fbeb20f --- /dev/null +++ b/tests/units/components/core/test_colors.py @@ -0,0 +1,136 @@ +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.vars.base import LiteralVar + + +class ColorState(rx.State): + """Test color state.""" + + color: str = "mint" + color_part: str = "tom" + shade: int = 4 + alpha: bool = False + + +color_state_name = ColorState.get_full_name().replace(".", "__") + + +def create_color_var(color): + return LiteralVar.create(color) + + +@pytest.mark.parametrize( + "color, expected, expected_type", + [ + (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+"-"+(((__to_string) => __to_string.toString())({str(color_state_name)}.shade))+")")', + Color, + ), + ( + create_color_var( + rx.color(ColorState.color, ColorState.shade, ColorState.alpha) # type: ignore + ), + f'("var(--"+{str(color_state_name)}.color+"-"+({str(color_state_name)}.alpha ? "a" : "")+(((__to_string) => __to_string.toString())({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, expected_type: Union[Type[str], Type[Color]]): + assert color._var_type is expected_type + assert str(color) == expected + + +@pytest.mark.parametrize( + "cond_var, expected", + [ + ( + rx.cond(True, rx.color("mint"), rx.color("tomato", 5)), + '(true ? "var(--mint-7)" : "var(--tomato-5)")', + ), + ( + rx.cond(True, rx.color(ColorState.color), rx.color(ColorState.color, 5)), # type: ignore + f'(true ? ("var(--"+{str(color_state_name)}.color+"-7)") : ("var(--"+{str(color_state_name)}.color+"-5)"))', + ), + ( + rx.match( + "condition", + ("first", rx.color("mint")), + ("second", rx.color("tomato", 5)), + rx.color(ColorState.color, 2), # type: ignore + ), + '(() => { switch (JSON.stringify("condition")) {case JSON.stringify("first"): return ("var(--mint-7)");' + ' break;case JSON.stringify("second"): return ("var(--tomato-5)"); break;default: ' + f'return (("var(--"+{str(color_state_name)}.color+"-2)")); break;}};}})()', + ), + ( + rx.match( + "condition", + ("first", rx.color(ColorState.color)), # type: ignore + ("second", rx.color(ColorState.color, 5)), # type: ignore + rx.color(ColorState.color, 2), # type: ignore + ), + '(() => { switch (JSON.stringify("condition")) {case JSON.stringify("first"): ' + f'return (("var(--"+{str(color_state_name)}.color+"-7)")); break;case JSON.stringify("second"): ' + f'return (("var(--"+{str(color_state_name)}.color+"-5)")); break;default: ' + f'return (("var(--"+{str(color_state_name)}.color+"-2)")); break;}};}})()', + ), + ], +) +def test_color_with_conditionals(cond_var, expected): + assert str(cond_var) == expected + + +@pytest.mark.parametrize( + "color, expected", + [ + (create_color_var(rx.color("red")), '"var(--red-7)"'), + (create_color_var(rx.color("green", shade=1)), '"var(--green-1)"'), + (create_color_var(rx.color("blue", alpha=True)), '"var(--blue-a7)"'), + ("red", '"red"'), + ("green", '"green"'), + ("blue", '"blue"'), + ], +) +def test_radix_color(color, expected): + """Test that custom_style can accept both string + literals and rx.color inputs. + + Args: + color (Color): A Color made with rx.color + expected (str): The expected custom_style string, radix or literal + """ + code_block = CodeBlock.create("Hello World", background_color=color) + assert str(code_block.custom_style["backgroundColor"]) == expected # type: ignore diff --git a/tests/components/core/test_cond.py b/tests/units/components/core/test_cond.py similarity index 65% rename from tests/components/core/test_cond.py rename to tests/units/components/core/test_cond.py index a7604fb9a..f9bdc7d60 100644 --- a/tests/components/core/test_cond.py +++ b/tests/units/components/core/test_cond.py @@ -1,5 +1,5 @@ import json -from typing import Any +from typing import Any, Union import pytest @@ -7,7 +7,8 @@ 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.state import BaseState -from reflex.vars import Var +from reflex.utils.format import format_state_name +from reflex.vars.base import LiteralVar, Var, computed_var @pytest.fixture @@ -20,8 +21,8 @@ def cond_state(request): def test_f_string_cond_interpolation(): # make sure backticks inside interpolation don't get escaped - var = Var.create(f"x {cond(True, 'a', 'b')}") - assert str(var) == "x ${isTrue(true) ? `a` : `b`}" + var = LiteralVar.create(f"x {cond(True, 'a', 'b')}") + assert str(var) == '("x "+(true ? "a" : "b"))' @pytest.mark.parametrize( @@ -33,7 +34,7 @@ def test_f_string_cond_interpolation(): ], indirect=True, ) -def test_validate_cond(cond_state: Var): +def test_validate_cond(cond_state: BaseState): """Test if cond can be a rx.Var with any values. Args: @@ -44,11 +45,11 @@ def test_validate_cond(cond_state: Var): Text.create("cond is True"), Text.create("cond is False"), ) - cond_dict = cond_component.render() if type(cond_component) == Fragment else {} + cond_dict = cond_component.render() if type(cond_component) is Fragment else {} assert cond_dict["name"] == "Fragment" [condition] = cond_dict["children"] - assert condition["cond_state"] == "isTrue(cond_state.value)" + assert condition["cond_state"] == f"isTrue({cond_state.get_full_name()}.value)" # true value true_value = condition["true_value"] @@ -56,7 +57,7 @@ def test_validate_cond(cond_state: Var): [true_value_text] = true_value["children"] assert true_value_text["name"] == "RadixThemesText" - assert true_value_text["children"][0]["contents"] == "{`cond is True`}" + assert true_value_text["children"][0]["contents"] == '{"cond is True"}' # false value false_value = condition["false_value"] @@ -64,7 +65,7 @@ def test_validate_cond(cond_state: Var): [false_value_text] = false_value["children"] assert false_value_text["name"] == "RadixThemesText" - assert false_value_text["children"][0]["contents"] == "{`cond is False`}" + assert false_value_text["children"][0]["contents"] == '{"cond is False"}' @pytest.mark.parametrize( @@ -74,7 +75,7 @@ def test_validate_cond(cond_state: Var): (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): @@ -92,16 +93,16 @@ def test_prop_cond(c1: Any, c2: Any): assert isinstance(prop_cond, Var) if not isinstance(c1, Var): - c1 = json.dumps(c1).replace('"', "`") + c1 = json.dumps(c1) if not isinstance(c2, Var): - c2 = json.dumps(c2).replace('"', "`") - assert str(prop_cond) == f"{{isTrue(true) ? {c1} : {c2}}}" + c2 = json.dumps(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(): @@ -118,3 +119,28 @@ def test_cond_no_else(): # Props do not support the use of cond without else with pytest.raises(ValueError): cond(True, "hello") # type: ignore + + +def test_cond_computed_var(): + """Test if cond works with computed vars.""" + + class CondStateComputed(BaseState): + @computed_var + def computed_int(self) -> int: + return 0 + + @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, Var) + + state_name = format_state_name(CondStateComputed.get_full_name()) + assert ( + 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/units/components/core/test_debounce.py similarity index 75% rename from tests/components/core/test_debounce.py rename to tests/units/components/core/test_debounce.py index 8a8ec394c..7856ee090 100644 --- a/tests/components/core/test_debounce.py +++ b/tests/units/components/core/test_debounce.py @@ -5,7 +5,7 @@ import pytest import reflex as rx from reflex.components.core.debounce import DEFAULT_DEBOUNCE_TIMEOUT from reflex.state import BaseState -from reflex.vars import BaseVar +from reflex.vars.base import LiteralVar, Var def test_create_no_child(): @@ -37,6 +37,7 @@ class S(BaseState): value: str = "" + @rx.event def on_change(self, v: str): """Dummy on_change handler. @@ -57,14 +58,10 @@ 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( - BaseVar( - _var_name="real", _var_type=str, _var_is_local=True, _var_is_string=False - ) - ) + assert tag.props["value"].equals(LiteralVar.create("real")) assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" @@ -77,7 +74,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"]) @@ -88,21 +85,43 @@ 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"]) +def test_render_with_key(): + tag = rx.debounce_input( + rx.input( + on_change=S.on_change, + key="foo_bar", + ) + )._render() + assert isinstance(tag.props["key"], rx.vars.Var) + assert "foo_bar" in str(tag.props["key"]) + + +def test_render_with_special_props(): + special_prop = Var(_js_expr="{foo_bar}") + tag = rx.debounce_input( + rx.input( + on_change=S.on_change, + special_props=[special_prop], + ) + )._render() + assert len(tag.special_props) == 1 + assert list(tag.special_props)[0].equals(special_prop) + + def test_event_triggers(): debounced_input = rx.debounce_input( rx.input( on_change=S.on_change, ) ) - default_event_triggers = list(rx.Component().get_event_triggers().keys()) - assert list(debounced_input.get_event_triggers().keys()) == [ - *default_event_triggers, + assert tuple(debounced_input.get_event_triggers()) == ( + *rx.Component().get_event_triggers(), # default event triggers "on_change", - ] + ) def test_render_child_props_recursive(): @@ -131,17 +150,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( - BaseVar( - _var_name="outer", _var_type=str, _var_is_local=True, _var_is_string=False - ) - ) - assert tag.props["forceNotifyOnBlur"]._var_name == "false" - assert tag.props["forceNotifyByEnter"]._var_name == "false" - assert tag.props["debounceTimeout"]._var_name == "42" + assert tag.props["value"].equals(LiteralVar.create("outer")) + 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 == "" @@ -153,7 +168,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 == "" @@ -165,7 +180,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/units/components/core/test_foreach.py similarity index 71% rename from tests/components/core/test_foreach.py rename to tests/units/components/core/test_foreach.py index 9691ed50e..228165d3e 100644 --- a/tests/components/core/test_foreach.py +++ b/tests/units/components/core/test_foreach.py @@ -2,10 +2,20 @@ from typing import Dict, List, Set, Tuple, Union import pytest -from reflex.components import box, el, foreach, text -from reflex.components.core.foreach import Foreach, ForeachRenderError, ForeachVarError -from reflex.state import BaseState -from reflex.vars import Var +from reflex import el +from reflex.components.component import Component +from reflex.components.core.foreach import ( + Foreach, + ForeachRenderError, + ForeachVarError, + foreach, +) +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.base import Var +from reflex.vars.number import NumberVar +from reflex.vars.sequence import ArrayVar class ForEachState(BaseState): @@ -37,8 +47,27 @@ class ForEachState(BaseState): color_index_tuple: Tuple[int, str] = (0, "red") +class ComponentStateTest(ComponentState): + """A test component state.""" + + foo: bool + + @classmethod + def get_component(cls, *children, **props) -> Component: + """Get the component. + + Args: + children: The children components. + props: The component props. + + Returns: + The component. + """ + return el.div(*children, **props) + + def display_color(color): - assert color._var_type == str + assert color._var_type is str return box(text(color)) @@ -77,18 +106,18 @@ def display_nested_color_with_shades_v2(color): def display_color_tuple(color): - assert color._var_type == str + assert color._var_type is str return box(text(color)) def display_colors_set(color): - assert color._var_type == str + assert color._var_type is str 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 + assert index._var_type is int return box(text(element[index])) @@ -107,7 +136,7 @@ seen_index_vars = set() ForEachState.colors_list, display_color, { - "iterable_state": "for_each_state.colors_list", + "iterable_state": f"{ForEachState.get_full_name()}.colors_list", "iterable_type": "list", }, ), @@ -115,7 +144,7 @@ seen_index_vars = set() ForEachState.colors_dict_list, display_color_name, { - "iterable_state": "for_each_state.colors_dict_list", + "iterable_state": f"{ForEachState.get_full_name()}.colors_dict_list", "iterable_type": "list", }, ), @@ -123,7 +152,7 @@ seen_index_vars = set() ForEachState.colors_nested_dict_list, display_shade, { - "iterable_state": "for_each_state.colors_nested_dict_list", + "iterable_state": f"{ForEachState.get_full_name()}.colors_nested_dict_list", "iterable_type": "list", }, ), @@ -131,7 +160,7 @@ seen_index_vars = set() ForEachState.primary_color, display_primary_colors, { - "iterable_state": "for_each_state.primary_color", + "iterable_state": f"{ForEachState.get_full_name()}.primary_color", "iterable_type": "dict", }, ), @@ -139,7 +168,7 @@ seen_index_vars = set() ForEachState.color_with_shades, display_color_with_shades, { - "iterable_state": "for_each_state.color_with_shades", + "iterable_state": f"{ForEachState.get_full_name()}.color_with_shades", "iterable_type": "dict", }, ), @@ -147,7 +176,7 @@ seen_index_vars = set() ForEachState.nested_colors_with_shades, display_nested_color_with_shades, { - "iterable_state": "for_each_state.nested_colors_with_shades", + "iterable_state": f"{ForEachState.get_full_name()}.nested_colors_with_shades", "iterable_type": "dict", }, ), @@ -155,7 +184,7 @@ seen_index_vars = set() ForEachState.nested_colors_with_shades, display_nested_color_with_shades_v2, { - "iterable_state": "for_each_state.nested_colors_with_shades", + "iterable_state": f"{ForEachState.get_full_name()}.nested_colors_with_shades", "iterable_type": "dict", }, ), @@ -163,7 +192,7 @@ seen_index_vars = set() ForEachState.color_tuple, display_color_tuple, { - "iterable_state": "for_each_state.color_tuple", + "iterable_state": f"{ForEachState.get_full_name()}.color_tuple", "iterable_type": "tuple", }, ), @@ -171,7 +200,7 @@ seen_index_vars = set() ForEachState.colors_set, display_colors_set, { - "iterable_state": "for_each_state.colors_set", + "iterable_state": f"{ForEachState.get_full_name()}.colors_set", "iterable_type": "set", }, ), @@ -179,7 +208,7 @@ seen_index_vars = set() ForEachState.nested_colors_list, lambda el, i: display_nested_list_element(el, i), { - "iterable_state": "for_each_state.nested_colors_list", + "iterable_state": f"{ForEachState.get_full_name()}.nested_colors_list", "iterable_type": "list", }, ), @@ -187,7 +216,7 @@ seen_index_vars = set() ForEachState.color_index_tuple, display_color_index_tuple, { - "iterable_state": "for_each_state.color_index_tuple", + "iterable_state": f"{ForEachState.get_full_name()}.color_index_tuple", "iterable_type": "tuple", }, ), @@ -210,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._var_type == int - seen_index_vars.add(arg_index._var_name) + assert arg_index._js_expr not in seen_index_vars + assert arg_index._var_type is int + seen_index_vars.add(arg_index._js_expr) def test_foreach_bad_annotations(): @@ -251,4 +280,13 @@ def test_foreach_component_styles(): ) ) component._add_style_recursive({box: {"color": "red"}}) - assert 'css={{"color": "red"}}' in str(component) + assert 'css={({ ["color"] : "red" })}' in str(component) + + +def test_foreach_component_state(): + """Test that using a component state to render in the foreach raises an error.""" + with pytest.raises(TypeError): + Foreach.create( + ForEachState.colors_list, + ComponentStateTest.create, + ) diff --git a/tests/units/components/core/test_html.py b/tests/units/components/core/test_html.py new file mode 100644 index 000000000..4847e1d5a --- /dev/null +++ b/tests/units/components/core/test_html.py @@ -0,0 +1,41 @@ +import pytest + +from reflex.components.core.html import Html +from reflex.state import State + + +def test_html_no_children(): + with pytest.raises(ValueError): + _ = Html.create() + + +def test_html_many_children(): + with pytest.raises(ValueError): + _ = Html.create("foo", "bar") + + +def test_html_create(): + html = Html.create("

Hello !

") + assert str(html.dangerouslySetInnerHTML) == '({ ["__html"] : "

Hello !

" })' # type: ignore + assert ( + str(html) + == '
Hello !

" })}/>' + ) + + +def test_html_fstring_create(): + class TestState(State): + """The app state.""" + + myvar: str = "Blue" + + html = Html.create(f"

Hello {TestState.myvar}!

") + + assert ( + str(html.dangerouslySetInnerHTML) # type: ignore + == f'({{ ["__html"] : ("

Hello "+{str(TestState.myvar)}+"!

") }})' + ) + assert ( + str(html) + == f'
' # type: ignore + ) diff --git a/tests/components/core/test_match.py b/tests/units/components/core/test_match.py similarity index 71% rename from tests/components/core/test_match.py rename to tests/units/components/core/test_match.py index 5a0e46e9e..f09e800e5 100644 --- a/tests/components/core/test_match.py +++ b/tests/units/components/core/test_match.py @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import Dict, List, Tuple import pytest @@ -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 BaseVar +from reflex.vars.base import Var class MatchState(BaseState): @@ -35,53 +35,53 @@ def test_match_components(): [match_child] = match_dict["children"] assert match_child["name"] == "match" - assert str(match_child["cond"]) == "{match_state.value}" + assert str(match_child["cond"]) == f"{MatchState.get_name()}.value" match_cases = match_child["match_cases"] assert len(match_cases) == 6 - assert match_cases[0][0]._var_name == "1" - assert match_cases[0][0]._var_type == int + assert match_cases[0][0]._js_expr == "1" + assert match_cases[0][0]._var_type is 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 first_return_value_render["children"][0]["contents"] == '{"first value"}' - assert match_cases[1][0]._var_name == "2" - assert match_cases[1][0]._var_type == int - assert match_cases[1][1]._var_name == "3" - assert match_cases[1][1]._var_type == int + assert match_cases[1][0]._js_expr == "2" + assert match_cases[1][0]._var_type is int + assert match_cases[1][1]._js_expr == "3" + assert match_cases[1][1]._var_type is 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 second_return_value_render["children"][0]["contents"] == '{"second value"}' - assert match_cases[2][0]._var_name == "[1, 2]" - assert match_cases[2][0]._var_type == list + 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 third_return_value_render["children"][0]["contents"] == '{"third value"}' - assert match_cases[3][0]._var_name == "random" - assert match_cases[3][0]._var_type == str + assert match_cases[3][0]._js_expr == '"random"' + assert match_cases[3][0]._var_type is 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 fourth_return_value_render["children"][0]["contents"] == '{"fourth value"}' - assert match_cases[4][0]._var_name == '{"foo": "bar"}' - assert match_cases[4][0]._var_type == dict + 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 fifth_return_value_render["children"][0]["contents"] == '{"fifth value"}' - assert match_cases[5][0]._var_name == "((match_state.num) + (1))" - assert match_cases[5][0]._var_type == int + assert match_cases[5][0]._js_expr == f"({MatchState.get_name()}.num + 1)" + assert match_cases[5][0]._var_type is int fifth_return_value_render = match_cases[5][1].render() assert fifth_return_value_render["name"] == "RadixThemesText" - assert fifth_return_value_render["children"][0]["contents"] == "{`sixth value`}" + assert fifth_return_value_render["children"][0]["contents"] == '{"sixth value"}' default = match_child["default"].render() assert default["name"] == "RadixThemesText" - assert default["children"][0]["contents"] == "{`default value`}" + assert default["children"][0]["contents"] == '{"default value"}' @pytest.mark.parametrize( @@ -99,12 +99,12 @@ def test_match_components(): (MatchState.string, f"{MatchState.value} - string"), "default value", ), - "(() => { switch (JSON.stringify(match_state.value)) {case JSON.stringify(1): return (`first`); break;case JSON.stringify(2): case JSON.stringify(3): return " - "(`second value`); break;case JSON.stringify([1, 2]): return (`third-value`); break;case JSON.stringify(`random`): " - 'return (`fourth_value`); break;case JSON.stringify({"foo": "bar"}): return (`fifth value`); ' - "break;case JSON.stringify(((match_state.num) + (1))): return (`sixth value`); break;case JSON.stringify(`${match_state.value} - string`): " - "return (match_state.string); break;case JSON.stringify(match_state.string): return (`${match_state.value} - string`); break;default: " - "return (`default value`); break;};})()", + f'(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return ("first"); break;case JSON.stringify(2): case JSON.stringify(3): return ' + '("second value"); break;case JSON.stringify([1, 2]): return ("third-value"); break;case JSON.stringify("random"): ' + 'return ("fourth_value"); break;case JSON.stringify(({ ["foo"] : "bar" })): return ("fifth value"); ' + f'break;case JSON.stringify(({MatchState.get_name()}.num + 1)): return ("sixth value"); break;case JSON.stringify(({MatchState.get_name()}.value+" - string")): ' + f'return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (({MatchState.get_name()}.value+" - string")); break;default: ' + 'return ("default value"); break;};})()', ), ( ( @@ -118,12 +118,12 @@ def test_match_components(): (MatchState.string, f"{MatchState.value} - string"), MatchState.string, ), - "(() => { switch (JSON.stringify(match_state.value)) {case JSON.stringify(1): return (`first`); break;case JSON.stringify(2): case JSON.stringify(3): return " - "(`second value`); break;case JSON.stringify([1, 2]): return (`third-value`); break;case JSON.stringify(`random`): " - 'return (`fourth_value`); break;case JSON.stringify({"foo": "bar"}): return (`fifth value`); ' - "break;case JSON.stringify(((match_state.num) + (1))): return (`sixth value`); break;case JSON.stringify(`${match_state.value} - string`): " - "return (match_state.string); break;case JSON.stringify(match_state.string): return (`${match_state.value} - string`); break;default: " - "return (match_state.string); break;};})()", + f'(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return ("first"); break;case JSON.stringify(2): case JSON.stringify(3): return ' + '("second value"); break;case JSON.stringify([1, 2]): return ("third-value"); break;case JSON.stringify("random"): ' + 'return ("fourth_value"); break;case JSON.stringify(({ ["foo"] : "bar" })): return ("fifth value"); ' + f'break;case JSON.stringify(({MatchState.get_name()}.num + 1)): return ("sixth value"); break;case JSON.stringify(({MatchState.get_name()}.value+" - string")): ' + f'return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (({MatchState.get_name()}.value+" - string")); break;default: ' + f"return ({MatchState.get_name()}.string); break;}};}})()", ), ], ) @@ -135,8 +135,8 @@ def test_match_vars(cases, expected): expected: The expected var full name. """ match_comp = Match.create(MatchState.value, *cases) - assert isinstance(match_comp, BaseVar) - assert match_comp._var_full_name == expected + assert isinstance(match_comp, Var) + assert str(match_comp) == expected def test_match_on_component_without_default(): @@ -247,8 +247,8 @@ def test_match_case_tuple_elements(match_case): (MatchState.num + 1, "black"), rx.text("default value"), ), - "Match cases should have the same return types. Case 3 with return value `red` of type " - " is not ", + 'Match cases should have the same return types. Case 3 with return value `"red"` of type ' + " is not ", ), ( ( @@ -260,8 +260,8 @@ def test_match_case_tuple_elements(match_case): ([1, 2], rx.text("third value")), rx.text("default value"), ), - "Match cases should have the same return types. Case 3 with return value ` {`first value`} ` " - "of type is not ", + 'Match cases should have the same return types. Case 3 with return value ` {"first value"} ` ' + "of type is not ", ), ], ) diff --git a/tests/components/core/test_responsive.py b/tests/units/components/core/test_responsive.py similarity index 100% rename from tests/components/core/test_responsive.py rename to tests/units/components/core/test_responsive.py diff --git a/tests/components/core/test_upload.py b/tests/units/components/core/test_upload.py similarity index 79% rename from tests/components/core/test_upload.py rename to tests/units/components/core/test_upload.py index e6b27effc..710baa161 100644 --- a/tests/components/core/test_upload.py +++ b/tests/units/components/core/test_upload.py @@ -1,3 +1,6 @@ +from typing import Any + +from reflex import event from reflex.components.core.upload import ( StyledUpload, Upload, @@ -8,13 +11,14 @@ 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): +class UploadStateTest(State): """Test upload state.""" - def drop_handler(self, files): + @event + def drop_handler(self, files: Any): """Handle the drop event. Args: @@ -22,7 +26,8 @@ class TestUploadState(State): """ pass - def not_drop_handler(self, not_files): + @event + def not_drop_handler(self, not_files: Any): """Handle the drop event without defining the files argument. Args: @@ -42,7 +47,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([])), tuple) def test_upload_create(): @@ -55,7 +60,7 @@ def test_upload_create(): up_comp_2 = Upload.create( id="foo_id", - on_drop=TestUploadState.drop_handler([]), # type: ignore + on_drop=UploadStateTest.drop_handler([]), # type: ignore ) assert isinstance(up_comp_2, Upload) assert up_comp_2.is_used @@ -65,7 +70,7 @@ def test_upload_create(): up_comp_3 = Upload.create( id="foo_id", - on_drop=TestUploadState.drop_handler, + on_drop=UploadStateTest.drop_handler, ) assert isinstance(up_comp_3, Upload) assert up_comp_3.is_used @@ -75,7 +80,7 @@ def test_upload_create(): up_comp_4 = Upload.create( id="foo_id", - on_drop=TestUploadState.not_drop_handler([]), # type: ignore + on_drop=UploadStateTest.not_drop_handler([]), # type: ignore ) assert isinstance(up_comp_4, Upload) assert up_comp_4.is_used @@ -91,7 +96,7 @@ def test_styled_upload_create(): styled_up_comp_2 = StyledUpload.create( id="foo_id", - on_drop=TestUploadState.drop_handler([]), # type: ignore + on_drop=UploadStateTest.drop_handler([]), # type: ignore ) assert isinstance(styled_up_comp_2, StyledUpload) assert styled_up_comp_2.is_used @@ -101,7 +106,7 @@ def test_styled_upload_create(): styled_up_comp_3 = StyledUpload.create( id="foo_id", - on_drop=TestUploadState.drop_handler, + on_drop=UploadStateTest.drop_handler, ) assert isinstance(styled_up_comp_3, StyledUpload) assert styled_up_comp_3.is_used @@ -111,7 +116,7 @@ def test_styled_upload_create(): styled_up_comp_4 = StyledUpload.create( id="foo_id", - on_drop=TestUploadState.not_drop_handler([]), # type: ignore + on_drop=UploadStateTest.not_drop_handler([]), # type: ignore ) assert isinstance(styled_up_comp_4, StyledUpload) assert styled_up_comp_4.is_used diff --git a/tests/components/datadisplay/__init__.py b/tests/units/components/datadisplay/__init__.py similarity index 100% rename from tests/components/datadisplay/__init__.py rename to tests/units/components/datadisplay/__init__.py diff --git a/tests/components/datadisplay/conftest.py b/tests/units/components/datadisplay/conftest.py similarity index 99% rename from tests/components/datadisplay/conftest.py rename to tests/units/components/datadisplay/conftest.py index 93796ed23..13c571c8c 100644 --- a/tests/components/datadisplay/conftest.py +++ b/tests/units/components/datadisplay/conftest.py @@ -1,4 +1,5 @@ """Data display component tests fixtures.""" + from typing import List import pandas as pd diff --git a/tests/components/datadisplay/test_code.py b/tests/units/components/datadisplay/test_code.py similarity index 75% rename from tests/components/datadisplay/test_code.py rename to tests/units/components/datadisplay/test_code.py index 64452e90c..809c68fe5 100644 --- a/tests/components/datadisplay/test_code.py +++ b/tests/units/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/units/components/datadisplay/test_dataeditor.py b/tests/units/components/datadisplay/test_dataeditor.py new file mode 100644 index 000000000..63b156e74 --- /dev/null +++ b/tests/units/components/datadisplay/test_dataeditor.py @@ -0,0 +1,11 @@ +from reflex.components.datadisplay.dataeditor import DataEditor + + +def test_dataeditor(): + editor_wrapper = DataEditor.create().render() + editor = editor_wrapper["children"][0] + assert editor_wrapper["name"] == "div" + assert editor_wrapper["props"] == [ + 'css={({ ["width"] : "100%", ["height"] : "100%" })}' + ] + assert editor["name"] == "DataEditor" diff --git a/tests/components/datadisplay/test_datatable.py b/tests/units/components/datadisplay/test_datatable.py similarity index 90% rename from tests/components/datadisplay/test_datatable.py rename to tests/units/components/datadisplay/test_datatable.py index c755064ce..b3d31ea32 100644 --- a/tests/components/datadisplay/test_datatable.py +++ b/tests/units/components/datadisplay/test_datatable.py @@ -16,14 +16,14 @@ from reflex.utils.serializers import serialize, serialize_dataframe [["foo", "bar"], ["foo1", "bar1"]], columns=["column1", "column2"] ) }, - "data_table_state.data", + "data", ), - pytest.param({"data": ["foo", "bar"]}, "data_table_state"), - pytest.param({"data": [["foo", "bar"], ["foo1", "bar1"]]}, "data_table_state"), + pytest.param({"data": ["foo", "bar"]}, ""), + pytest.param({"data": [["foo", "bar"], ["foo1", "bar1"]]}, ""), ], indirect=["data_table_state"], ) -def test_validate_data_table(data_table_state: rx.Var, expected): +def test_validate_data_table(data_table_state: rx.State, expected): """Test the str/render function. Args: @@ -40,6 +40,10 @@ def test_validate_data_table(data_table_state: rx.Var, expected): data_table_dict = data_table_component.render() + # prefix expected with state name + state_name = data_table_state.get_name() + expected = f"{state_name}.{expected}" if expected else state_name + assert data_table_dict["props"] == [ f"columns={{{expected}.columns}}", f"data={{{expected}.data}}", @@ -114,4 +118,4 @@ def test_serialize_dataframe(): value = serialize(df) assert value == serialize_dataframe(df) assert isinstance(value, dict) - assert list(value.keys()) == ["columns", "data"] + assert tuple(value) == ("columns", "data") diff --git a/tests/units/components/datadisplay/test_shiki_code.py b/tests/units/components/datadisplay/test_shiki_code.py new file mode 100644 index 000000000..eb473ba06 --- /dev/null +++ b/tests/units/components/datadisplay/test_shiki_code.py @@ -0,0 +1,172 @@ +import pytest + +from reflex.components.datadisplay.shiki_code_block import ( + ShikiBaseTransformers, + ShikiCodeBlock, + ShikiHighLevelCodeBlock, + ShikiJsTransformer, +) +from reflex.components.el.elements.forms import Button +from reflex.components.lucide.icon import Icon +from reflex.components.radix.themes.layout.box import Box +from reflex.style import Style +from reflex.vars import Var + + +@pytest.mark.parametrize( + "library, fns, expected_output, raises_exception", + [ + ("some_library", ["function_one"], ["function_one"], False), + ("some_library", [123], None, True), + ("some_library", [], [], False), + ( + "some_library", + ["function_one", "function_two"], + ["function_one", "function_two"], + False, + ), + ("", ["function_one"], ["function_one"], False), + ("some_library", ["function_one", 789], None, True), + ("", [], [], False), + ], +) +def test_create_transformer(library, fns, expected_output, raises_exception): + if raises_exception: + # Ensure ValueError is raised for invalid cases + with pytest.raises(ValueError): + ShikiCodeBlock.create_transformer(library, fns) + else: + transformer = ShikiCodeBlock.create_transformer(library, fns) + assert isinstance(transformer, ShikiBaseTransformers) + assert transformer.library == library + + # Verify that the functions are correctly wrapped in FunctionStringVar + function_names = [str(fn) for fn in transformer.fns] + assert function_names == expected_output + + +@pytest.mark.parametrize( + "code_block, children, props, expected_first_child, expected_styles", + [ + ("print('Hello')", ["print('Hello')"], {}, "print('Hello')", {}), + ( + "print('Hello')", + ["print('Hello')", "More content"], + {}, + "print('Hello')", + {}, + ), + ( + "print('Hello')", + ["print('Hello')"], + { + "transformers": [ + ShikiBaseTransformers( + library="lib", fns=[], style=Style({"color": "red"}) + ) + ] + }, + "print('Hello')", + {"color": "red"}, + ), + ( + "print('Hello')", + ["print('Hello')"], + { + "transformers": [ + ShikiBaseTransformers( + library="lib", fns=[], style=Style({"color": "red"}) + ) + ], + "style": {"background": "blue"}, + }, + "print('Hello')", + {"color": "red", "background": "blue"}, + ), + ], +) +def test_create_shiki_code_block( + code_block, children, props, expected_first_child, expected_styles +): + component = ShikiCodeBlock.create(code_block, *children, **props) + + # Test that the created component is a Box + assert isinstance(component, Box) + + # Test that the first child is the code + code_block_component = component.children[0] + assert code_block_component.code._var_value == expected_first_child # type: ignore + + applied_styles = component.style + for key, value in expected_styles.items(): + assert Var.create(applied_styles[key])._var_value == value + + +@pytest.mark.parametrize( + "children, props, expected_transformers, expected_button_type", + [ + (["print('Hello')"], {"use_transformers": True}, [ShikiJsTransformer], None), + (["print('Hello')"], {"can_copy": True}, None, Button), + ( + ["print('Hello')"], + { + "can_copy": True, + "copy_button": Button.create(Icon.create(tag="a_arrow_down")), + }, + None, + Button, + ), + ], +) +def test_create_shiki_high_level_code_block( + children, props, expected_transformers, expected_button_type +): + component = ShikiHighLevelCodeBlock.create(*children, **props) + + # Test that the created component is a Box + assert isinstance(component, Box) + + # Test that the first child is the code block component + code_block_component = component.children[0] + assert code_block_component.code._var_value == children[0] # type: ignore + + # Check if the transformer is set correctly if expected + if expected_transformers: + exp_trans_names = [t.__name__ for t in expected_transformers] + for transformer in code_block_component.transformers._var_value: # type: ignore + assert type(transformer).__name__ in exp_trans_names + + # Check if the second child is the copy button if can_copy is True + if props.get("can_copy", False): + if props.get("copy_button"): + assert isinstance(component.children[1], expected_button_type) + assert component.children[1] == props["copy_button"] + else: + assert isinstance(component.children[1], expected_button_type) + else: + assert len(component.children) == 1 + + +@pytest.mark.parametrize( + "children, props", + [ + (["print('Hello')"], {"theme": "dark"}), + (["print('Hello')"], {"language": "javascript"}), + ], +) +def test_shiki_high_level_code_block_theme_language_mapping(children, props): + component = ShikiHighLevelCodeBlock.create(*children, **props) + + # Test that the theme is mapped correctly + if "theme" in props: + assert component.children[ + 0 + ].theme._var_value == ShikiHighLevelCodeBlock._map_themes(props["theme"]) # type: ignore + + # Test that the language is mapped correctly + if "language" in props: + assert component.children[ + 0 + ].language._var_value == ShikiHighLevelCodeBlock._map_languages( # type: ignore + props["language"] + ) diff --git a/tests/components/el/test_html.py b/tests/units/components/el/test_html.py similarity index 100% rename from tests/components/el/test_html.py rename to tests/units/components/el/test_html.py diff --git a/tests/units/components/el/test_svg.py b/tests/units/components/el/test_svg.py new file mode 100644 index 000000000..29aaa96dd --- /dev/null +++ b/tests/units/components/el/test_svg.py @@ -0,0 +1,74 @@ +from reflex.components.el.elements.media import ( + Circle, + Defs, + Ellipse, + Line, + LinearGradient, + Path, + Polygon, + RadialGradient, + Rect, + Stop, + Svg, + Text, +) + + +def test_circle(): + circle = Circle.create().render() + assert circle["name"] == "circle" + + +def test_defs(): + defs = Defs.create().render() + assert defs["name"] == "defs" + + +def test_ellipse(): + ellipse = Ellipse.create().render() + assert ellipse["name"] == "ellipse" + + +def test_line(): + line = Line.create().render() + assert line["name"] == "line" + + +def test_linear_gradient(): + linear_gradient = LinearGradient.create().render() + assert linear_gradient["name"] == "linearGradient" + + +def test_path(): + path = Path.create().render() + assert path["name"] == "path" + + +def test_polygon(): + polygon = Polygon.create().render() + assert polygon["name"] == "polygon" + + +def test_radial_gradient(): + radial_gradient = RadialGradient.create().render() + assert radial_gradient["name"] == "radialGradient" + + +def test_rect(): + rect = Rect.create().render() + assert rect["name"] == "rect" + + +def test_svg(): + svg = Svg.create().render() + assert svg["name"] == "svg" + + +def test_text(): + text = Text.create().render() + assert text["name"] == "text" + + +def test_stop(): + stop = Stop.create().render() + assert stop["name"] == "stop" diff --git a/tests/components/core/__init__.py b/tests/units/components/forms/__init__.py similarity index 100% rename from tests/components/core/__init__.py rename to tests/units/components/forms/__init__.py diff --git a/tests/components/forms/test_form.py b/tests/units/components/forms/test_form.py similarity index 54% rename from tests/components/forms/test_form.py rename to tests/units/components/forms/test_form.py index b9eff2daf..5f3ba2d37 100644 --- a/tests/components/forms/test_form.py +++ b/tests/units/components/forms/test_form.py @@ -1,12 +1,12 @@ -from reflex.components.chakra.forms.form import Form -from reflex.event import EventChain -from reflex.vars import BaseVar +from reflex.components.radix.primitives.form import Form +from reflex.event import EventChain, prevent_default +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) @@ -15,7 +15,6 @@ def test_render_on_submit(): def test_render_no_on_submit(): - """A form without on_submit should not render a submit handler.""" + """A form without on_submit should render a prevent_default handler.""" f = Form.create() - for prop in f.render()["props"]: - assert "onSubmit" not in prop + assert f.event_triggers["on_submit"] == prevent_default diff --git a/tests/components/graphing/__init__.py b/tests/units/components/graphing/__init__.py similarity index 100% rename from tests/components/graphing/__init__.py rename to tests/units/components/graphing/__init__.py diff --git a/tests/components/graphing/test_plotly.py b/tests/units/components/graphing/test_plotly.py similarity index 96% rename from tests/components/graphing/test_plotly.py rename to tests/units/components/graphing/test_plotly.py index 0e17789b5..69b046bea 100644 --- a/tests/components/graphing/test_plotly.py +++ b/tests/units/components/graphing/test_plotly.py @@ -30,7 +30,7 @@ def test_serialize_plotly(plotly_fig: go.Figure): plotly_fig: The figure to serialize. """ value = serialize(plotly_fig) - assert isinstance(value, list) + assert isinstance(value, dict) assert value == serialize_figure(plotly_fig) diff --git a/tests/components/graphing/test_recharts.py b/tests/units/components/graphing/test_recharts.py similarity index 96% rename from tests/components/graphing/test_recharts.py rename to tests/units/components/graphing/test_recharts.py index b87935d1a..c1b986dfd 100644 --- a/tests/components/graphing/test_recharts.py +++ b/tests/units/components/graphing/test_recharts.py @@ -1,4 +1,4 @@ -from reflex.components.recharts import ( +from reflex.components.recharts.charts import ( AreaChart, BarChart, LineChart, diff --git a/tests/components/layout/__init__.py b/tests/units/components/layout/__init__.py similarity index 100% rename from tests/components/layout/__init__.py rename to tests/units/components/layout/__init__.py diff --git a/tests/components/lucide/test_icon.py b/tests/units/components/lucide/test_icon.py similarity index 59% rename from tests/components/lucide/test_icon.py rename to tests/units/components/lucide/test_icon.py index d61f3a9aa..b0a3475dd 100644 --- a/tests/components/lucide/test_icon.py +++ b/tests/units/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/__init__.py b/tests/units/components/media/__init__.py similarity index 100% rename from tests/components/media/__init__.py rename to tests/units/components/media/__init__.py diff --git a/tests/components/media/test_image.py b/tests/units/components/media/test_image.py similarity index 78% rename from tests/components/media/test_image.py rename to tests/units/components/media/test_image.py index a39895c67..f8618347c 100644 --- a/tests/components/media/test_image.py +++ b/tests/units/components/media/test_image.py @@ -1,4 +1,3 @@ -# PIL is only available in python 3.8+ import numpy as np import PIL import pytest @@ -7,6 +6,7 @@ from PIL.Image import Image as Img import reflex as rx from reflex.components.next.image import Image # type: ignore from reflex.utils.serializers import serialize, serialize_image +from reflex.vars.sequence import StringVar @pytest.fixture @@ -36,9 +36,13 @@ def test_set_src_str(): """Test that setting the src works.""" image = rx.image(src="pic2.jpeg") # when using next/image, we explicitly create a _var_is_str Var - # assert str(image.src) == "{`pic2.jpeg`}" # type: ignore + assert str(image.src) in ( # type: ignore + '"pic2.jpeg"', + "'pic2.jpeg'", + "`pic2.jpeg`", + ) # For plain rx.el.img, an explicit var is not created, so the quoting happens later - assert str(image.src) == "pic2.jpeg" # type: ignore + # assert str(image.src) == "pic2.jpeg" # type: ignore def test_set_src_img(pil_image: Img): @@ -48,7 +52,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): @@ -58,4 +62,4 @@ def test_render(pil_image: Img): pil_image: The image to serialize. """ image = Image.create(src=pil_image) - assert image.src._var_is_string # type: ignore + assert isinstance(image.src, StringVar) # type: ignore diff --git a/tests/components/radix/test_icon_button.py b/tests/units/components/radix/test_icon_button.py similarity index 86% rename from tests/components/radix/test_icon_button.py rename to tests/units/components/radix/test_icon_button.py index 852c0c97c..8047cf7b2 100644 --- a/tests/components/radix/test_icon_button.py +++ b/tests/units/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/radix/test_layout.py b/tests/units/components/radix/test_layout.py similarity index 100% rename from tests/components/radix/test_layout.py rename to tests/units/components/radix/test_layout.py diff --git a/tests/units/components/recharts/test_cartesian.py b/tests/units/components/recharts/test_cartesian.py new file mode 100644 index 000000000..3337427bd --- /dev/null +++ b/tests/units/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/units/components/recharts/test_polar.py b/tests/units/components/recharts/test_polar.py new file mode 100644 index 000000000..4e4af0f49 --- /dev/null +++ b/tests/units/components/recharts/test_polar.py @@ -0,0 +1,38 @@ +from reflex.components.recharts import ( + Pie, + PolarAngleAxis, + PolarGrid, + PolarRadiusAxis, + Radar, + RadialBar, +) + + +def test_pie(): + pie = Pie.create().render() + assert pie["name"] == "RechartsPie" + + +def test_radar(): + radar = Radar.create().render() + assert radar["name"] == "RechartsRadar" + + +def test_radialbar(): + radialbar = RadialBar.create().render() + assert radialbar["name"] == "RechartsRadialBar" + + +def test_polarangleaxis(): + polarangleaxis = PolarAngleAxis.create().render() + assert polarangleaxis["name"] == "RechartsPolarAngleAxis" + + +def test_polargrid(): + polargrid = PolarGrid.create().render() + assert polargrid["name"] == "RechartsPolarGrid" + + +def test_polarradiusaxis(): + polarradiusaxis = PolarRadiusAxis.create().render() + assert polarradiusaxis["name"] == "RechartsPolarRadiusAxis" diff --git a/tests/components/test_component.py b/tests/units/components/test_component.py similarity index 73% rename from tests/components/test_component.py rename to tests/units/components/test_component.py index 6245746c9..a614fd715 100644 --- a/tests/components/test_component.py +++ b/tests/units/components/test_component.py @@ -8,20 +8,32 @@ from reflex.base import Base from reflex.compiler.compiler import compile_components from reflex.components.base.bare import Bare from reflex.components.base.fragment import Fragment -from reflex.components.chakra.layout.box import Box from reflex.components.component import ( Component, CustomComponent, 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.event import ( + EventChain, + EventHandler, + empty_event, + identity_event, + input_event, + parse_args_spec, +) from reflex.state import BaseState from reflex.style import Style from reflex.utils import imports -from reflex.utils.imports import ImportVar -from reflex.vars import BaseVar, Var, VarData +from reflex.utils.exceptions import ( + EventFnArgMismatch, + EventHandlerArgMismatch, +) +from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var @pytest.fixture @@ -35,6 +47,18 @@ def test_state(): def do_something_arg(self, arg): pass + def do_something_with_bool(self, arg: bool): + pass + + def do_something_with_int(self, arg: int): + pass + + def do_something_with_list_int(self, arg: list[int]): + pass + + def do_something_with_list_str(self, arg: list[str]): + pass + return TestState @@ -56,7 +80,7 @@ def component1() -> Type[Component]: # A test string/number prop. text_or_number: Var[Union[int, str]] - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ParsedImportDict: return {"react": [ImportVar(tag="Component")]} def _get_custom_code(self) -> str: @@ -77,6 +101,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. @@ -85,11 +111,13 @@ def component2() -> Type[Component]: """ return { **super().get_event_triggers(), - "on_open": lambda e0: [e0], - "on_close": lambda e0: [e0], + "on_open": identity_event(bool), + "on_close": identity_event(bool), + "on_user_visited_count_changed": identity_event(int), + "on_user_list_changed": identity_event(List[str]), } - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ParsedImportDict: return {"react-redux": [ImportVar(tag="connect")]} def _get_custom_code(self) -> str: @@ -229,8 +257,8 @@ def test_set_style_attrs(component1): component1: A test component. """ component = component1(color="white", text_align="center") - assert component.style["color"] == "white" - assert component.style["textAlign"] == "center" + assert str(component.style["color"]) == '"white"' + assert str(component.style["textAlign"]) == '"center"' def test_custom_attrs(component1): @@ -254,7 +282,10 @@ def test_create_component(component1): c = component1.create(*children, **attrs) assert isinstance(c, component1) assert c.children == children - assert c.style == {"color": "white", "textAlign": "center"} + assert ( + str(LiteralVar.create(c.style)) + == '({ ["color"] : "white", ["textAlign"] : "center" })' + ) @pytest.mark.parametrize( @@ -262,121 +293,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", ), @@ -418,8 +449,8 @@ def test_add_style(component1, component2): } c1 = component1()._add_style_recursive(style) # type: ignore c2 = component2()._add_style_recursive(style) # type: ignore - assert c1.style["color"] == "white" - assert c2.style["color"] == "black" + assert str(c1.style["color"]) == '"white"' + assert str(c2.style["color"]) == '"black"' def test_add_style_create(component1, component2): @@ -435,8 +466,8 @@ def test_add_style_create(component1, component2): } c1 = component1()._add_style_recursive(style) # type: ignore c2 = component2()._add_style_recursive(style) # type: ignore - assert c1.style["color"] == "white" - assert c2.style["color"] == "black" + assert str(c1.style["color"]) == '"white"' + assert str(c2.style["color"]) == '"black"' def test_get_imports(component1, component2): @@ -491,7 +522,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( @@ -566,10 +597,17 @@ def test_get_event_triggers(component1, component2): EventTriggers.ON_MOUNT, EventTriggers.ON_UNMOUNT, } - assert set(component1().get_event_triggers().keys()) == default_triggers + 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", + "on_user_visited_count_changed", + "on_user_list_changed", + } + | default_triggers ) @@ -606,8 +644,8 @@ def test_create_filters_none_props(test_component): assert "prop4" not in component.get_props() # Assert that the style prop is present in the component's props - assert component.style["color"] == "white" - assert component.style["text-align"] == "center" + assert str(component.style["color"]) == '"white"' + assert str(component.style["text-align"]) == '"center"' @pytest.mark.parametrize("children", [((None,),), ("foo", ("bar", (None,)))]) @@ -629,22 +667,19 @@ def test_component_create_unallowed_types(children, test_component): "name": "Fragment", "props": [], "contents": "", - "args": None, - "special_props": set(), + "special_props": [], "children": [ { "name": "RadixThemesText", - "props": ["as={`p`}"], + "props": ['as={"p"}'], "contents": "", - "args": None, - "special_props": set(), + "special_props": [], "children": [ { "name": "", "props": [], - "contents": "{`first_text`}", - "args": None, - "special_props": set(), + "contents": '{"first_text"}', + "special_props": [], "children": [], "autofocus": False, } @@ -658,123 +693,111 @@ def test_component_create_unallowed_types(children, test_component): ( (rx.text("first_text"), rx.text("second_text")), { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [], - "contents": "{`first_text`}", + "contents": '{"first_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", - "props": ["as={`p`}"], - "special_props": set(), + "props": ['as={"p"}'], + "special_props": [], }, { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [], - "contents": "{`second_text`}", + "contents": '{"second_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", - "props": ["as={`p`}"], - "special_props": set(), + "props": ['as={"p"}'], + "special_props": [], }, ], "contents": "", "name": "Fragment", "props": [], - "special_props": set(), + "special_props": [], }, ), ( (rx.text("first_text"), rx.box((rx.text("second_text"),))), { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [], - "contents": "{`first_text`}", + "contents": '{"first_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", - "props": ["as={`p`}"], - "special_props": set(), + "props": ['as={"p"}'], + "special_props": [], }, { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [ { - "args": None, "autofocus": False, "children": [], - "contents": "{`second_text`}", + "contents": '{"second_text"}', "name": "", "props": [], - "special_props": set(), + "special_props": [], } ], "contents": "", "name": "RadixThemesText", - "props": ["as={`p`}"], - "special_props": set(), + "props": ['as={"p"}'], + "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": [], }, ), ], @@ -824,9 +847,9 @@ def test_component_event_trigger_arbitrary_args(): comp = C1.create(on_foo=C1State.mock_handler) assert comp.render()["props"][0] == ( - "onFoo={(__e,_alpha,_bravo,_charlie) => addEvents(" - '[Event("c1_state.mock_handler", {_e:__e.target.value,_bravo:_bravo["nested"],_charlie:((_charlie.custom) + (42))})], ' - "(__e,_alpha,_bravo,_charlie), {})}" + "onFoo={((__e, _alpha, _bravo, _charlie) => ((addEvents(" + f'[(Event("{C1State.get_full_name()}.mock_handler", ({{ ["_e"] : __e["target"]["value"], ["_bravo"] : _bravo["nested"], ["_charlie"] : (_charlie["custom"] + 42) }}), ({{ }})))], ' + "[__e, _alpha, _bravo, _charlie], ({ })))))}" ) @@ -866,7 +889,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 @@ -883,18 +906,121 @@ 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] + ) + + # Enable when 0.7.0 happens + # # Event Handler types must match + # with pytest.raises(EventHandlerArgTypeMismatch): + # component2.create( + # on_user_visited_count_changed=test_state.do_something_with_bool + # ) + # with pytest.raises(EventHandlerArgTypeMismatch): + # component2.create(on_user_list_changed=test_state.do_something_with_int) + # with pytest.raises(EventHandlerArgTypeMismatch): + # component2.create(on_user_list_changed=test_state.do_something_with_list_int) + + # component2.create(on_open=test_state.do_something_with_int) + # component2.create(on_open=test_state.do_something_with_bool) + # component2.create(on_user_visited_count_changed=test_state.do_something_with_int) + # component2.create(on_user_list_changed=test_state.do_something_with_list_str) + + # 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] ) @@ -902,9 +1028,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): @@ -1002,10 +1143,10 @@ def test_component_with_only_valid_children(fixture, request): @pytest.mark.parametrize( "component,rendered", [ - (rx.text("hi"), "\n {`hi`}\n"), + (rx.text("hi"), '\n\n{"hi"}\n'), ( - rx.box(rx.chakra.heading("test", size="md")), - "\n \n {`test`}\n\n", + rx.box(rx.heading("test", size="3")), + '\n\n\n\n{"test"}\n\n', ), ], ) @@ -1060,44 +1201,43 @@ def test_stateful_banner(): assert isinstance(stateful_component, StatefulComponent) -TEST_VAR = Var.create_safe("test")._replace( +TEST_VAR = LiteralVar.create("test")._replace( merge_var_data=VarData( hooks={"useTest": None}, - imports={"test": {ImportVar(tag="test")}}, + imports={"test": [ImportVar(tag="test")]}, state="Test", - interpolations=[], ) ) -FORMATTED_TEST_VAR = Var.create(f"foo{TEST_VAR}bar") -STYLE_VAR = TEST_VAR._replace(_var_name="style", _var_is_local=False) -EVENT_CHAIN_VAR = TEST_VAR._replace(_var_type=EventChain) -ARG_VAR = Var.create("arg") +FORMATTED_TEST_VAR = LiteralVar.create(f"foo{TEST_VAR}bar") +STYLE_VAR = TEST_VAR._replace(_js_expr="style") +EVENT_CHAIN_VAR = TEST_VAR.to(EventChain) +ARG_VAR = Var(_js_expr="arg") -TEST_VAR_DICT_OF_DICT = Var.create_safe({"a": {"b": "test"}})._replace( +TEST_VAR_DICT_OF_DICT = LiteralVar.create({"a": {"b": "test"}})._replace( merge_var_data=TEST_VAR._var_data ) -FORMATTED_TEST_VAR_DICT_OF_DICT = Var.create_safe({"a": {"b": f"footestbar"}})._replace( +FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create( + {"a": {"b": f"footestbar"}} +)._replace(merge_var_data=TEST_VAR._var_data) + +TEST_VAR_LIST_OF_LIST = LiteralVar.create([["test"]])._replace( + merge_var_data=TEST_VAR._var_data +) +FORMATTED_TEST_VAR_LIST_OF_LIST = LiteralVar.create([["footestbar"]])._replace( merge_var_data=TEST_VAR._var_data ) -TEST_VAR_LIST_OF_LIST = Var.create_safe([["test"]])._replace( - merge_var_data=TEST_VAR._var_data -) -FORMATTED_TEST_VAR_LIST_OF_LIST = Var.create_safe([["footestbar"]])._replace( +TEST_VAR_LIST_OF_LIST_OF_LIST = LiteralVar.create([[["test"]]])._replace( merge_var_data=TEST_VAR._var_data ) +FORMATTED_TEST_VAR_LIST_OF_LIST_OF_LIST = LiteralVar.create( + [[["footestbar"]]] +)._replace(merge_var_data=TEST_VAR._var_data) -TEST_VAR_LIST_OF_LIST_OF_LIST = Var.create_safe([[["test"]]])._replace( +TEST_VAR_LIST_OF_DICT = LiteralVar.create([{"a": "test"}])._replace( merge_var_data=TEST_VAR._var_data ) -FORMATTED_TEST_VAR_LIST_OF_LIST_OF_LIST = Var.create_safe([[["footestbar"]]])._replace( - merge_var_data=TEST_VAR._var_data -) - -TEST_VAR_LIST_OF_DICT = Var.create_safe([{"a": "test"}])._replace( - merge_var_data=TEST_VAR._var_data -) -FORMATTED_TEST_VAR_LIST_OF_DICT = Var.create_safe([{"a": "footestbar"}])._replace( +FORMATTED_TEST_VAR_LIST_OF_DICT = LiteralVar.create([{"a": "footestbar"}])._replace( merge_var_data=TEST_VAR._var_data ) @@ -1116,6 +1256,7 @@ class EventState(rx.State): v: int = 42 + @rx.event def handler(self): """A handler that does nothing.""" @@ -1181,12 +1322,22 @@ class EventState(rx.State): id="fstring-class_name", ), pytest.param( - rx.fragment(special_props={TEST_VAR}), + rx.fragment(class_name=f"foo{TEST_VAR}bar other-class"), + [LiteralVar.create(f"{FORMATTED_TEST_VAR} other-class")], + id="fstring-dual-class_name", + ), + pytest.param( + rx.fragment(class_name=[TEST_VAR, "other-class"]), + [LiteralVar.create([TEST_VAR, "other-class"]).join(" ")], + id="fstring-dual-class_name", + ), + pytest.param( + rx.fragment(special_props=[TEST_VAR]), [TEST_VAR], id="direct-special_props", ), pytest.param( - rx.fragment(special_props={Var.create(f"foo{TEST_VAR}bar")}), + rx.fragment(special_props=[LiteralVar.create(f"foo{TEST_VAR}bar")]), [FORMATTED_TEST_VAR], id="fstring-special_props", ), @@ -1289,12 +1440,15 @@ 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), ): + # print(str(comp_var), str(exp_var)) + # print(comp_var._get_all_var_data(), exp_var._get_all_var_data()) assert comp_var.equals(exp_var) @@ -1320,10 +1474,26 @@ def test_instantiate_all_components(): "Tfoot", "Thead", } - for component_name in rx._ALL_COMPONENTS: # type: ignore + component_nested_list = [ + *rx.RADIX_MAPPING.values(), + *rx.COMPONENTS_BASE_MAPPING.values(), + *rx.COMPONENTS_CORE_MAPPING.values(), + ] + for component_name in [ + comp_name + for submodule_list in component_nested_list + for comp_name in submodule_list + ]: # type: ignore if component_name in untested_components: continue - component = getattr(rx, component_name) + component = getattr( + rx, + ( + component_name + if not isinstance(component_name, tuple) + else component_name[1] + ), + ) if isinstance(component, type) and issubclass(component, Component): component.create() @@ -1390,7 +1560,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 ), ) ) @@ -1450,7 +1620,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)), ) ), @@ -1517,7 +1687,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 ), ) ) @@ -1580,70 +1752,14 @@ def test_rename_props(): c1 = C1.create(prop1="prop1_1", prop2="prop2_1") rendered_c1 = c1.render() - assert "renamed_prop1={`prop1_1`}" in rendered_c1["props"] - assert "renamed_prop2={`prop2_1`}" in rendered_c1["props"] + assert 'renamed_prop1={"prop1_1"}' in rendered_c1["props"] + assert 'renamed_prop2={"prop2_1"}' in rendered_c1["props"] c2 = C2.create(prop1="prop1_2", prop2="prop2_2", prop3="prop3_2") rendered_c2 = c2.render() - assert "renamed_prop1={`prop1_2`}" in rendered_c2["props"] - assert "subclass_prop2={`prop2_2`}" in rendered_c2["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"] + assert 'renamed_prop1={"prop1_2"}' in rendered_c2["props"] + assert 'subclass_prop2={"prop2_2"}' in rendered_c2["props"] + assert 'renamed_prop3={"prop3_2"}' in rendered_c2["props"] def test_custom_component_get_imports(): @@ -1695,7 +1811,7 @@ def test_custom_component_declare_event_handlers_in_fields(): return { **super().get_event_triggers(), "on_a": lambda e0: [e0], - "on_b": lambda e0: [e0.target.value], + "on_b": input_event, "on_c": lambda e0: [], "on_d": lambda: [], "on_e": lambda: [], @@ -1704,9 +1820,9 @@ def test_custom_component_declare_event_handlers_in_fields(): class TestComponent(Component): on_a: EventHandler[lambda e0: [e0]] - on_b: EventHandler[lambda e0: [e0.target.value]] - on_c: EventHandler[lambda e0: []] - on_d: EventHandler[lambda: []] + on_b: EventHandler[input_event] + on_c: EventHandler[empty_event] + on_d: EventHandler[empty_event] on_e: EventHandler on_f: EventHandler[lambda a, b, c: [c, b, a]] @@ -1759,21 +1875,15 @@ def test_invalid_event_trigger(): ), ) def test_component_add_imports(tags): - def _list_to_import_vars(tags: List[str]) -> List[ImportVar]: - return [ - ImportVar(tag=tag) if not isinstance(tag, ImportVar) else tag - for tag in tags - ] - class BaseComponent(Component): - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ImportDict: return {} class Reference(Component): - def _get_imports(self) -> imports.ImportDict: + def _get_imports(self) -> ParsedImportDict: return imports.merge_imports( super()._get_imports(), - {"react": _list_to_import_vars(tags)}, + parse_imports({"react": tags}), {"foo": [ImportVar(tag="bar")]}, ) @@ -1792,10 +1902,12 @@ def test_component_add_imports(tags): baseline = Reference.create() test = Test.create() - assert baseline._get_all_imports() == { - "react": _list_to_import_vars(tags), - "foo": [ImportVar(tag="bar")], - } + assert baseline._get_all_imports() == parse_imports( + { + "react": tags, + "foo": [ImportVar(tag="bar")], + } + ) assert test._get_all_imports() == baseline._get_all_imports() @@ -1953,17 +2065,53 @@ def test_component_add_custom_code(): } +def test_component_add_hooks_var(): + class HookComponent(Component): + def add_hooks(self): + return [ + "const hook3 = useRef(null)", + "const hook1 = 42", + Var( + _js_expr="useEffect(() => () => {}, [])", + _var_data=VarData( + hooks={ + "const hook2 = 43": None, + "const hook3 = useRef(null)": None, + }, + imports={"react": [ImportVar(tag="useEffect")]}, + ), + ), + Var( + _js_expr="const hook3 = useRef(null)", + _var_data=VarData(imports={"react": [ImportVar(tag="useRef")]}), + ), + ] + + assert list(HookComponent()._get_all_hooks()) == [ + "const hook3 = useRef(null)", + "const hook1 = 42", + "const hook2 = 43", + "useEffect(() => () => {}, [])", + ] + imports = HookComponent()._get_all_imports() + assert len(imports) == 1 + assert "react" in imports + assert len(imports["react"]) == 2 + assert ImportVar(tag="useRef") in imports["react"] + assert ImportVar(tag="useEffect") in imports["react"] + + def test_add_style_embedded_vars(test_state: BaseState): """Test that add_style works with embedded vars when returning a plain dict. Args: test_state: A test state. """ - v0 = Var.create_safe("parent")._replace( + v0 = LiteralVar.create("parent")._replace( merge_var_data=VarData(hooks={"useParent": None}), # type: ignore ) v1 = rx.color("plum", 10) - v2 = Var.create_safe("text")._replace( + v2 = LiteralVar.create("text")._replace( merge_var_data=VarData(hooks={"useText": None}), # type: ignore ) @@ -1989,14 +2137,14 @@ def test_add_style_embedded_vars(test_state: BaseState): page._add_style_recursive(Style()) assert ( - "const test_state = useContext(StateContexts.test_state)" + f"const {test_state.get_name()} = useContext(StateContexts.{test_state.get_name()})" in page._get_all_hooks_internal() ) assert "useText" in page._get_all_hooks_internal() assert "useParent" in page._get_all_hooks_internal() assert ( str(page).count( - 'css={{"fakeParent": "parent", "color": "var(--plum-10)", "fake": "text", "margin": `${test_state.num}%`}}' + f'css={{({{ ["fakeParent"] : "parent", ["color"] : "var(--plum-10)", ["fake"] : "text", ["margin"] : ({test_state.get_name()}.num+"%") }})}}' ) == 1 ) @@ -2017,7 +2165,134 @@ def test_add_style_foreach(): assert len(page.children[0].children) == 1 # Expect the style to be added to the child of the foreach - assert 'css={{"color": "red"}}' in str(page.children[0].children[0]) + assert 'css={({ ["color"] : "red" })}' in str(page.children[0].children[0]) # Expect only one instance of this CSS dict in the rendered page - assert str(page).count('css={{"color": "red"}}') == 1 + assert str(page).count('css={({ ["color"] : "red" })}') == 1 + + +class TriggerState(rx.State): + """Test state with event handlers.""" + + @rx.event + def do_something(self): + """Sample event handler.""" + pass + + +@pytest.mark.parametrize( + "component, output", + [ + (rx.box(rx.text("random text")), False), + ( + rx.box(rx.text("random text", on_click=rx.console_log("log"))), + False, + ), + ( + rx.box( + rx.text("random text", on_click=TriggerState.do_something), + rx.text( + "random text", + on_click=Var(_js_expr="toggleColorMode").to(EventChain), + ), + ), + True, + ), + ( + rx.box( + rx.text("random text", on_click=rx.console_log("log")), + rx.text( + "random text", + on_click=Var(_js_expr="toggleColorMode").to(EventChain), + ), + ), + False, + ), + ( + rx.box(rx.text("random text", on_click=TriggerState.do_something)), + True, + ), + ( + rx.box( + rx.text( + "random text", + on_click=[rx.console_log("log"), rx.window_alert("alert")], + ), + ), + False, + ), + ( + rx.box( + rx.text( + "random text", + on_click=[rx.console_log("log"), TriggerState.do_something], + ), + ), + True, + ), + ( + rx.box( + rx.text( + "random text", + on_blur=lambda: TriggerState.do_something, + ), + ), + True, + ), + ], +) +def test_has_state_event_triggers(component, output): + assert component._has_stateful_event_triggers() == output + + +class SpecialComponent(Box): + """A special component with custom attributes.""" + + data_prop: Var[str] + aria_prop: Var[str] + + +@pytest.mark.parametrize( + ("component_kwargs", "exp_custom_attrs", "exp_style"), + [ + ( + {"data_test": "test", "aria_test": "test"}, + {"data-test": "test", "aria-test": "test"}, + {}, + ), + ( + {"data-test": "test", "aria-test": "test"}, + {"data-test": "test", "aria-test": "test"}, + {}, + ), + ( + {"custom_attrs": {"data-existing": "test"}, "data_new": "test"}, + {"data-existing": "test", "data-new": "test"}, + {}, + ), + ( + {"data_test": "test", "data_prop": "prop"}, + {"data-test": "test"}, + {}, + ), + ( + {"aria_test": "test", "aria_prop": "prop"}, + {"aria-test": "test"}, + {}, + ), + ], +) +def test_special_props(component_kwargs, exp_custom_attrs, exp_style): + """Test that data_ and aria_ special props are correctly added to the component. + + Args: + component_kwargs: The component kwargs. + exp_custom_attrs: The expected custom attributes. + exp_style: The expected style. + """ + component = SpecialComponent.create(**component_kwargs) + assert component.custom_attrs == exp_custom_attrs + assert component.style == exp_style + for prop in SpecialComponent.get_props(): + if prop in component_kwargs: + assert getattr(component, prop)._var_value == component_kwargs[prop] diff --git a/tests/components/test_component_future_annotations.py b/tests/units/components/test_component_future_annotations.py similarity index 84% rename from tests/components/test_component_future_annotations.py rename to tests/units/components/test_component_future_annotations.py index 37aeb813a..44ec52c16 100644 --- a/tests/components/test_component_future_annotations.py +++ b/tests/units/components/test_component_future_annotations.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Any from reflex.components.component import Component -from reflex.event import EventHandler +from reflex.event import EventHandler, empty_event, input_event # This is a repeat of its namesake in test_component.py. @@ -25,9 +25,9 @@ def test_custom_component_declare_event_handlers_in_fields(): class TestComponent(Component): on_a: EventHandler[lambda e0: [e0]] - on_b: EventHandler[lambda e0: [e0.target.value]] - on_c: EventHandler[lambda e0: []] - on_d: EventHandler[lambda: []] + on_b: EventHandler[input_event] + on_c: EventHandler[empty_event] + on_d: EventHandler[empty_event] custom_component = ReferenceComponent.create() test_component = TestComponent.create() diff --git a/tests/components/test_component_state.py b/tests/units/components/test_component_state.py similarity index 89% rename from tests/components/test_component_state.py rename to tests/units/components/test_component_state.py index 0dc0956e2..574997ba5 100644 --- a/tests/components/test_component_state.py +++ b/tests/units/components/test_component_state.py @@ -35,8 +35,8 @@ def test_component_state(): assert cs1.State.increment != cs2.State.increment assert len(cs1.children) == 1 - assert cs1.children[0].render() == Bare.create("{`a`}").render() + assert cs1.children[0].render() == Bare.create("a").render() assert cs1.id == "a" assert len(cs2.children) == 1 - assert cs2.children[0].render() == Bare.create("{`b`}").render() + assert cs2.children[0].render() == Bare.create("b").render() assert cs2.id == "b" diff --git a/tests/units/components/test_props.py b/tests/units/components/test_props.py new file mode 100644 index 000000000..8ab07f135 --- /dev/null +++ b/tests/units/components/test_props.py @@ -0,0 +1,63 @@ +import pytest + +from reflex.components.props import NoExtrasAllowedProps +from reflex.utils.exceptions import InvalidPropValueError + +try: + from pydantic.v1 import ValidationError +except ModuleNotFoundError: + from pydantic import ValidationError + + +class PropA(NoExtrasAllowedProps): + """Base prop class.""" + + foo: str + bar: str + + +class PropB(NoExtrasAllowedProps): + """Prop class with nested props.""" + + foobar: str + foobaz: PropA + + +@pytest.mark.parametrize( + "props_class, kwargs, should_raise", + [ + (PropA, {"foo": "value", "bar": "another_value"}, False), + (PropA, {"fooz": "value", "bar": "another_value"}, True), + ( + PropB, + { + "foobaz": {"foo": "value", "bar": "another_value"}, + "foobar": "foo_bar_value", + }, + False, + ), + ( + PropB, + { + "fooba": {"foo": "value", "bar": "another_value"}, + "foobar": "foo_bar_value", + }, + True, + ), + ( + PropB, + { + "foobaz": {"foobar": "value", "bar": "another_value"}, + "foobar": "foo_bar_value", + }, + True, + ), + ], +) +def test_no_extras_allowed_props(props_class, kwargs, should_raise): + if should_raise: + with pytest.raises((ValidationError, InvalidPropValueError)): + props_class(**kwargs) + else: + props_instance = props_class(**kwargs) + assert isinstance(props_instance, props_class) diff --git a/tests/components/test_tag.py b/tests/units/components/test_tag.py similarity index 87% rename from tests/components/test_tag.py rename to tests/units/components/test_tag.py index 2fb2f4563..a69e40b8b 100644 --- a/tests/components/test_tag.py +++ b/tests/units/components/test_tag.py @@ -3,7 +3,7 @@ from typing import Dict, List import pytest from reflex.components.tags import CondTag, Tag, tagless -from reflex.vars import BaseVar, Var +from reflex.vars.base import LiteralVar, Var @pytest.mark.parametrize( @@ -12,8 +12,8 @@ from reflex.vars import BaseVar, Var ({}, []), ({"key-hypen": 1}, ["key-hypen={1}"]), ({"key": 1}, ["key={1}"]), - ({"key": "value"}, ["key={`value`}"]), - ({"key": True, "key2": "value2"}, ["key={true}", "key2={`value2`}"]), + ({"key": "value"}, ['key={"value"}']), + ({"key": True, "key2": "value2"}, ["key={true}", 'key2={"value2"}']), ], ) def test_format_props(props: Dict[str, Var], test_props: List): @@ -53,8 +53,8 @@ def test_is_valid_prop(prop: Var, valid: bool): def test_add_props(): """Test that the props are added.""" tag = Tag().add_props(key="value", key2=42, invalid=None, invalid2={}) - assert tag.props["key"].equals(Var.create("value")) - assert tag.props["key2"].equals(Var.create(42)) + assert tag.props["key"].equals(LiteralVar.create("value")) + assert tag.props["key2"].equals(LiteralVar.create(42)) assert "invalid" not in tag.props assert "invalid2" not in tag.props @@ -102,7 +102,7 @@ def test_format_tag(tag: Tag, expected: Dict): assert tag_dict["name"] == expected["name"] assert tag_dict["contents"] == expected["contents"] for prop, prop_value in tag_dict["props"].items(): - assert prop_value.equals(Var.create_safe(expected["props"][prop])) + assert prop_value.equals(LiteralVar.create(expected["props"][prop])) def test_format_cond_tag(): @@ -110,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 = ( @@ -118,8 +118,8 @@ def test_format_cond_tag(): tag_dict["true_value"], tag_dict["false_value"], ) - assert cond._var_name == "logged_in" - assert cond._var_type == bool + assert cond._js_expr == "logged_in" + assert cond._var_type is bool assert true_value["name"] == "h1" assert true_value["contents"] == "True content" diff --git a/tests/components/forms/__init__.py b/tests/units/components/typography/__init__.py similarity index 100% rename from tests/components/forms/__init__.py rename to tests/units/components/typography/__init__.py diff --git a/tests/components/typography/test_markdown.py b/tests/units/components/typography/test_markdown.py similarity index 91% rename from tests/components/typography/test_markdown.py rename to tests/units/components/typography/test_markdown.py index 8033ec606..5e9abbb1f 100644 --- a/tests/components/typography/test_markdown.py +++ b/tests/units/components/typography/test_markdown.py @@ -36,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( - rx.chakra.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/conftest.py b/tests/units/conftest.py similarity index 91% rename from tests/conftest.py rename to tests/units/conftest.py index be9290edb..2f619a941 100644 --- a/tests/conftest.py +++ b/tests/units/conftest.py @@ -1,16 +1,19 @@ """Test fixtures.""" + +import asyncio import contextlib import os import platform import uuid from pathlib import Path -from typing import Dict, Generator +from typing import Dict, Generator, Type from unittest import mock import pytest from reflex.app import App from reflex.event import EventSpec +from reflex.model import ModelRegistry from reflex.utils import prerequisites from .states import ( @@ -22,6 +25,11 @@ from .states import ( ) +def pytest_configure(config): + if config.getoption("asyncio_mode") == "auto": + asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy()) + + @pytest.fixture def app() -> App: """A base app. @@ -229,7 +237,7 @@ def tmp_working_dir(tmp_path): @pytest.fixture -def mutable_state(): +def mutable_state() -> MutableTestState: """Create a Test state containing mutable types. Returns: @@ -246,3 +254,14 @@ def token() -> str: A fresh/unique token string. """ return str(uuid.uuid4()) + + +@pytest.fixture +def model_registry() -> Generator[Type[ModelRegistry], None, None]: + """Create a model registry. + + Yields: + A fresh model registry. + """ + yield ModelRegistry + ModelRegistry._metadata = None diff --git a/tests/units/experimental/custom_script.js b/tests/units/experimental/custom_script.js new file mode 100644 index 000000000..81bae3136 --- /dev/null +++ b/tests/units/experimental/custom_script.js @@ -0,0 +1 @@ +const test = "inside custom_script.js"; \ No newline at end of file diff --git a/tests/units/experimental/test_assets.py b/tests/units/experimental/test_assets.py new file mode 100644 index 000000000..8037bcc75 --- /dev/null +++ b/tests/units/experimental/test_assets.py @@ -0,0 +1,36 @@ +import shutil +from pathlib import Path + +import pytest + +import reflex as rx + + +def test_asset(): + # Test the asset function. + + # The asset function copies a file to the app's external assets directory. + asset = rx._x.asset("custom_script.js", "subfolder") + assert asset == "/external/test_assets/subfolder/custom_script.js" + result_file = Path( + Path.cwd(), "assets/external/test_assets/subfolder/custom_script.js" + ) + assert result_file.exists() + + # Running a second time should not raise an error. + asset = rx._x.asset("custom_script.js", "subfolder") + + # Test the asset function without a subfolder. + asset = rx._x.asset("custom_script.js") + assert asset == "/external/test_assets/custom_script.js" + result_file = Path(Path.cwd(), "assets/external/test_assets/custom_script.js") + assert result_file.exists() + + # clean up + shutil.rmtree(Path.cwd() / "assets/external") + + with pytest.raises(FileNotFoundError): + asset = rx._x.asset("non_existent_file.js") + + # Nothing is done to assets when file does not exist. + assert not Path(Path.cwd() / "assets/external").exists() diff --git a/tests/components/typography/__init__.py b/tests/units/middleware/__init__.py similarity index 100% rename from tests/components/typography/__init__.py rename to tests/units/middleware/__init__.py diff --git a/tests/middleware/conftest.py b/tests/units/middleware/conftest.py similarity index 82% rename from tests/middleware/conftest.py rename to tests/units/middleware/conftest.py index 5a1897110..d786db652 100644 --- a/tests/middleware/conftest.py +++ b/tests/units/middleware/conftest.py @@ -1,6 +1,7 @@ import pytest from reflex.event import Event +from reflex.state import State def create_event(name): @@ -21,4 +22,4 @@ def create_event(name): @pytest.fixture def event1(): - return create_event("state.hydrate") + return create_event(f"{State.get_name()}.hydrate") diff --git a/tests/middleware/test_hydrate_middleware.py b/tests/units/middleware/test_hydrate_middleware.py similarity index 100% rename from tests/middleware/test_hydrate_middleware.py rename to tests/units/middleware/test_hydrate_middleware.py diff --git a/tests/states/__init__.py b/tests/units/states/__init__.py similarity index 99% rename from tests/states/__init__.py rename to tests/units/states/__init__.py index 11e891ab4..6aae7683a 100644 --- a/tests/states/__init__.py +++ b/tests/units/states/__init__.py @@ -1,4 +1,5 @@ """Common rx.BaseState subclasses for use in tests.""" + import reflex as rx from reflex.state import BaseState diff --git a/tests/states/mutation.py b/tests/units/states/mutation.py similarity index 77% rename from tests/states/mutation.py rename to tests/units/states/mutation.py index 5825b6d12..b05f558a1 100644 --- a/tests/states/mutation.py +++ b/tests/units/states/mutation.py @@ -2,8 +2,12 @@ from typing import Dict, List, Set, Union +from sqlalchemy import ARRAY, JSON, String +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column + import reflex as rx from reflex.state import BaseState +from reflex.utils.serializers import serializer class DictMutationTestState(BaseState): @@ -145,15 +149,47 @@ class CustomVar(rx.Base): custom: OtherBase = OtherBase() +class MutableSQLABase(DeclarativeBase): + """SQLAlchemy base model for mutable vars.""" + + pass + + +class MutableSQLAModel(MutableSQLABase): + """SQLAlchemy model for mutable vars.""" + + __tablename__: str = "mutable_test_state" + + id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) + strlist: Mapped[List[str]] = mapped_column(ARRAY(String)) + hashmap: Mapped[Dict[str, str]] = mapped_column(JSON) + test_set: Mapped[Set[str]] = mapped_column(ARRAY(String)) + + +@serializer +def serialize_mutable_sqla_model( + model: MutableSQLAModel, +) -> Dict[str, Union[List[str], Dict[str, str]]]: + """Serialize the MutableSQLAModel. + + Args: + model: The MutableSQLAModel instance to serialize. + + Returns: + The serialized model. + """ + return {"strlist": model.strlist, "hashmap": model.hashmap} + + class MutableTestState(BaseState): """A test state.""" - array: List[Union[str, List, Dict[str, str]]] = [ + array: List[Union[str, int, List, Dict[str, str]]] = [ "value", [1, 2, 3], {"key": "value"}, ] - hashmap: Dict[str, Union[List, str, Dict[str, str]]] = { + hashmap: Dict[str, Union[List, str, Dict[str, Union[str, Dict]]]] = { "key": ["list", "of", "values"], "another_key": "another_value", "third_key": {"key": "value"}, @@ -161,6 +197,11 @@ class MutableTestState(BaseState): test_set: Set[Union[str, int]] = {1, 2, 3, 4, "five"} custom: CustomVar = CustomVar() _be_custom: CustomVar = CustomVar() + sqla_model: MutableSQLAModel = MutableSQLAModel( + strlist=["a", "b", "c"], + hashmap={"key": "value"}, + test_set={"one", "two", "three"}, + ) def reassign_mutables(self): """Assign mutable fields to different values.""" @@ -171,3 +212,8 @@ class MutableTestState(BaseState): "mod_third_key": {"key": "value"}, } self.test_set = {1, 2, 3, 4, "five"} + self.sqla_model = MutableSQLAModel( + strlist=["d", "e", "f"], + hashmap={"key": "value"}, + test_set={"one", "two", "three"}, + ) diff --git a/tests/states/upload.py b/tests/units/states/upload.py similarity index 97% rename from tests/states/upload.py rename to tests/units/states/upload.py index 8abe11c24..338025bcd 100644 --- a/tests/states/upload.py +++ b/tests/units/states/upload.py @@ -1,4 +1,5 @@ """Test states for upload-related tests.""" + from pathlib import Path from typing import ClassVar, List @@ -70,7 +71,7 @@ class FileUploadState(State): assert file.filename is not None self.img_list.append(file.filename) - @rx.background + @rx.event(background=True) async def bg_upload(self, files: List[rx.UploadFile]): """Background task cannot be upload handler. @@ -118,7 +119,7 @@ class ChildFileUploadState(FileStateBase1): assert file.filename is not None self.img_list.append(file.filename) - @rx.background + @rx.event(background=True) async def bg_upload(self, files: List[rx.UploadFile]): """Background task cannot be upload handler. @@ -166,7 +167,7 @@ class GrandChildFileUploadState(FileStateBase2): assert file.filename is not None self.img_list.append(file.filename) - @rx.background + @rx.event(background=True) async def bg_upload(self, files: List[rx.UploadFile]): """Background task cannot be upload handler. diff --git a/tests/test_app.py b/tests/units/test_app.py similarity index 74% rename from tests/test_app.py rename to tests/units/test_app.py index 0e204c7d5..1e34a67c3 100644 --- a/tests/test_app.py +++ b/tests/units/test_app.py @@ -1,11 +1,13 @@ from __future__ import annotations +import functools import io import json import os.path import re import unittest.mock import uuid +from contextlib import nullcontext as does_not_raise from pathlib import Path from typing import Generator, List, Tuple, Type from unittest.mock import AsyncMock @@ -27,7 +29,9 @@ from reflex.app import ( process, upload, ) -from reflex.components import Component, Cond, Fragment +from reflex.components import Component +from reflex.components.base.fragment import Fragment +from reflex.components.core.cond import Cond from reflex.components.radix.themes.typography.text import Text from reflex.event import Event from reflex.middleware import HydrateMiddleware @@ -37,6 +41,7 @@ from reflex.state import ( OnLoadInternalState, RouterData, State, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateUpdate, @@ -44,7 +49,7 @@ from reflex.state import ( ) from reflex.style import Style from reflex.utils import exceptions, format -from reflex.vars import ComputedVar +from reflex.vars.base import computed_var from .conftest import chdir from .states import ( @@ -63,7 +68,7 @@ class EmptyState(BaseState): @pytest.fixture -def index_page(): +def index_page() -> ComponentCallable: """An index page. Returns: @@ -77,7 +82,7 @@ def index_page(): @pytest.fixture -def about_page(): +def about_page() -> ComponentCallable: """An about page. Returns: @@ -232,10 +237,13 @@ def test_add_page_default_route(app: App, index_page, about_page): about_page: The about page. """ assert app.pages == {} + assert app.unevaluated_pages == {} app.add_page(index_page) - assert set(app.pages.keys()) == {"index"} + app._compile_page("index") + assert app.pages.keys() == {"index"} app.add_page(about_page) - assert set(app.pages.keys()) == {"index", "about"} + app._compile_page("about") + assert app.pages.keys() == {"index", "about"} def test_add_page_set_route(app: App, index_page, windows_platform: bool): @@ -247,9 +255,10 @@ def test_add_page_set_route(app: App, index_page, windows_platform: bool): windows_platform: Whether the system is windows. """ route = "test" if windows_platform else "/test" - assert app.pages == {} + assert app.unevaluated_pages == {} app.add_page(index_page, route=route) - assert set(app.pages.keys()) == {"test"} + app._compile_page("test") + assert app.pages.keys() == {"test"} def test_add_page_set_route_dynamic(index_page, windows_platform: bool): @@ -262,11 +271,10 @@ 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.pages == {} + assert app.unevaluated_pages == {} app.add_page(index_page, route=route) - assert set(app.pages.keys()) == {"test/[dynamic]"} + app._compile_page("test/[dynamic]") + assert app.pages.keys() == {"test/[dynamic]"} assert "dynamic" in app.state.computed_vars assert app.state.computed_vars["dynamic"]._deps(objclass=EmptyState) == { constants.ROUTER @@ -283,9 +291,9 @@ def test_add_page_set_route_nested(app: App, index_page, windows_platform: bool) windows_platform: Whether the system is windows. """ route = "test\\nested" if windows_platform else "/test/nested" - assert app.pages == {} + assert app.unevaluated_pages == {} app.add_page(index_page, route=route) - assert set(app.pages.keys()) == {route.strip(os.path.sep)} + assert app.unevaluated_pages.keys() == {route.strip(os.path.sep)} def test_add_page_invalid_api_route(app: App, index_page): @@ -481,20 +489,12 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): pytest.param( [ ( - "list_mutation_test_state.make_friend", - { - "list_mutation_test_state": { - "plain_friends": ["Tommy", "another-fd"] - } - }, + "make_friend", + {"plain_friends": ["Tommy", "another-fd"]}, ), ( - "list_mutation_test_state.change_first_friend", - { - "list_mutation_test_state": { - "plain_friends": ["Jenny", "another-fd"] - } - }, + "change_first_friend", + {"plain_friends": ["Jenny", "another-fd"]}, ), ], id="append then __setitem__", @@ -502,12 +502,12 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): pytest.param( [ ( - "list_mutation_test_state.unfriend_first_friend", - {"list_mutation_test_state": {"plain_friends": []}}, + "unfriend_first_friend", + {"plain_friends": []}, ), ( - "list_mutation_test_state.make_friend", - {"list_mutation_test_state": {"plain_friends": ["another-fd"]}}, + "make_friend", + {"plain_friends": ["another-fd"]}, ), ], id="delitem then append", @@ -515,24 +515,20 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): pytest.param( [ ( - "list_mutation_test_state.make_friends_with_colleagues", - { - "list_mutation_test_state": { - "plain_friends": ["Tommy", "Peter", "Jimmy"] - } - }, + "make_friends_with_colleagues", + {"plain_friends": ["Tommy", "Peter", "Jimmy"]}, ), ( - "list_mutation_test_state.remove_tommy", - {"list_mutation_test_state": {"plain_friends": ["Peter", "Jimmy"]}}, + "remove_tommy", + {"plain_friends": ["Peter", "Jimmy"]}, ), ( - "list_mutation_test_state.remove_last_friend", - {"list_mutation_test_state": {"plain_friends": ["Peter"]}}, + "remove_last_friend", + {"plain_friends": ["Peter"]}, ), ( - "list_mutation_test_state.unfriend_all_friends", - {"list_mutation_test_state": {"plain_friends": []}}, + "unfriend_all_friends", + {"plain_friends": []}, ), ], id="extend, remove, pop, clear", @@ -540,28 +536,16 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): pytest.param( [ ( - "list_mutation_test_state.add_jimmy_to_second_group", - { - "list_mutation_test_state": { - "friends_in_nested_list": [["Tommy"], ["Jenny", "Jimmy"]] - } - }, + "add_jimmy_to_second_group", + {"friends_in_nested_list": [["Tommy"], ["Jenny", "Jimmy"]]}, ), ( - "list_mutation_test_state.remove_first_person_from_first_group", - { - "list_mutation_test_state": { - "friends_in_nested_list": [[], ["Jenny", "Jimmy"]] - } - }, + "remove_first_person_from_first_group", + {"friends_in_nested_list": [[], ["Jenny", "Jimmy"]]}, ), ( - "list_mutation_test_state.remove_first_group", - { - "list_mutation_test_state": { - "friends_in_nested_list": [["Jenny", "Jimmy"]] - } - }, + "remove_first_group", + {"friends_in_nested_list": [["Jenny", "Jimmy"]]}, ), ], id="nested list", @@ -569,24 +553,16 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): pytest.param( [ ( - "list_mutation_test_state.add_jimmy_to_tommy_friends", - { - "list_mutation_test_state": { - "friends_in_dict": {"Tommy": ["Jenny", "Jimmy"]} - } - }, + "add_jimmy_to_tommy_friends", + {"friends_in_dict": {"Tommy": ["Jenny", "Jimmy"]}}, ), ( - "list_mutation_test_state.remove_jenny_from_tommy", - { - "list_mutation_test_state": { - "friends_in_dict": {"Tommy": ["Jimmy"]} - } - }, + "remove_jenny_from_tommy", + {"friends_in_dict": {"Tommy": ["Jimmy"]}}, ), ( - "list_mutation_test_state.tommy_has_no_fds", - {"list_mutation_test_state": {"friends_in_dict": {"Tommy": []}}}, + "tommy_has_no_fds", + {"friends_in_dict": {"Tommy": []}}, ), ], id="list in dict", @@ -610,12 +586,14 @@ async def test_list_mutation_detection__plain_list( result = await list_mutation_state._process( Event( token=token, - name=event_name, + name=f"{list_mutation_state.get_name()}.{event_name}", router_data={"pathname": "/", "query": {}}, payload={}, ) ).__anext__() + # prefix keys in expected_delta with the state name + expected_delta = {list_mutation_state.get_name(): expected_delta} assert result.delta == expected_delta @@ -626,24 +604,16 @@ async def test_list_mutation_detection__plain_list( pytest.param( [ ( - "dict_mutation_test_state.add_age", - { - "dict_mutation_test_state": { - "details": {"name": "Tommy", "age": 20} - } - }, + "add_age", + {"details": {"name": "Tommy", "age": 20}}, ), ( - "dict_mutation_test_state.change_name", - { - "dict_mutation_test_state": { - "details": {"name": "Jenny", "age": 20} - } - }, + "change_name", + {"details": {"name": "Jenny", "age": 20}}, ), ( - "dict_mutation_test_state.remove_last_detail", - {"dict_mutation_test_state": {"details": {"name": "Jenny"}}}, + "remove_last_detail", + {"details": {"name": "Jenny"}}, ), ], id="update then __setitem__", @@ -651,12 +621,12 @@ async def test_list_mutation_detection__plain_list( pytest.param( [ ( - "dict_mutation_test_state.clear_details", - {"dict_mutation_test_state": {"details": {}}}, + "clear_details", + {"details": {}}, ), ( - "dict_mutation_test_state.add_age", - {"dict_mutation_test_state": {"details": {"age": 20}}}, + "add_age", + {"details": {"age": 20}}, ), ], id="delitem then update", @@ -664,20 +634,16 @@ async def test_list_mutation_detection__plain_list( pytest.param( [ ( - "dict_mutation_test_state.add_age", - { - "dict_mutation_test_state": { - "details": {"name": "Tommy", "age": 20} - } - }, + "add_age", + {"details": {"name": "Tommy", "age": 20}}, ), ( - "dict_mutation_test_state.remove_name", - {"dict_mutation_test_state": {"details": {"age": 20}}}, + "remove_name", + {"details": {"age": 20}}, ), ( - "dict_mutation_test_state.pop_out_age", - {"dict_mutation_test_state": {"details": {}}}, + "pop_out_age", + {"details": {}}, ), ], id="add, remove, pop", @@ -685,22 +651,16 @@ async def test_list_mutation_detection__plain_list( pytest.param( [ ( - "dict_mutation_test_state.remove_home_address", - { - "dict_mutation_test_state": { - "address": [{}, {"work": "work address"}] - } - }, + "remove_home_address", + {"address": [{}, {"work": "work address"}]}, ), ( - "dict_mutation_test_state.add_street_to_home_address", + "add_street_to_home_address", { - "dict_mutation_test_state": { - "address": [ - {"street": "street address"}, - {"work": "work address"}, - ] - } + "address": [ + {"street": "street address"}, + {"work": "work address"}, + ] }, ), ], @@ -709,34 +669,26 @@ async def test_list_mutation_detection__plain_list( pytest.param( [ ( - "dict_mutation_test_state.change_friend_name", + "change_friend_name", { - "dict_mutation_test_state": { - "friend_in_nested_dict": { - "name": "Nikhil", - "friend": {"name": "Tommy"}, - } + "friend_in_nested_dict": { + "name": "Nikhil", + "friend": {"name": "Tommy"}, } }, ), ( - "dict_mutation_test_state.add_friend_age", + "add_friend_age", { - "dict_mutation_test_state": { - "friend_in_nested_dict": { - "name": "Nikhil", - "friend": {"name": "Tommy", "age": 30}, - } + "friend_in_nested_dict": { + "name": "Nikhil", + "friend": {"name": "Tommy", "age": 30}, } }, ), ( - "dict_mutation_test_state.remove_friend", - { - "dict_mutation_test_state": { - "friend_in_nested_dict": {"name": "Nikhil"} - } - }, + "remove_friend", + {"friend_in_nested_dict": {"name": "Nikhil"}}, ), ], id="nested dict", @@ -760,12 +712,15 @@ async def test_dict_mutation_detection__plain_list( result = await dict_mutation_state._process( Event( token=token, - name=event_name, + name=f"{dict_mutation_state.get_name()}.{event_name}", router_data={"pathname": "/", "query": {}}, payload={}, ) ).__anext__() + # prefix keys in expected_delta with the state name + expected_delta = {dict_mutation_state.get_name(): expected_delta} + assert result.delta == expected_delta @@ -775,12 +730,16 @@ async def test_dict_mutation_detection__plain_list( [ ( FileUploadState, - {"state.file_upload_state": {"img_list": ["image1.jpg", "image2.jpg"]}}, + { + FileUploadState.get_full_name(): { + "img_list": ["image1.jpg", "image2.jpg"] + } + }, ), ( ChildFileUploadState, { - "state.file_state_base1.child_file_upload_state": { + ChildFileUploadState.get_full_name(): { "img_list": ["image1.jpg", "image2.jpg"] } }, @@ -788,7 +747,7 @@ async def test_dict_mutation_detection__plain_list( ( GrandChildFileUploadState, { - "state.file_state_base1.file_state_base2.grand_child_file_upload_state": { + GrandChildFileUploadState.get_full_name(): { "img_list": ["image1.jpg", "image2.jpg"] } }, @@ -811,7 +770,8 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker): ) state._tmp_path = tmp_path # The App state must be the "root" of the state tree - app = App(state=State) + app = App() + app._enable_state() app.event_namespace.emit = AsyncMock() # type: ignore current_state = await app.state_manager.get_state(_substate_key(token, state)) data = b"This is binary data" @@ -914,7 +874,7 @@ async def test_upload_file_background(state, tmp_path, token): await fn(request_mock, [file_mock]) assert ( err.value.args[0] - == f"@rx.background is not supported for upload handler `{state.get_full_name()}.bg_upload`." + == f"@rx.event(background=True) is not supported for upload handler `{state.get_full_name()}.bg_upload`." ) if isinstance(app.state_manager, StateManagerRedis): @@ -945,11 +905,12 @@ class DynamicState(BaseState): """Event handler for page on_load, should trigger for all navigation events.""" self.loaded = self.loaded + 1 + @rx.event def on_counter(self): """Increment the counter var.""" self.counter = self.counter + 1 - @ComputedVar + @computed_var(cache=True) def comp_dynamic(self) -> str: """A computed var that depends on the dynamic var. @@ -962,9 +923,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, @@ -984,8 +993,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 @@ -1061,7 +1068,7 @@ async def test_dynamic_route_var_route_change_completed_on_load( val=exp_val, ), _event( - name="state.set_is_hydrated", + name=f"{State.get_name()}.set_is_hydrated", payload={"value": True}, val=exp_val, router_data={}, @@ -1092,9 +1099,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, }, }, @@ -1116,9 +1120,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, }, }, @@ -1140,9 +1141,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, } }, @@ -1184,7 +1182,10 @@ async def test_process_events(mocker, token: str): app = App(state=GenState) mocker.patch.object(app, "_postprocess", AsyncMock()) event = Event( - token=token, name="gen_state.go", payload={"c": 5}, router_data=router_data + token=token, + name=f"{GenState.get_name()}.go", + payload={"c": 5}, + router_data=router_data, ) async for _update in process(app, event, "mock_sid", {}, "127.0.0.1"): @@ -1210,7 +1211,7 @@ async def test_process_events(mocker, token: str): ], ) def test_overlay_component( - state: State | None, + state: Type[State] | None, overlay_component: Component | ComponentCallable | None, exp_page_child: Type[Component] | None, ): @@ -1242,6 +1243,7 @@ def test_overlay_component( app.add_page(rx.box("Index"), route="/test") # overlay components are wrapped during compile only + app._compile_page("test") app._setup_overlay_component() page = app.pages["test"] @@ -1269,14 +1271,14 @@ def compilable_app(tmp_path) -> Generator[tuple[App, Path], None, None]: app_path = tmp_path / "app" web_dir = app_path / ".web" web_dir.mkdir(parents=True) - (web_dir / "package.json").touch() + (web_dir / constants.PackageJson.PATH).touch() app = App(theme=None) app._get_frontend_packages = unittest.mock.Mock() with chdir(app_path): yield app, web_dir -def test_app_wrap_compile_theme(compilable_app): +def test_app_wrap_compile_theme(compilable_app: tuple[App, Path]): """Test that the radix theme component wraps the app. Args: @@ -1293,7 +1295,7 @@ def test_app_wrap_compile_theme(compilable_app): "function AppWrap({children}) {" "return (" "" - "" + "" "" "{children}" "" @@ -1304,7 +1306,7 @@ def test_app_wrap_compile_theme(compilable_app): ) in "".join(app_js_lines) -def test_app_wrap_priority(compilable_app): +def test_app_wrap_priority(compilable_app: tuple[App, Path]): """Test that the app wrap components are wrapped in the correct order. Args: @@ -1316,13 +1318,13 @@ def test_app_wrap_priority(compilable_app): tag = "Fragment1" def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: - return {(99, "Box"): rx.chakra.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"): rx.chakra.text()} + return {(50, "Text"): rx.text()} class Fragment3(Component): tag = "Fragment3" @@ -1342,19 +1344,17 @@ def test_app_wrap_priority(compilable_app): assert ( "function AppWrap({children}) {" "return (" - "" - "" - "" - "" + "" + '' + "" "" "" "{children}" "" "" - "" - "" - "" - "" + "" + "" + "" ")" "}" ) in "".join(app_js_lines) @@ -1371,6 +1371,7 @@ def test_app_state_determination(): # Add a page with `on_load` enables state. a1.add_page(rx.box("About"), route="/about", on_load=rx.console_log("")) + a1._compile_page("about") assert a1.state is not None a2 = App() @@ -1378,6 +1379,7 @@ def test_app_state_determination(): # Referencing a state Var enables state. a2.add_page(rx.box(rx.text(GenState.value)), route="/") + a2._compile_page("index") assert a2.state is not None a3 = App() @@ -1385,23 +1387,22 @@ def test_app_state_determination(): # Referencing router enables state. a3.add_page(rx.box(rx.text(State.router.page.full_path)), route="/") + a3._compile_page("index") assert a3.state is not None a4 = App() assert a4.state is None - # Referencing an event handler enables state. a4.add_page(rx.box(rx.button("Click", on_click=rx.console_log(""))), route="/") + assert a4.state is None + + a4.add_page( + rx.box(rx.button("Click", on_click=DynamicState.on_counter)), route="/page2" + ) + a4._compile_page("page2") assert a4.state is not None -# for coverage -def test_raise_on_connect_error(): - """Test that the connect_error function is called.""" - with pytest.raises(ValueError): - App(connect_error_component="Foo") - - def test_raise_on_state(): """Test that the state is set.""" # state kwargs is deprecated, we just make sure the app is created anyway. @@ -1432,7 +1433,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(): @@ -1469,22 +1472,25 @@ def test_add_page_component_returning_tuple(): app.add_page(index) # type: ignore app.add_page(page2) # type: ignore + app._compile_page("index") + app._compile_page("page2") + assert isinstance((fragment_wrapper := app.pages["index"].children[0]), Fragment) assert isinstance((first_text := fragment_wrapper.children[0]), Text) - assert str(first_text.children[0].contents) == "{`first`}" # type: ignore + assert str(first_text.children[0].contents) == '"first"' # type: ignore assert isinstance((second_text := fragment_wrapper.children[1]), Text) - assert str(second_text.children[0].contents) == "{`second`}" # type: ignore + assert str(second_text.children[0].contents) == '"second"' # type: ignore # Test page with trailing comma. assert isinstance( (page2_fragment_wrapper := app.pages["page2"].children[0]), Fragment ) assert isinstance((third_text := page2_fragment_wrapper.children[0]), Text) - assert str(third_text.children[0].contents) == "{`third`}" # type: ignore + assert str(third_text.children[0].contents) == '"third"' # type: ignore @pytest.mark.parametrize("export", (True, False)) -def test_app_with_transpile_packages(compilable_app, export): +def test_app_with_transpile_packages(compilable_app: tuple[App, Path], export: bool): class C1(rx.Component): library = "foo@1.2.3" tag = "Foo" @@ -1533,3 +1539,197 @@ def test_app_with_transpile_packages(compilable_app, export): else: assert 'output: "export"' not in next_config assert f'distDir: "{constants.Dirs.STATIC}"' not in next_config + + +def test_app_with_valid_var_dependencies(compilable_app: tuple[App, Path]): + app, _ = compilable_app + + class ValidDepState(BaseState): + base: int = 0 + _backend: int = 0 + + @computed_var(cache=True) + def foo(self) -> str: + return "foo" + + @computed_var(deps=["_backend", "base", foo], cache=True) + def bar(self) -> str: + return "bar" + + app.state = ValidDepState + app._compile() + + +def test_app_with_invalid_var_dependencies(compilable_app: tuple[App, Path]): + app, _ = compilable_app + + class InvalidDepState(BaseState): + @computed_var(deps=["foolksjdf"], cache=True) + def bar(self) -> str: + return "bar" + + app.state = InvalidDepState + with pytest.raises(exceptions.VarDependencyError): + app._compile() + + +# Test custom exception handlers + + +def valid_custom_handler(exception: Exception, logger: str = "test"): + print("Custom Backend Exception") + print(exception) + + +def custom_exception_handler_with_wrong_arg_order( + logger: str, + exception: Exception, # Should be first +): + print("Custom Backend Exception") + print(exception) + + +def custom_exception_handler_with_wrong_argspec( + exception: str, # Should be Exception +): + print("Custom Backend Exception") + print(exception) + + +class DummyExceptionHandler: + """Dummy exception handler class.""" + + def handle(self, exception: Exception): + """Handle the exception. + + Args: + exception: The exception. + + """ + print("Custom Backend Exception") + print(exception) + + +custom_exception_handlers = { + "lambda": lambda exception: print("Custom Exception Handler", exception), + "wrong_argspec": custom_exception_handler_with_wrong_argspec, + "wrong_arg_order": custom_exception_handler_with_wrong_arg_order, + "valid": valid_custom_handler, + "partial": functools.partial(valid_custom_handler, logger="test"), + "method": DummyExceptionHandler().handle, +} + + +@pytest.mark.parametrize( + "handler_fn, expected", + [ + pytest.param( + custom_exception_handlers["partial"], + pytest.raises(ValueError), + id="partial", + ), + pytest.param( + custom_exception_handlers["lambda"], + pytest.raises(ValueError), + id="lambda", + ), + pytest.param( + custom_exception_handlers["wrong_argspec"], + pytest.raises(ValueError), + id="wrong_argspec", + ), + pytest.param( + custom_exception_handlers["wrong_arg_order"], + pytest.raises(ValueError), + id="wrong_arg_order", + ), + pytest.param( + custom_exception_handlers["valid"], + does_not_raise(), + id="valid_handler", + ), + pytest.param( + custom_exception_handlers["method"], + does_not_raise(), + id="valid_class_method", + ), + ], +) +def test_frontend_exception_handler_validation(handler_fn, expected): + """Test that the custom frontend exception handler is properly validated. + + Args: + handler_fn: The handler function. + expected: The expected result. + + """ + with expected: + rx.App(frontend_exception_handler=handler_fn)._validate_exception_handlers() + + +def backend_exception_handler_with_wrong_return_type(exception: Exception) -> int: + """Custom backend exception handler with wrong return type. + + Args: + exception: The exception. + + Returns: + int: The wrong return type. + + """ + print("Custom Backend Exception") + print(exception) + + return 5 + + +@pytest.mark.parametrize( + "handler_fn, expected", + [ + pytest.param( + backend_exception_handler_with_wrong_return_type, + pytest.raises(ValueError), + id="wrong_return_type", + ), + pytest.param( + custom_exception_handlers["partial"], + pytest.raises(ValueError), + id="partial", + ), + pytest.param( + custom_exception_handlers["lambda"], + pytest.raises(ValueError), + id="lambda", + ), + pytest.param( + custom_exception_handlers["wrong_argspec"], + pytest.raises(ValueError), + id="wrong_argspec", + ), + pytest.param( + custom_exception_handlers["wrong_arg_order"], + pytest.raises(ValueError), + id="wrong_arg_order", + ), + pytest.param( + custom_exception_handlers["valid"], + does_not_raise(), + id="valid_handler", + ), + pytest.param( + custom_exception_handlers["method"], + does_not_raise(), + id="valid_class_method", + ), + ], +) +def test_backend_exception_handler_validation(handler_fn, expected): + """Test that the custom backend exception handler is properly validated. + + Args: + handler_fn: The handler function. + expected: The expected result. + + """ + with expected: + rx.App(backend_exception_handler=handler_fn)._validate_exception_handlers() diff --git a/tests/test_attribute_access_type.py b/tests/units/test_attribute_access_type.py similarity index 71% rename from tests/test_attribute_access_type.py rename to tests/units/test_attribute_access_type.py index 821ccad04..0d490ec1e 100644 --- a/tests/test_attribute_access_type.py +++ b/tests/units/test_attribute_access_type.py @@ -1,10 +1,11 @@ from __future__ import annotations -from typing import List, Optional, Union +from typing import Dict, List, Optional, Type, Union import attrs import pytest import sqlalchemy +from sqlalchemy import JSON, TypeDecorator from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship @@ -12,10 +13,29 @@ import reflex as rx from reflex.utils.types import GenericType, get_attribute_access_type +class SQLAType(TypeDecorator): + """SQLAlchemy custom dict type.""" + + impl = JSON + + @property + def python_type(self) -> Type[Dict[str, str]]: + """Python type. + + Returns: + Python Type of the column. + """ + return Dict[str, str] + + class SQLABase(DeclarativeBase): """Base class for bare SQLAlchemy models.""" - pass + type_annotation_map = { + # do not use lower case dict here! + # https://github.com/sqlalchemy/sqlalchemy/issues/9902 + Dict[str, str]: SQLAType, + } class SQLATag(SQLABase): @@ -52,6 +72,9 @@ class SQLAClass(SQLABase): sqla_tag_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey(SQLATag.id)) sqla_tag: Mapped[Optional[SQLATag]] = relationship() labels: Mapped[List[SQLALabel]] = relationship(back_populates="test") + # do not use lower case dict here! + # https://github.com/sqlalchemy/sqlalchemy/issues/9902 + dict_str_str: Mapped[Dict[str, str]] = mapped_column() @property def str_property(self) -> str: @@ -71,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.""" @@ -82,6 +114,7 @@ class ModelClass(rx.Model): optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] + dict_str_str: Dict[str, str] = {} @property def str_property(self) -> str: @@ -101,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.""" @@ -112,6 +154,7 @@ class BaseClass(rx.Base): optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] + dict_str_str: Dict[str, str] = {} @property def str_property(self) -> str: @@ -131,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.""" @@ -142,6 +194,7 @@ class BareClass: optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] + dict_str_str: Dict[str, str] = {} @property def str_property(self) -> str: @@ -161,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: @@ -173,6 +235,7 @@ class AttrClass: optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] + dict_str_str: Dict[str, str] = {} @property def str_property(self) -> str: @@ -192,8 +255,25 @@ class AttrClass: """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. -@pytest.fixture(params=[SQLAClass, BaseClass, BareClass, ModelClass, AttrClass]) + Returns: + First label + """ + return self.labels[0] if self.labels else None + + +@pytest.fixture( + params=[ + SQLAClass, + BaseClass, + BareClass, + ModelClass, + AttrClass, + ] +) def cls(request: pytest.FixtureRequest) -> type: """Fixture for the class to test. @@ -216,8 +296,10 @@ def cls(request: pytest.FixtureRequest) -> type: pytest.param("optional_int", Optional[int], id="Optional[int]"), pytest.param("sqla_tag", Optional[SQLATag], id="Optional[SQLATag]"), pytest.param("labels", List[SQLALabel], id="List[SQLALabel]"), + 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_base.py b/tests/units/test_base.py similarity index 100% rename from tests/test_base.py rename to tests/units/test_base.py diff --git a/tests/test_config.py b/tests/units/test_config.py similarity index 76% rename from tests/test_config.py rename to tests/units/test_config.py index 31dd77649..0c63abc96 100644 --- a/tests/test_config.py +++ b/tests/units/test_config.py @@ -1,11 +1,19 @@ import multiprocessing import os +from pathlib import Path +from typing import Any, Dict import pytest import reflex as rx import reflex.config -from reflex.constants import Endpoint +from reflex.config import ( + environment, + interpret_boolean_env, + interpret_enum_env, + interpret_int_env, +) +from reflex.constants import Endpoint, Env def test_requires_app_name(): @@ -41,7 +49,12 @@ def test_set_app_name(base_config_values): ("TELEMETRY_ENABLED", True), ], ) -def test_update_from_env(base_config_values, monkeypatch, env_var, value): +def test_update_from_env( + base_config_values: Dict[str, Any], + monkeypatch: pytest.MonkeyPatch, + env_var: str, + value: Any, +): """Test that environment variables override config values. Args: @@ -56,6 +69,29 @@ def test_update_from_env(base_config_values, monkeypatch, env_var, value): assert getattr(config, env_var.lower()) == value +def test_update_from_env_path( + base_config_values: Dict[str, Any], + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +): + """Test that environment variables override config values. + + Args: + base_config_values: Config values. + monkeypatch: The pytest monkeypatch object. + tmp_path: The pytest tmp_path fixture object. + """ + monkeypatch.setenv("BUN_PATH", "/test") + assert os.environ.get("BUN_PATH") == "/test" + with pytest.raises(ValueError): + rx.Config(**base_config_values) + + monkeypatch.setenv("BUN_PATH", str(tmp_path)) + assert os.environ.get("BUN_PATH") == str(tmp_path) + config = rx.Config(**base_config_values) + assert config.bun_path == tmp_path + + @pytest.mark.parametrize( "kwargs, expected", [ @@ -177,11 +213,11 @@ def test_replace_defaults( assert getattr(c, key) == value -def reflex_dir_constant(): - return rx.constants.Reflex.DIR +def reflex_dir_constant() -> Path: + return environment.REFLEX_DIR -def test_reflex_dir_env_var(monkeypatch, tmp_path): +def test_reflex_dir_env_var(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: """Test that the REFLEX_DIR environment variable is used to set the Reflex.DIR constant. Args: @@ -192,4 +228,17 @@ def test_reflex_dir_env_var(monkeypatch, tmp_path): mp_ctx = multiprocessing.get_context(method="spawn") with mp_ctx.Pool(processes=1) as pool: - assert pool.apply(reflex_dir_constant) == str(tmp_path) + assert pool.apply(reflex_dir_constant) == tmp_path + + +def test_interpret_enum_env() -> None: + assert interpret_enum_env(Env.PROD.value, Env, "REFLEX_ENV") == Env.PROD + + +def test_interpret_int_env() -> None: + assert interpret_int_env("3001", "FRONTEND_PORT") == 3001 + + +@pytest.mark.parametrize("value, expected", [("true", True), ("false", False)]) +def test_interpret_bool_env(value: str, expected: bool) -> None: + assert interpret_boolean_env(value, "TELEMETRY_ENABLED") == expected diff --git a/tests/test_db_config.py b/tests/units/test_db_config.py similarity index 100% rename from tests/test_db_config.py rename to tests/units/test_db_config.py diff --git a/tests/test_event.py b/tests/units/test_event.py similarity index 64% rename from tests/test_event.py rename to tests/units/test_event.py index 885263157..d7b7cf7a2 100644 --- a/tests/test_event.py +++ b/tests/units/test_event.py @@ -1,13 +1,19 @@ -import json from typing import List import pytest -from reflex import event -from reflex.event import Event, EventHandler, EventSpec, call_event_handler, fix_events +from reflex.event import ( + Event, + EventChain, + EventHandler, + EventSpec, + call_event_handler, + event, + fix_events, +) from reflex.state import BaseState from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Field, LiteralVar, Var, field def make_var(value) -> Var: @@ -19,9 +25,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 +61,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})' @@ -70,7 +74,7 @@ def test_call_event_handler(): event_spec = handler("first", "second") # type: ignore assert ( format.format_event(event_spec) - == 'Event("test_fn_with_args", {arg1:`first`,arg2:`second`})' + == 'Event("test_fn_with_args", {arg1:"first",arg2:"second"})' ) first, second = 123, "456" @@ -78,14 +82,14 @@ def test_call_event_handler(): event_spec = handler(first, second) # type: ignore assert ( format.format_event(event_spec) - == 'Event("test_fn_with_args", {arg1:123,arg2:`456`})' + == 'Event("test_fn_with_args", {arg1:123,arg2:"456"})' ) 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(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) with pytest.raises(TypeError): @@ -100,7 +104,7 @@ def test_call_event_handler_partial(): test_fn_with_args.__qualname__ = "test_fn_with_args" - def spec(a2: str) -> List[str]: + def spec(a2: Var[str]) -> List[Var[str]]: return [a2] handler = EventHandler(fn=test_fn_with_args) @@ -109,17 +113,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})' @@ -158,12 +162,29 @@ def test_fix_events(arg1, arg2): @pytest.mark.parametrize( "input,output", [ - (("/path", None), 'Event("_redirect", {path:`/path`,external:false})'), - (("/path", True), 'Event("_redirect", {path:`/path`,external:true})'), - (("/path", False), 'Event("_redirect", {path:`/path`,external:false})'), ( - (Var.create_safe("path"), None), - 'Event("_redirect", {path:path,external:false})', + ("/path", None, None), + 'Event("_redirect", {path:"/path",external:false,replace:false})', + ), + ( + ("/path", True, None), + 'Event("_redirect", {path:"/path",external:true,replace:false})', + ), + ( + ("/path", False, None), + 'Event("_redirect", {path:"/path",external:false,replace:false})', + ), + ( + (Var(_js_expr="path"), None, None), + 'Event("_redirect", {path:path,external:false,replace:false})', + ), + ( + ("/path", None, True), + 'Event("_redirect", {path:"/path",external:false,replace:true})', + ), + ( + ("/path", True, True), + 'Event("_redirect", {path:"/path",external:true,replace:true})', ), ], ) @@ -174,17 +195,19 @@ def test_event_redirect(input, output): input: The input for running the test. output: The expected output to validate the test. """ - path, external = input - if external is None: - spec = event.redirect(path) - else: - spec = event.redirect(path, external=external) + path, external, replace = input + kwargs = {} + if external is not None: + kwargs["external"] = external + if replace is not None: + kwargs["replace"] = replace + spec = event.redirect(path, **kwargs) assert isinstance(spec, EventSpec) 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 @@ -194,10 +217,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(Var.create_safe("message")) - assert spec.args[0][1].equals(Var.create_safe("message")) - assert format.format_event(spec) == 'Event("_console", {message:`message`})' - spec = event.console_log(Var.create_safe("message")) + 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(Var(_js_expr="message")) assert format.format_event(spec) == 'Event("_console", {message:message})' @@ -206,10 +229,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(Var.create_safe("message")) - assert spec.args[0][1].equals(Var.create_safe("message")) - assert format.format_event(spec) == 'Event("_alert", {message:`message`})' - spec = event.window_alert(Var.create_safe("message")) + 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(Var(_js_expr="message")) assert format.format_event(spec) == 'Event("_alert", {message:message})' @@ -218,11 +241,11 @@ 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][1].equals(Var.create_safe("ref_input1")) - assert format.format_event(spec) == 'Event("_set_focus", {ref:`ref_input1`})' + 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") - assert format.format_event(spec) == 'Event("_set_focus", {ref:`ref_input1`})' + assert format.format_event(spec) == 'Event("_set_focus", {ref:"ref_input1"})' def test_set_value(): @@ -230,17 +253,17 @@ 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][1].equals(Var.create_safe("ref_input1")) - assert spec.args[1][0].equals(Var.create_safe("value")) - assert spec.args[1][1].equals(Var.create_safe("")) + 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(_js_expr="value")) + assert spec.args[1][1].equals(LiteralVar.create("")) assert ( - format.format_event(spec) == 'Event("_set_value", {ref:`ref_input1`,value:``})' + format.format_event(spec) == 'Event("_set_value", {ref:"ref_input1",value:""})' ) - spec = event.set_value("input1", Var.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})' + == 'Event("_set_value", {ref:"ref_input1",value:message})' ) @@ -249,13 +272,13 @@ 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][1].equals(Var.create_safe("testkey")) - assert spec.args[1][0].equals(Var.create_safe("options")) - assert spec.args[1][1].equals(Var.create_safe({"path": "/"})) + 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(_js_expr="options")) + assert spec.args[1][1].equals(LiteralVar.create({"path": "/"})) assert ( format.format_event(spec) - == 'Event("_remove_cookie", {key:`testkey`,options:{"path": "/"}})' + == 'Event("_remove_cookie", {key:"testkey",options:({ ["path"] : "/" })})' ) @@ -270,13 +293,13 @@ 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][1].equals(Var.create_safe("testkey")) - assert spec.args[1][0].equals(Var.create_safe("options")) - assert spec.args[1][1].equals(Var.create_safe(options)) + 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(_js_expr="options")) + assert spec.args[1][1].equals(LiteralVar.create(options)) assert ( format.format_event(spec) - == f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})' + == f'Event("_remove_cookie", {{key:"testkey",options:{str(LiteralVar.create(options))}}})' ) @@ -294,10 +317,10 @@ 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][1].equals(Var.create_safe("testkey")) + 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`})' + format.format_event(spec) == 'Event("_remove_local_storage", {key:"testkey"})' ) @@ -372,3 +395,28 @@ def test_event_actions_on_state(): assert sp_handler.event_actions == {"stopPropagation": True} # should NOT affect other references to the handler assert not handler.event_actions + + +def test_event_var_data(): + class S(BaseState): + x: Field[int] = field(0) + + @event + def s(self, value: int): + pass + + # Handler doesn't have any _var_data because it's just a str + handler_var = Var.create(S.s) + assert handler_var._get_all_var_data() is None + + # Ensure spec carries _var_data + spec_var = Var.create(S.s(S.x)) + assert spec_var._get_all_var_data() == S.x._get_all_var_data() + + # Needed to instantiate the EventChain + def _args_spec(value: Var[int]) -> tuple[Var[int]]: + return (value,) + + # Ensure chain carries _var_data + chain_var = Var.create(EventChain(events=[S.s(S.x)], args_spec=_args_spec)) + assert chain_var._get_all_var_data() == S.x._get_all_var_data() diff --git a/tests/units/test_health_endpoint.py b/tests/units/test_health_endpoint.py new file mode 100644 index 000000000..fe350266f --- /dev/null +++ b/tests/units/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_model.py b/tests/units/test_model.py similarity index 81% rename from tests/test_model.py rename to tests/units/test_model.py index ee0336b37..ac8187e03 100644 --- a/tests/test_model.py +++ b/tests/units/test_model.py @@ -1,4 +1,5 @@ -from typing import Optional +from pathlib import Path +from typing import Optional, Type from unittest import mock import pytest @@ -7,7 +8,7 @@ import sqlmodel import reflex.constants import reflex.model -from reflex.model import Model +from reflex.model import Model, ModelRegistry @pytest.fixture @@ -39,7 +40,7 @@ def model_custom_primary() -> Model: return ChildModel(name="name") -def test_default_primary_key(model_default_primary): +def test_default_primary_key(model_default_primary: Model): """Test that if a primary key is not defined a default is added. Args: @@ -48,7 +49,7 @@ def test_default_primary_key(model_default_primary): assert "id" in model_default_primary.__class__.__fields__ -def test_custom_primary_key(model_custom_primary): +def test_custom_primary_key(model_custom_primary: Model): """Test that if a primary key is defined no default key is added. Args: @@ -60,12 +61,17 @@ def test_custom_primary_key(model_custom_primary): @pytest.mark.filterwarnings( "ignore:This declarative base already contains a class with the same class name", ) -def test_automigration(tmp_working_dir, monkeypatch): +def test_automigration( + tmp_working_dir: Path, + monkeypatch: pytest.MonkeyPatch, + model_registry: Type[ModelRegistry], +): """Test alembic automigration with add and drop table and column. Args: tmp_working_dir: directory where database and migrations are stored monkeypatch: pytest fixture to overwrite attributes + model_registry: clean reflex ModelRegistry """ alembic_ini = tmp_working_dir / "alembic.ini" versions = tmp_working_dir / "alembic" / "versions" @@ -84,8 +90,10 @@ def test_automigration(tmp_working_dir, monkeypatch): t1: str with Model.get_db_engine().connect() as connection: - Model.alembic_autogenerate(connection=connection, message="Initial Revision") - Model.migrate() + assert Model.alembic_autogenerate( + connection=connection, message="Initial Revision" + ) + assert Model.migrate() version_scripts = list(versions.glob("*.py")) assert len(version_scripts) == 1 assert version_scripts[0].name.endswith("initial_revision.py") @@ -94,14 +102,14 @@ def test_automigration(tmp_working_dir, monkeypatch): session.add(AlembicThing(id=None, t1="foo")) session.commit() - sqlmodel.SQLModel.metadata.clear() + model_registry.get_metadata().clear() # Create column t2, mark t1 as optional with default class AlembicThing(Model, table=True): # type: ignore t1: Optional[str] = "default" t2: str = "bar" - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 2 with reflex.model.session() as session: @@ -114,13 +122,13 @@ def test_automigration(tmp_working_dir, monkeypatch): assert result[1].t1 == "default" assert result[1].t2 == "baz" - sqlmodel.SQLModel.metadata.clear() + model_registry.get_metadata().clear() # Drop column t1 class AlembicThing(Model, table=True): # type: ignore t2: str = "bar" - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 3 with reflex.model.session() as session: @@ -134,7 +142,7 @@ def test_automigration(tmp_working_dir, monkeypatch): a: int = 42 b: float = 4.2 - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 4 with reflex.model.session() as session: @@ -146,16 +154,16 @@ def test_automigration(tmp_working_dir, monkeypatch): assert result[0].b == 4.2 # No-op - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 4 # drop table (AlembicSecond) - sqlmodel.SQLModel.metadata.clear() + model_registry.get_metadata().clear() class AlembicThing(Model, table=True): # type: ignore t2: str = "bar" - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 5 with reflex.model.session() as session: @@ -168,18 +176,18 @@ def test_automigration(tmp_working_dir, monkeypatch): assert result[0].t2 == "bar" assert result[1].t2 == "baz" - sqlmodel.SQLModel.metadata.clear() + model_registry.get_metadata().clear() class AlembicThing(Model, table=True): # type: ignore # changing column type not supported by default t2: int = 42 - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 5 # clear all metadata to avoid influencing subsequent tests - sqlmodel.SQLModel.metadata.clear() + model_registry.get_metadata().clear() # drop remaining tables - Model.migrate(autogenerate=True) + assert Model.migrate(autogenerate=True) assert len(list(versions.glob("*.py"))) == 6 diff --git a/tests/units/test_page.py b/tests/units/test_page.py new file mode 100644 index 000000000..e1dd70905 --- /dev/null +++ b/tests/units/test_page.py @@ -0,0 +1,79 @@ +from reflex import text +from reflex.config import get_config +from reflex.page import DECORATED_PAGES, get_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() + + +def test_get_decorated_pages(): + assert get_decorated_pages() == [] + + def foo_(): + return text("foo") + + page()(foo_) + + assert get_decorated_pages() == [] + assert get_decorated_pages(omit_implicit_routes=False) == [{}] + + page(route="foo2")(foo_) + + assert get_decorated_pages() == [{"route": "foo2"}] + assert get_decorated_pages(omit_implicit_routes=False) == [{}, {"route": "foo2"}] + + page(route="foo3", title="Foo3")(foo_) + + assert get_decorated_pages() == [ + {"route": "foo2"}, + {"route": "foo3", "title": "Foo3"}, + ] + assert get_decorated_pages(omit_implicit_routes=False) == [ + {}, + {"route": "foo2"}, + {"route": "foo3", "title": "Foo3"}, + ] diff --git a/tests/test_prerequisites.py b/tests/units/test_prerequisites.py similarity index 90% rename from tests/test_prerequisites.py rename to tests/units/test_prerequisites.py index c4f57a998..2497318e7 100644 --- a/tests/test_prerequisites.py +++ b/tests/units/test_prerequisites.py @@ -24,7 +24,15 @@ from reflex.utils.prerequisites import ( app_name="test", ), False, - 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true};', + 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};', + ), + ( + Config( + app_name="test", + static_page_generation_timeout=30, + ), + False, + 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 30};', ), ( Config( @@ -32,7 +40,7 @@ from reflex.utils.prerequisites import ( next_compression=False, ), False, - 'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true};', + 'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};', ), ( Config( @@ -40,7 +48,7 @@ from reflex.utils.prerequisites import ( frontend_path="/test", ), False, - 'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true};', + 'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};', ), ( Config( @@ -49,14 +57,14 @@ from reflex.utils.prerequisites import ( next_compression=False, ), False, - 'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true};', + 'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};', ), ( Config( app_name="test", ), True, - 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, output: "export", distDir: "_static"};', + 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60, output: "export", distDir: "_static"};', ), ], ) diff --git a/tests/test_route.py b/tests/units/test_route.py similarity index 100% rename from tests/test_route.py rename to tests/units/test_route.py diff --git a/tests/units/test_sqlalchemy.py b/tests/units/test_sqlalchemy.py new file mode 100644 index 000000000..b18799e0c --- /dev/null +++ b/tests/units/test_sqlalchemy.py @@ -0,0 +1,166 @@ +from pathlib import Path +from typing import Optional, Type +from unittest import mock + +import pytest +from sqlalchemy import select +from sqlalchemy.exc import OperationalError +from sqlalchemy.orm import ( + DeclarativeBase, + Mapped, + MappedAsDataclass, + declared_attr, + mapped_column, +) + +import reflex.constants +import reflex.model +from reflex.model import Model, ModelRegistry, sqla_session + + +@pytest.mark.filterwarnings( + "ignore:This declarative base already contains a class with the same class name", +) +def test_automigration( + tmp_working_dir: Path, + monkeypatch: pytest.MonkeyPatch, + model_registry: Type[ModelRegistry], +): + """Test alembic automigration with add and drop table and column. + + Args: + tmp_working_dir: directory where database and migrations are stored + monkeypatch: pytest fixture to overwrite attributes + model_registry: clean reflex ModelRegistry + """ + alembic_ini = tmp_working_dir / "alembic.ini" + versions = tmp_working_dir / "alembic" / "versions" + monkeypatch.setattr(reflex.constants, "ALEMBIC_CONFIG", str(alembic_ini)) + + config_mock = mock.Mock() + config_mock.db_url = f"sqlite:///{tmp_working_dir}/reflex.db" + monkeypatch.setattr(reflex.model, "get_config", mock.Mock(return_value=config_mock)) + + assert alembic_ini.exists() is False + assert versions.exists() is False + Model.alembic_init() + assert alembic_ini.exists() + assert versions.exists() + + class Base(DeclarativeBase): + @declared_attr.directive + def __tablename__(cls) -> str: + return cls.__name__.lower() + + assert model_registry.register(Base) + + class ModelBase(Base, MappedAsDataclass): + __abstract__ = True + id: Mapped[Optional[int]] = mapped_column(primary_key=True, default=None) + + # initial table + class AlembicThing(ModelBase): # pyright: ignore[reportGeneralTypeIssues] + t1: Mapped[str] = mapped_column(default="") + + with Model.get_db_engine().connect() as connection: + assert Model.alembic_autogenerate( + connection=connection, message="Initial Revision" + ) + assert Model.migrate() + version_scripts = list(versions.glob("*.py")) + assert len(version_scripts) == 1 + assert version_scripts[0].name.endswith("initial_revision.py") + + with sqla_session() as session: + session.add(AlembicThing(t1="foo")) + session.commit() + + model_registry.get_metadata().clear() + + # Create column t2, mark t1 as optional with default + class AlembicThing(ModelBase): # pyright: ignore[reportGeneralTypeIssues] + t1: Mapped[Optional[str]] = mapped_column(default="default") + t2: Mapped[str] = mapped_column(default="bar") + + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 2 + + with sqla_session() as session: + session.add(AlembicThing(t2="baz")) + session.commit() + result = session.scalars(select(AlembicThing)).all() + assert len(result) == 2 + assert result[0].t1 == "foo" + assert result[0].t2 == "bar" + assert result[1].t1 == "default" + assert result[1].t2 == "baz" + + model_registry.get_metadata().clear() + + # Drop column t1 + class AlembicThing(ModelBase): # pyright: ignore[reportGeneralTypeIssues] + t2: Mapped[str] = mapped_column(default="bar") + + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 3 + + with sqla_session() as session: + result = session.scalars(select(AlembicThing)).all() + assert len(result) == 2 + assert result[0].t2 == "bar" + assert result[1].t2 == "baz" + + # Add table + class AlembicSecond(ModelBase): + a: Mapped[int] = mapped_column(default=42) + b: Mapped[float] = mapped_column(default=4.2) + + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 4 + + with reflex.model.session() as session: + session.add(AlembicSecond(id=None)) + session.commit() + result = session.scalars(select(AlembicSecond)).all() + assert len(result) == 1 + assert result[0].a == 42 + assert result[0].b == 4.2 + + # No-op + # assert Model.migrate(autogenerate=True) + # assert len(list(versions.glob("*.py"))) == 4 + + # drop table (AlembicSecond) + model_registry.get_metadata().clear() + + class AlembicThing(ModelBase): # pyright: ignore[reportGeneralTypeIssues] + t2: Mapped[str] = mapped_column(default="bar") + + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 5 + + with reflex.model.session() as session: + with pytest.raises(OperationalError) as errctx: + _ = session.scalars(select(AlembicSecond)).all() + assert errctx.match(r"no such table: alembicsecond") + # first table should still exist + result = session.scalars(select(AlembicThing)).all() + assert len(result) == 2 + assert result[0].t2 == "bar" + assert result[1].t2 == "baz" + + model_registry.get_metadata().clear() + + class AlembicThing(ModelBase): + # changing column type not supported by default + t2: Mapped[int] = mapped_column(default=42) + + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 5 + + # clear all metadata to avoid influencing subsequent tests + model_registry.get_metadata().clear() + + # drop remaining tables + assert Model.migrate(autogenerate=True) + assert len(list(versions.glob("*.py"))) == 6 diff --git a/tests/test_state.py b/tests/units/test_state.py similarity index 73% rename from tests/test_state.py rename to tests/units/test_state.py index e6e16ddef..271f2e794 100644 --- a/tests/test_state.py +++ b/tests/units/test_state.py @@ -2,20 +2,27 @@ from __future__ import annotations import asyncio import copy +import dataclasses import datetime import functools import json import os import sys -from typing import Any, Dict, Generator, List, Optional, Union +import threading +from textwrap import dedent +from typing import Any, AsyncGenerator, Callable, Dict, List, Optional, Union from unittest.mock import AsyncMock, Mock import pytest +import pytest_asyncio from plotly.graph_objects import Figure import reflex as rx +import reflex.config +from reflex import constants from reflex.app import App from reflex.base import Base +from reflex.components.sonner.toast import Toaster from reflex.constants import CompileVars, RouteVar, SocketEvent from reflex.event import Event, EventHandler from reflex.state import ( @@ -27,15 +34,19 @@ from reflex.state import ( RouterData, State, StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateProxy, StateUpdate, _substate_key, ) +from reflex.testing import chdir from reflex.utils import format, prerequisites, types +from reflex.utils.exceptions import SetUndefinedStateVarError from reflex.utils.format import json_dumps -from reflex.vars import BaseVar, ComputedVar +from reflex.vars.base import ComputedVar, Var +from tests.units.states.mutation import MutableSQLAModel, MutableTestState from .states import GenState @@ -51,6 +62,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -94,6 +106,8 @@ class TestState(BaseState): complex: Dict[int, Object] = {1: Object(), 2: Object()} fig: Figure = Figure() dt: datetime.datetime = datetime.datetime.fromisoformat("1989-11-09T18:53:00+01:00") + _backend: int = 0 + asynctest: int = 0 @ComputedVar def sum(self) -> float: @@ -117,6 +131,14 @@ class TestState(BaseState): """Do something.""" pass + async def set_asynctest(self, value: int): + """Set the asynctest value. Intentionally overwrite the default setter with an async one. + + Args: + value: The new value. + """ + self.asynctest = value + class ChildState(TestState): """A child state fixture.""" @@ -160,7 +182,7 @@ class GrandchildState(ChildState): class GrandchildState2(ChildState2): """A grandchild state fixture.""" - @rx.cached_var + @rx.var(cache=True) def cached(self) -> str: """A cached var. @@ -212,7 +234,7 @@ def child_state(test_state) -> ChildState: Returns: A test child state. """ - child_state = test_state.get_substate(["child_state"]) + child_state = test_state.get_substate([ChildState.get_name()]) assert child_state is not None return child_state @@ -227,7 +249,7 @@ def child_state2(test_state) -> ChildState2: Returns: A second test child state. """ - child_state2 = test_state.get_substate(["child_state2"]) + child_state2 = test_state.get_substate([ChildState2.get_name()]) assert child_state2 is not None return child_state2 @@ -242,7 +264,7 @@ def grandchild_state(child_state) -> GrandchildState: Returns: A test state. """ - grandchild_state = child_state.get_substate(["grandchild_state"]) + grandchild_state = child_state.get_substate([GrandchildState.get_name()]) assert grandchild_state is not None return grandchild_state @@ -260,12 +282,12 @@ def test_base_class_vars(test_state): if field in test_state.get_skip_vars(): continue prop = getattr(cls, field) - assert isinstance(prop, BaseVar) - assert prop._var_name == field + assert isinstance(prop, Var) + assert prop._js_expr.split(".")[-1] == field - assert cls.num1._var_type == int - assert cls.num2._var_type == float - assert cls.key._var_type == str + assert cls.num1._var_type is int + assert cls.num2._var_type is float + assert cls.key._var_type is str def test_computed_class_var(test_state): @@ -275,7 +297,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 @@ -287,7 +309,7 @@ def test_class_vars(test_state): test_state: A state. """ cls = type(test_state) - assert set(cls.vars.keys()) == { + assert cls.vars.keys() == { "router", "num1", "num2", @@ -301,6 +323,7 @@ def test_class_vars(test_state): "upper", "fig", "dt", + "asynctest", } @@ -310,7 +333,7 @@ def test_event_handlers(test_state): Args: test_state: A state. """ - expected = { + expected_keys = ( "do_something", "set_array", "set_complex", @@ -320,10 +343,10 @@ def test_event_handlers(test_state): "set_num1", "set_num2", "set_obj", - } + ) cls = type(test_state) - assert set(cls.event_handlers.keys()).intersection(expected) == expected + assert all(key in cls.event_handlers for key in expected_keys) def test_default_value(test_state): @@ -352,20 +375,20 @@ def test_computed_vars(test_state): assert test_state.upper == "HELLO WORLD" -def test_dict(test_state): +def test_dict(test_state: TestState): """Test that the dict representation of a state is correct. Args: test_state: A state. """ substates = { - "test_state", - "test_state.child_state", - "test_state.child_state.grandchild_state", - "test_state.child_state2", - "test_state.child_state2.grandchild_state2", - "test_state.child_state3", - "test_state.child_state3.grandchild_state3", + test_state.get_full_name(), + ChildState.get_full_name(), + GrandchildState.get_full_name(), + ChildState2.get_full_name(), + GrandchildState2.get_full_name(), + ChildState3.get_full_name(), + GrandchildState3.get_full_name(), } test_state_dict = test_state.dict() assert set(test_state_dict) == substates @@ -389,22 +412,27 @@ def test_default_setters(test_state): def test_class_indexing_with_vars(): """Test that we can index into a state var with another var.""" prop = TestState.array[TestState.num1] - assert str(prop) == "{test_state.array.at(test_state.num1)}" + assert str(prop) == f"{TestState.get_name()}.array.at({TestState.get_name()}.num1)" prop = TestState.mapping["a"][TestState.num1] - assert str(prop) == '{test_state.mapping["a"].at(test_state.num1)}' + assert ( + str(prop) + == f'{TestState.get_name()}.mapping["a"].at({TestState.get_name()}.num1)' + ) prop = TestState.mapping[TestState.map_key] - assert str(prop) == "{test_state.mapping[test_state.map_key]}" + assert ( + str(prop) == f"{TestState.get_name()}.mapping[{TestState.get_name()}.map_key]" + ) def test_class_attributes(): """Test that we can get class attributes.""" prop = TestState.obj.prop1 - assert str(prop) == "{test_state.obj.prop1}" + assert str(prop) == f'{TestState.get_name()}.obj["prop1"]' prop = TestState.complex[1].prop1 - assert str(prop) == "{test_state.complex[1].prop1}" + assert str(prop) == f'{TestState.get_name()}.complex[1]["prop1"]' def test_get_parent_state(): @@ -426,27 +454,42 @@ def test_get_substates(): def test_get_name(): """Test getting the name of a state.""" - assert TestState.get_name() == "test_state" - assert ChildState.get_name() == "child_state" - assert ChildState2.get_name() == "child_state2" - assert GrandchildState.get_name() == "grandchild_state" + assert TestState.get_name() == "tests___units___test_state____test_state" + assert ChildState.get_name() == "tests___units___test_state____child_state" + assert ChildState2.get_name() == "tests___units___test_state____child_state2" + assert ( + GrandchildState.get_name() == "tests___units___test_state____grandchild_state" + ) def test_get_full_name(): """Test getting the full name.""" - assert TestState.get_full_name() == "test_state" - assert ChildState.get_full_name() == "test_state.child_state" - assert ChildState2.get_full_name() == "test_state.child_state2" - assert GrandchildState.get_full_name() == "test_state.child_state.grandchild_state" + assert TestState.get_full_name() == "tests___units___test_state____test_state" + assert ( + ChildState.get_full_name() + == "tests___units___test_state____test_state.tests___units___test_state____child_state" + ) + assert ( + ChildState2.get_full_name() + == "tests___units___test_state____test_state.tests___units___test_state____child_state2" + ) + assert ( + GrandchildState.get_full_name() + == "tests___units___test_state____test_state.tests___units___test_state____child_state.tests___units___test_state____grandchild_state" + ) def test_get_class_substate(): """Test getting the substate of a class.""" - assert TestState.get_class_substate(("child_state",)) == ChildState - assert TestState.get_class_substate(("child_state2",)) == ChildState2 - assert ChildState.get_class_substate(("grandchild_state",)) == GrandchildState + assert TestState.get_class_substate((ChildState.get_name(),)) == ChildState + assert TestState.get_class_substate((ChildState2.get_name(),)) == ChildState2 assert ( - TestState.get_class_substate(("child_state", "grandchild_state")) + ChildState.get_class_substate((GrandchildState.get_name(),)) == GrandchildState + ) + assert ( + TestState.get_class_substate( + (ChildState.get_name(), GrandchildState.get_name()) + ) == GrandchildState ) with pytest.raises(ValueError): @@ -454,7 +497,7 @@ def test_get_class_substate(): with pytest.raises(ValueError): TestState.get_class_substate( ( - "child_state", + ChildState.get_name(), "invalid_child", ) ) @@ -466,13 +509,15 @@ def test_get_class_var(): assert TestState.get_class_var(("num2",)).equals(TestState.num2) assert ChildState.get_class_var(("value",)).equals(ChildState.value) assert GrandchildState.get_class_var(("value2",)).equals(GrandchildState.value2) - assert TestState.get_class_var(("child_state", "value")).equals(ChildState.value) + assert TestState.get_class_var((ChildState.get_name(), "value")).equals( + ChildState.value + ) assert TestState.get_class_var( - ("child_state", "grandchild_state", "value2") + (ChildState.get_name(), GrandchildState.get_name(), "value2") ).equals( GrandchildState.value2, ) - assert ChildState.get_class_var(("grandchild_state", "value2")).equals( + assert ChildState.get_class_var((GrandchildState.get_name(), "value2")).equals( GrandchildState.value2, ) with pytest.raises(ValueError): @@ -480,7 +525,7 @@ def test_get_class_var(): with pytest.raises(ValueError): TestState.get_class_var( ( - "child_state", + ChildState.get_name(), "invalid_var", ) ) @@ -490,12 +535,10 @@ 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._var_type == int + assert var._js_expr == TestState.get_full_name() + ".num3" + assert var._var_type is int assert var._var_state == TestState.get_full_name() @@ -508,11 +551,15 @@ def test_set_parent_and_substates(test_state, child_state, grandchild_state): grandchild_state: A grandchild state. """ assert len(test_state.substates) == 3 - assert set(test_state.substates) == {"child_state", "child_state2", "child_state3"} + assert set(test_state.substates) == { + ChildState.get_name(), + ChildState2.get_name(), + ChildState3.get_name(), + } assert child_state.parent_state == test_state assert len(child_state.substates) == 1 - assert set(child_state.substates) == {"grandchild_state"} + assert set(child_state.substates) == {GrandchildState.get_name()} assert grandchild_state.parent_state == child_state assert len(grandchild_state.substates) == 0 @@ -579,18 +626,21 @@ def test_get_substate(test_state, child_state, child_state2, grandchild_state): child_state2: A child state. grandchild_state: A grandchild state. """ - assert test_state.get_substate(("child_state",)) == child_state - assert test_state.get_substate(("child_state2",)) == child_state2 + assert test_state.get_substate((ChildState.get_name(),)) == child_state + assert test_state.get_substate((ChildState2.get_name(),)) == child_state2 assert ( - test_state.get_substate(("child_state", "grandchild_state")) == grandchild_state + test_state.get_substate((ChildState.get_name(), GrandchildState.get_name())) + == grandchild_state ) - assert child_state.get_substate(("grandchild_state",)) == grandchild_state + assert child_state.get_substate((GrandchildState.get_name(),)) == grandchild_state with pytest.raises(ValueError): test_state.get_substate(("invalid",)) with pytest.raises(ValueError): - test_state.get_substate(("child_state", "invalid")) + test_state.get_substate((ChildState.get_name(), "invalid")) with pytest.raises(ValueError): - test_state.get_substate(("child_state", "grandchild_state", "invalid")) + test_state.get_substate( + (ChildState.get_name(), GrandchildState.get_name(), "invalid") + ) def test_set_dirty_var(test_state): @@ -615,7 +665,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: @@ -633,7 +688,7 @@ def test_set_dirty_substate(test_state, child_state, child_state2, grandchild_st # Setting a var should mark it as dirty. child_state.value = "test" assert child_state.dirty_vars == {"value"} - assert test_state.dirty_substates == {"child_state"} + assert test_state.dirty_substates == {ChildState.get_name()} assert child_state.dirty_substates == set() # Cleaning the parent state should remove the dirty substate. @@ -643,12 +698,12 @@ def test_set_dirty_substate(test_state, child_state, child_state2, grandchild_st # Setting a var on the grandchild should bubble up. grandchild_state.value2 = "test2" - assert child_state.dirty_substates == {"grandchild_state"} - assert test_state.dirty_substates == {"child_state"} + assert child_state.dirty_substates == {GrandchildState.get_name()} + assert test_state.dirty_substates == {ChildState.get_name()} # Cleaning the middle state should keep the parent state dirty. child_state._clean() - assert test_state.dirty_substates == {"child_state"} + assert test_state.dirty_substates == {ChildState.get_name()} assert child_state.dirty_substates == set() assert grandchild_state.dirty_vars == set() @@ -663,6 +718,7 @@ def test_reset(test_state, child_state): # Set some values. test_state.num1 = 1 test_state.num2 = 2 + test_state._backend = 3 child_state.value = "test" # Reset the state. @@ -671,6 +727,7 @@ def test_reset(test_state, child_state): # The values should be reset. assert test_state.num1 == 0 assert test_state.num2 == 3.14 + assert test_state._backend == 0 assert child_state.value == "" expected_dirty_vars = { @@ -686,6 +743,8 @@ def test_reset(test_state, child_state): "map_key", "mapping", "dt", + "_backend", + "asynctest", } # The dirty vars should be reset. @@ -693,7 +752,11 @@ def test_reset(test_state, child_state): assert child_state.dirty_vars == {"count", "value"} # The dirty substates should be reset. - assert test_state.dirty_substates == {"child_state", "child_state2", "child_state3"} + assert test_state.dirty_substates == { + ChildState.get_name(), + ChildState2.get_name(), + ChildState3.get_name(), + } @pytest.mark.asyncio @@ -714,8 +777,8 @@ async def test_process_event_simple(test_state): # The delta should contain the changes, including computed vars. # assert update.delta == {"test_state": {"num1": 69, "sum": 72.14}} assert update.delta == { - "test_state": {"num1": 69, "sum": 72.14, "upper": ""}, - "test_state.child_state3.grandchild_state3": {"computed": ""}, + TestState.get_full_name(): {"num1": 69, "sum": 72.14, "upper": ""}, + GrandchildState3.get_full_name(): {"computed": ""}, } assert update.events == [] @@ -733,15 +796,17 @@ async def test_process_event_substate(test_state, child_state, grandchild_state) assert child_state.value == "" assert child_state.count == 23 event = Event( - token="t", name="child_state.change_both", payload={"value": "hi", "count": 12} + token="t", + name=f"{ChildState.get_name()}.change_both", + payload={"value": "hi", "count": 12}, ) update = await test_state._process(event).__anext__() assert child_state.value == "HI" assert child_state.count == 24 assert update.delta == { - "test_state": {"sum": 3.14, "upper": ""}, - "test_state.child_state": {"value": "HI", "count": 24}, - "test_state.child_state3.grandchild_state3": {"computed": ""}, + TestState.get_full_name(): {"sum": 3.14, "upper": ""}, + ChildState.get_full_name(): {"value": "HI", "count": 24}, + GrandchildState3.get_full_name(): {"computed": ""}, } test_state._clean() @@ -749,15 +814,15 @@ async def test_process_event_substate(test_state, child_state, grandchild_state) assert grandchild_state.value2 == "" event = Event( token="t", - name="child_state.grandchild_state.set_value2", + name=f"{GrandchildState.get_full_name()}.set_value2", payload={"value": "new"}, ) update = await test_state._process(event).__anext__() assert grandchild_state.value2 == "new" assert update.delta == { - "test_state": {"sum": 3.14, "upper": ""}, - "test_state.child_state.grandchild_state": {"value2": "new"}, - "test_state.child_state3.grandchild_state3": {"computed": ""}, + TestState.get_full_name(): {"sum": 3.14, "upper": ""}, + GrandchildState.get_full_name(): {"value2": "new"}, + GrandchildState3.get_full_name(): {"computed": ""}, } @@ -781,7 +846,7 @@ async def test_process_event_generator(): else: assert gen_state.value == count assert update.delta == { - "gen_state": {"value": count}, + GenState.get_full_name(): {"value": count}, } assert not update.final @@ -820,8 +885,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() } @@ -903,7 +970,7 @@ class InterdependentState(BaseState): v1: int = 0 _v2: int = 1 - @rx.cached_var + @rx.var(cache=True) def v1x2(self) -> int: """Depends on var v1. @@ -912,7 +979,7 @@ class InterdependentState(BaseState): """ return self.v1 * 2 - @rx.cached_var + @rx.var(cache=True) def v2x2(self) -> int: """Depends on backend var _v2. @@ -921,7 +988,16 @@ class InterdependentState(BaseState): """ return self._v2 * 2 - @rx.cached_var + @rx.var(cache=True, backend=True) + def v2x2_backend(self) -> int: + """Depends on backend var _v2. + + Returns: + backend var _v2 multiplied by 2 + """ + return self._v2 * 2 + + @rx.var(cache=True) def v1x2x2(self) -> int: """Depends on ComputedVar v1x2. @@ -930,7 +1006,7 @@ class InterdependentState(BaseState): """ return self.v1x2 * 2 # type: ignore - @rx.cached_var + @rx.var(cache=True) def _v3(self) -> int: """Depends on backend var _v2. @@ -939,7 +1015,7 @@ class InterdependentState(BaseState): """ return self._v2 - @rx.cached_var + @rx.var(cache=True) def v3x2(self) -> int: """Depends on ComputedVar _v3. @@ -961,7 +1037,24 @@ def interdependent_state() -> BaseState: return s -def test_not_dirty_computed_var_from_var(interdependent_state): +def test_interdependent_state_initial_dict() -> None: + s = InterdependentState() + state_name = s.get_name() + d = s.dict(initial=True)[state_name] + d.pop("router") + assert d == { + "x": 0, + "v1": 0, + "v1x2": 0, + "v2x2": 2, + "v1x2x2": 0, + "v3x2": 2, + } + + +def test_not_dirty_computed_var_from_var( + interdependent_state: InterdependentState, +) -> None: """Set Var that no ComputedVar depends on, expect no recalculation. Args: @@ -973,7 +1066,7 @@ def test_not_dirty_computed_var_from_var(interdependent_state): } -def test_dirty_computed_var_from_var(interdependent_state): +def test_dirty_computed_var_from_var(interdependent_state: InterdependentState) -> None: """Set Var that ComputedVar depends on, expect recalculation. The other ComputedVar depends on the changed ComputedVar and should also be @@ -988,20 +1081,23 @@ def test_dirty_computed_var_from_var(interdependent_state): } -def test_dirty_computed_var_from_backend_var(interdependent_state): +def test_dirty_computed_var_from_backend_var( + interdependent_state: InterdependentState, +) -> None: """Set backend var that ComputedVar depends on, expect recalculation. Args: interdependent_state: A state with varying Var dependencies. """ + # Accessing ._v3 returns the immutable var it represents instead of the actual computed var + # assert InterdependentState._v3._backend is True interdependent_state._v2 = 2 assert interdependent_state.get_delta() == { interdependent_state.get_full_name(): {"v2x2": 4, "v3x2": 4}, } - assert "_v3" in InterdependentState.backend_vars -def test_per_state_backend_var(interdependent_state): +def test_per_state_backend_var(interdependent_state: InterdependentState) -> None: """Set backend var on one instance, expect no affect in other instances. Args: @@ -1124,7 +1220,7 @@ def test_computed_var_cached(): class ComputedState(BaseState): v: int = 0 - @rx.cached_var + @rx.var(cache=True) def comp_v(self) -> int: nonlocal comp_v_calls comp_v_calls += 1 @@ -1144,7 +1240,7 @@ def test_computed_var_cached(): def test_computed_var_cached_depends_on_non_cached(): - """Test that a cached_var is recalculated if it depends on non-cached ComputedVar.""" + """Test that a cached var is recalculated if it depends on non-cached ComputedVar.""" class ComputedState(BaseState): v: int = 0 @@ -1153,11 +1249,11 @@ def test_computed_var_cached_depends_on_non_cached(): def no_cache_v(self) -> int: return self.v - @rx.cached_var + @rx.var(cache=True) def dep_v(self) -> int: return self.no_cache_v # type: ignore - @rx.cached_var + @rx.var(cache=True) def comp_v(self) -> int: return self.v @@ -1185,7 +1281,7 @@ def test_computed_var_cached_depends_on_non_cached(): def test_computed_var_depends_on_parent_non_cached(): - """Child state cached_var that depends on parent state un cached var is always recalculated.""" + """Child state cached var that depends on parent state un cached var is always recalculated.""" counter = 0 class ParentState(BaseState): @@ -1196,7 +1292,7 @@ def test_computed_var_depends_on_parent_non_cached(): return counter class ChildState(ParentState): - @rx.cached_var + @rx.var(cache=True) def dep_v(self) -> int: return self.no_cache_v # type: ignore @@ -1206,19 +1302,19 @@ def test_computed_var_depends_on_parent_non_cached(): assert ps.dirty_vars == set() assert cs.dirty_vars == set() - dict1 = ps.dict() + dict1 = json.loads(json_dumps(ps.dict())) assert dict1[ps.get_full_name()] == { "no_cache_v": 1, "router": formatted_router, } assert dict1[cs.get_full_name()] == {"dep_v": 2} - dict2 = ps.dict() + dict2 = json.loads(json_dumps(ps.dict())) assert dict2[ps.get_full_name()] == { "no_cache_v": 3, "router": formatted_router, } assert dict2[cs.get_full_name()] == {"dep_v": 4} - dict3 = ps.dict() + dict3 = json.loads(json_dumps(ps.dict())) assert dict3[ps.get_full_name()] == { "no_cache_v": 5, "router": formatted_router, @@ -1229,7 +1325,7 @@ def test_computed_var_depends_on_parent_non_cached(): @pytest.mark.parametrize("use_partial", [True, False]) def test_cached_var_depends_on_event_handler(use_partial: bool): - """A cached_var that calls an event handler calculates deps correctly. + """A cached var that calls an event handler calculates deps correctly. Args: use_partial: if true, replace the EventHandler with functools.partial @@ -1242,7 +1338,7 @@ def test_cached_var_depends_on_event_handler(use_partial: bool): def handler(self): self.x = self.x + 1 - @rx.cached_var + @rx.var(cache=True) def cached_x_side_effect(self) -> int: self.handler() nonlocal counter @@ -1274,7 +1370,11 @@ def test_computed_var_dependencies(): y: List[int] = [1, 2, 3] _z: List[int] = [1, 2, 3] - @rx.cached_var + @property + def testprop(self) -> int: + return self.v + + @rx.var(cache=True) def comp_v(self) -> int: """Direct access. @@ -1283,7 +1383,25 @@ def test_computed_var_dependencies(): """ return self.v - @rx.cached_var + @rx.var(cache=True, backend=True) + def comp_v_backend(self) -> int: + """Direct access backend var. + + Returns: + The value of self.v. + """ + return self.v + + @rx.var(cache=True) + def comp_v_via_property(self) -> int: + """Access v via property. + + Returns: + The value of v via property. + """ + return self.testprop + + @rx.var(cache=True) def comp_w(self): """Nested lambda. @@ -1292,7 +1410,7 @@ def test_computed_var_dependencies(): """ return lambda: self.w - @rx.cached_var + @rx.var(cache=True) def comp_x(self): """Nested function. @@ -1305,7 +1423,7 @@ def test_computed_var_dependencies(): return _ - @rx.cached_var + @rx.var(cache=True) def comp_y(self) -> List[int]: """Comprehension iterating over attribute. @@ -1314,7 +1432,7 @@ def test_computed_var_dependencies(): """ return [round(y) for y in self.y] - @rx.cached_var + @rx.var(cache=True) def comp_z(self) -> List[bool]: """Comprehension accesses attribute. @@ -1324,7 +1442,11 @@ def test_computed_var_dependencies(): return [z in self._z for z in range(5)] cs = ComputedState() - assert cs._computed_var_dependencies["v"] == {"comp_v"} + assert cs._computed_var_dependencies["v"] == { + "comp_v", + "comp_v_backend", + "comp_v_via_property", + } assert cs._computed_var_dependencies["w"] == {"comp_w"} assert cs._computed_var_dependencies["x"] == {"comp_x"} assert cs._computed_var_dependencies["y"] == {"comp_y"} @@ -1346,7 +1468,7 @@ def test_backend_method(): assert bms._be_method() -def test_setattr_of_mutable_types(mutable_state): +def test_setattr_of_mutable_types(mutable_state: MutableTestState): """Test that mutable types are converted to corresponding Reflex wrappers. Args: @@ -1355,6 +1477,7 @@ def test_setattr_of_mutable_types(mutable_state): array = mutable_state.array hashmap = mutable_state.hashmap test_set = mutable_state.test_set + sqla_model = mutable_state.sqla_model assert isinstance(array, MutableProxy) assert isinstance(array, list) @@ -1382,11 +1505,21 @@ def test_setattr_of_mutable_types(mutable_state): assert isinstance(mutable_state.custom.test_set, set) assert isinstance(mutable_state.custom.custom, MutableProxy) + assert isinstance(sqla_model, MutableProxy) + assert isinstance(sqla_model, MutableSQLAModel) + assert isinstance(sqla_model.strlist, MutableProxy) + assert isinstance(sqla_model.strlist, list) + assert isinstance(sqla_model.hashmap, MutableProxy) + assert isinstance(sqla_model.hashmap, dict) + assert isinstance(sqla_model.test_set, MutableProxy) + assert isinstance(sqla_model.test_set, set) + mutable_state.reassign_mutables() array = mutable_state.array hashmap = mutable_state.hashmap test_set = mutable_state.test_set + sqla_model = mutable_state.sqla_model assert isinstance(array, MutableProxy) assert isinstance(array, list) @@ -1405,6 +1538,15 @@ def test_setattr_of_mutable_types(mutable_state): assert isinstance(test_set, MutableProxy) assert isinstance(test_set, set) + assert isinstance(sqla_model, MutableProxy) + assert isinstance(sqla_model, MutableSQLAModel) + assert isinstance(sqla_model.strlist, MutableProxy) + assert isinstance(sqla_model.strlist, list) + assert isinstance(sqla_model.hashmap, MutableProxy) + assert isinstance(sqla_model.hashmap, dict) + assert isinstance(sqla_model.test_set, MutableProxy) + assert isinstance(sqla_model.test_set, set) + def test_error_on_state_method_shadow(): """Test that an error is thrown when an event handler shadows a state method.""" @@ -1421,11 +1563,12 @@ def test_error_on_state_method_shadow(): @pytest.mark.asyncio -async def test_state_with_invalid_yield(capsys): +async def test_state_with_invalid_yield(capsys, mock_app): """Test that an error is thrown when a state yields an invalid value. Args: capsys: Pytest fixture for capture standard streams. + mock_app: Mock app fixture. """ class StateWithInvalidYield(BaseState): @@ -1444,16 +1587,37 @@ async def test_state_with_invalid_yield(capsys): rx.event.Event(token="fake_token", name="invalid_handler") ): assert not update.delta - assert update.events == rx.event.fix_events( - [rx.window_alert("An error occurred. See logs for details.")], - token="", - ) + if Toaster.is_used: + assert update.events == rx.event.fix_events( + [ + rx.toast( + "An error occurred.", + description="TypeError: Your handler test_state_with_invalid_yield..StateWithInvalidYield.invalid_handler must only return/yield: None, Events or other EventHandlers referenced by their class (not using `self`).
See logs for details.", + level="error", + id="backend_error", + position="top-center", + style={"width": "500px"}, + ) # type: ignore + ], + token="", + ) + else: + assert update.events == rx.event.fix_events( + [ + rx.window_alert( + "An error occurred.\nContact the website administrator." + ) + ], + token="", + ) captured = capsys.readouterr() assert "must only return/yield: None, Events or other EventHandlers" in captured.out -@pytest.fixture(scope="function", params=["in_process", "redis"]) -def state_manager(request) -> Generator[StateManager, None, None]: +@pytest_asyncio.fixture( + loop_scope="function", scope="function", params=["in_process", "disk", "redis"] +) +async def state_manager(request) -> AsyncGenerator[StateManager, None]: """Instance of state manager parametrized for redis and in-process. Args: @@ -1466,15 +1630,18 @@ 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 yield state_manager if isinstance(state_manager, StateManagerRedis): - asyncio.get_event_loop().run_until_complete(state_manager.close()) + await state_manager.close() @pytest.fixture() @@ -1505,7 +1672,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 @@ -1515,11 +1682,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: @@ -1557,13 +1724,13 @@ 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() -@pytest.fixture(scope="function") -def state_manager_redis() -> Generator[StateManager, None, None]: +@pytest_asyncio.fixture(loop_scope="function", scope="function") +async def state_manager_redis() -> AsyncGenerator[StateManager, None]: """Instance of state manager for redis only. Yields: @@ -1576,7 +1743,7 @@ def state_manager_redis() -> Generator[StateManager, None, None]: yield state_manager - asyncio.get_event_loop().run_until_complete(state_manager.close()) + await state_manager.close() @pytest.fixture() @@ -1697,14 +1864,14 @@ 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): - mock_app.state_manager.states[ - parent_state.router.session.client_token - ] = parent_state + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): + mock_app.state_manager.states[parent_state.router.session.client_token] = ( + parent_state + ) sp = StateProxy(grandchild_state) assert sp.__wrapped__ == grandchild_state - assert sp._self_substate_path == grandchild_state.get_full_name().split(".") + assert sp._self_substate_path == tuple(grandchild_state.get_full_name().split(".")) assert sp._self_app is mock_app assert not sp._self_mutable assert sp._self_actx is None @@ -1736,7 +1903,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): async with sp: assert sp._self_actx is not None assert sp._self_mutable # proxy is mutable inside context - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): # For in-process store, only one instance of the state exists assert sp.__wrapped__ is grandchild_state else: @@ -1751,7 +1918,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): gotten_state = await mock_app.state_manager.get_state( _substate_key(grandchild_state.router.session.client_token, grandchild_state) ) - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): # For in-process store, only one instance of the state exists assert gotten_state is parent_state else: @@ -1765,19 +1932,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 @@ -1797,7 +1966,7 @@ class BackgroundTaskState(BaseState): """ return self.order - @rx.background + @rx.event(background=True) async def background_task(self): """A background task that updates the state.""" async with self: @@ -1834,7 +2003,7 @@ class BackgroundTaskState(BaseState): self.other() # direct calling event handlers works in context self._private_method() - @rx.background + @rx.event(background=True) async def background_task_reset(self): """A background task that resets the state.""" with pytest.raises(ImmutableStateError): @@ -1848,7 +2017,7 @@ class BackgroundTaskState(BaseState): async with self: self.order.append("reset") - @rx.background + @rx.event(background=True) async def background_task_generator(self): """A background task generator that does nothing. @@ -1889,7 +2058,7 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): mock_app, Event( token=token, - name=f"{BackgroundTaskState.get_name()}.background_task", + name=f"{BackgroundTaskState.get_full_name()}.background_task", router_data=router_data, payload={}, ), @@ -1909,7 +2078,7 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): mock_app, Event( token=token, - name=f"{BackgroundTaskState.get_name()}.other", + name=f"{BackgroundTaskState.get_full_name()}.other", router_data=router_data, payload={}, ), @@ -1920,7 +2089,7 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): # other task returns delta assert update == StateUpdate( delta={ - BackgroundTaskState.get_name(): { + BackgroundTaskState.get_full_name(): { "order": [ "background_task:start", "other", @@ -1956,10 +2125,13 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): emit_mock = mock_app.event_namespace.emit first_ws_message = json.loads(emit_mock.mock_calls[0].args[1]) - assert first_ws_message["delta"]["background_task_state"].pop("router") is not None + assert ( + first_ws_message["delta"][BackgroundTaskState.get_full_name()].pop("router") + is not None + ) assert first_ws_message == { "delta": { - "background_task_state": { + BackgroundTaskState.get_full_name(): { "order": ["background_task:start"], "computed_order": ["background_task:start"], } @@ -1970,14 +2142,16 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): for call in emit_mock.mock_calls[1:5]: assert json.loads(call.args[1]) == { "delta": { - "background_task_state": {"computed_order": ["background_task:start"]} + BackgroundTaskState.get_full_name(): { + "computed_order": ["background_task:start"], + } }, "events": [], "final": True, } assert json.loads(emit_mock.mock_calls[-2].args[1]) == { "delta": { - "background_task_state": { + BackgroundTaskState.get_full_name(): { "order": exp_order, "computed_order": exp_order, "dict_list": {}, @@ -1988,7 +2162,7 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): } assert json.loads(emit_mock.mock_calls[-1].args[1]) == { "delta": { - "background_task_state": { + BackgroundTaskState.get_full_name(): { "computed_order": exp_order, }, }, @@ -2046,7 +2220,7 @@ async def test_background_task_no_chain(): await bts.bad_chain2() -def test_mutable_list(mutable_state): +def test_mutable_list(mutable_state: MutableTestState): """Test that mutable lists are tracked correctly. Args: @@ -2076,7 +2250,7 @@ def test_mutable_list(mutable_state): assert_array_dirty() mutable_state.array.reverse() assert_array_dirty() - mutable_state.array.sort() + mutable_state.array.sort() # type: ignore[reportCallIssue,reportUnknownMemberType] assert_array_dirty() mutable_state.array[0] = 666 assert_array_dirty() @@ -2100,7 +2274,7 @@ def test_mutable_list(mutable_state): assert_array_dirty() -def test_mutable_dict(mutable_state): +def test_mutable_dict(mutable_state: MutableTestState): """Test that mutable dicts are tracked correctly. Args: @@ -2114,40 +2288,40 @@ def test_mutable_dict(mutable_state): assert not mutable_state.dirty_vars # Test all dict operations - mutable_state.hashmap.update({"new_key": 43}) + mutable_state.hashmap.update({"new_key": "43"}) assert_hashmap_dirty() - assert mutable_state.hashmap.setdefault("another_key", 66) == "another_value" + assert mutable_state.hashmap.setdefault("another_key", "66") == "another_value" assert_hashmap_dirty() - assert mutable_state.hashmap.setdefault("setdefault_key", 67) == 67 + assert mutable_state.hashmap.setdefault("setdefault_key", "67") == "67" assert_hashmap_dirty() - assert mutable_state.hashmap.setdefault("setdefault_key", 68) == 67 + assert mutable_state.hashmap.setdefault("setdefault_key", "68") == "67" assert_hashmap_dirty() - assert mutable_state.hashmap.pop("new_key") == 43 + assert mutable_state.hashmap.pop("new_key") == "43" assert_hashmap_dirty() mutable_state.hashmap.popitem() assert_hashmap_dirty() mutable_state.hashmap.clear() assert_hashmap_dirty() - mutable_state.hashmap["new_key"] = 42 + mutable_state.hashmap["new_key"] = "42" assert_hashmap_dirty() del mutable_state.hashmap["new_key"] assert_hashmap_dirty() if sys.version_info >= (3, 9): - mutable_state.hashmap |= {"new_key": 44} + mutable_state.hashmap |= {"new_key": "44"} assert_hashmap_dirty() # Test nested dict operations mutable_state.hashmap["array"] = [] assert_hashmap_dirty() - mutable_state.hashmap["array"].append(1) + mutable_state.hashmap["array"].append("1") assert_hashmap_dirty() mutable_state.hashmap["dict"] = {} assert_hashmap_dirty() - mutable_state.hashmap["dict"]["key"] = 42 + mutable_state.hashmap["dict"]["key"] = "42" assert_hashmap_dirty() mutable_state.hashmap["dict"]["dict"] = {} assert_hashmap_dirty() - mutable_state.hashmap["dict"]["dict"]["key"] = 43 + mutable_state.hashmap["dict"]["dict"]["key"] = "43" assert_hashmap_dirty() # Test proxy returned from `setdefault` and `get` @@ -2169,14 +2343,14 @@ def test_mutable_dict(mutable_state): mutable_value_third_ref = mutable_state.hashmap.pop("setdefault_mutable_key") assert not isinstance(mutable_value_third_ref, MutableProxy) assert_hashmap_dirty() - mutable_value_third_ref.append("baz") + mutable_value_third_ref.append("baz") # type: ignore[reportUnknownMemberType,reportAttributeAccessIssue,reportUnusedCallResult] assert not mutable_state.dirty_vars # Unfortunately previous refs still will mark the state dirty... nothing doing about that assert mutable_value.pop() assert_hashmap_dirty() -def test_mutable_set(mutable_state): +def test_mutable_set(mutable_state: MutableTestState): """Test that mutable sets are tracked correctly. Args: @@ -2218,7 +2392,7 @@ def test_mutable_set(mutable_state): assert_set_dirty() -def test_mutable_custom(mutable_state): +def test_mutable_custom(mutable_state: MutableTestState): """Test that mutable custom types derived from Base are tracked correctly. Args: @@ -2233,17 +2407,38 @@ def test_mutable_custom(mutable_state): mutable_state.custom.foo = "bar" assert_custom_dirty() - mutable_state.custom.array.append(42) + mutable_state.custom.array.append("42") assert_custom_dirty() - mutable_state.custom.hashmap["key"] = 68 + mutable_state.custom.hashmap["key"] = "value" assert_custom_dirty() - mutable_state.custom.test_set.add(42) + mutable_state.custom.test_set.add("foo") assert_custom_dirty() mutable_state.custom.custom.bar = "baz" assert_custom_dirty() -def test_mutable_backend(mutable_state): +def test_mutable_sqla_model(mutable_state: MutableTestState): + """Test that mutable SQLA models are tracked correctly. + + Args: + mutable_state: A test state. + """ + assert not mutable_state.dirty_vars + + def assert_sqla_model_dirty(): + assert mutable_state.dirty_vars == {"sqla_model"} + mutable_state._clean() + assert not mutable_state.dirty_vars + + mutable_state.sqla_model.strlist.append("foo") + assert_sqla_model_dirty() + mutable_state.sqla_model.hashmap["key"] = "value" + assert_sqla_model_dirty() + mutable_state.sqla_model.test_set.add("bar") + assert_sqla_model_dirty() + + +def test_mutable_backend(mutable_state: MutableTestState): """Test that mutable backend vars are tracked correctly. Args: @@ -2258,11 +2453,11 @@ def test_mutable_backend(mutable_state): mutable_state._be_custom.foo = "bar" assert_custom_dirty() - mutable_state._be_custom.array.append(42) + mutable_state._be_custom.array.append("baz") assert_custom_dirty() - mutable_state._be_custom.hashmap["key"] = 68 + mutable_state._be_custom.hashmap["key"] = "value" assert_custom_dirty() - mutable_state._be_custom.test_set.add(42) + mutable_state._be_custom.test_set.add("foo") assert_custom_dirty() mutable_state._be_custom.custom.bar = "baz" assert_custom_dirty() @@ -2275,7 +2470,7 @@ def test_mutable_backend(mutable_state): (copy.deepcopy,), ], ) -def test_mutable_copy(mutable_state, copy_func): +def test_mutable_copy(mutable_state: MutableTestState, copy_func: Callable): """Test that mutable types are copied correctly. Args: @@ -2302,7 +2497,7 @@ def test_mutable_copy(mutable_state, copy_func): (copy.deepcopy,), ], ) -def test_mutable_copy_vars(mutable_state, copy_func): +def test_mutable_copy_vars(mutable_state: MutableTestState, copy_func: Callable): """Test that mutable types are copied correctly. Args: @@ -2319,7 +2514,10 @@ def test_mutable_copy_vars(mutable_state, copy_func): def test_duplicate_substate_class(mocker): + # Neuter pytest escape hatch, because we want to test duplicate detection. mocker.patch("reflex.state.is_testing_env", lambda: False) + # Neuter state handling since these _are_ defined inside a function. + mocker.patch("reflex.state.BaseState._handle_local_def", lambda: None) with pytest.raises(ValueError): class TestState(BaseState): @@ -2347,7 +2545,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("'", '"') @@ -2392,6 +2590,22 @@ class Custom1(Base): foo: str + def set_foo(self, val: str): + """Set the attribute foo. + + Args: + val: The value to set. + """ + self.foo = val + + def double_foo(self) -> str: + """Concantenate foo with foo. + + Returns: + foo + foo + """ + return self.foo + self.foo + class Custom2(Base): """A custom class with a Custom1 field.""" @@ -2399,6 +2613,14 @@ class Custom2(Base): c1: Optional[Custom1] = None c1r: Custom1 + def set_c1r_foo(self, val: str): + """Set the foo attribute of the c1 field. + + Args: + val: The value to set. + """ + self.c1r.set_foo(val) + class Custom3(Base): """A custom class with a Custom2 field.""" @@ -2418,15 +2640,23 @@ def test_state_union_optional(): c3r: Custom3 = Custom3(c2r=Custom2(c1r=Custom1(foo=""))) custom_union: Union[Custom1, Custom2, Custom3] = Custom1(foo="") - assert UnionState.c3.c2._var_name == "c3?.c2" # type: ignore - assert UnionState.c3.c2.c1._var_name == "c3?.c2?.c1" # type: ignore - assert UnionState.c3.c2.c1.foo._var_name == "c3?.c2?.c1?.foo" # type: ignore - assert UnionState.c3.c2.c1r.foo._var_name == "c3?.c2?.c1r.foo" # type: ignore - assert UnionState.c3.c2r.c1._var_name == "c3?.c2r.c1" # type: ignore - assert UnionState.c3.c2r.c1.foo._var_name == "c3?.c2r.c1?.foo" # type: ignore - assert UnionState.c3.c2r.c1r.foo._var_name == "c3?.c2r.c1r.foo" # type: ignore - assert UnionState.c3i.c2._var_name == "c3i.c2" # type: ignore - assert UnionState.c3r.c2._var_name == "c3r.c2" # type: ignore + assert str(UnionState.c3.c2) == f'{str(UnionState.c3)}?.["c2"]' # type: ignore + assert str(UnionState.c3.c2.c1) == f'{str(UnionState.c3)}?.["c2"]?.["c1"]' # type: ignore + assert ( + str(UnionState.c3.c2.c1.foo) == f'{str(UnionState.c3)}?.["c2"]?.["c1"]?.["foo"]' # type: ignore + ) + assert ( + str(UnionState.c3.c2.c1r.foo) == f'{str(UnionState.c3)}?.["c2"]?.["c1r"]["foo"]' # type: ignore + ) + assert str(UnionState.c3.c2r.c1) == f'{str(UnionState.c3)}?.["c2r"]["c1"]' # type: ignore + assert ( + str(UnionState.c3.c2r.c1.foo) == f'{str(UnionState.c3)}?.["c2r"]["c1"]?.["foo"]' # type: ignore + ) + assert ( + str(UnionState.c3.c2r.c1r.foo) == f'{str(UnionState.c3)}?.["c2r"]["c1r"]["foo"]' # type: ignore + ) + assert str(UnionState.c3i.c2) == f'{str(UnionState.c3i)}["c2"]' # type: ignore + assert str(UnionState.c3r.c2) == f'{str(UnionState.c3r)}["c2"]' # type: ignore assert UnionState.custom_union.foo is not None # type: ignore assert UnionState.custom_union.c1 is not None # type: ignore assert UnionState.custom_union.c1r is not None # type: ignore @@ -2436,6 +2666,47 @@ def test_state_union_optional(): assert types.is_union(UnionState.int_float._var_type) # type: ignore +def test_set_base_field_via_setter(): + """When calling a setter on a Base instance, also track changes.""" + + class BaseFieldSetterState(BaseState): + c1: Custom1 = Custom1(foo="") + c2: Custom2 = Custom2(c1r=Custom1(foo="")) + + bfss = BaseFieldSetterState() + assert "c1" not in bfss.dirty_vars + + # Non-mutating function, not dirty + bfss.c1.double_foo() + assert "c1" not in bfss.dirty_vars + + # Mutating function, dirty + bfss.c1.set_foo("bar") + assert "c1" in bfss.dirty_vars + bfss.dirty_vars.clear() + assert "c1" not in bfss.dirty_vars + + # Mutating function from Base, dirty + bfss.c1.set(foo="bar") + assert "c1" in bfss.dirty_vars + bfss.dirty_vars.clear() + assert "c1" not in bfss.dirty_vars + + # Assert identity of MutableProxy + mp = bfss.c1 + assert isinstance(mp, MutableProxy) + mp2 = mp.set() + assert mp is mp2 + mp3 = bfss.c1.set() + assert mp is not mp3 + # Since none of these set calls had values, the state should not be dirty + assert not bfss.dirty_vars + + # Chained Mutating function, dirty + bfss.c2.set_c1r_foo("baz") + assert "c2" in bfss.dirty_vars + + def exp_is_hydrated(state: State, is_hydrated: bool = True) -> Dict[str, Any]: """Expected IS_HYDRATED delta that would be emitted by HydrateMiddleware. @@ -2454,6 +2725,7 @@ class OnLoadState(State): num: int = 0 + @rx.event def test_handler(self): """Test handler.""" self.num += 1 @@ -2531,7 +2803,7 @@ async def test_preprocess(app_module_mock, token, test_state, expected, mocker): assert isinstance(update, StateUpdate) updates.append(update) assert len(updates) == 1 - assert updates[0].delta["state"].pop("router") is not None + assert updates[0].delta[State.get_name()].pop("router") is not None assert updates[0].delta == exp_is_hydrated(state, False) events = updates[0].events @@ -2541,6 +2813,9 @@ async def test_preprocess(app_module_mock, token, test_state, expected, mocker): } assert (await state._process(events[1]).__anext__()).delta == exp_is_hydrated(state) + if isinstance(app.state_manager, StateManagerRedis): + await app.state_manager.close() + @pytest.mark.asyncio async def test_preprocess_multiple_load_events(app_module_mock, token, mocker): @@ -2575,7 +2850,7 @@ async def test_preprocess_multiple_load_events(app_module_mock, token, mocker): assert isinstance(update, StateUpdate) updates.append(update) assert len(updates) == 1 - assert updates[0].delta["state"].pop("router") is not None + assert updates[0].delta[State.get_name()].pop("router") is not None assert updates[0].delta == exp_is_hydrated(state, False) events = updates[0].events @@ -2588,6 +2863,9 @@ async def test_preprocess_multiple_load_events(app_module_mock, token, mocker): } assert (await state._process(events[2]).__anext__()).delta == exp_is_hydrated(state) + if isinstance(app.state_manager, StateManagerRedis): + await app.state_manager.close() + @pytest.mark.asyncio async def test_get_state(mock_app: rx.App, token: str): @@ -2604,25 +2882,30 @@ 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)) == ( - "child_state", - "child_state2", - "child_state3", + ChildState.get_name(), + ChildState2.get_name(), + ChildState3.get_name(), ) else: # Sibling states are only populated if they have computed vars - assert tuple(sorted(test_state.substates)) == ("child_state2", "child_state3") + assert tuple(sorted(test_state.substates)) == ( + ChildState2.get_name(), + ChildState3.get_name(), + ) # Because ChildState3 has a computed var, it is always dirty, and always populated. assert ( - test_state.substates["child_state3"].substates["grandchild_state3"].computed + test_state.substates[ChildState3.get_name()] + .substates[GrandchildState3.get_name()] + .computed == "" ) # Get the child_state2 directly. - child_state2_direct = test_state.get_substate(["child_state2"]) + child_state2_direct = test_state.get_substate([ChildState2.get_name()]) child_state2_get_state = await test_state.get_state(ChildState2) # These should be the same object. assert child_state2_direct is child_state2_get_state @@ -2633,19 +2916,21 @@ async def test_get_state(mock_app: rx.App, token: str): # Now the original root should have all substates populated. assert tuple(sorted(test_state.substates)) == ( - "child_state", - "child_state2", - "child_state3", + ChildState.get_name(), + ChildState2.get_name(), + ChildState3.get_name(), ) # ChildState should be retrievable - child_state_direct = test_state.get_substate(["child_state"]) + child_state_direct = test_state.get_substate([ChildState.get_name()]) child_state_get_state = await test_state.get_state(ChildState) # These should be the same object. assert child_state_direct is child_state_get_state # GrandchildState instance should be the same as the one retrieved from the child_state2. - assert grandchild_state is child_state_direct.get_substate(["grandchild_state"]) + assert grandchild_state is child_state_direct.get_substate( + [GrandchildState.get_name()] + ) grandchild_state.value2 = "set_value" assert test_state.get_delta() == { @@ -2666,27 +2951,27 @@ async def test_get_state(mock_app: rx.App, token: str): _substate_key(token, ChildState2) ) assert isinstance(new_test_state, TestState) - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): # In memory, it's the same instance assert new_test_state is test_state test_state._clean() # All substates are available assert tuple(sorted(new_test_state.substates)) == ( - "child_state", - "child_state2", - "child_state3", + 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 # Sibling states are only populated if they have computed vars assert tuple(sorted(new_test_state.substates)) == ( - "child_state2", - "child_state3", + ChildState2.get_name(), + ChildState3.get_name(), ) # Set a value on child_state2, should update cached var in grandchild_state2 - child_state2 = new_test_state.get_substate(("child_state2",)) + child_state2 = new_test_state.get_substate((ChildState2.get_name(),)) child_state2.value = "set_c2_value" assert new_test_state.get_delta() == { @@ -2777,8 +3062,8 @@ async def test_get_state_from_sibling_not_cached(mock_app: rx.App, token: str): if isinstance(mock_app.state_manager, StateManagerRedis): # When redis is used, only states with computed vars are pre-fetched. - assert "child2" not in root.substates - assert "child3" in root.substates # (due to @rx.var) + assert Child2.get_name() not in root.substates + assert Child3.get_name() in root.substates # (due to @rx.var) # Get the unconnected sibling state, which will be used to `get_state` other instances. child = root.get_substate(Child.get_full_name().split(".")) @@ -2824,6 +3109,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. @@ -2860,3 +3190,217 @@ async def test_setvar(mock_app: rx.App, token: str): # Cannot setvar with non-string with pytest.raises(ValueError): TestState.setvar(42, 42) + + +@pytest.mark.asyncio +async def test_setvar_async_setter(): + """Test that overridden async setters raise Exception when used with setvar.""" + with pytest.raises(NotImplementedError): + TestState.setvar("asynctest", 42) + + +@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis") +@pytest.mark.parametrize( + "expiration_kwargs, expected_values", + [ + ({"redis_lock_expiration": 20000}, (20000, constants.Expiration.TOKEN)), + ( + {"redis_lock_expiration": 50000, "redis_token_expiration": 5600}, + (50000, 5600), + ), + ({"redis_token_expiration": 7600}, (constants.Expiration.LOCK, 7600)), + ], +) +def test_redis_state_manager_config_knobs(tmp_path, expiration_kwargs, expected_values): + proj_root = tmp_path / "project1" + proj_root.mkdir() + + config_items = ",\n ".join( + f"{key} = {value}" for key, value in expiration_kwargs.items() + ) + + config_string = f""" +import reflex as rx +config = rx.Config( + app_name="project1", + redis_url="redis://localhost:6379", + state_manager_mode="redis", + {config_items} +) +""" + (proj_root / "rxconfig.py").write_text(dedent(config_string)) + + with chdir(proj_root): + # reload config for each parameter to avoid stale values + reflex.config.get_config(reload=True) + from reflex.state import State, StateManager + + state_manager = StateManager.create(state=State) + assert state_manager.lock_expiration == expected_values[0] # type: ignore + assert state_manager.token_expiration == expected_values[1] # type: ignore + + +class MixinState(State, mixin=True): + """A mixin state for testing.""" + + num: int = 0 + _backend: int = 0 + _backend_no_default: dict + + @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.""" + + 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, "_backend_no_default": {}} + + assert "computed" in UsesMixinState.computed_vars + assert "computed" in UsesMixinState.vars + + assert ( + UsesMixinState(_reflex_internal_init=True)._backend_no_default # type: ignore + is not UsesMixinState.backend_vars["_backend_no_default"] + ) + + +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 + + +def test_assignment_to_undeclared_vars(): + """Test that an attribute error is thrown when undeclared vars are set.""" + + class State(BaseState): + val: str + _val: str + __val: str # type: ignore + + def handle_supported_regular_vars(self): + self.val = "no underscore" + self._val = "single leading underscore" + self.__val = "double leading undercore" + + def handle_regular_var(self): + self.num = 5 + + def handle_backend_var(self): + self._num = 5 + + def handle_non_var(self): + self.__num = 5 + + class Substate(State): + def handle_var(self): + self.value = 20 + + state = State() # type: ignore + sub_state = Substate() # type: ignore + + with pytest.raises(SetUndefinedStateVarError): + state.handle_regular_var() + + with pytest.raises(SetUndefinedStateVarError): + sub_state.handle_var() + + with pytest.raises(SetUndefinedStateVarError): + state.handle_backend_var() + + state.handle_supported_regular_vars() + state.handle_non_var() + + +@pytest.mark.asyncio +async def test_deserialize_gc_state_disk(token): + """Test that a state can be deserialized from disk with a grandchild state. + + Args: + token: A token. + """ + + class Root(BaseState): + pass + + class State(Root): + num: int = 42 + + class Child(State): + foo: str = "bar" + + dsm = StateManagerDisk(state=Root) + async with dsm.modify_state(token) as root: + s = await root.get_state(State) + s.num += 1 + c = await root.get_state(Child) + assert s._get_was_touched() + assert not c._get_was_touched() + + dsm2 = StateManagerDisk(state=Root) + root = await dsm2.get_state(token) + s = await root.get_state(State) + assert s.num == 43 + c = await root.get_state(Child) + assert c.foo == "bar" + + +class Obj(Base): + """A object containing a callable for testing fallback pickle.""" + + _f: Callable + + +def test_fallback_pickle(): + """Test that state serialization will fall back to dill.""" + + class DillState(BaseState): + _o: Optional[Obj] = None + _f: Optional[Callable] = None + _g: Any = None + + state = DillState(_reflex_internal_init=True) # type: ignore + state._o = Obj(_f=lambda: 42) + state._f = lambda: 420 + + pk = state._serialize() + + unpickled_state = BaseState._deserialize(pk) + assert unpickled_state._f() == 420 + assert unpickled_state._o._f() == 42 + + # Threading locks are unpicklable normally, and raise TypeError instead of PicklingError. + state2 = DillState(_reflex_internal_init=True) # type: ignore + state2._g = threading.Lock() + pk2 = state2._serialize() + unpickled_state2 = BaseState._deserialize(pk2) + assert isinstance(unpickled_state2._g, type(threading.Lock())) + + # Some object, like generator, are still unpicklable with dill. + state3 = DillState(_reflex_internal_init=True) # type: ignore + state3._g = (i for i in range(10)) + pk3 = state3._serialize() + assert len(pk3) == 0 diff --git a/tests/test_state_tree.py b/tests/units/test_state_tree.py similarity index 88% rename from tests/test_state_tree.py rename to tests/units/test_state_tree.py index 0747f900c..ebdd877de 100644 --- a/tests/test_state_tree.py +++ b/tests/units/test_state_tree.py @@ -1,8 +1,9 @@ """Specialized test for a larger state tree.""" -import asyncio -from typing import Generator + +from typing import AsyncGenerator import pytest +import pytest_asyncio import reflex as rx from reflex.state import BaseState, StateManager, StateManagerRedis, _substate_key @@ -41,7 +42,7 @@ class SubA_A_A_A(SubA_A_A): class SubA_A_A_B(SubA_A_A): """SubA_A_A_B is a child of SubA_A_A.""" - @rx.cached_var + @rx.var(cache=True) def sub_a_a_a_cached(self) -> int: """A cached var. @@ -182,7 +183,7 @@ class SubE_A_A_A_D(SubE_A_A_A): sub_e_a_a_a_d: int - @rx.cached_var + @rx.var(cache=True) def sub_e_a_a_a_d_var(self) -> int: """A computed var. @@ -209,8 +210,10 @@ ALWAYS_COMPUTED_DICT_KEYS = [ ] -@pytest.fixture(scope="function") -def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: +@pytest_asyncio.fixture(loop_scope="function", scope="function") +async def state_manager_redis( + app_module_mock, +) -> AsyncGenerator[StateManager, None]: """Instance of state manager for redis only. Args: @@ -227,7 +230,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: yield state_manager - asyncio.get_event_loop().run_until_complete(state_manager.close()) + await state_manager.close() @pytest.mark.asyncio @@ -236,7 +239,13 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: [ ( Root, - ["tree_a", "tree_b", "tree_c", "tree_d", "tree_e"], + [ + TreeA.get_name(), + TreeB.get_name(), + TreeC.get_name(), + TreeD.get_name(), + TreeE.get_name(), + ], [ TreeA.get_full_name(), SubA_A.get_full_name(), @@ -260,7 +269,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( TreeA, - ("tree_a", "tree_d", "tree_e"), + (TreeA.get_name(), TreeD.get_name(), TreeE.get_name()), [ TreeA.get_full_name(), SubA_A.get_full_name(), @@ -275,7 +284,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( SubA_A_A_A, - ["tree_a", "tree_d", "tree_e"], + [TreeA.get_name(), TreeD.get_name(), TreeE.get_name()], [ TreeA.get_full_name(), SubA_A.get_full_name(), @@ -287,7 +296,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( TreeB, - ["tree_b", "tree_d", "tree_e"], + [TreeB.get_name(), TreeD.get_name(), TreeE.get_name()], [ TreeB.get_full_name(), SubB_A.get_full_name(), @@ -299,7 +308,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( SubB_B, - ["tree_b", "tree_d", "tree_e"], + [TreeB.get_name(), TreeD.get_name(), TreeE.get_name()], [ TreeB.get_full_name(), SubB_B.get_full_name(), @@ -308,7 +317,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( SubB_C_A, - ["tree_b", "tree_d", "tree_e"], + [TreeB.get_name(), TreeD.get_name(), TreeE.get_name()], [ TreeB.get_full_name(), SubB_C.get_full_name(), @@ -318,7 +327,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( TreeC, - ["tree_c", "tree_d", "tree_e"], + [TreeC.get_name(), TreeD.get_name(), TreeE.get_name()], [ TreeC.get_full_name(), SubC_A.get_full_name(), @@ -327,14 +336,14 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]: ), ( TreeD, - ["tree_d", "tree_e"], + [TreeD.get_name(), TreeE.get_name()], [ *ALWAYS_COMPUTED_DICT_KEYS, ], ), ( TreeE, - ["tree_d", "tree_e"], + [TreeE.get_name(), TreeD.get_name()], [ # Extra siblings of computed var included now. SubE_A_A_A_B.get_full_name(), diff --git a/tests/test_style.py b/tests/units/test_style.py similarity index 87% rename from tests/test_style.py rename to tests/units/test_style.py index 825d72a9d..e1d652798 100644 --- a/tests/test_style.py +++ b/tests/units/test_style.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any +from typing import Any, Dict import pytest @@ -8,21 +8,22 @@ import reflex as rx from reflex import style from reflex.components.component import evaluate_style_namespaces from reflex.style import Style -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var test_style = [ ({"a": 1}, {"a": 1}), - ({"a": Var.create("abc")}, {"a": "abc"}), + ({"a": LiteralVar.create("abc")}, {"a": "abc"}), ({"test_case": 1}, {"testCase": 1}), - ({"test_case": {"a": 1}}, {"testCase": {"a": 1}}), - ({":test_case": {"a": 1}}, {":testCase": {"a": 1}}), - ({"::test_case": {"a": 1}}, {"::testCase": {"a": 1}}), + ({"test_case": {"a": 1}}, {"test_case": {"a": 1}}), + ({":test_case": {"a": 1}}, {":test_case": {"a": 1}}), + ({"::test_case": {"a": 1}}, {"::test_case": {"a": 1}}), ( {"::-webkit-scrollbar": {"display": "none"}}, {"::-webkit-scrollbar": {"display": "none"}}, ), - ({"margin_y": "2rem"}, {"marginBottom": "2rem", "marginTop": "2rem"}), - ({"marginY": "2rem"}, {"marginBottom": "2rem", "marginTop": "2rem"}), + ({"margin_y": "2rem"}, {"marginTop": "2rem", "marginBottom": "2rem"}), + ({"marginY": "2rem"}, {"marginTop": "2rem", "marginBottom": "2rem"}), ( {"::-webkit-scrollbar": {"bgColor": "red"}}, {"::-webkit-scrollbar": {"backgroundColor": "red"}}, @@ -49,7 +50,7 @@ def test_convert(style_dict, expected): expected: The expected formatted style. """ converted_dict, _var_data = style.convert(style_dict) - assert converted_dict == expected + assert LiteralVar.create(converted_dict).equals(LiteralVar.create(expected)) @pytest.mark.parametrize( @@ -63,7 +64,9 @@ def test_create_style(style_dict, expected): style_dict: The style to check. expected: The expected formatted style. """ - assert style.Style(style_dict) == expected + assert LiteralVar.create(style.Style(style_dict)).equals( + LiteralVar.create(expected) + ) def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): @@ -87,39 +90,47 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): @pytest.mark.parametrize( ("kwargs", "style_dict", "expected_get_style"), [ - ({}, {}, {"css": None}), - ({"color": "hotpink"}, {}, {"css": Var.create(Style({"color": "hotpink"}))}), - ({}, {"color": "red"}, {"css": Var.create(Style({"color": "red"}))}), + ({}, {}, {}), + ( + {"color": "hotpink"}, + {}, + {"css": LiteralVar.create(Style({"color": "hotpink"}))}, + ), + ({}, {"color": "red"}, {"css": LiteralVar.create(Style({"color": "red"}))}), ( {"color": "hotpink"}, {"color": "red"}, - {"css": Var.create(Style({"color": "hotpink"}))}, + {"css": LiteralVar.create(Style({"color": "hotpink"}))}, ), ( {"_hover": {"color": "hotpink"}}, {}, - {"css": Var.create(Style({"&:hover": {"color": "hotpink"}}))}, + {"css": LiteralVar.create(Style({"&:hover": {"color": "hotpink"}}))}, ), ( {}, {"_hover": {"color": "red"}}, - {"css": Var.create(Style({"&:hover": {"color": "red"}}))}, + {"css": LiteralVar.create(Style({"&:hover": {"color": "red"}}))}, ), ( {}, {":hover": {"color": "red"}}, - {"css": Var.create(Style({"&:hover": {"color": "red"}}))}, + {"css": LiteralVar.create(Style({"&:hover": {"color": "red"}}))}, ), ( {}, {"::-webkit-scrollbar": {"display": "none"}}, - {"css": Var.create(Style({"&::-webkit-scrollbar": {"display": "none"}}))}, + { + "css": LiteralVar.create( + Style({"&::-webkit-scrollbar": {"display": "none"}}) + ) + }, ), ( {}, {"::-moz-progress-bar": {"background_color": "red"}}, { - "css": Var.create( + "css": LiteralVar.create( Style({"&::-moz-progress-bar": {"backgroundColor": "red"}}) ) }, @@ -128,7 +139,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): {"color": ["#111", "#222", "#333", "#444", "#555"]}, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "@media screen and (min-width: 0)": {"color": "#111"}, @@ -148,7 +159,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): }, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "@media screen and (min-width: 0)": {"color": "#111"}, @@ -169,7 +180,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): }, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "@media screen and (min-width: 0)": { @@ -209,7 +220,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): }, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -236,7 +247,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): {"_hover": {"color": ["#111", "#222", "#333", "#444", "#555"]}}, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -268,7 +279,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): }, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -307,7 +318,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]): }, {}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -361,20 +372,20 @@ class StyleState(rx.State): [ ( {"color": StyleState.color}, - {"css": Var.create(Style({"color": StyleState.color}))}, + {"css": LiteralVar.create(Style({"color": StyleState.color}))}, ), ( {"color": f"dark{StyleState.color}"}, { - "css": Var.create_safe(f'{{"color": `dark{StyleState.color}`}}').to( - Style - ) + "css": Var( + _js_expr=f'({{ ["color"] : ("dark"+{StyleState.color}) }})' + ).to(Dict[str, str]) }, ), ( {"color": StyleState.color, "_hover": {"color": StyleState.color2}}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "color": StyleState.color, @@ -387,7 +398,7 @@ class StyleState(rx.State): ( {"color": [StyleState.color, "gray", StyleState.color2, "yellow", "blue"]}, { - "css": Var.create( + "css": LiteralVar.create( Style( { "@media screen and (min-width: 0)": { @@ -415,7 +426,7 @@ class StyleState(rx.State): ] }, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -453,7 +464,7 @@ class StyleState(rx.State): } }, { - "css": Var.create( + "css": LiteralVar.create( Style( { "&:hover": { @@ -492,7 +503,10 @@ def test_style_via_component_with_state( """ comp = rx.el.div(**kwargs) - assert comp.style._var_data == expected_get_style["css"]._var_data + assert ( + VarData.merge(comp.style._var_data) + == expected_get_style["css"]._get_all_var_data() + ) # Assert that style values are equal. compare_dict_of_var(comp._get_style(), expected_get_style) @@ -507,10 +521,10 @@ def test_evaluate_style_namespaces(): def test_style_update_with_var_data(): """Test that .update with a Style containing VarData works.""" - red_var = Var.create_safe("red")._replace( + red_var = LiteralVar.create("red")._replace( merge_var_data=VarData(hooks={"const red = true": None}), # type: ignore ) - blue_var = Var.create_safe("blue", _var_is_local=False)._replace( + blue_var = LiteralVar.create("blue")._replace( merge_var_data=VarData(hooks={"const blue = true": None}), # type: ignore ) @@ -521,7 +535,9 @@ def test_style_update_with_var_data(): ) s2 = Style() s2.update(s1, background_color=f"{blue_var}ish") - assert s2 == {"color": "red", "backgroundColor": "`${blue}ish`"} + assert str(LiteralVar.create(s2)) == str( + LiteralVar.create({"color": "red", "backgroundColor": "blueish"}) + ) assert s2._var_data is not None assert "const red = true" in s2._var_data.hooks assert "const blue = true" in s2._var_data.hooks diff --git a/tests/test_telemetry.py b/tests/units/test_telemetry.py similarity index 64% rename from tests/test_telemetry.py rename to tests/units/test_telemetry.py index 58786c67b..25ad91323 100644 --- a/tests/test_telemetry.py +++ b/tests/units/test_telemetry.py @@ -1,4 +1,3 @@ -import httpx import pytest from packaging.version import parse as parse_python_version @@ -29,25 +28,28 @@ def test_telemetry(): def test_disable(): """Test that disabling telemetry works.""" - assert not telemetry.send("test", telemetry_enabled=False) + assert not telemetry._send("test", telemetry_enabled=False) @pytest.mark.parametrize("event", ["init", "reinit", "run-dev", "run-prod", "export"]) def test_send(mocker, event): - mocker.patch("httpx.post") - mocker.patch( - "builtins.open", - mocker.mock_open( - read_data='{"project_hash": "78285505863498957834586115958872998605"}' - ), + httpx_post_mock = mocker.patch("httpx.post") + # mocker.patch( + # "builtins.open", + # mocker.mock_open( + # read_data='{"project_hash": "78285505863498957834586115958872998605"}' + # ), + # ) + + # Mock the read_text method of Path + pathlib_path_read_text_mock = mocker.patch( + "pathlib.Path.read_text", + return_value='{"project_hash": "78285505863498957834586115958872998605"}', ) + mocker.patch("platform.platform", return_value="Mocked Platform") - telemetry.send(event, telemetry_enabled=True) - httpx.post.assert_called_once() - if telemetry.get_os() == "Windows": - open.assert_called_with(".web\\reflex.json", "r") - elif telemetry.get_os() == "Linux": - open.assert_called_with("/proc/meminfo", "rb", buffering=32768) - else: - open.assert_called_with(".web/reflex.json", "r") + telemetry._send(event, telemetry_enabled=True) + httpx_post_mock.assert_called_once() + + assert pathlib_path_read_text_mock.call_count == 2 diff --git a/tests/test_testing.py b/tests/units/test_testing.py similarity index 99% rename from tests/test_testing.py rename to tests/units/test_testing.py index c53e9e775..b01709202 100644 --- a/tests/test_testing.py +++ b/tests/units/test_testing.py @@ -1,4 +1,5 @@ """Unit tests for the included testing tools.""" + import pytest from reflex.constants import IS_WINDOWS diff --git a/tests/units/test_var.py b/tests/units/test_var.py new file mode 100644 index 000000000..a8b4b759d --- /dev/null +++ b/tests/units/test_var.py @@ -0,0 +1,1853 @@ +import json +import math +import sys +import typing +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.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.vars.function import ArgsFunctionOperation, FunctionStringVar +from reflex.vars.number import ( + LiteralBooleanVar, + LiteralNumberVar, + NumberVar, +) +from reflex.vars.object import LiteralObjectVar, ObjectVar +from reflex.vars.sequence import ( + ArrayVar, + ConcatVarOperation, + LiteralArrayVar, + LiteralStringVar, +) + +test_vars = [ + 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), +] + + +class ATestState(BaseState): + """Test state.""" + + value: str + dict_val: Dict[str, List] = {} + + +@pytest.fixture +def TestObj(): + class TestObj(Base): + foo: int + bar: str + + return TestObj + + +@pytest.fixture +def ParentState(TestObj): + class ParentState(BaseState): + foo: int + bar: int + + @computed_var + def var_without_annotation(self): + return TestObj + + return ParentState + + +@pytest.fixture +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 + + +@pytest.fixture +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 + + +@pytest.fixture +def StateWithAnyVar(TestObj): + class StateWithAnyVar(BaseState): + @computed_var + def var_without_annotation(self) -> typing.Any: + return TestObj + + return StateWithAnyVar + + +@pytest.fixture +def StateWithCorrectVarAnnotation(): + class StateWithCorrectVarAnnotation(BaseState): + @computed_var + def var_with_annotation(self) -> str: + return "Correct annotation" + + return StateWithCorrectVarAnnotation + + +@pytest.fixture +def StateWithWrongVarAnnotation(TestObj): + class StateWithWrongVarAnnotation(BaseState): + @computed_var + def var_with_annotation(self) -> str: + return TestObj + + return StateWithWrongVarAnnotation + + +@pytest.fixture +def StateWithInitialComputedVar(): + class StateWithInitialComputedVar(BaseState): + @computed_var(initial_value="Initial value") + def var_with_initial_value(self) -> str: + return "Runtime value" + + return StateWithInitialComputedVar + + +@pytest.fixture +def ChildWithInitialComputedVar(StateWithInitialComputedVar): + class ChildWithInitialComputedVar(StateWithInitialComputedVar): + @computed_var(initial_value="Initial value") + def var_with_initial_value_child(self) -> str: + return "Runtime value" + + return ChildWithInitialComputedVar + + +@pytest.fixture +def StateWithRuntimeOnlyVar(): + class StateWithRuntimeOnlyVar(BaseState): + @computed_var(initial_value=None) + def var_raises_at_runtime(self) -> str: + raise ValueError("So nicht, mein Freund") + + return StateWithRuntimeOnlyVar + + +@pytest.fixture +def ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar): + class ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar): + @computed_var(initial_value="Initial value") + def var_raises_at_runtime_child(self) -> str: + raise ValueError("So nicht, mein Freund") + + return ChildWithRuntimeOnlyVar + + +@pytest.mark.parametrize( + "prop,expected", + zip( + test_vars, + [ + "prop1", + "key", + "state.value", + "state.local", + "local2", + ], + ), +) +def test_full_name(prop, expected): + """Test that the full name of a var is correct. + + Args: + prop: The var to test. + expected: The expected full name. + """ + assert str(prop) == expected + + +@pytest.mark.parametrize( + "prop,expected", + zip( + test_vars, + ["prop1", "key", "state.value", "state.local", "local2"], + ), +) +def test_str(prop, expected): + """Test that the string representation of a var is correct. + + Args: + prop: The var to test. + expected: The expected string representation. + """ + assert str(prop) == expected + + +@pytest.mark.parametrize( + "prop,expected", + [ + (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): + """Test that the default value of a var is correct. + + Args: + prop: The var to test. + expected: The expected default value. + """ + assert prop.get_default_value() == expected + + +@pytest.mark.parametrize( + "prop,expected", + zip( + test_vars, + [ + "set_prop1", + "set_key", + "state.set_value", + "state.set_local", + "set_local2", + ], + ), +) +def test_get_setter(prop, expected): + """Test that the name of the setter function of a var is correct. + + Args: + prop: The var to test. + expected: The expected name of the setter function. + """ + assert prop.get_setter_name() == expected + + +@pytest.mark.parametrize( + "value,expected", + [ + (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}, + Var(_js_expr='({ ["a"] : 1, ["b"] : 2 })', _var_type=Dict[str, int]), + ), + ], +) +def test_create(value, expected): + """Test the var create function. + + Args: + value: The value to create a var from. + expected: The expected name of the setter function. + """ + prop = LiteralVar.create(value) + assert prop.equals(expected) # type: ignore + + +def test_create_type_error(): + """Test the var create function when inputs type error.""" + + class ErrorType: + pass + + value = ErrorType() + + with pytest.raises(TypeError): + LiteralVar.create(value) + + +def v(value) -> Var: + return LiteralVar.create(value) + + +def test_basic_operations(TestObj): + """Test the var operations. + + Args: + TestObj: The test object. + """ + 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(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar + == LiteralVar.create("bar") + ) + == '(state.foo["bar"] === "bar")' + ) + assert ( + 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(LiteralArrayVar.create([1, 2]) + LiteralArrayVar.create([3, 4])) + == "[...[1, 2], ...[3, 4]]" + ) + + # Tests for reverse operation + assert ( + str(LiteralArrayVar.create([1, 2, 3]).reverse()) + == "[1, 2, 3].slice().reverse()" + ) + assert ( + str(LiteralArrayVar.create(["1", "2", "3"]).reverse()) + == '["1", "2", "3"].slice().reverse()' + ) + assert ( + 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( + "var, expected", + [ + (v([1, 2, 3]), "[1, 2, 3]"), + (v(set([1, 2, 3])), "[1, 2, 3]"), + (v(["1", "2", "3"]), '["1", "2", "3"]'), + ( + 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"]'), + ( + Var(_js_expr="foo")._var_set_state("state").to(tuple), + "state.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 = 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)" + + +class Foo(rx.Base): + """Foo class.""" + + bar: int + baz: str + + +class Bar(rx.Base): + """Bar class.""" + + bar: str + baz: str + foo: int + + +@pytest.mark.parametrize( + ("var", "var_type"), + ( + [ + (Var(_js_expr="", _var_type=Foo | Bar).guess_type(), Foo | Bar), + (Var(_js_expr="", _var_type=Foo | Bar).guess_type().bar, Union[int, str]), + ] + if sys.version_info >= (3, 10) + else [] + ) + + [ + (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type(), Union[Foo, Bar]), + (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().baz, str), + ( + Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().foo, + Union[int, None], + ), + ], +) +def test_var_types(var, var_type): + assert var._var_type == var_type + + +@pytest.mark.parametrize( + "var, expected", + [ + (v("123"), json.dumps("123")), + (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 = 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(obj => obj["hello"] === "1")' + ) + + +@pytest.mark.parametrize( + "var, expected", + [ + (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 = 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)" + ) + assert str(var.contains(other_var)) == f"{expected}.hasOwnProperty(other)" + + +@pytest.mark.parametrize( + "var", + [ + 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): + """Test that we can index into str, list or tuple vars. + + Args: + var : The str, list or tuple base var. + """ + # Test basic indexing. + 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._js_expr}.at(-1)" + + +@pytest.mark.parametrize( + "var, type_", + [ + (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_): + """Test that indexing returns valid types. + + Args: + var : The list, typle base var. + type_ : The type on indexed object. + + """ + assert var[0]._var_type == type_[0] + assert var[1]._var_type == type_[1] + + +def test_var_indexing_str(): + """Test that we can index into str vars.""" + 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 is str + + # Test basic indexing. + 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)" + + +@pytest.mark.parametrize( + "var", + [ + (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 argument" in str(excinfo.value) + + +def test_computed_var_replace_with_invalid_kwargs(): + @computed_var(initial_value=1) + def test_var(state) -> int: + return 1 + + with pytest.raises(TypeError) as excinfo: + test_var._replace(_random_kwarg=True) + assert "Unexpected keyword argument" in str(excinfo.value) + + +@pytest.mark.parametrize( + "var, index", + [ + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), [1, 2]), + ( + 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, + ), + ), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), 1.5), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), "str"), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), + ), + (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"}), + ( + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), + ), + (Var(_js_expr="str", _var_type=Tuple[str]).guess_type(), [1, 2]), + ( + 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(), + ), + ( + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), + ), + ], +) +def test_var_unsupported_indexing_lists(var, index): + """Test unsupported indexing throws a type error. + + Args: + var: The base var. + index: The base var index. + """ + with pytest.raises(TypeError): + var[index] + + +@pytest.mark.parametrize( + "var", + [ + 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): + """Test that we can slice into str, list or tuple vars. + + Args: + var : The str, list or tuple base var. + """ + 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 is 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 = Var(_js_expr="dct").to(ObjectVar, Dict[str, str]) + + # Check correct indexing. + assert str(dct["a"]) == 'dct["a"]' + assert str(dct["asdf"]) == 'dct["asdf"]' + + +@pytest.mark.parametrize( + "var, index", + [ + ( + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), + [1, 2], + ), + ( + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), + {"name": "dict"}, + ), + ( + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), + {"set"}, + ), + ( + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), + ( + 1, + 2, + ), + ), + ( + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), + ), + ( + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + [1, 2], + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + {"name": "dict"}, + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + {"set"}, + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + ( + 1, + 2, + ), + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), + ), + ( + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), + ), + ], +) +def test_var_unsupported_indexing_dicts(var, index): + """Test unsupported indexing throws a type error. + + Args: + var: The base var. + index: The base var index. + """ + with pytest.raises(TypeError): + var[index] + + +@pytest.mark.parametrize( + "fixture", + [ + "ParentState", + "StateWithAnyVar", + ], +) +def test_computed_var_without_annotation_error(request, fixture): + """Test that a type error is thrown when an attribute of a computed var is + accessed without annotating the computed var. + + Args: + request: Fixture Request. + fixture: The state fixture. + """ + with pytest.raises(TypeError) as err: + state = request.getfixturevalue(fixture) + state.var_without_annotation.foo + full_name = state.var_without_annotation._var_full_name + assert ( + err.value.args[0] + == f"You must provide an annotation for the state var `{full_name}`. Annotation cannot be `typing.Any`" + ) + + +@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", + [ + "StateWithCorrectVarAnnotation", + "StateWithWrongVarAnnotation", + ], +) +def test_computed_var_with_annotation_error(request, fixture): + """Test that an Attribute error is thrown when a non-existent attribute of an annotated computed var is + accessed or when the wrong annotation is provided to a computed var. + + Args: + request: Fixture Request. + fixture: The state fixture. + """ + with pytest.raises(AttributeError) as err: + state = request.getfixturevalue(fixture) + state.var_with_annotation.foo + full_name = state.var_with_annotation._var_full_name + assert ( + err.value.args[0] + == f"The State var `{full_name}` has no attribute 'foo' or may have been annotated wrongly." + ) + + +@pytest.mark.parametrize( + "fixture,var_name,expected_initial,expected_runtime,raises_at_runtime", + [ + ( + "StateWithInitialComputedVar", + "var_with_initial_value", + "Initial value", + "Runtime value", + False, + ), + ( + "ChildWithInitialComputedVar", + "var_with_initial_value_child", + "Initial value", + "Runtime value", + False, + ), + ( + "StateWithRuntimeOnlyVar", + "var_raises_at_runtime", + None, + None, + True, + ), + ( + "ChildWithRuntimeOnlyVar", + "var_raises_at_runtime_child", + "Initial value", + None, + True, + ), + ], +) +def test_state_with_initial_computed_var( + request, fixture, var_name, expected_initial, expected_runtime, raises_at_runtime +): + """Test that the initial and runtime values of a computed var are correct. + + Args: + request: Fixture Request. + fixture: The state fixture. + var_name: The name of the computed var. + expected_initial: The expected initial value of the computed var. + expected_runtime: The expected runtime value of the computed var. + raises_at_runtime: Whether the computed var is runtime only. + """ + state = request.getfixturevalue(fixture)() + state_name = state.get_full_name() + initial_dict = state.dict(initial=True)[state_name] + assert initial_dict[var_name] == expected_initial + + if raises_at_runtime: + with pytest.raises(ValueError): + state.dict()[state_name][var_name] + else: + runtime_dict = state.dict()[state_name] + assert runtime_dict[var_name] == expected_runtime + + +def test_literal_var(): + complicated_var = LiteralVar.create( + [ + {"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, + [1, 2, 3, 4], + 9, + "string", + True, + False, + None, + set([1, 2, 3]), + ] + ) + assert ( + str(complicated_var) + == '[({ ["a"] : 1, ["b"] : 2, ["c"] : ({ ["d"] : 3, ["e"] : 4 }) }), [1, 2, 3, 4], 9, "string", true, false, null, [1, 2, 3]]' + ) + + +def test_function_var(): + addition_func = FunctionStringVar.create("((a, b) => a + b)") + assert str(addition_func.call(1, 2)) == "(((a, b) => a + b)(1, 2))" + + manual_addition_func = ArgsFunctionOperation.create( + ("a", "b"), + { + "args": [Var(_js_expr="a"), Var(_js_expr="b")], + "result": Var(_js_expr="a + b"), + }, + ) + assert ( + str(manual_addition_func.call(1, 2)) + == '(((a, b) => (({ ["args"] : [a, b], ["result"] : a + b })))(1, 2))' + ) + + increment_func = addition_func(1) + assert ( + str(increment_func.call(2)) + == "(((...args) => ((((a, b) => a + b)(1, ...args))))(2))" + ) + + create_hello_statement = ArgsFunctionOperation.create( + ("name",), f"Hello, {Var(_js_expr='name')}!" + ) + first_name = LiteralStringVar.create("Steven") + last_name = LiteralStringVar.create("Universe") + assert ( + str(create_hello_statement.call(f"{first_name} {last_name}")) + == '(((name) => (("Hello, "+name+"!")))("Steven Universe"))' + ) + + +def test_var_operation(): + @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)" + + five = LiteralNumberVar.create(5) + seven = add(2, five) + + assert isinstance(seven, NumberVar) + + +def test_string_operations(): + basic_string = LiteralStringVar.create("Hello, World!") + + assert str(basic_string.length()) == '"Hello, World!".split("").length' + assert str(basic_string.lower()) == '"Hello, World!".toLowerCase()' + assert str(basic_string.upper()) == '"Hello, World!".toUpperCase()' + assert str(basic_string.strip()) == '"Hello, World!".trim()' + assert str(basic_string.contains("World")) == '"Hello, World!".includes("World")' + assert ( + str(basic_string.split(" ").join(",")) == '"Hello, World!".split(" ").join(",")' + ) + + +def test_all_number_operations(): + starting_number = LiteralNumberVar.create(-5.4) + + complicated_number = (((-(starting_number + 1)) * 2 / 3) // 2 % 3) ** 2 + + assert ( + str(complicated_number) + == "((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2)" + ) + + even_more_complicated_number = ~( + abs(math.floor(complicated_number)) | 2 & 3 & round(complicated_number) + ) + + assert ( + str(even_more_complicated_number) + == "!(((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) == "(Number(false) < 5)" + assert ( + str(LiteralBooleanVar.create(False) < LiteralBooleanVar.create(True)) + == "(Number(false) < Number(true))" + ) + + +@pytest.mark.parametrize( + ("var", "expected"), + [ + (Var.create(False), "false"), + (Var.create(True), "true"), + (Var.create("false"), 'isTrue("false")'), + (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)" + assert str(array_var[1:2]) == "[1, 2, 3, 4, 5].slice(1, 2)" + assert ( + str(array_var[1:4:2]) + == "[1, 2, 3, 4, 5].slice(1, 4).filter((_, i) => i % 2 === 0)" + ) + assert ( + str(array_var[::-1]) + == "[1, 2, 3, 4, 5].slice(0, [1, 2, 3, 4, 5].length).slice().reverse().slice(undefined, undefined).filter((_, i) => i % 1 === 0)" + ) + assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].slice().reverse()" + 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]) + + assert str(array_var.length()) == "[1, 2, 3, 4, 5].length" + assert str(array_var.contains(3)) == "[1, 2, 3, 4, 5].includes(3)" + assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].slice().reverse()" + assert ( + str(ArrayVar.range(10)) + == "Array.from({ length: (10 - 0) / 1 }, (_, i) => 0 + i * 1)" + ) + assert ( + str(ArrayVar.range(1, 10)) + == "Array.from({ length: (10 - 1) / 1 }, (_, i) => 1 + i * 1)" + ) + assert ( + str(ArrayVar.range(1, 10, 2)) + == "Array.from({ length: (10 - 1) / 2 }, (_, i) => 1 + i * 2)" + ) + assert ( + str(ArrayVar.range(1, 10, -1)) + == "Array.from({ length: (10 - 1) / -1 }, (_, i) => 1 + i * -1)" + ) + + +def test_object_operations(): + object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3}) + + assert ( + str(object_var.keys()) == 'Object.keys(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }))' + ) + assert ( + str(object_var.values()) + == 'Object.values(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }))' + ) + assert ( + str(object_var.entries()) + == 'Object.entries(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }))' + ) + assert str(object_var.a) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]' + assert str(object_var["a"]) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]' + assert ( + str(object_var.merge(LiteralObjectVar.create({"c": 4, "d": 5}))) + == '({...({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }), ...({ ["c"] : 4, ["d"] : 5 })})' + ) + + +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) + assert (object_var.keys()._var_type, object_var.values()._var_type) == ( + List[str], + List[int], + ) + assert ( + str(object_var.keys()[0].upper()) # type: ignore + == 'Object.keys(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })).at(0).toUpperCase()' + ) + assert ( + str(object_var.entries()[1][1] - 1) # type: ignore + == '(Object.entries(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })).at(1).at(1) - 1)' + ) + assert ( + str(object_var["c"] + object_var["b"]) # type: ignore + == '(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["c"] + ({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["b"])' + ) + + +def test_nested_dict(): + arr = LiteralArrayVar.create([{"bar": ["foo", "bar"]}], List[Dict[str, List[str]]]) + + assert ( + str(arr[0]["bar"][0]) == '[({ ["bar"] : ["foo", "bar"] })].at(0)["bar"].at(0)' + ) + + +def nested_base(): + class Boo(Base): + foo: str + bar: int + + class Foo(Base): + bar: Boo + baz: int + + parent_obj = LiteralObjectVar.create( + Foo(bar=Boo(foo="bar", bar=5), baz=5).dict(), Foo + ) + + assert ( + str(parent_obj.bar.foo) + == '({ ["bar"] : ({ ["foo"] : "bar", ["bar"] : 5 }), ["baz"] : 5 })["bar"]["foo"]' + ) + + +def test_retrival(): + var_without_data = Var(_js_expr="test") + assert var_without_data is not None + + original_var_data = VarData( + state="Test", + imports={"react": [ImportVar(tag="useRef")]}, + hooks={"const state = useContext(StateContexts.state)": None}, + ) + + var_with_data = var_without_data._replace(merge_var_data=original_var_data) + + f_string = f"foo{var_with_data}bar" + + assert REFLEX_VAR_OPENING_TAG in f_string + assert REFLEX_VAR_CLOSING_TAG in f_string + + 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 + == result_immutable_var_data.state + == original_var_data.state + ) + assert ( + result_var_data.imports + == result_immutable_var_data.imports + == original_var_data.imports + ) + assert ( + tuple(result_var_data.hooks) + == tuple(result_immutable_var_data.hooks) + == tuple(original_var_data.hooks) + ) + + +def test_fstring_concat(): + original_var_with_data = LiteralVar.create( + "imagination", _var_data=VarData(state="fear") + ) + + immutable_var_with_data = Var( + _js_expr="consequences", + _var_data=VarData( + imports={ + "react": [ImportVar(tag="useRef")], + "utils": [ImportVar(tag="useEffect")], + } + ), + ) + + f_string = f"foo{original_var_with_data}bar{immutable_var_with_data}baz" + + string_concat = LiteralStringVar.create( + f_string, + _var_data=VarData( + hooks={"const state = useContext(StateContexts.state)": None} + ), + ) + + assert str(string_concat) == '("fooimaginationbar"+consequences+"baz")' + assert isinstance(string_concat, ConcatVarOperation) + assert string_concat._get_all_var_data() == VarData( + state="fear", + imports={ + "react": [ImportVar(tag="useRef")], + "utils": [ImportVar(tag="useEffect")], + }, + hooks={"const state = useContext(StateContexts.state)": None}, + ) + + +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"{var}", f"{hash(var)}var"), + ( + f"testing f-string with {myvar}", + f"testing f-string with {hash(myvar)}state.myvar", + ), + ( + f"testing local f-string {x}", + f"testing local f-string {hash(x)}x", + ), + ], +) +def test_fstrings(out, expected): + assert out == expected + + +@pytest.mark.parametrize( + ("value", "expect_state"), + [ + ([1], ""), + ({"a": 1}, ""), + ([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): + """Test that _var_state is extracted from containers containing BaseVar. + + Args: + value: The value to create a var from. + expect_state: The expected 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( + "value", + [ + "var", + "\nvar", + ], +) +def test_fstring_roundtrip(value): + """Test that f-string roundtrip carries state. + + Args: + value: The value to create a Var from. + """ + var = Var(_js_expr=value)._var_set_state("state") + rt_var = LiteralVar.create(f"{var}") + assert var._var_state == rt_var._var_state + assert str(rt_var) == str(var) + + +@pytest.mark.parametrize( + "var", + [ + 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): + """Test that unsupported types for reverse throw a type error. + + Args: + var: The base var. + """ + with pytest.raises(TypeError) as err: + var.reverse() + assert err.value.args[0] == f"Cannot reverse non-list var." + + +@pytest.mark.parametrize( + "var", + [ + 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): + """Test that unsupported types for contains throw a type error. + + Args: + var: The base var. + """ + with pytest.raises(TypeError) as err: + assert var.contains(1) + assert ( + err.value.args[0] + == f"Var of type {var._var_type} does not support contains check." + ) + + +@pytest.mark.parametrize( + "other", + [ + 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 Var(_js_expr="var").to(str).contains(other) + assert ( + err.value.args[0] + == 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 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." + ) + + +@pytest.mark.parametrize( + "operand1_var,operand2_var,operators", + [ + ( + LiteralVar.create(10), + LiteralVar.create(5), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "|", + "&", + ], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(5), + ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], + ), + ( + LiteralVar.create(5), + LiteralVar.create(True), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "|", + "&", + ], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(5.5), + ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(True), + ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], + ), + (LiteralVar.create("10"), LiteralVar.create("5"), ["+", ">", "<", "<=", ">="]), + ( + 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), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "|", + "&", + ], + ), + ], +) +def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): + """Test that operations do not raise a TypeError. + + Args: + operand1_var: left operand. + operand2_var: right operand. + operators: list of supported operators. + """ + for operator in operators: + 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", + [ + ( + LiteralVar.create(10), + LiteralVar.create(5), + [ + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(5), + [ + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(True), + [ + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create(10.5), + LiteralVar.create(5.5), + [ + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create("10"), + LiteralVar.create("5"), + [ + "-", + "/", + "//", + "*", + "%", + "**", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create([5, 6]), + [ + "-", + "/", + "//", + "*", + "%", + "**", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create(5), + [ + "+", + "-", + "/", + "//", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create(True), + [ + "+", + "-", + "/", + "//", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create("5"), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create({"key": "value"}), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create([10, 20]), + LiteralVar.create(5.5), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create({"key": "value"}), + LiteralVar.create({"another_key": "another_value"}), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create({"key": "value"}), + LiteralVar.create(5), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create({"key": "value"}), + LiteralVar.create(True), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create({"key": "value"}), + LiteralVar.create(5.5), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ( + LiteralVar.create({"key": "value"}), + LiteralVar.create("5"), + [ + "+", + "-", + "/", + "//", + "*", + "%", + "**", + ">", + "<", + "<=", + ">=", + "^", + "<<", + ">>", + ], + ), + ], +) +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): + print(eval(f"operand1_var {operator} operand2_var")) + # operand1_var.operation(op=operator, other=operand2_var) + + with pytest.raises(TypeError): + print(eval(f"operand2_var {operator} operand1_var")) + # operand1_var.operation(op=operator, other=operand2_var, flip=True) + + +@pytest.mark.parametrize( + "var, expected", + [ + (LiteralVar.create("string_value"), '"string_value"'), + (LiteralVar.create(1), "1"), + (LiteralVar.create([1, 2, 3]), "[1, 2, 3]"), + (LiteralVar.create({"foo": "bar"}), '({ ["foo"] : "bar" })'), + ( + LiteralVar.create(ATestState.value), + f"{ATestState.get_full_name()}.value", + ), + ( + LiteralVar.create(f"{ATestState.value} string"), + f'({ATestState.get_full_name()}.value+" string")', + ), + ( + LiteralVar.create(ATestState.dict_val), + f"{ATestState.get_full_name()}.dict_val", + ), + ], +) +def test_var_name_unwrapped(var, expected): + assert str(var) == expected + + +def cv_fget(state: BaseState) -> int: + return 1 + + +@pytest.mark.parametrize( + "deps,expected", + [ + (["a"], {"a"}), + (["b"], {"b"}), + ([ComputedVar(fget=cv_fget)], {"cv_fget"}), + ], +) +def test_computed_var_deps(deps: List[Union[str, Var]], expected: Set[str]): + @computed_var( + deps=deps, + cache=True, + ) + def test_var(state) -> int: + return 1 + + assert test_var._static_deps == expected + + +@pytest.mark.parametrize( + "deps", + [ + [""], + [1], + ["", "abc"], + ], +) +def test_invalid_computed_var_deps(deps: List): + with pytest.raises(TypeError): + + @computed_var( + deps=deps, + cache=True, + ) + 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] + + single_var = Var.create(Email()) + assert single_var._var_type == Email diff --git a/tests/middleware/__init__.py b/tests/units/utils/__init__.py similarity index 100% rename from tests/middleware/__init__.py rename to tests/units/utils/__init__.py diff --git a/tests/utils/test_format.py b/tests/units/utils/test_format.py similarity index 66% rename from tests/utils/test_format.py rename to tests/units/utils/test_format.py index 19f385175..f8b605541 100644 --- a/tests/utils/test_format.py +++ b/tests/units/utils/test_format.py @@ -1,16 +1,20 @@ from __future__ import annotations import datetime +import json from typing import Any, List +import plotly.graph_objects as go import pytest from reflex.components.tags.tag import Tag -from reflex.event import EventChain, EventHandler, EventSpec, FrontendEvent +from reflex.event import EventChain, EventHandler, EventSpec, JavascriptInputEvent from reflex.style import Style from reflex.utils import format -from reflex.vars import BaseVar, Var -from tests.test_state import ( +from reflex.utils.serializers import serialize_figure +from reflex.vars.base import LiteralVar, Var +from reflex.vars.object import ObjectVar +from tests.units.test_state import ( ChildState, ChildState2, ChildState3, @@ -94,6 +98,36 @@ def test_wrap(text: str, open: str, expected: str, check_first: bool, num: int): assert format.wrap(text, open, check_first=check_first, num=num) == expected +@pytest.mark.parametrize( + "string,expected_output", + [ + ("This is a random string", "This is a random string"), + ( + "This is a random string with `backticks`", + "This is a random string with \\`backticks\\`", + ), + ( + "This is a random string with `backticks`", + "This is a random string with \\`backticks\\`", + ), + ( + "This is a string with ${someValue[`string interpolation`]} unescaped", + "This is a string with ${someValue[`string interpolation`]} unescaped", + ), + ( + "This is a string with `backticks` and ${someValue[`string interpolation`]} unescaped", + "This is a string with \\`backticks\\` and ${someValue[`string interpolation`]} unescaped", + ), + ( + "This is a string with `backticks`, ${someValue[`the first string interpolation`]} and ${someValue[`the second`]}", + "This is a string with \\`backticks\\`, ${someValue[`the first string interpolation`]} and ${someValue[`the second`]}", + ), + ], +) +def test_escape_js_string(string, expected_output): + assert format._escape_js_string(string) == expected_output + + @pytest.mark.parametrize( "text,indent_level,expected", [ @@ -240,16 +274,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( @@ -280,134 +310,33 @@ 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", [ ( "state__state.value", [ - [Var.create(1), Var.create("red", _var_is_string=True)], - [Var.create(2), Var.create(3), Var.create("blue", _var_is_string=True)], + [LiteralVar.create(1), LiteralVar.create("red")], + [LiteralVar.create(2), LiteralVar.create(3), LiteralVar.create("blue")], [TestState.mapping, TestState.num1], [ - Var.create(f"{TestState.map_key}-key", _var_is_string=True), - Var.create("return-key", _var_is_string=True), + LiteralVar.create(f"{TestState.map_key}-key"), + LiteralVar.create("return-key"), ], ], - Var.create("yellow", _var_is_string=True), - "(() => { switch (JSON.stringify(state__state.value)) {case JSON.stringify(1): return (`red`); break;case JSON.stringify(2): case JSON.stringify(3): " - "return (`blue`); break;case JSON.stringify(test_state.mapping): return " - "(test_state.num1); break;case JSON.stringify(`${test_state.map_key}-key`): return (`return-key`);" - " break;default: return (`yellow`); break;};})()", + LiteralVar.create("yellow"), + '(() => { switch (JSON.stringify(state__state.value)) {case JSON.stringify(1): return ("red"); break;case JSON.stringify(2): case JSON.stringify(3): ' + f'return ("blue"); break;case JSON.stringify({TestState.get_full_name()}.mapping): return ' + f'({TestState.get_full_name()}.num1); break;case JSON.stringify(({TestState.get_full_name()}.map_key+"-key")): return ("return-key");' + ' break;default: return ("yellow"); break;};})()', ) ], ) 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. @@ -424,28 +353,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: [], ), - '{(_e) => addEvents([Event("mock_event", {})], (_e), {})}', + '((...args) => ((addEvents([(Event("mock_event", ({ }), ({ })))], args, ({ })))))', ), ( EventChain( @@ -454,18 +383,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, JavascriptInputEvent) + .target.value, ), ), ) ], - args_spec=lambda: [], + 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( @@ -473,7 +403,19 @@ def test_format_match( args_spec=lambda: [], event_actions={"stopPropagation": True}, ), - '{(_e) => addEvents([Event("mock_event", {})], (_e), {"stopPropagation": true})}', + '((...args) => ((addEvents([(Event("mock_event", ({ }), ({ })))], args, ({ ["stopPropagation"] : true })))))', + ), + ( + EventChain( + events=[ + EventSpec( + handler=EventHandler(fn=mock_event), + event_actions={"stopPropagation": True}, + ) + ], + args_spec=lambda: [], + ), + '((...args) => ((addEvents([(Event("mock_event", ({ }), ({ ["stopPropagation"] : true })))], args, ({ })))))', ), ( EventChain( @@ -481,35 +423,41 @@ def test_format_match( args_spec=lambda: [], event_actions={"preventDefault": True}, ), - '{(_e) => addEvents([Event("mock_event", {})], (_e), {"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}) => ) })', ), ], ) @@ -520,13 +468,17 @@ 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", [ - (["string"], {"key": 42}, ["key={42}", "string"]), + ( + [Var(_js_expr="{...props}")], + {"key": 42}, + ["key={42}", "{...props}"], + ), ], ) def test_format_props(single_props, key_value_props, output): @@ -553,11 +505,14 @@ def test_get_handler_parts(input, output): @pytest.mark.parametrize( "input,output", [ - (TestState.do_something, "test_state.do_something"), - (ChildState.change_both, "test_state.child_state.change_both"), + (TestState.do_something, f"{TestState.get_full_name()}.do_something"), + ( + ChildState.change_both, + f"{ChildState.get_full_name()}.change_both", + ), ( GrandchildState.do_nothing, - "test_state.child_state.grandchild_state.do_nothing", + f"{GrandchildState.get_full_name()}.do_nothing", ), ], ) @@ -574,40 +529,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( @@ -628,6 +557,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -661,7 +591,7 @@ formatted_router = { 2: {"prop1": 42, "prop2": "hello"}, }, "dt": "1989-11-09 18:53:00+01:00", - "fig": [], + "fig": serialize_figure(go.Figure()), "key": "", "map_key": "a", "mapping": {"a": [1, 2, 3], "b": [4, 5, 6]}, @@ -671,6 +601,7 @@ formatted_router = { "sum": 3.14, "upper": "", "router": formatted_router, + "asynctest": 0, }, ChildState.get_full_name(): { "count": 23, @@ -704,7 +635,7 @@ def test_format_state(input, output): input: The state to format. output: The expected formatted state. """ - assert format.format_state(input) == output + assert json.loads(format.json_dumps(input)) == json.loads(format.json_dumps(output)) @pytest.mark.parametrize( @@ -731,29 +662,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/units/utils/test_imports.py similarity index 57% rename from tests/utils/test_imports.py rename to tests/units/utils/test_imports.py index c7253ff6b..c30d1d85c 100644 --- a/tests/utils/test_imports.py +++ b/tests/units/utils/test_imports.py @@ -1,6 +1,12 @@ import pytest -from reflex.utils.imports import ImportVar, merge_imports +from reflex.utils.imports import ( + ImportDict, + ImportVar, + ParsedImportDict, + merge_imports, + parse_imports, +) @pytest.mark.parametrize( @@ -48,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")}}, ), ], ) @@ -72,7 +82,36 @@ def test_merge_imports(input_1, input_2, output): """ res = merge_imports(input_1, input_2) - assert set(res.keys()) == set(output.keys()) + assert res.keys() == output.keys() for key in output: assert set(res[key]) == set(output[key]) + + +@pytest.mark.parametrize( + "input, output", + [ + ({}, {}), + ( + {"react": "Component"}, + {"react": [ImportVar(tag="Component")]}, + ), + ( + {"react": ["Component"]}, + {"react": [ImportVar(tag="Component")]}, + ), + ( + {"react": ["Component", ImportVar(tag="useState")]}, + {"react": [ImportVar(tag="Component"), ImportVar(tag="useState")]}, + ), + ( + {"react": ["Component"], "foo": "anotherFunction"}, + { + "react": [ImportVar(tag="Component")], + "foo": [ImportVar(tag="anotherFunction")], + }, + ), + ], +) +def test_parse_imports(input: ImportDict, output: ParsedImportDict): + assert parse_imports(input) == output diff --git a/tests/utils/test_serializers.py b/tests/units/utils/test_serializers.py similarity index 57% rename from tests/utils/test_serializers.py rename to tests/units/utils/test_serializers.py index 62834d3cc..8050470c6 100644 --- a/tests/utils/test_serializers.py +++ b/tests/units/utils/test_serializers.py @@ -1,18 +1,21 @@ import datetime +import json from enum import Enum -from typing import Any, Dict, List, Type +from pathlib import Path +from typing import Any, 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.utils.format import json_dumps +from reflex.vars.base import LiteralVar @pytest.mark.parametrize( "type_,expected", - [(str, True), (dict, True), (Dict[int, int], True), (Enum, True)], + [(Enum, True)], ) def test_has_serializer(type_: Type, expected: bool): """Test that has_serializer returns the correct value. @@ -28,20 +31,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), ], ) @@ -90,6 +83,9 @@ def test_add_serializer(): # Remove the serializer. serializers.SERIALIZERS.pop(Foo) + # LRU cache will still have the serializer, so we need to clear it. + assert serializers.has_serializer(Foo) + serializers.get_serializer.cache_clear() assert not serializers.has_serializer(Foo) @@ -100,7 +96,7 @@ class StrEnum(str, Enum): BAR = "bar" -class TestEnum(Enum): +class FooBarEnum(Enum): """A lone enum class.""" FOO = "foo" @@ -129,48 +125,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"]'), + (FooBarEnum.FOO, "foo"), + ([FooBarEnum.FOO, FooBarEnum.BAR], ["foo", "bar"]), ( - {"key1": TestEnum.FOO, "key2": TestEnum.BAR}, - '{"key1": "foo", "key2": "bar"}', + {"key1": FooBarEnum.FOO, "key2": FooBarEnum.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"), @@ -178,7 +185,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)"), @@ -193,4 +200,43 @@ def test_serialize(value: Any, expected: str): value: The value to serialize. expected: The expected result. """ - assert serializers.serialize(value) == expected + assert json.loads(json_dumps(value)) == json.loads(json_dumps(expected)) + + +@pytest.mark.parametrize( + "value,expected,exp_var_is_string", + [ + ("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), + ([StrEnum.FOO, StrEnum.BAR], '["foo", "bar"]', False), + ( + BaseSubclass(ts=datetime.timedelta(1, 1, 1)), + '({ ["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), + ], +) +def test_serialize_var_to_str(value: Any, expected: str, exp_var_is_string: bool): + """Test that serialize with `to=str` passed to a Var is marked with _var_is_string. + + Args: + value: The value to serialize. + expected: The expected result. + exp_var_is_string: The expected value of _var_is_string. + """ + v = LiteralVar.create(value) + assert str(v) == expected diff --git a/tests/utils/test_types.py b/tests/units/utils/test_types.py similarity index 60% rename from tests/utils/test_types.py rename to tests/units/utils/test_types.py index fc9261e04..623aacc1f 100644 --- a/tests/utils/test_types.py +++ b/tests/units/utils/test_types.py @@ -1,4 +1,4 @@ -from typing import Any, List, Literal, Tuple, Union +from typing import Any, Dict, List, Literal, Tuple, Union import pytest @@ -45,3 +45,48 @@ def test_issubclass( cls: types.GenericType, cls_check: types.GenericType, expected: bool ) -> None: assert types._issubclass(cls, cls_check) == expected + + +class CustomDict(dict[str, str]): + """A custom dict with generic arguments.""" + + pass + + +class ChildCustomDict(CustomDict): + """A child of CustomDict.""" + + pass + + +class GenericDict(dict): + """A generic dict with no generic arguments.""" + + pass + + +class ChildGenericDict(GenericDict): + """A child of GenericDict.""" + + pass + + +@pytest.mark.parametrize( + "cls,expected", + [ + (int, False), + (str, False), + (float, False), + (Tuple[int], True), + (List[int], True), + (Union[int, str], True), + (Union[str, int], True), + (Dict[str, int], True), + (CustomDict, True), + (ChildCustomDict, True), + (GenericDict, False), + (ChildGenericDict, False), + ], +) +def test_has_args(cls, expected: bool) -> None: + assert types.has_args(cls) == expected diff --git a/tests/utils/test_utils.py b/tests/units/utils/test_utils.py similarity index 83% rename from tests/utils/test_utils.py rename to tests/units/utils/test_utils.py index 79dda0a70..dd88138bf 100644 --- a/tests/utils/test_utils.py +++ b/tests/units/utils/test_utils.py @@ -1,7 +1,8 @@ import os import typing +from functools import cached_property from pathlib import Path -from typing import Any, List, Literal, Union +from typing import Any, ClassVar, Dict, List, Literal, Type, Union import pytest import typer @@ -17,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): @@ -76,6 +77,47 @@ def test_is_generic_alias(cls: type, expected: bool): assert types.is_generic_alias(cls) == expected +@pytest.mark.parametrize( + ("subclass", "superclass", "expected"), + [ + *[ + (base_type, base_type, True) + for base_type in [int, float, str, bool, list, dict] + ], + *[ + (one_type, another_type, False) + for one_type in [int, float, str, list, dict] + for another_type in [int, float, str, list, dict] + if one_type != another_type + ], + (bool, int, True), + (int, bool, False), + (list, List, True), + (list, List[str], True), # this is wrong, but it's a limitation of the function + (List, list, True), + (List[int], list, True), + (List[int], List, True), + (List[int], List[str], False), + (List[int], List[int], True), + (List[int], List[float], False), + (List[int], List[Union[int, float]], True), + (List[int], List[Union[float, str]], False), + (Union[int, float], List[Union[int, float]], False), + (Union[int, float], Union[int, float, str], True), + (Union[int, float], Union[str, float], False), + (Dict[str, int], Dict[str, int], True), + (Dict[str, bool], Dict[str, int], True), + (Dict[str, int], Dict[str, bool], False), + (Dict[str, Any], dict[str, str], False), + (Dict[str, str], dict[str, str], True), + (Dict[str, str], dict[str, Any], True), + (Dict[str, Any], dict[str, Any], True), + ], +) +def test_typehint_issubclass(subclass, superclass, expected): + assert types.typehint_issubclass(subclass, superclass) == expected + + def test_validate_invalid_bun_path(mocker): """Test that an error is thrown when a custom specified bun path is not valid or does not exist. @@ -116,7 +158,7 @@ def test_remove_existing_bun_installation(mocker): Args: mocker: Pytest mocker. """ - mocker.patch("reflex.utils.prerequisites.os.path.exists", return_value=True) + mocker.patch("reflex.utils.prerequisites.Path.exists", return_value=True) rm = mocker.patch("reflex.utils.prerequisites.path_ops.rm", mocker.Mock()) prerequisites.remove_existing_bun_installation() @@ -146,26 +188,49 @@ def test_setup_frontend(tmp_path, mocker): @pytest.fixture def test_backend_variable_cls(): - class TestBackendVariable: + class TestBackendVariable(BaseState): """Test backend variable.""" + _classvar: ClassVar[int] = 0 _hidden: int = 0 not_hidden: int = 0 __dunderattr__: int = 0 + @classmethod + def _class_method(cls): + pass + + def _hidden_method(self): + pass + + @property + def _hidden_property(self): + pass + + @cached_property + def _cached_hidden_property(self): + pass + return TestBackendVariable @pytest.mark.parametrize( "input, output", [ + ("_classvar", False), + ("_class_method", False), + ("_hidden_method", False), ("_hidden", True), ("not_hidden", False), ("__dundermethod__", False), + ("_hidden_property", False), + ("_cached_hidden_property", False), ], ) -def test_is_backend_variable(test_backend_variable_cls, input, output): - assert types.is_backend_variable(input, test_backend_variable_cls) == output +def test_is_backend_base_variable( + test_backend_variable_cls: Type[BaseState], input: str, output: bool +): + assert types.is_backend_base_variable(input, test_backend_variable_cls) == output @pytest.mark.parametrize( @@ -434,7 +499,7 @@ def test_bun_install_without_unzip(mocker): mocker: Pytest mocker object. """ mocker.patch("reflex.utils.path_ops.which", return_value=None) - mocker.patch("os.path.exists", return_value=False) + mocker.patch("pathlib.Path.exists", return_value=False) mocker.patch("reflex.utils.prerequisites.constants.IS_WINDOWS", False) with pytest.raises(FileNotFoundError): @@ -452,7 +517,7 @@ def test_bun_install_version(mocker, bun_version): """ mocker.patch("reflex.utils.prerequisites.constants.IS_WINDOWS", False) - mocker.patch("os.path.exists", return_value=True) + mocker.patch("pathlib.Path.exists", return_value=True) mocker.patch( "reflex.utils.prerequisites.get_bun_version", return_value=version.parse(bun_version), @@ -514,11 +579,17 @@ 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 + EventHandler(fn=callable) + if type(callable) is not 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/units/vars/test_base.py b/tests/units/vars/test_base.py new file mode 100644 index 000000000..68bc0c38e --- /dev/null +++ b/tests/units/vars/test_base.py @@ -0,0 +1,49 @@ +from typing import Dict, List, Union + +import pytest + +from reflex.vars.base import figure_out_type + + +class CustomDict(dict[str, str]): + """A custom dict with generic arguments.""" + + pass + + +class ChildCustomDict(CustomDict): + """A child of CustomDict.""" + + pass + + +class GenericDict(dict): + """A generic dict with no generic arguments.""" + + pass + + +class ChildGenericDict(GenericDict): + """A child of GenericDict.""" + + pass + + +@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]]), + (CustomDict(), CustomDict), + (ChildCustomDict(), ChildCustomDict), + (GenericDict({1: 1}), Dict[int, int]), + (ChildGenericDict({1: 1}), Dict[int, int]), + ], +) +def test_figure_out_type(value, expected): + assert figure_out_type(value) == expected diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py deleted file mode 100644 index e69de29bb..000000000